openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r826111 - in /incubator/openwebbeans/trunk/webbeans-porting: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/test/ src/main/java/org/apache/w...
Date Fri, 16 Oct 2009 22:16:40 GMT
Author: gerdogdu
Date: Fri Oct 16 22:16:39 2009
New Revision: 826111

URL: http://svn.apache.org/viewvc?rev=826111&view=rev
Log:
Adding TCK Porting project

Added:
    incubator/openwebbeans/trunk/webbeans-porting/   (with props)
    incubator/openwebbeans/trunk/webbeans-porting/pom.xml   (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/
    incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-porting/src/main/resources/

Propchange: incubator/openwebbeans/trunk/webbeans-porting/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct 16 22:16:39 2009
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Added: incubator/openwebbeans/trunk/webbeans-porting/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/pom.xml?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/pom.xml (added)
+++ incubator/openwebbeans/trunk/webbeans-porting/pom.xml Fri Oct 16 22:16:39 2009
@@ -0,0 +1,74 @@
+<?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.
+-->
+
+<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.openwebbeans</groupId>
+		<artifactId>openwebbeans</artifactId>
+		<version>1.0.0-incubating-SNAPSHOT</version>
+	</parent>
+    
+	<artifactId>openwebbeans-porting</artifactId>
+	<name>Apache OpenWebBeans :: TCK Porting Package</name>
+	<packaging>jar</packaging>
+	<version>1.0.0-incubating-SNAPSHOT</version>
+	<description>TCK Porting Package OpenWebBeans Implementation</description>
+
+    <dependencies>
+        <!-- we need some test classes like e.g. MockMangager from webbeans-impl -->
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_3.0_spec</artifactId>
+        </dependency>
+
+	<dependency>
+           <groupId>org.apache.geronimo.specs</groupId>
+	    <artifactId>geronimo-servlet_2.5_spec</artifactId>
+	</dependency>
+
+
+       <dependency>
+         <groupId>org.jboss.jsr299.tck</groupId>
+         <artifactId>jsr299-tck-api</artifactId>
+         <version>1.0.0-SNAPSHOT</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-el_1.0_spec</artifactId>
+      </dependency>
+
+</dependencies>
+
+
+</project>

Propchange: incubator/openwebbeans/trunk/webbeans-porting/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,76 @@
+/*
+ * 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.test.tck;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.persistence.Entity;
+
+
+import org.apache.webbeans.component.AbstractBean;
+import org.apache.webbeans.component.ManagedBean;
+import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.config.DefinitionUtil;
+import org.apache.webbeans.config.ManagedBeanConfigurator;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.jboss.jsr299.tck.spi.Beans;
+
+public class BeansImpl implements Beans
+{
+
+    @SuppressWarnings("unchecked")
+    public <T> Bean<T> createProducerMethodBean(Method method, Bean<?>
declaringBean)
+    {
+        return DefinitionUtil.createProducerComponent((Class<T>)method.getReturnType(),
method, (AbstractBean<?>)declaringBean, false);
+        
+    }
+
+    public <T> Bean<T> createSimpleBean(Class<T> clazz)
+    {
+        ManagedBean<T> bean = null;
+
+        ManagedBeanConfigurator.checkSimpleWebBeanCondition(clazz);
+        
+        bean = ManagedBeanConfigurator.define(clazz, WebBeansType.MANAGED);
+
+        return bean;
+    }
+
+    public boolean isEnterpriseBean( Class<?> clazz ) {
+        return false;
+    }
+
+    public boolean isEntityBean( Class<?> clazz ) 
+    {
+        return (AnnotationUtil.hasClassAnnotation(clazz, Entity.class));
+    }        
+
+    public boolean isProxy( Object instance ) {
+        return instance.getClass().getName().contains("$$");
+    }
+
+    public boolean isStatefulBean( Class<?> clazz ) {
+        return false;
+    }
+
+    public boolean isStatelessBean( Class<?> clazz ) {
+        return false;
+    }
+
+    public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T>
localInterface)
+    {
+        return null;
+    }
+}
\ No newline at end of file

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/BeansImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.test.tck;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.Containers;
+
+
+public class ContainersImpl implements Containers
+{
+
+  //  private Logger logger = Logger.getLogger(ContainersImpl.class);
+
+    public void cleanup() throws IOException
+    {
+
+    }
+
+    public boolean deploy(InputStream archive, String name)
+    {
+        try
+        {
+            if(archive.available() > 0)
+            {
+                File file = new File("target/container/" + name);
+                FileOutputStream os = new FileOutputStream(file);            
+                byte temp[] = new byte[512];
+                
+                while(archive.read(temp) != -1)
+                {
+                    os.write(temp);
+                }            
+   
+            }
+        } catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+        return false;
+    }
+
+    public void setup() throws IOException
+    {
+
+    }
+
+    public void undeploy(String name) throws IOException
+    {
+
+    }
+
+    public DeploymentException getDeploymentException()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContainersImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.test.tck;
+
+import org.apache.webbeans.context.AbstractContext;
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.context.type.ContextTypes;
+import org.jboss.jsr299.tck.spi.Contexts;
+
+public class ContextsImpl implements Contexts<AbstractContext>
+{
+
+    public AbstractContext getRequestContext()
+    {
+        ContextFactory.initRequestContext(null);
+        return (AbstractContext) ContextFactory.getStandartContext(ContextTypes.REQUEST);
+    }
+
+    public void setActive(AbstractContext context)
+    {
+        context.setActive(true);
+        
+    }
+
+    public void setInactive(AbstractContext context)
+    {
+        context.setActive(false);
+    }
+
+    public AbstractContext getDependentContext() {
+        return (AbstractContext) ContextFactory.getStandartContext(ContextTypes.DEPENDENT);
+    }
+
+    public void destroyContext(AbstractContext context)
+    {
+        context.destroy();
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,119 @@
+/*
+ * 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.test.tck;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+import org.apache.webbeans.el.WebBeansELResolver;
+import org.jboss.jsr299.tck.spi.EL;
+
+public class ELImpl implements EL
+{
+    private WebBeansELResolver resolver = new WebBeansELResolver();
+    
+    public static class ELContextImpl extends ELContext
+    {
+
+        @Override
+        public ELResolver getELResolver()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public FunctionMapper getFunctionMapper()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public VariableMapper getVariableMapper()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+        
+    }
+    
+    @SuppressWarnings("unchecked")
+    public <T> T evaluateMethodExpression(String expression, Class<T> expectedType,
Class<?>[] expectedParamTypes, Object[] expectedParams)
+    {
+        int firstDot = expression.indexOf('.');
+        String property = expression.substring(expression.indexOf("#"),firstDot) + "}"; //object
name
+        String methodName = expression.substring(firstDot+1,expression.length()-1);
+        
+        Object object = evaluateValueExpression(property, expectedType);
+        
+        try
+        {
+            Method method = object.getClass().getMethod(methodName, expectedParamTypes);
+            return (T)method.invoke(object, expectedParams);
+        }
+        catch (SecurityException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (NoSuchMethodException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (IllegalArgumentException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (IllegalAccessException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (InvocationTargetException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T evaluateValueExpression(String expression, Class<T> expectedType)
+    {
+        String property = expression.substring(expression.indexOf("#")+2,expression.length()-1);
+        
+        T object = (T) resolver.getValue(new ELContextImpl() , null, property);
+        
+        return object;
+    }
+
+    @Override
+    public ELContext createELContext()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ELImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,64 @@
+/*
+ * 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.test.tck;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.container.activity.ActivityManager;
+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
+{
+
+    public BeanManager getManager()
+    {
+        BeanManagerImpl impl = ActivityManager.getInstance().getRootActivity();
+        
+        if(impl == null)
+        {
+            impl = new BeanManagerImpl();
+            ActivityManager.getInstance().setRootActivity(impl);
+        }
+        
+        return impl;
+    }
+
+    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;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ManagersImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,134 @@
+/*
+ * 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.test.tck;
+
+import java.net.URL;
+import java.util.Iterator;
+
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.lifecycle.WebBeansLifeCycle;
+import org.apache.webbeans.spi.ServiceLoader;
+import org.apache.webbeans.spi.deployer.MetaDataDiscoveryService;
+import org.apache.webbeans.test.mock.MockHttpSession;
+import org.apache.webbeans.test.mock.MockServletContextEvent;
+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 WebBeansLifeCycle lifeCycle = null;
+    
+    private MockServletContextEvent servletContextEvent;
+    
+    private MockHttpSession mockHttpSession;
+    
+    private DeploymentException excpetion;
+        
+    public void deploy(Iterable<Class<?>> classes) throws DeploymentException
+    {
+        initializeContexts();
+        
+        TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl)ServiceLoader.getService(MetaDataDiscoveryService.class);
+        
+        this.lifeCycle = new WebBeansLifeCycle();
+        
+        try
+        {
+            Iterator<Class<?>> it = classes.iterator();
+            while(it.hasNext())
+            {
+                discovery.addBeanClass(it.next());
+            }
+            
+            this.lifeCycle.applicationStarted(servletContextEvent);
+            
+        }catch(Throwable e)
+        {
+            this.excpetion = new DeploymentException("Standalone Container Impl.",e);
+        }
+        
+    }
+
+
+    public boolean deploy(Iterable<Class<?>> classes, Iterable<URL> beansXmls)
+    {
+        try
+        {
+            initializeContexts();
+            
+            TCKMetaDataDiscoveryImpl discovery = (TCKMetaDataDiscoveryImpl)ServiceLoader.getService(MetaDataDiscoveryService.class);
+            
+            this.lifeCycle = new WebBeansLifeCycle();
+            
+            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.applicationStarted(servletContextEvent);            
+        }
+        catch(Throwable e)
+        {
+            this.excpetion = new DeploymentException("Standalone Container Impl.",e);
+        }
+        
+        return true;
+    }
+
+    
+    private void initializeContexts()
+    {
+        this.mockHttpSession = new MockHttpSession();
+        
+        ContextFactory.initRequestContext(null);
+        ContextFactory.initSessionContext(mockHttpSession);
+        ContextFactory.initConversationContext(null);
+        
+        this.servletContextEvent = new MockServletContextEvent();        
+    }
+    
+    public void setup()
+    {
+        
+    }
+    
+    public void cleanup()
+    {
+        
+    }
+    
+
+    public void undeploy()
+    {
+        ContextFactory.destroyRequestContext(null);
+        ContextFactory.destroySessionContext(this.mockHttpSession);
+        ContextFactory.destroyConversationContext();
+        
+        this.lifeCycle.applicationEnded(this.servletContextEvent);
+    }
+
+    public DeploymentException getDeploymentException()
+    {
+        return this.excpetion;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java?rev=826111&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
Fri Oct 16 22:16:39 2009
@@ -0,0 +1,63 @@
+/*
+ *  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.test.tck.mock;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javassist.ClassPool;
+
+import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
+import org.apache.webbeans.util.Asserts;
+
+public class TCKMetaDataDiscoveryImpl extends AbstractMetaDataDiscovery
+{
+
+    public TCKMetaDataDiscoveryImpl()
+    {
+        super();
+    }
+    
+    @Override
+    protected void configure() throws Exception
+    {
+        
+        
+    }
+
+    public void addBeanClass(Class<?> clazz)
+    {
+        Asserts.assertNotNull(clazz);
+        
+        URL url = ClassPool.getDefault().find(clazz.getName());
+        try
+        {
+            this.getAnnotationDB().scanClass(url.openStream());
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+    }
+    
+    public void addBeanXml(URL url)
+    {
+        Asserts.assertNotNull(url);
+        addWebBeansXmlLocation(url);
+    }
+    
+}

Propchange: incubator/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message