openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1452147 - in /openwebbeans/trunk/webbeans-arquillian: ./ owb-arquillian-standalone/ owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/ owb-arquillian-standalone/src/test/java/org/ owb-arquillian-standalone/s...
Date Sun, 03 Mar 2013 22:28:55 GMT
Author: struberg
Date: Sun Mar  3 22:28:55 2013
New Revision: 1452147

URL: http://svn.apache.org/r1452147
Log:
OWB-710 first version of our new arquillian container

Only handles JavaArchives for now. 
beans.xml scanning doesn't work yet, etc
work in progress...

Added:
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianLifecycle.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianSingletonService.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbLifecycleHandler.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/OwbArquillianJarDeploymentTest.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/SampleUser.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/beans.xml
Modified:
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/pom.xml
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianExtension.java
    openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
    openwebbeans/trunk/webbeans-arquillian/pom.xml

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/pom.xml?rev=1452147&r1=1452146&r2=1452147&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/pom.xml (original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/pom.xml Sun Mar  3 22:28:55
2013
@@ -22,7 +22,7 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.openwebbeans.arquillian</groupId>
-        <artifactId>parent</artifactId>
+        <artifactId>owb-arquillian-parent</artifactId>
         <version>1.2.0-SNAPSHOT</version>
     </parent>
     <artifactId>owb-arquillian-standalone</artifactId>
@@ -38,20 +38,50 @@
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jcdi_1.0_spec</artifactId>
-            <optional>true</optional>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <optional>true</optional>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.arquillian.container</groupId>
+            <artifactId>arquillian-container-spi</artifactId>
+            <version>${arquillian.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.arquillian.test</groupId>
+            <artifactId>arquillian-test-spi</artifactId>
+            <version>${arquillian.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.arquillian.testenricher</groupId>
+            <artifactId>arquillian-testenricher-cdi</artifactId>
+            <version>${arquillian.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-spi</artifactId>
+            <scope>compile</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+            <scope>compile</scope>
             <optional>true</optional>
         </dependency>
     </dependencies>
 
+
 </project>

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianExtension.java?rev=1452147&r1=1452146&r2=1452147&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianExtension.java
(original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianExtension.java
Sun Mar  3 22:28:55 2013
@@ -27,6 +27,7 @@ public class OwbArquillianExtension impl
 {
     public void register(ExtensionBuilder builder)
     {
-        builder.service(DeployableContainer.class, OwbStandaloneContainer.class);
+        builder.service(DeployableContainer.class, OwbStandaloneContainer.class)
+                .observer(OwbLifecycleHandler.class);
     }
 }

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianLifecycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianLifecycle.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianLifecycle.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianLifecycle.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.standalone;
+
+
+import org.apache.webbeans.lifecycle.AbstractLifeCycle;
+import org.apache.webbeans.spi.ScannerService;
+
+/**
+ *
+ */
+public class OwbArquillianLifecycle extends AbstractLifeCycle
+{
+
+
+    public OwbArquillianLifecycle(ScannerService scannerService)
+    {
+        super();
+
+        // we replace the ScannerService which shall get used
+        this.scannerService = scannerService;
+    }
+
+}

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianScannerService.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.standalone;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.webbeans.spi.BDABeansXmlScanner;
+import org.apache.webbeans.spi.ScannerService;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.Filters;
+import org.jboss.shrinkwrap.api.Node;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ *
+ */
+public class OwbArquillianScannerService implements ScannerService
+{
+    private final boolean beansXmlBdaScanningEnabled;
+    private Archive archive;
+
+    private Set<URL> beansXmls = new HashSet<URL>();
+    private Set<Class<?>> beanClasses = new HashSet<Class<?>>();
+
+
+    public OwbArquillianScannerService()
+    {
+        this.beansXmlBdaScanningEnabled = false;
+    }
+
+    @Override
+    public BDABeansXmlScanner getBDABeansXmlScanner()
+    {
+        return null;
+    }
+
+    @Override
+    public void init(Object object)
+    {
+        // nothing to do
+    }
+
+    public void setArchive(Archive archive)
+    {
+        this.archive = archive;
+    }
+
+    @Override
+    public void scan()
+    {
+        if (archive == null)
+        {
+            return;
+        }
+
+        //X TODO add WebArchive and others as well
+        if (archive instanceof JavaArchive)
+        {
+            scanJarArchive((JavaArchive) archive);
+        }
+        else
+        {
+            //X TODO
+            throw new IllegalStateException("Not yet implemented");
+        }
+    }
+
+    @Override
+    public Set<URL> getBeanXmls()
+    {
+        return beansXmls;
+    }
+
+    @Override
+    public Set<Class<?>> getBeanClasses()
+    {
+        return beanClasses;
+    }
+
+    @Override
+    public void release()
+    {
+        beansXmls.clear();
+        beanClasses.clear();
+    }
+
+    @Override
+    public boolean isBDABeansXmlScanningEnabled()
+    {
+        return beansXmlBdaScanningEnabled;
+    }
+
+    // --------- private implementation -----------
+
+
+    private void scanJarArchive(JavaArchive archive)
+    {
+        Node beansXml = archive.get("META-INF/beans.xml");
+
+        if (beansXml == null)
+        {
+            // this is not a CDI archive
+            return;
+        }
+
+        // otherwise we store it for later use
+        //X TODO beansXmls.add(beansXml.getAsset())
+
+        // and now add all classes
+        Map<ArchivePath, Node> classes = archive.getContent(Filters.include(".*\\.class"));
+        for (Map.Entry<ArchivePath, Node> classEntry : classes.entrySet())
+        {
+            String className = classEntry.getKey().get();
+
+            // cut off leading slashes
+            if (className.startsWith("/"))
+            {
+                className = className.substring(1);
+            }
+
+            // cut off ".class"
+            className = className.substring(0, className.length() - ".class".length());
+
+            className = className.replace('/', '.');
+
+            try
+            {
+                Class<?> beanClass = Class.forName(className);
+                beanClasses.add(beanClass);
+            }
+            catch (ClassNotFoundException cnfe)
+            {
+                throw new RuntimeException("Could not scan class", cnfe);
+            }
+        }
+
+    }
+
+
+}

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianSingletonService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianSingletonService.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianSingletonService.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbArquillianSingletonService.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.standalone;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.corespi.security.SimpleSecurityService;
+import org.apache.webbeans.spi.ScannerService;
+import org.apache.webbeans.spi.SecurityService;
+import org.apache.webbeans.spi.SingletonService;
+
+/**
+ *
+ */
+public class OwbArquillianSingletonService implements SingletonService<WebBeansContext>
+{
+
+    private final WebBeansContext webBeansContext;
+
+    public OwbArquillianSingletonService()
+    {
+        ScannerService dummyScannerService = new OwbArquillianScannerService();
+
+        Map<Class<?>, Object> initialServices = new HashMap<Class<?>,
Object>();
+        initialServices.put(ScannerService.class,  dummyScannerService);
+
+        //X TODO this is needed because of a dirty hack in the OpenWebBeansConfiguration
+        initialServices.put(SecurityService.class, new SimpleSecurityService());
+
+        Properties initialConfig = new Properties();
+
+        webBeansContext = new WebBeansContext(initialServices, initialConfig);
+        webBeansContext.getOpenWebBeansConfiguration().parseConfiguration();
+    }
+
+    @Override
+    public void clear(Object key)
+    {
+    }
+
+    @Override
+    public WebBeansContext get(Object key)
+    {
+        return webBeansContext;
+    }
+}

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbLifecycleHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbLifecycleHandler.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbLifecycleHandler.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbLifecycleHandler.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.standalone;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.spi.ContextsService;
+import org.jboss.arquillian.container.spi.event.container.AfterDeploy;
+import org.jboss.arquillian.container.spi.event.container.BeforeUnDeploy;
+import org.jboss.arquillian.core.api.Instance;
+import org.jboss.arquillian.core.api.annotation.Inject;
+import org.jboss.arquillian.core.api.annotation.Observes;
+import org.jboss.arquillian.test.spi.event.suite.After;
+import org.jboss.arquillian.test.spi.event.suite.Before;
+
+/**
+ * Starts and stops the application and the contexts in it.
+ */
+public class OwbLifecycleHandler
+{
+    @Inject
+    private Instance<ContainerLifecycle> lifecycle;
+
+    public void afterDeployment(@Observes AfterDeploy event)
+    {
+        ContextsService service = lifecycle.get().getContextService();
+
+        //service.startContext(ApplicationScoped.class, null);
+        service.startContext(ApplicationScoped.class, null);
+    }
+
+    public void beforeUndeployment(@Observes BeforeUnDeploy event)
+    {
+        ContextsService service = lifecycle.get().getContextService();
+
+        //service.startContext(ApplicationScoped.class, null);
+        service.endContext(ApplicationScoped.class, null);
+    }
+
+    public void beforeMethod(@Observes Before event)
+    {
+        ContextsService service = lifecycle.get().getContextService();
+
+        service.startContext(RequestScoped.class, null);
+        service.startContext(SessionScoped.class, null);
+        service.startContext(ConversationScoped.class, null);
+    }
+
+    public void afterMethod(@Observes After event)
+    {
+        ContainerLifecycle lc = lifecycle.get();
+        if (lc == null)
+        {
+            // this may happen if there was a DeploymentError during CDI boot
+            return;
+        }
+
+        ContextsService service = lc.getContextService();
+
+        service.endContext(ConversationScoped.class, null);
+        service.endContext(SessionScoped.class, null);
+        service.endContext(RequestScoped.class, null);
+    }
+
+
+}

Modified: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java?rev=1452147&r1=1452146&r2=1452147&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
(original)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/main/java/org/apache/webbeans/arquillian/standalone/OwbStandaloneContainer.java
Sun Mar  3 22:28:55 2013
@@ -18,11 +18,21 @@
  */
 package org.apache.webbeans.arquillian.standalone;
 
+import javax.enterprise.inject.spi.BeanManager;
+
+import java.util.logging.Logger;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.spi.ContainerLifecycle;
 import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
 import org.jboss.arquillian.container.spi.client.container.DeploymentException;
 import org.jboss.arquillian.container.spi.client.container.LifecycleException;
 import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription;
 import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
+import org.jboss.arquillian.container.spi.context.annotation.DeploymentScoped;
+import org.jboss.arquillian.core.api.InstanceProducer;
+import org.jboss.arquillian.core.api.annotation.Inject;
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.descriptor.api.Descriptor;
 
@@ -30,48 +40,89 @@ import org.jboss.shrinkwrap.descriptor.a
  */
 public class OwbStandaloneContainer implements DeployableContainer<OwbStandaloneConfiguration>
 {
-    public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException
+    private static final Logger LOG = Logger.getLogger(OwbStandaloneContainer.class.getName());
+
+
+    @Inject
+    @DeploymentScoped
+    private InstanceProducer<ContainerLifecycle> lifecycleProducer;
+
+    @Inject
+    @DeploymentScoped
+    private InstanceProducer<BeanManager> beanManagerProducer;
+
+    private WebBeansContext webBeansContext;
+
+    public Class<OwbStandaloneConfiguration> getConfigurationClass()
     {
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+        return OwbStandaloneConfiguration.class;
     }
 
-    public Class<OwbStandaloneConfiguration> getConfigurationClass()
+    public ProtocolDescription getDefaultProtocol()
     {
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+        return new ProtocolDescription("Local");
     }
 
     public void setup(OwbStandaloneConfiguration owbStandaloneConfiguration)
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        LOG.fine("OpenWebBeans Arquillian setup started");
+
+        WebBeansFinder.setSingletonService(new OwbArquillianSingletonService());
+
     }
 
     public void start() throws LifecycleException
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        LOG.fine("OpenWebBeans Arquillian starting");
+
+        webBeansContext = WebBeansContext.getInstance();
     }
 
-    public void stop() throws LifecycleException
+    public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        LOG.fine("OpenWebBeans Arquillian starting deployment");
+
+        ContainerLifecycle lifecycle = webBeansContext.getService(ContainerLifecycle.class);
+
+        lifecycleProducer.set(lifecycle);
+        beanManagerProducer.set(lifecycle.getBeanManager());
+
+        OwbArquillianScannerService dummyScannerService = (OwbArquillianScannerService) webBeansContext.getScannerService();
+        dummyScannerService.setArchive(archive);
+
+        lifecycle.startApplication(null);
+
+        return new ProtocolMetaData();
     }
 
-    public ProtocolDescription getDefaultProtocol()
+    public void undeploy(Archive<?> archive) throws DeploymentException
     {
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+        LOG.fine("OpenWebBeans Arquillian undeploying");
+
+        ContainerLifecycle lifecycle = lifecycleProducer.get();
+        if (lifecycle != null)
+        {
+            // end the session lifecycle
+
+            lifecycle.stopApplication(null);
+        }
     }
 
-    public void undeploy(Archive<?> archive) throws DeploymentException
+    public void stop() throws LifecycleException
     {
+        LOG.fine("OpenWebBeans Arquillian stopping");
         //To change body of implemented methods use File | Settings | File Templates.
     }
 
     public void deploy(Descriptor descriptor) throws DeploymentException
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        throw new UnsupportedOperationException("Deployment of Descriptors is not supported
in owb-arquillian-standalone!");
     }
 
     public void undeploy(Descriptor descriptor) throws DeploymentException
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        throw new UnsupportedOperationException("Deployment of Descriptors is not supported
in owb-arquillian-standalone!");
     }
+
+
 }

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/OwbArquillianJarDeploymentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/OwbArquillianJarDeploymentTest.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/OwbArquillianJarDeploymentTest.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/OwbArquillianJarDeploymentTest.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.test;
+
+import javax.inject.Inject;
+
+import org.apache.webbeans.arquillian.test.beans.SampleUser;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * This test verifies the deployment of a JAR packaging.
+ */
+@RunWith(Arquillian.class)
+public class OwbArquillianJarDeploymentTest
+{
+
+    @Inject
+    private SampleUser sampleUser;
+
+
+    @Deployment
+    public static JavaArchive deploy()
+    {
+        JavaArchive testJar = ShrinkWrap
+                .create(JavaArchive.class, "sampleUserTest.jar")
+                .addClass(OwbArquillianJarDeploymentTest.class)
+                .addPackage(SampleUser.class.getPackage())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return testJar;
+    }
+
+    @Test
+    public void testOwbArqContainerStartup()
+    {
+        Assert.assertNotNull(sampleUser);
+        Assert.assertEquals("Hans", sampleUser.getFirstName());
+
+        sampleUser.setFirstName("Karl");
+        Assert.assertEquals("Karl", sampleUser.getFirstName());
+    }
+}

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/SampleUser.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/SampleUser.java?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/SampleUser.java
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/java/org/apache/webbeans/arquillian/test/beans/SampleUser.java
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.arquillian.test.beans;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import java.io.Serializable;
+
+/**
+ * A sample User to get injected into an Arquillian test
+ */
+@SessionScoped
+public class SampleUser implements Serializable
+{
+    private String firstName;
+
+    @PostConstruct
+    public void init()
+    {
+        firstName = "Hans";
+    }
+
+    public String getFirstName()
+    {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName)
+    {
+        this.firstName = firstName;
+    }
+}

Added: openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/beans.xml?rev=1452147&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/beans.xml
(added)
+++ openwebbeans/trunk/webbeans-arquillian/owb-arquillian-standalone/src/test/resources/META-INF/beans.xml
Sun Mar  3 22:28:55 2013
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans/>
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-arquillian/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-arquillian/pom.xml?rev=1452147&r1=1452146&r2=1452147&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-arquillian/pom.xml (original)
+++ openwebbeans/trunk/webbeans-arquillian/pom.xml Sun Mar  3 22:28:55 2013
@@ -25,7 +25,7 @@
         <version>1.2.0-SNAPSHOT</version>
     </parent>
     <groupId>org.apache.openwebbeans.arquillian</groupId>
-    <artifactId>parent</artifactId>
+    <artifactId>owb-arquillian-parent</artifactId>
     <packaging>pom</packaging>
     <name>OWB Arquillian Parent</name>
     <modules>
@@ -33,7 +33,7 @@
     </modules>
 
     <properties>
-        <arquillian.version>1.0.2.Final</arquillian.version>
+        <arquillian.version>1.0.3.Final</arquillian.version>
     </properties>
 
     <dependencyManagement>
@@ -71,6 +71,25 @@
             <version>${arquillian.version}</version>
             <scope>provided</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.jboss.arquillian.junit</groupId>
+            <artifactId>arquillian-junit-container</artifactId>
+            <version>${arquillian.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.shrinkwrap</groupId>
+            <artifactId>shrinkwrap-api</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+
+
     </dependencies>
 
 



Mime
View raw message