[jboss-cvs] JBossAS SVN: r99647 - in projects/reloaded/trunk/naming: src/main/java/org/jboss/reloaded/naming/simple and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 20 04:22:34 EST 2010


Author: wolfc
Date: 2010-01-20 04:22:33 -0500 (Wed, 20 Jan 2010)
New Revision: 99647

Added:
   projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyAndNewTestCase.java
Modified:
   projects/reloaded/trunk/naming/pom.xml
   projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/simple/SimpleJavaEEModule.java
   projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/common/AbstractNamingTestCase.java
   projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/interceptor/unit/InterceptorTestCase.java
   projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java
   projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/simple/unit/SimpleTestCase.java
Log:
RELOADED-12: make a stand-alone module behave like an application (note that JavaEEModule and JavaEEApplication are still unlinked)

Modified: projects/reloaded/trunk/naming/pom.xml
===================================================================
--- projects/reloaded/trunk/naming/pom.xml	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/pom.xml	2010-01-20 09:22:33 UTC (rev 99647)
@@ -15,6 +15,7 @@
   <name>JBoss Reloaded Naming</name>
   <url>http://www.jboss.org</url>
   <description>
+     Provide the facilities to fulfil the naming requirements of the JavaEE specification.
   </description>
   
   <build>
@@ -29,15 +30,8 @@
   </build>
 
   <dependencies>
-    <!--
+    <!-- unscoped, because we depend on ENCFactory for legacy integration -->
     <dependency>
-      <groupId>org.jboss.bootstrap</groupId>
-      <artifactId>jboss-bootstrap</artifactId>
-      <version>1.0.0-SNAPSHOT</version>
-      <scope>test</scope>
-    </dependency>
-    -->
-    <dependency>
       <groupId>org.jboss.naming</groupId>
       <artifactId>jnpserver</artifactId>
       <version>5.0.4.GA</version>

Modified: projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/simple/SimpleJavaEEModule.java
===================================================================
--- projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/simple/SimpleJavaEEModule.java	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/src/main/java/org/jboss/reloaded/naming/simple/SimpleJavaEEModule.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -21,11 +21,11 @@
  */
 package org.jboss.reloaded.naming.simple;
 
-import javax.naming.Context;
-
 import org.jboss.reloaded.naming.spi.JavaEEApplication;
 import org.jboss.reloaded.naming.spi.JavaEEModule;
 
+import javax.naming.Context;
+
 /**
  * A simple implementation of {@link JavaEEModule}.
  * 
@@ -49,6 +49,8 @@
    {
       assert name != null : "name is null";
       assert context != null : "context is null";
+      // JavaEE 6 FR 5.2.2: “single application” means a single deployment unit, such as a ... single module deployed standalone
+      assert application != null : "application is null";
       
       this.name = name;
       this.context = context;

Modified: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/common/AbstractNamingTestCase.java
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/common/AbstractNamingTestCase.java	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/common/AbstractNamingTestCase.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -22,6 +22,10 @@
 package org.jboss.reloaded.naming.test.common;
 
 import org.jboss.reloaded.naming.service.NameSpaces;
+import org.jboss.reloaded.naming.simple.SimpleJavaEEApplication;
+import org.jboss.reloaded.naming.simple.SimpleJavaEEModule;
+import org.jboss.reloaded.naming.spi.JavaEEApplication;
+import org.jboss.reloaded.naming.spi.JavaEEModule;
 import org.jnp.interfaces.NamingContext;
 import org.jnp.server.NamingServer;
 import org.jnp.server.SingletonNamingServer;
@@ -72,4 +76,13 @@
       NamingServer srv = new NamingServer();
       return new NamingContext(environment, null, srv);
    }
+
+   protected static JavaEEModule createStandaloneModule(String moduleName) throws NamingException
+   {
+      Context context = javaGlobal.createSubcontext(moduleName);
+      // standalone == app
+      JavaEEApplication application = new SimpleJavaEEApplication(moduleName, context);
+      JavaEEModule module = new SimpleJavaEEModule(moduleName, context, application);
+      return module;
+   }   
 }

Modified: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/interceptor/unit/InterceptorTestCase.java
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/interceptor/unit/InterceptorTestCase.java	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/interceptor/unit/InterceptorTestCase.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -21,15 +21,7 @@
  */
 package org.jboss.reloaded.naming.test.interceptor.unit;
 
-import static org.junit.Assert.assertEquals;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-
-import javax.naming.NamingException;
-
 import org.jboss.reloaded.naming.simple.SimpleJavaEEComponent;
-import org.jboss.reloaded.naming.simple.SimpleJavaEEModule;
 import org.jboss.reloaded.naming.spi.JavaEEComponent;
 import org.jboss.reloaded.naming.spi.JavaEEModule;
 import org.jboss.reloaded.naming.test.common.AbstractNamingTestCase;
@@ -37,8 +29,16 @@
 import org.jboss.reloaded.naming.test.interceptor.ValueHolder;
 import org.jboss.reloaded.naming.test.interceptor.ValueHolderBean;
 import org.jboss.util.naming.Util;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
+import javax.naming.NamingException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import static org.junit.Assert.assertEquals;
+
 /**
  * Since we provide an abstract interceptor, might as well test it. :-)
  * 
@@ -47,10 +47,23 @@
  */
 public class InterceptorTestCase extends AbstractNamingTestCase
 {
+   private JavaEEModule module;
+
+   @After
+   public void after() throws NamingException
+   {
+      javaGlobal.unbind(module.getName());
+   }
+
+   @Before
+   public void before() throws NamingException
+   {
+      this.module = createStandaloneModule("module");
+   }
+
    @Test
    public void test1() throws NamingException
    {
-      JavaEEModule module = new SimpleJavaEEModule("module", createContext(iniCtx.getEnvironment()), null);
       JavaEEComponent component = new SimpleJavaEEComponent("intercepted", createContext(iniCtx.getEnvironment()), module);
       
       Util.rebind(component.getContext(), "env/value", "Hello intercepted");

Copied: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyAndNewTestCase.java (from rev 99642, projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java)
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyAndNewTestCase.java	                        (rev 0)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyAndNewTestCase.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.naming.test.legacy.unit;
+
+import org.jboss.naming.ENCFactory;
+import org.jboss.reloaded.naming.CurrentComponent;
+import org.jboss.reloaded.naming.simple.SimpleJavaEEComponent;
+import org.jboss.reloaded.naming.spi.JavaEEComponent;
+import org.jboss.reloaded.naming.spi.JavaEEModule;
+import org.jboss.reloaded.naming.test.common.AbstractNamingTestCase;
+import org.jboss.util.naming.Util;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * Test the interaction between the legacy java:comp (ENCFactory) and the new
+ * one (CurrentComponent).
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LegacyAndNewTestCase extends AbstractNamingTestCase
+{
+   private JavaEEComponent component;
+
+   @After
+   public void after() throws NamingException
+   {
+      javaGlobal.unbind(component.getModule().getName());
+   }
+
+   @Before
+   public void before() throws NamingException
+   {
+      JavaEEModule module = createStandaloneModule("module");
+      component = new SimpleJavaEEComponent("new", createContext(iniCtx.getEnvironment()), module);
+   }
+
+   @Test
+   public void testLegacyCallingNew() throws NamingException
+   {
+      final String newValue = "testNewCallingLegacy new";
+      final String legacyValue = "testNewCallingLegacy legacy";
+      
+      Util.rebind(component.getContext(), "env/value", newValue);
+
+      ENCFactory.pushContextId("legacy");
+      try
+      {
+         Context ctx = (Context) iniCtx.lookup("java:comp");
+         Util.rebind(ctx, "env/value", legacyValue);
+      }
+      finally
+      {
+         ENCFactory.popContextId();
+      }
+      
+      ENCFactory.pushContextId("legacy");
+      try
+      {
+         String value = (String) iniCtx.lookup("java:comp/env/value");
+         assertEquals(legacyValue, value);
+         
+         CurrentComponent.push(component);
+         try
+         {
+            value = (String) iniCtx.lookup("java:comp/env/value");
+            assertEquals(newValue, value);
+         }
+         finally
+         {
+            CurrentComponent.pop();
+         }
+         
+         value = (String) iniCtx.lookup("java:comp/env/value");
+         assertEquals(legacyValue, value);
+      }
+      finally
+      {
+         ENCFactory.popContextId();
+      }
+   }
+   
+   @Test
+   public void testNewCallingLegacy() throws NamingException
+   {
+      final String newValue = "testNewCallingLegacy new";
+      final String legacyValue = "testNewCallingLegacy legacy";
+      
+      Util.rebind(component.getContext(), "env/value", newValue);
+
+      ENCFactory.pushContextId("legacy");
+      try
+      {
+         Context ctx = (Context) iniCtx.lookup("java:comp");
+         Util.rebind(ctx, "env/value", legacyValue);
+      }
+      finally
+      {
+         ENCFactory.popContextId();
+      }
+      
+      CurrentComponent.push(component);
+      try
+      {
+         String value = (String) iniCtx.lookup("java:comp/env/value");
+         assertEquals(newValue, value);
+         
+         ENCFactory.pushContextId("legacy");
+         try
+         {
+            value = (String) iniCtx.lookup("java:comp/env/value");
+            assertEquals(legacyValue, value);
+         }
+         finally
+         {
+            ENCFactory.popContextId();
+         }
+         
+         value = (String) iniCtx.lookup("java:comp/env/value");
+         assertEquals(newValue, value);
+      }
+      finally
+      {
+         CurrentComponent.pop();
+      }
+   }
+}

Modified: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/legacy/unit/LegacyTestCase.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -23,11 +23,6 @@
 
 import junit.framework.Assert;
 import org.jboss.naming.ENCFactory;
-import org.jboss.reloaded.naming.CurrentComponent;
-import org.jboss.reloaded.naming.simple.SimpleJavaEEComponent;
-import org.jboss.reloaded.naming.simple.SimpleJavaEEModule;
-import org.jboss.reloaded.naming.spi.JavaEEComponent;
-import org.jboss.reloaded.naming.spi.JavaEEModule;
 import org.jboss.reloaded.naming.test.common.AbstractNamingTestCase;
 import org.jboss.util.naming.Util;
 import org.junit.Test;
@@ -35,10 +30,11 @@
 import javax.naming.Context;
 import javax.naming.NamingException;
 
-import static junit.framework.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 /**
+ * Some simple tests against the legacy java:comp (ENCFactory).
+ * 
  * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
  * @version $Revision: $
  */
@@ -108,101 +104,4 @@
          ENCFactory.popContextId();
       }
    }
-
-   @Test
-   public void testLegacyCallingNew() throws NamingException
-   {
-      final String newValue = "testNewCallingLegacy new";
-      final String legacyValue = "testNewCallingLegacy legacy";
-      
-      JavaEEModule module = new SimpleJavaEEModule("module", createContext(iniCtx.getEnvironment()), null);
-      JavaEEComponent component = new SimpleJavaEEComponent("new", createContext(iniCtx.getEnvironment()), module);
-      
-      Util.rebind(component.getContext(), "env/value", newValue);
-
-      ENCFactory.pushContextId("legacy");
-      try
-      {
-         Context ctx = (Context) iniCtx.lookup("java:comp");
-         Util.rebind(ctx, "env/value", legacyValue);
-      }
-      finally
-      {
-         ENCFactory.popContextId();
-      }
-      
-      ENCFactory.pushContextId("legacy");
-      try
-      {
-         String value = (String) iniCtx.lookup("java:comp/env/value");
-         assertEquals(legacyValue, value);
-         
-         CurrentComponent.push(component);
-         try
-         {
-            value = (String) iniCtx.lookup("java:comp/env/value");
-            assertEquals(newValue, value);
-         }
-         finally
-         {
-            CurrentComponent.pop();
-         }
-         
-         value = (String) iniCtx.lookup("java:comp/env/value");
-         assertEquals(legacyValue, value);
-      }
-      finally
-      {
-         ENCFactory.popContextId();
-      }
-      
-   }
-   
-   @Test
-   public void testNewCallingLegacy() throws NamingException
-   {
-      final String newValue = "testNewCallingLegacy new";
-      final String legacyValue = "testNewCallingLegacy legacy";
-      
-      JavaEEModule module = new SimpleJavaEEModule("module", createContext(iniCtx.getEnvironment()), null);
-      JavaEEComponent component = new SimpleJavaEEComponent("new", createContext(iniCtx.getEnvironment()), module);
-      
-      Util.rebind(component.getContext(), "env/value", newValue);
-
-      ENCFactory.pushContextId("legacy");
-      try
-      {
-         Context ctx = (Context) iniCtx.lookup("java:comp");
-         Util.rebind(ctx, "env/value", legacyValue);
-      }
-      finally
-      {
-         ENCFactory.popContextId();
-      }
-      
-      CurrentComponent.push(component);
-      try
-      {
-         String value = (String) iniCtx.lookup("java:comp/env/value");
-         assertEquals(newValue, value);
-         
-         ENCFactory.pushContextId("legacy");
-         try
-         {
-            value = (String) iniCtx.lookup("java:comp/env/value");
-            assertEquals(legacyValue, value);
-         }
-         finally
-         {
-            ENCFactory.popContextId();
-         }
-         
-         value = (String) iniCtx.lookup("java:comp/env/value");
-         assertEquals(newValue, value);
-      }
-      finally
-      {
-         CurrentComponent.pop();
-      }
-   }
 }

Modified: projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/simple/unit/SimpleTestCase.java
===================================================================
--- projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/simple/unit/SimpleTestCase.java	2010-01-20 08:51:37 UTC (rev 99646)
+++ projects/reloaded/trunk/naming/src/test/java/org/jboss/reloaded/naming/test/simple/unit/SimpleTestCase.java	2010-01-20 09:22:33 UTC (rev 99647)
@@ -63,13 +63,6 @@
       return component;
    }
 
-   protected static JavaEEModule createModule(String moduleName) throws NamingException
-   {
-      Context context = javaGlobal.createSubcontext(moduleName);
-      JavaEEModule module = new SimpleJavaEEModule(moduleName, context, null);
-      return module;
-   }
-
    protected static JavaEEModule createModule(JavaEEApplication app, String moduleName) throws NamingException
    {
       Context context = app.getContext().createSubcontext(moduleName);
@@ -86,7 +79,7 @@
    @Before
    public void before() throws NamingException
    {
-      module = createModule("a_module");
+      module = createStandaloneModule("a_module");
       component = createComponent(module, "a_component");
 
       Util.rebind(component.getContext(), "env/value", "Hello world");




More information about the jboss-cvs-commits mailing list