geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r985425 - in /geronimo/tck/branches/3.0/atinject-tck-runner: ./ src/test/java/org/apache/webbeans/atinject/tck/container/
Date Sat, 14 Aug 2010 01:48:52 GMT
Author: linsun
Date: Sat Aug 14 01:48:52 2010
New Revision: 985425

URL: http://svn.apache.org/viewvc?rev=985425&view=rev
Log:
[atinject-tck]provide a standalone container in the tck runner so we could control the openejb
version it uses by the container, instead of getting the container from openwebbeans-porting

Added:
    geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/ManagersImpl.java
    geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/StandaloneContainersImpl.java
Modified:
    geronimo/tck/branches/3.0/atinject-tck-runner/pom.xml
    geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/AtInjectContainer.java

Modified: geronimo/tck/branches/3.0/atinject-tck-runner/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/tck/branches/3.0/atinject-tck-runner/pom.xml?rev=985425&r1=985424&r2=985425&view=diff
==============================================================================
--- geronimo/tck/branches/3.0/atinject-tck-runner/pom.xml (original)
+++ geronimo/tck/branches/3.0/atinject-tck-runner/pom.xml Sat Aug 14 01:48:52 2010
@@ -13,11 +13,11 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.geronimo</groupId>
-        <artifactId>geronimo</artifactId>
-        <version>3.0-SNAPSHOT</version>
-    </parent>
+	<parent>
+		<groupId>org.apache.geronimo</groupId>
+		<artifactId>geronimo</artifactId>
+		<version>3.0-SNAPSHOT</version>
+	</parent>
 
 	<artifactId>atinject-tck</artifactId>
 	<version> 1.0.0-SNAPSHOT</version>
@@ -40,33 +40,33 @@
 	</build>
 
 
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>org.apache.openejb</groupId>
-                <artifactId>openejb-core</artifactId>
-                <version>${openejbVersion}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>activemq-ra</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>activemq-core</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.springframework</groupId>
-                        <artifactId>spring</artifactId>
-                    </exclusion>
-                    <exclusion>
-                        <groupId>org.quartz-scheduler</groupId>
-                        <artifactId>quartz</artifactId>
-                    </exclusion>
-                </exclusions>
-		</dependency>
-        </dependencies>
-    </dependencyManagement>
+	<dependencyManagement>
+		<dependencies>
+			<dependency>
+				<groupId>org.apache.openejb</groupId>
+				<artifactId>openejb-core</artifactId>
+				<version>${openejbVersion}</version>
+				<exclusions>
+					<exclusion>
+						<groupId>org.apache.activemq</groupId>
+						<artifactId>activemq-ra</artifactId>
+					</exclusion>
+					<exclusion>
+						<groupId>org.apache.activemq</groupId>
+						<artifactId>activemq-core</artifactId>
+					</exclusion>
+					<exclusion>
+						<groupId>org.springframework</groupId>
+						<artifactId>spring</artifactId>
+					</exclusion>
+					<exclusion>
+						<groupId>org.quartz-scheduler</groupId>
+						<artifactId>quartz</artifactId>
+					</exclusion>
+				</exclusions>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
 
 
 	<dependencies>
@@ -92,26 +92,54 @@
 		<dependency>
 			<groupId>org.apache.openwebbeans</groupId>
 			<artifactId>openwebbeans-porting</artifactId>
-                        <version> 1.0.0-SNAPSHOT</version>
+			<version> 1.0.0-SNAPSHOT</version>
 			<scope>test</scope>
 		</dependency>
 
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
-                        <scope>test</scope>
+			<scope>test</scope>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>org.apache.openejb</groupId>
 			<artifactId>openejb-core</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>org.apache.geronimo.specs</groupId>
 			<artifactId>geronimo-validation_1.0_spec</artifactId>
 		</dependency>
 
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-spi</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-impl</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.jboss.jsr299.tck</groupId>
+			<artifactId>jsr299-tck-api</artifactId>
+			<version>1.0.0</version>
+			<exclusions>
+				<exclusion>
+					<groupId>javax.enterprise</groupId>
+					<artifactId>cdi-api</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.el</groupId>
+					<artifactId>el-api</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+
 
 	</dependencies>
 </project>

Modified: geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/AtInjectContainer.java
URL: http://svn.apache.org/viewvc/geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/AtInjectContainer.java?rev=985425&r1=985424&r2=985425&view=diff
==============================================================================
--- geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/AtInjectContainer.java
(original)
+++ geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/AtInjectContainer.java
Sat Aug 14 01:48:52 2010
@@ -28,7 +28,6 @@ import javax.enterprise.inject.spi.BeanM
 import junit.framework.Test;
 
 import org.apache.webbeans.atinject.tck.specific.SpecificProducer;
-import org.apache.webbeans.test.tck.StandaloneContainersImpl;
 import org.atinject.tck.Tck;
 import org.atinject.tck.auto.Car;
 import org.atinject.tck.auto.Convertible;

Added: geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/ManagersImpl.java
URL: http://svn.apache.org/viewvc/geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/ManagersImpl.java?rev=985425&view=auto
==============================================================================
--- geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/ManagersImpl.java
(added)
+++ geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/ManagersImpl.java
Sat Aug 14 01:48:52 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.atinject.tck.container;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.webbeans.container.InjectableBeanManager;
+import org.apache.webbeans.exception.inject.DefinitionException;
+import org.jboss.jsr299.tck.spi.Managers;
+import org.jboss.testharness.api.DeploymentException;
+
+public class ManagersImpl implements Managers
+{
+    private static InjectableBeanManager beanManager;
+    
+    public static void cleanUp()
+    {
+        beanManager = null;
+    }
+    
+    public BeanManager getManager()
+    {
+        if(beanManager == null)
+        {
+            beanManager = new InjectableBeanManager();
+        }
+        
+        return beanManager; 
+    }
+
+    public boolean isDefinitionError(DeploymentException deploymentException)
+    {
+        Throwable cause = deploymentException.getCause();
+        
+        if(DefinitionException.class.isAssignableFrom(cause.getClass()))
+        {
+            return true;
+        }
+        
+        return false;
+    }
+
+    public boolean isDeploymentError(DeploymentException deploymentException)
+    {
+        Throwable cause = deploymentException.getCause();
+        
+        if(DeploymentException.class.isAssignableFrom(cause.getClass()))
+        {
+            return true;
+        }
+        
+        return false;
+    }
+
+}

Added: geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/StandaloneContainersImpl.java
URL: http://svn.apache.org/viewvc/geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/StandaloneContainersImpl.java?rev=985425&view=auto
==============================================================================
--- geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/StandaloneContainersImpl.java
(added)
+++ geronimo/tck/branches/3.0/atinject-tck-runner/src/test/java/org/apache/webbeans/atinject/tck/container/StandaloneContainersImpl.java
Sat Aug 14 01:48:52 2010
@@ -0,0 +1,273 @@
+/*
+ * 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.atinject.tck.container;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.ejb.Singleton;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.SingletonSessionContainerInfo;
+import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
+import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.StatefulBean;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.corespi.ServiceLoader;
+import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
+import org.apache.webbeans.plugins.PluginLoader;
+import org.apache.webbeans.spi.ScannerService;
+import org.apache.webbeans.test.tck.mock.TCKMetaDataDiscoveryImpl;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.StandaloneContainers;
+
+public class StandaloneContainersImpl implements StandaloneContainers
+{
+    private StandaloneLifeCycle lifeCycle = null;
+
+    private DeploymentException excpetion;
+
+    public void deployInternal(Iterable<Class<?>> classes) throws DeploymentException
+    {
+        // Scanner service
+        final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) ServiceLoader.getService(ScannerService.class);
+
+        // Lifecycle container
+        this.lifeCycle = new StandaloneLifeCycle()
+        {
+            protected void afterInitApplication(Properties event)
+            {
+                this.scannerService = discovery;
+            }
+        };
+
+        try
+        {
+            Iterator<Class<?>> it = classes.iterator();
+            while (it.hasNext())
+            {
+                discovery.addBeanClass(it.next());
+            }
+
+            this.lifeCycle.startApplication(null);
+
+        }
+        catch (Throwable e)
+        {
+            e.printStackTrace();
+            this.excpetion = new DeploymentException("Standalone Container Impl.", e);
+            throw this.excpetion;
+        }
+
+    }
+
+    public boolean deployInternal(Iterable<Class<?>> classes, Iterable<URL>
beansXmls)
+    {
+        try
+        {
+            final TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl) ServiceLoader.getService(ScannerService.class);
+
+            // Lifecycle container
+            this.lifeCycle = new StandaloneLifeCycle()
+            {
+                protected void afterInitApplication(Properties event)
+                {
+                    this.scannerService = discovery;
+                }
+
+                @Override
+                public void beforeStartApplication(Object object)
+                {
+                    super.beforeStartApplication(object);
+                    try
+                    {
+                        PluginLoader.getInstance().startUp();
+                        //EjbPlugin plugin = (EjbPlugin) PluginLoader.getInstance().getEjbPlugin();
+                        //plugin.setUseInTest(true);
+                    }
+                    catch (Throwable e)
+                    {
+                        // Not worry
+                    }
+                }
+
+            };
+
+            Iterator<Class<?>> it = classes.iterator();
+            while (it.hasNext())
+            {
+                discovery.addBeanClass(it.next());
+            }
+
+            Iterator<URL> itUrl = beansXmls.iterator();
+            while (itUrl.hasNext())
+            {
+                discovery.addBeanXml(itUrl.next());
+            }
+
+            this.lifeCycle.startApplication(null);
+        }
+        catch (Throwable e)
+        {
+            e.printStackTrace();
+            this.excpetion = new DeploymentException("Standalone Container Impl.", e);
+
+            return false;
+        }
+
+        return true;
+    }
+
+    public void setup()
+    {
+
+    }
+
+    public void cleanup()
+    {
+
+    }
+
+    public void undeploy()
+    {
+        try
+        {
+            this.lifeCycle.stopApplication(null);
+            this.lifeCycle = null;
+        }
+        finally
+        {
+            ManagersImpl.cleanUp();
+        }
+    }
+
+    public DeploymentException getDeploymentException()
+    {
+        return this.excpetion;
+    }
+
+    protected BeanManager getBeanManager()
+    {
+        return BeanManagerImpl.getManager();
+    }
+
+    @Override
+    public void deploy(Collection<Class<?>> classes) throws DeploymentException
+    {
+        setUp(classes);
+        deployInternal(classes);
+    }
+
+    @Override
+    public boolean deploy(Collection<Class<?>> classes, Collection<URL>
xmls)
+    {
+        setUp(classes);
+        return deployInternal(classes, xmls);
+    }
+
+    private void setUp(Collection<Class<?>> classes)
+    {
+
+        try
+        {
+            ConfigurationFactory config = new ConfigurationFactory();
+            Assembler assembler = new Assembler();
+
+            assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
+            assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+            assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+            assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
+            assembler.createContainer(config.configureService(StatefulSessionContainerInfo.class));
+            assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
+
+            EjbJarInfo ejbJar = config.configureApplication(buildTestApp(classes));
+
+            assembler.createApplication(ejbJar);
+
+            System.setProperty("openejb.validation.output.level", "VERBOSE");
+            Properties properties = new Properties(System.getProperties());
+            properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+            new InitialContext(properties);
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private EjbModule buildTestApp(Collection<Class<?>> classes)
+    {
+        EjbJar ejbJar = new EjbJar();
+        ejbJar.setId(this.getClass().getName());
+
+        for (Class<?> clazz : classes)
+        {
+            if (isSingleton(clazz))
+            {
+                ejbJar.addEnterpriseBean(new SingletonBean(clazz));
+            }
+            if (isStateless(clazz))
+            {
+                ejbJar.addEnterpriseBean(new StatelessBean(clazz));
+            }
+
+            if (isStatefull(clazz))
+            {
+                ejbJar.addEnterpriseBean(new StatefulBean(clazz));
+            }
+        }
+
+        return new EjbModule(ejbJar);
+
+    }
+
+    private boolean isSingleton(Class<?> clazz)
+    {
+        return clazz.isAnnotationPresent(Singleton.class) ? true : false;
+    }
+
+    private boolean isStateless(Class<?> clazz)
+    {
+        return clazz.isAnnotationPresent(Stateless.class) ? true : false;
+    }
+
+    private boolean isStatefull(Class<?> clazz)
+    {
+        return clazz.isAnnotationPresent(Stateful.class) ? true : false;
+    }
+}



Mime
View raw message