[jboss-cvs] JBossAS SVN: r61204 - branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 7 15:43:22 EST 2007
Author: bstansberry at jboss.com
Date: 2007-03-07 15:43:22 -0500 (Wed, 07 Mar 2007)
New Revision: 61204
Modified:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
Log:
Better failure reporting
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java 2007-03-07 18:46:26 UTC (rev 61203)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java 2007-03-07 20:43:22 UTC (rev 61204)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.cluster.test;
-import java.util.Hashtable;
+import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -93,25 +93,25 @@
// lookup binding locally on Node0 - should succeed
naming = getContext(NODE0_JNDI);
- String value = (String)lookup(naming, LOCAL0_KEY);
+ String value = (String)lookup(naming, LOCAL0_KEY, true);
closeContext(naming);
assertEquals("lookup local binding on same server", LOCAL0_VALUE, value);
// lookup binding locally on Node1 - should fail
naming = getContext(NODE1_JNDI);
- value = (String)lookup(naming, LOCAL0_KEY);
+ value = (String)lookup(naming, LOCAL0_KEY, false);
closeContext(naming);
assertNull("lookup local binding on different server in cluster", value);
// lookup binding using HA-JNDI on Node0 - should succeed
naming = getContext(NODE0_HAJNDI);
- value = (String)lookup(naming, LOCAL0_KEY);
+ value = (String)lookup(naming, LOCAL0_KEY, true);
closeContext(naming);
assertEquals("lookup local binding on same server using HA-JNDI", LOCAL0_VALUE, value);
// lookup binding using HA-JNDI on Node1 - should succeed
naming = getContext(NODE1_HAJNDI);
- value = (String)lookup(naming, LOCAL0_KEY);
+ value = (String)lookup(naming, LOCAL0_KEY, true);
closeContext(naming);
assertEquals("lookup local binding on different server in cluster using HA-JNDI", LOCAL0_VALUE, value);
}
@@ -134,25 +134,25 @@
// lookup binding locally on Node0 - should fail
naming = getContext(NODE0_JNDI);
- String value = (String)lookup(naming, GLOBAL0_KEY);
+ String value = (String)lookup(naming, GLOBAL0_KEY, false);
closeContext(naming);
assertNull("lookup HA-JNDI binding on same server using local JNDI", value);
// lookup binding locally on Node1 - should fail
naming = getContext(NODE1_JNDI);
- value = (String)lookup(naming, GLOBAL0_KEY);
+ value = (String)lookup(naming, GLOBAL0_KEY, false);
closeContext(naming);
assertNull("lookup HA-JNDI binding on different server in cluster using local JNDI", value);
// lookup binding using HA-JNDI on Node0 - should succeed
naming = getContext(NODE0_HAJNDI);
- value = (String)lookup(naming, GLOBAL0_KEY);
+ value = (String)lookup(naming, GLOBAL0_KEY, true);
closeContext(naming);
assertEquals("lookup HA-JNDI binding on same server using HA-JNDI", GLOBAL0_VALUE, value);
// lookup binding using HA-JNDI on Node1 - should succeed
naming = getContext(NODE1_HAJNDI);
- value = (String)lookup(naming, GLOBAL0_KEY);
+ value = (String)lookup(naming, GLOBAL0_KEY, true);
closeContext(naming);
assertEquals("lookup HA-JNDI binding on different server in cluster using HA-JNDI", GLOBAL0_VALUE, value);
@@ -174,7 +174,7 @@
naming.bind(JNDI_KEY, JNDI_VALUE1);
// lookup binding using HA-JNDI on Node0 - should succeed
- String value = (String)lookup(naming, JNDI_KEY);
+ String value = (String)lookup(naming, JNDI_KEY, true);
assertEquals("lookup after initial HA-JNDI binding operation", JNDI_VALUE1, value);
// bind it again - this should fail with NameAlreadyBoundException
@@ -192,14 +192,14 @@
naming.rebind(JNDI_KEY, JNDI_VALUE2);
// lookup binding - should return new value
- value = (String)lookup(naming, JNDI_KEY);
+ value = (String)lookup(naming, JNDI_KEY, true);
assertEquals("lookup after HA-JNDI rebind operation", JNDI_VALUE2, value);
// unbind it
naming.unbind(JNDI_KEY);
// lookup binding - should fail with NamingException
- value = (String)lookup(naming, JNDI_KEY);
+ value = (String)lookup(naming, JNDI_KEY, false);
assertNull("lookup after HA-JNDI unbind operation", value);
closeContext(naming);
@@ -220,7 +220,7 @@
// lookup binding locally on Node0 - should succeed
Context naming = getContext(NODE0_JNDI);
- CalledHome home = (CalledHome)lookup(naming, CALLED_HOME_KEY);
+ CalledHome home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
if (home != null)
{ // ensure that EJB is operational
CalledRemote remote = home.create();
@@ -231,7 +231,7 @@
// lookup binding locally on Node1 - should succeed
naming = getContext(NODE1_JNDI);
- home = (CalledHome)lookup(naming, CALLED_HOME_KEY);
+ home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
if (home != null)
{ // ensure that EJB is operational
CalledRemote remote = home.create();
@@ -242,7 +242,7 @@
// lookup binding using HA-JNDI on Node0 - should succeed
naming = getContext(NODE0_HAJNDI);
- home = (CalledHome)lookup(naming, CALLED_HOME_KEY);
+ home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
if (home != null)
{ // ensure that EJB is operational
CalledRemote remote = home.create();
@@ -253,7 +253,7 @@
// lookup binding using HA-JNDI on Node1 - should succeed
naming = getContext(NODE1_HAJNDI);
- home = (CalledHome)lookup(naming, CALLED_HOME_KEY);
+ home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
if (home != null)
{ // ensure that EJB is operational
CalledRemote remote = home.create();
@@ -296,11 +296,11 @@
naming = getAutoDiscoveryContext(false);
// lookup local binding using HA-JNDI AutoDiscovery - should succeed
- String value = (String)lookup(naming, LOCAL1_KEY);
+ String value = (String)lookup(naming, LOCAL1_KEY, true);
assertEquals("local lookup with AutoDiscovery enabled", LOCAL1_VALUE, value);
// lookup HA binding using HA-JNDI AutoDiscovery - should succeed
- value = (String)lookup(naming, JNDI_KEY3);
+ value = (String)lookup(naming, JNDI_KEY3, true);
assertEquals("lookup of HA-JNDI binding with AutoDiscovery enabled", JNDI_VALUE3, value);
// now disable AutoDiscovery and confirm that the same lookups fail
@@ -308,12 +308,12 @@
naming = getAutoDiscoveryContext(true);
// lookup local binding without HA-JNDI AutoDiscovery - should fail
- value = (String)lookup(naming, LOCAL1_KEY);
+ value = (String)lookup(naming, LOCAL1_KEY, false);
assertNull("local lookup with AutoDiscovery disabled", value);
// lookup HA binding without HA-JNDI AutoDiscovery - should fail
- value = (String)lookup(naming, JNDI_KEY3);
- assertNull("llookup of HA-JNDI binding with AutoDiscovery disabled", value);
+ value = (String)lookup(naming, JNDI_KEY3, false);
+ assertNull("lookup of HA-JNDI binding with AutoDiscovery disabled", value);
closeContext(naming);
@@ -322,10 +322,10 @@
private Context getContext(String url)
throws Exception
{
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- env.put(Context.PROVIDER_URL, url);
- env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ env.setProperty(Context.PROVIDER_URL, url);
+ env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
Context naming = new InitialContext (env);
return naming;
@@ -336,12 +336,12 @@
throws Exception
{
// do not add any urls to the context
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
// Don't let the discovery packet off the test server so we don't
// get spurious responses from other servers on the network
- env.put("jnp.discoveryTTL", DISCOVERY_TTL);
+ env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
if (autoDisabled)
{
@@ -370,7 +370,7 @@
}
}
- private Object lookup(Context context, String name)
+ private Object lookup(Context context, String name, boolean failIfMissing)
{
try
{
@@ -380,7 +380,16 @@
}
catch (NamingException e)
{
- log.info("Name " + name + " not found.");
+ if (failIfMissing)
+ {
+ String msg = "Name " + name + " not found. " + e.getLocalizedMessage();
+ log.info(msg, e);
+ fail(msg);
+ }
+ else
+ {
+ log.debug("Name " + name + " not found.");
+ }
return null;
}
}
More information about the jboss-cvs-commits
mailing list