You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/03/05 23:09:05 UTC

svn commit: r750626 - in /incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck: StandaloneContainersImpl.java mock/TCKMetaDataDiscoveryImpl.java mock/TCKWebBeansContainerDeployer.java

Author: gerdogdu
Date: Thu Mar  5 22:09:05 2009
New Revision: 750626

URL: http://svn.apache.org/viewvc?rev=750626&view=rev
Log:
Updating the test startup process.

Added:
    incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java   (with props)
Removed:
    incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKWebBeansContainerDeployer.java
Modified:
    incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java

Modified: incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java?rev=750626&r1=750625&r2=750626&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/StandaloneContainersImpl.java Thu Mar  5 22:09:05 2009
@@ -18,22 +18,26 @@
 
 import javax.inject.Production;
 
-import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.deployment.DeploymentTypeManager;
+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.MockServletContextEvent;
 import org.apache.webbeans.test.tck.mock.TCKManager;
-import org.apache.webbeans.test.tck.mock.TCKWebBeansContainerDeployer;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
+import org.apache.webbeans.test.tck.mock.TCKMetaDataDiscoveryImpl;
 import org.jboss.jsr299.tck.api.DeploymentException;
 import org.jboss.jsr299.tck.spi.StandaloneContainers;
 
 public class StandaloneContainersImpl implements StandaloneContainers
 {
-    private TCKWebBeansContainerDeployer tckContainerDeployer = null;
-    private WebBeansXMLConfigurator xmlConfigurator = null;
-
+    private WebBeansLifeCycle lifeCycle = null;
+    private MockServletContextEvent servletContextEvent;
+    
+    private TCKMetaDataDiscoveryImpl discovery = null;
+    
     public void cleanup()
     {
-        this.tckContainerDeployer = null;
+        this.lifeCycle.applicationEnded(this.servletContextEvent);
     }
 
     public void deploy(Iterable<Class<?>> classes) throws DeploymentException
@@ -41,10 +45,10 @@
         Iterator<Class<?>> it = classes.iterator();
         while(it.hasNext())
         {
-            tckContainerDeployer.addBeanClass(it.next());
+            discovery.addBeanClass(it.next());
         }
         
-        tckContainerDeployer.deploy(null);
+        this.lifeCycle.applicationStarted(servletContextEvent);
     }
 
 
@@ -53,23 +57,24 @@
         Iterator<Class<?>> it = classes.iterator();
         while(it.hasNext())
         {
-            tckContainerDeployer.addBeanClass(it.next());
+            discovery.addBeanClass(it.next());
         }
         
         Iterator<URL> itUrl = beansXmls.iterator();
         while(itUrl.hasNext())
         {
-            tckContainerDeployer.addBeanXml(itUrl.next());
+            discovery.addBeanXml(itUrl.next());
         }
         
-        tckContainerDeployer.deploy(null);
+        this.lifeCycle.applicationStarted(servletContextEvent);
+        
     }
 
     public void setup()
     {
-        this.xmlConfigurator = new WebBeansXMLConfigurator();
-        this.tckContainerDeployer = new TCKWebBeansContainerDeployer(this.xmlConfigurator);    
-        TCKManager.getInstance().setXMLConfigurator(this.xmlConfigurator);
+        this.discovery = (TCKMetaDataDiscoveryImpl)ServiceLoader.getService(MetaDataDiscoveryService.class);
+        this.lifeCycle = new WebBeansLifeCycle();
+        this.servletContextEvent = new MockServletContextEvent();
         DeploymentTypeManager.getInstance().addNewDeploymentType(Production.class, 1);
     }
 

Added: incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java?rev=750626&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java (added)
+++ incubator/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/test/tck/mock/TCKMetaDataDiscoveryImpl.java Thu Mar  5 22:09:05 2009
@@ -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.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.ANNOTATION_DB.scanClass(url.openStream());
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+    }
+    
+    public void addBeanXml(URL url)
+    {
+        Asserts.assertNotNull(url);
+        
+        try
+        {
+            getWEBBEANS_XML_LOCATIONS().put(url.getFile(), url.openStream());
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+    }
+    
+}

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