[jboss-cvs] JBossAS SVN: r112700 - in branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite: imports and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 27 11:28:45 EST 2012


Author: pskopek at redhat.com
Date: 2012-02-27 11:28:44 -0500 (Mon, 27 Feb 2012)
New Revision: 112700

Modified:
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/build.xml
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/imports/server-config.xml
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/NamingUtil.java
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
   branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
Log:
[JBPAPP-7791] fixing test failures

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/build.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/build.xml	2012-02-27 16:27:34 UTC (rev 112699)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/build.xml	2012-02-27 16:28:44 UTC (rev 112700)
@@ -810,7 +810,9 @@
     <!-- JBAS-4271, test intermittently fails -->
     <exclude name="org/jboss/test/pooled/test/SSLSocketsUnitTestCase.class"/>
   	<!-- JBPAPP-4487. Functionality excluded for security reasons -->
-  	<exclude name="org/jboss/test/console/jbas3861/**"/> 
+  	<exclude name="org/jboss/test/console/jbas3861/**"/>
+    <!-- JBPAPP-7791: test cannot be set up, functionality removed for security reasons -->
+  	<exclude name="org/jboss/test/naming/test/ImplUnitTestCase.class"/>
   </patternset>
 
   <patternset id="aop-with-classloader.excludes">

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/imports/server-config.xml
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/imports/server-config.xml	2012-02-27 16:27:34 UTC (rev 112699)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/imports/server-config.xml	2012-02-27 16:28:44 UTC (rev 112700)
@@ -683,6 +683,7 @@
                <include name="deploy/jbossws*.sar/**"/>
                <include name="deploy/ejb3.deployer/**"/>
                 <include name="deploy/properties-service.xml"/>
+               <include name="deploy/httpha-invoker.sar/**"/>
             </fileset>
          </copy>
          <antcall target="modify-farming">

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/NamingUtil.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/NamingUtil.java	2012-02-27 16:27:34 UTC (rev 112699)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/NamingUtil.java	2012-02-27 16:28:44 UTC (rev 112700)
@@ -23,6 +23,7 @@
 package org.jboss.test;
 
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.Properties;
 
@@ -44,6 +45,9 @@
    
    public static Logger log = Logger.getLogger(NamingUtil.class);
    
+   public static final String JNDI_INVOKER = "invoker/JNDIFactory";
+   public static final String HAJNDI_INVOKER = "invoker/HAJNDIFactory";
+   
    /**
     * Create test data. It needs to use org.jboss.naming.HttpNamingContextFactory since JNDI through RMI
     * is already secured and disallow bind/unbind/rebind operations.
@@ -97,13 +101,18 @@
    /**
     * Returns initial context which is able to perform all JNDI operations.
     * @param serverHost - use getServerHostForURL() from inside JBoss Testsuite
+    * @param jndiFactoryUrlSuffix - URL suffix to get proper invoker invoker/JNDIFactory or invoker/HAJNDIFactory
     * @return
     * @throws Exception
     */
-   public static InitialContext getFullInitialContext(String serverHost) 
+   public static InitialContext getFullInitialContext(String serverHost, String jndiFactoryUrlSuffix) 
          throws Exception 
    {
 
+      if (jndiFactoryUrlSuffix == null) {
+         jndiFactoryUrlSuffix = JNDI_INVOKER;
+      }
+      
       Properties env = new Properties();
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
 
@@ -117,7 +126,7 @@
 
       // Test the secured JNDI factory
       // JBPAPP-2997
-      env.setProperty(Context.PROVIDER_URL, "http://" + serverHost + ":8080/invoker/JNDIFactory");
+      env.setProperty(Context.PROVIDER_URL, "http://" + serverHost + ":8080/" + jndiFactoryUrlSuffix);
       log.debug("Creating InitialContext with env="+env);
       InitialContext ctx = new InitialContext(env);
       
@@ -125,7 +134,32 @@
    }
    
    
+   
    /**
+    * Returns initial context which is able to perform all JNDI operations.
+    * @param serverHost - use getServerHostForURL() from inside JBoss Testsuite
+    * @return
+    * @throws Exception
+    */
+   public static InitialContext getFullInitialContext(String serverHost) 
+         throws Exception 
+   {
+      return getFullInitialContext(serverHost, JNDI_INVOKER);
+   }
+   
+   /**
+    * Returns initial context which is able to perform all JNDI operations.
+    * @param serverHost - use getServerHostForURL() from inside JBoss Testsuite
+    * @return
+    * @throws Exception
+    */
+   public static InitialContext getFullHAInitialContext(String serverHost) 
+         throws Exception 
+   {
+      return getFullInitialContext(serverHost, HAJNDI_INVOKER);
+   }
+   
+   /**
     * Extract hostname from jndiURL parameter and get InitialContext using @see getFullInitialContext
     * @param jndiUrl
     * @return
@@ -135,11 +169,25 @@
          throws Exception 
    {
       log.debug("jndiUrl = " + jndiUrl);
-      URL url = new URL(jndiUrl);
-      log.debug("host="+url.getHost());
-      return NamingUtil.getFullInitialContext(url.getHost());
+      URI uri = new URI(jndiUrl);
+      log.debug("host="+uri.getHost());
+      return NamingUtil.getFullInitialContext(uri.getHost());
    }
    
+   /**
+    * Extract hostname from jndiURL parameter and get InitialContext using @see getFullInitialContext
+    * @param jndiUrl
+    * @return
+    * @throws Exception
+    */
+   public static InitialContext getFullHAInitialContextFromUrl(String jndiUrl) 
+         throws Exception 
+   {
+      log.debug("jndiUrl = " + jndiUrl);
+      URI uri = new URI(jndiUrl);
+      log.debug("host="+uri.getHost());
+      return NamingUtil.getFullHAInitialContext(uri.getHost());
+   }
    
    /**
     * Returns URL string for given resource. 

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java	2012-02-27 16:27:34 UTC (rev 112699)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java	2012-02-27 16:28:44 UTC (rev 112700)
@@ -31,7 +31,6 @@
 
 import org.jboss.test.cluster.ejb.CalledHome;
 import org.jboss.test.cluster.ejb.CalledRemote;
-import org.jboss.test.naming.util.JndiManipulator;
 import org.jboss.test.JBossClusteredTestCase;
 import org.jboss.test.NamingUtil;
 import org.jnp.interfaces.NamingContext;
@@ -76,7 +75,7 @@
 
    public static Test suite() throws Exception
    {
-      return getDeploySetup(HAJndiTestCase.class, "cross-server.jar,naming-helper.jar");
+      return getDeploySetup(HAJndiTestCase.class, "cross-server.jar");
    }
 
    /**
@@ -131,14 +130,10 @@
       getLog().debug("HAJndiTestCase.testHAJndiBinding()");
       validateUrls();
       
-      Context naming = null;
-      
       // bind to node0 using HA-JNDI
-      //Context naming = getContext(NODE0_HAJNDI);
-      //naming.bind(GLOBAL0_KEY, GLOBAL0_VALUE);
-      //closeContext(naming);
-      JndiManipulator m = getJndiManipulator(NODE0_HAJNDI);
-      m.bind(NODE0_HAJNDI, GLOBAL0_KEY, GLOBAL0_VALUE);
+      Context naming = NamingUtil.getFullHAInitialContextFromUrl(NODE0_HAJNDI);
+      naming.bind(GLOBAL0_KEY, GLOBAL0_VALUE);
+      closeContext(naming);
       
       // lookup binding locally on Node0 - should fail
       naming = getContext(NODE0_JNDI);
@@ -171,7 +166,6 @@
     *
     * @throws Exception
     */
-   /*  disabled, because testing Naming operations from client does not make sense anymore 
    public void testHAJndiOperations()
       throws Exception
    {
@@ -179,7 +173,7 @@
       validateUrls();
       
       // bind to node0 using HA-JNDI
-      Context naming = getContext(NODE0_HAJNDI);
+      Context naming = NamingUtil.getFullHAInitialContextFromUrl(NODE0_HAJNDI);
       naming.bind(JNDI_KEY, JNDI_VALUE1);     
      
       // lookup binding using HA-JNDI on Node0 - should succeed
@@ -213,7 +207,6 @@
       
       closeContext(naming);  
    }
-   */
    
    /**
     * Test EJB Bindings using local and HA-JNDI lookups
@@ -293,12 +286,12 @@
       }
       
       // bind to node1 locally
-      Context naming = getContext(NODE1_JNDI);
+      Context naming = NamingUtil.getFullInitialContextFromUrl(NODE1_JNDI);
       naming.bind(LOCAL1_KEY, LOCAL1_VALUE);
       closeContext(naming);
       
       // bind to node0 using HA-JNDI
-      naming = getContext(NODE0_HAJNDI);
+      naming = NamingUtil.getFullHAInitialContextFromUrl(NODE0_HAJNDI);
       naming.bind(JNDI_KEY3, JNDI_VALUE3);  
       closeContext(naming);
      
@@ -428,19 +421,5 @@
 
    }
 
-   private JndiManipulator getJndiManipulator(String jndiUrl) throws Exception {
-      
-      Properties env = new Properties();        
-      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-      env.setProperty(Context.PROVIDER_URL, jndiUrl);
-      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
-      
-      Context ctx = new InitialContext (env);
-      JndiManipulator m = (JndiManipulator)ctx.lookup("JndiManipulatorBean/remote");
-      ctx.close();
-      
-      return m;
-      
-   }
    
 }

Modified: branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java	2012-02-27 16:27:34 UTC (rev 112699)
+++ branches/JBPAPP_4_3_0_GA_CP10_JBPAPP-7791/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java	2012-02-27 16:28:44 UTC (rev 112700)
@@ -191,13 +191,7 @@
    {
       getLog().debug("+++ testCreateSubcontext");
       // Look a name that does not exist
-      java.util.Properties env = new java.util.Properties();
-      env.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-      // JBPAPP-2997
-      env.setProperty(javax.naming.Context.PROVIDER_URL, "jnp://" + getServerHostForURL() + ":1100/");
-      getLog().debug("Creating InitialContext with env="+env);
-
-      InitialContext ctx = new javax.naming.InitialContext(env);
+      InitialContext ctx = NamingUtil.getFullHAInitialContext(getServerHostForURL());
       Object obj = ctx.lookup("");
       getLog().debug("lookup('') against HA-JNDI succedded as expected, obj="+obj);
 



More information about the jboss-cvs-commits mailing list