You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2009/12/28 22:01:57 UTC
svn commit: r894246 -
/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java
Author: dblevins
Date: Mon Dec 28 21:01:55 2009
New Revision: 894246
URL: http://svn.apache.org/viewvc?rev=894246&view=rev
Log:
Added more output to the test to help us figure out why continuum may have an issue with this particular test.
Modified:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java?rev=894246&r1=894245&r2=894246&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/singleton/SingletonLazyInstantiationTest.java Mon Dec 28 21:01:55 2009
@@ -81,9 +81,9 @@
thread.start();
}
- finish.await(30, TimeUnit.SECONDS);
+ assertTrue("Client threads did not complete", finish.await(30, TimeUnit.SECONDS));
- assertEquals(1, MySingleton.instances.get());
+ assertEquals("incorrect number of instances", 1, MySingleton.instances.get());
// Invoke a business method just to be sure
MySingletonLocal singletonLocal = (MySingletonLocal) context.lookup("MySingletonLocal");
@@ -109,9 +109,9 @@
thread.start();
}
- finish.await(30, TimeUnit.SECONDS);
+ assertTrue("Client threads did not complete", finish.await(30, TimeUnit.SECONDS));
- assertEquals(1, MySingleton.instances.get());
+ assertEquals("incorrect number of instances", 1, MySingleton.instances.get());
// Invoke a business method just to be sure
MySingletonLocal singletonLocal = (MySingletonLocal) context.lookup("MySingletonLocal");
@@ -136,23 +136,34 @@
public void run() {
try {
- log("await");
+ log("waiting to start");
if (start != null) start.await(20, TimeUnit.SECONDS);
- log("get");
+ log("looking up the singleton");
MySingletonLocal singletonLocal = (MySingletonLocal) context.lookup("MySingletonLocal");
// Have to invoke a method to ensure creation
singletonLocal.getId();
- log("got " + singletonLocal);
+ log("singleton retrieved " + singletonLocal);
} catch (NoSuchEJBException e) {
- if (!exception.get()) throw new RuntimeException(e);
+ if (!exception.get()) {
+ synchronized (System.out) {
+ log("exception");
+ e.printStackTrace(System.out);
+ }
+ throw new RuntimeException(e);
+ }
} catch (Exception e) {
+ synchronized (System.out) {
+ log("exception");
+ e.printStackTrace(System.out);
+ }
throw new RuntimeException(e);
} finally {
+ log("finished");
finish.countDown();
}
}
@@ -160,7 +171,7 @@
}
public static void log(String s) {
-// System.out.println(Thread.currentThread().getName() + " : " + s);
+ System.out.println(Thread.currentThread().getName() + " : " + s);
}
@@ -175,6 +186,7 @@
@PostConstruct
public void construct() throws Exception {
id = instances.incrementAndGet();
+ log("constructing singleton: " + id);
Thread.sleep(5000);
if (exception.get()) throw new Exception("I threw an exception");
}