[jboss-cvs] JBossAS SVN: r114662 - branches/JBPAPP_5/testsuite/src/main/org/jboss/test/naming/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 13 10:37:58 EST 2014
Author: istudens at redhat.com
Date: 2014-01-13 10:37:58 -0500 (Mon, 13 Jan 2014)
New Revision: 114662
Modified:
branches/JBPAPP_5/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
Log:
JBPAPP-10955 hopefully fixing the intermittent issue in SimpleUnitTestCase
Modified: branches/JBPAPP_5/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
===================================================================
--- branches/JBPAPP_5/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java 2014-01-13 06:03:08 UTC (rev 114661)
+++ branches/JBPAPP_5/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java 2014-01-13 15:37:58 UTC (rev 114662)
@@ -70,19 +70,26 @@
{
getLog().debug("+++ testCreateSubcontext");
InitialContext ctx = NamingUtil.getFullInitialContext(getServerHost());
- ctx.createSubcontext("foo");
try
{
ctx.createSubcontext("foo");
- fail("Second createSubcontext(foo) did NOT fail");
+ try
+ {
+ ctx.createSubcontext("foo");
+ fail("Second createSubcontext(foo) did NOT fail");
+ }
+ catch (NameAlreadyBoundException e)
+ {
+ getLog().debug("Second createSubcontext(foo) failed as expected");
+ }
+ ctx.createSubcontext("foo/bar");
+ ctx.unbind("foo/bar");
+ ctx.unbind("foo");
}
- catch (NameAlreadyBoundException e)
+ finally
{
- getLog().debug("Second createSubcontext(foo) failed as expected");
+ ctx.close();
}
- ctx.createSubcontext("foo/bar");
- ctx.unbind("foo/bar");
- ctx.unbind("foo");
}
/** Lookup a name to test basic connectivity and lookup of a known name
@@ -92,9 +99,17 @@
public void testLookup() throws Exception
{
getLog().debug("+++ testLookup");
+ delegate.reinit();
InitialContext ctx = getInitialContext();
- Object obj = ctx.lookup("");
- getLog().debug("lookup('') = "+obj);
+ try
+ {
+ Object obj = ctx.lookup("");
+ getLog().debug("lookup('') = "+obj);
+ }
+ finally
+ {
+ ctx.close();
+ }
}
/** List the root context
@@ -104,28 +119,42 @@
public void testListing() throws Exception
{
log.debug("+++ testListing");
+ delegate.reinit();
InitialContext ctx = getInitialContext();
- NamingEnumeration names = ctx.list("");
- int count = 0;
- while( names.hasMore() )
+ try
{
- NameClassPair ncp = (NameClassPair) names.next();
- log.info(ncp);
- count ++;
+ NamingEnumeration names = ctx.list("");
+ int count = 0;
+ while( names.hasMore() )
+ {
+ NameClassPair ncp = (NameClassPair) names.next();
+ log.info(ncp);
+ count ++;
+ }
+ assertTrue("list count > 0 ", count > 0);
}
- assertTrue("list count > 0 ", count > 0);
- ctx.close();
+ finally
+ {
+ ctx.close();
+ }
}
public void testNameChanges() throws Exception
{
getLog().debug("+++ testNameChanges");
InitialContext ctx = NamingUtil.getFullInitialContext(getServerHost());
- Name name = ctx.getNameParser("").parse("jnp://" + getServerHost() + "/jmx");
- Name copy = (Name) name.clone();
- Object obj = ctx.lookup(name);
- getLog().debug("lookup("+name+") = "+obj);
- assertTrue("name.equals(copy), name="+name, name.equals(copy));
+ try
+ {
+ Name name = ctx.getNameParser("").parse("jnp://" + getServerHost() + "/jmx");
+ Name copy = (Name) name.clone();
+ Object obj = ctx.lookup(name);
+ getLog().debug("lookup("+name+") = "+obj);
+ assertTrue("name.equals(copy), name="+name, name.equals(copy));
+ }
+ finally
+ {
+ ctx.close();
+ }
}
/** Lookup a name to test basic connectivity and lookup of a known name
@@ -147,6 +176,10 @@
{
getLog().debug("lookup(__bad_name__) failed as expected", e);
}
+ finally
+ {
+ ctx.close();
+ }
// Do a lookup on a server port that does not exist
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
@@ -163,6 +196,10 @@
{
getLog().debug("lookup('') failed as expected", e);
}
+ finally
+ {
+ ctx.close();
+ }
}
public void testHaInvoker() throws Exception
@@ -172,17 +209,23 @@
env.setProperty(Context.PROVIDER_URL, "jnp://" + getServerHost() + ":1100/");
getLog().debug("Creating InitialContext with env="+env);
InitialContext ctx = new InitialContext(env);
- getLog().debug("Created InitialContext");
- Object obj = ctx.lookup("jmx");
- getLog().debug("lookup(jmx) : "+obj);
- Context invokersCtx = (Context) obj;
- NamingEnumeration list = invokersCtx.list("");
- while( list.hasMore() )
+ try
{
- Object entry = list.next();
- getLog().debug(" + "+entry);
+ getLog().debug("Created InitialContext");
+ Object obj = ctx.lookup("jmx");
+ getLog().debug("lookup(jmx) : "+obj);
+ Context invokersCtx = (Context) obj;
+ NamingEnumeration list = invokersCtx.list("");
+ while( list.hasMore() )
+ {
+ Object entry = list.next();
+ getLog().debug(" + "+entry);
+ }
}
- ctx.close();
+ finally
+ {
+ ctx.close();
+ }
}
/**
@@ -195,39 +238,47 @@
getLog().debug("+++ testCreateHaJndiSubcontext");
// Look a name that does not exist
InitialContext ctx = NamingUtil.getFullHAInitialContext(getServerHost());
- Object obj = ctx.lookup("");
- getLog().debug("lookup('') against HA-JNDI succeeded as expected, obj="+obj);
-
- ctx.createSubcontext("foo");
try
{
+ Object obj = ctx.lookup("");
+ getLog().debug("lookup('') against HA-JNDI succeeded as expected, obj="+obj);
+
ctx.createSubcontext("foo");
- fail("Second createSubcontext(foo) against HA-JNDI did NOT fail");
- }
- catch (javax.naming.NameAlreadyBoundException e)
- {
- getLog().debug("Second createSubcontext(foo) against HA-JNDI failed as expected");
- }
+ try
+ {
+ ctx.createSubcontext("foo");
+ fail("Second createSubcontext(foo) against HA-JNDI did NOT fail");
+ }
+ catch (javax.naming.NameAlreadyBoundException e)
+ {
+ getLog().debug("Second createSubcontext(foo) against HA-JNDI failed as expected");
+ }
- getLog().debug("binding foo/bar");
- ctx.createSubcontext("foo/bar");
+ getLog().debug("binding foo/bar");
+ ctx.createSubcontext("foo/bar");
- getLog().debug("unbinding foo/bar");
- ctx.unbind("foo/bar");
+ getLog().debug("unbinding foo/bar");
+ ctx.unbind("foo/bar");
- getLog().debug("unbinding foo");
- ctx.unbind("foo");
+ getLog().debug("unbinding foo");
+ ctx.unbind("foo");
- try
- {
- obj = ctx.lookup("foo");
- fail("lookup(foo) should have thrown an exception");
+ try
+ {
+ obj = ctx.lookup("foo");
+ fail("lookup(foo) should have thrown an exception");
+ }
+ catch(NameNotFoundException e)
+ {
+ getLog().debug("lookup(foo) failed as expected", e);
+ }
}
- catch(NameNotFoundException e)
+ finally
{
- getLog().debug("lookup(foo) failed as expected", e);
+ ctx.close();
}
}
+
public void testHttpInvoker() throws Exception
{
getLog().debug("+++ testHttpInvoker");
@@ -236,17 +287,23 @@
env.setProperty(Context.PROVIDER_URL, "http://" + getServerHost() + ":8080/invoker/JNDIFactory");
getLog().debug("Creating InitialContext with env="+env);
InitialContext ctx = new InitialContext(env);
- getLog().debug("Created InitialContext");
- Object obj = ctx.lookup("jmx");
- getLog().debug("lookup(jmx) : "+obj);
- Context invokersCtx = (Context) obj;
- NamingEnumeration list = invokersCtx.list("");
- while( list.hasMore() )
+ try
{
- Object entry = list.next();
- getLog().debug(" + "+entry);
+ getLog().debug("Created InitialContext");
+ Object obj = ctx.lookup("jmx");
+ getLog().debug("lookup(jmx) : "+obj);
+ Context invokersCtx = (Context) obj;
+ NamingEnumeration list = invokersCtx.list("");
+ while( list.hasMore() )
+ {
+ Object entry = list.next();
+ getLog().debug(" + "+entry);
+ }
}
- ctx.close();
+ finally
+ {
+ ctx.close();
+ }
}
}
More information about the jboss-cvs-commits
mailing list