You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/02/13 16:00:29 UTC
svn commit: r744137 - in /servicemix/smx4/nmr/trunk/jbi/itests/src/test:
java/org/apache/servicemix/jbi/IntegrationTest.java
resources/log4j.properties
Author: gnodet
Date: Fri Feb 13 15:00:28 2009
New Revision: 744137
URL: http://svn.apache.org/viewvc?rev=744137&view=rev
Log:
Fix integration tests for jbi
Modified:
servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java
servicemix/smx4/nmr/trunk/jbi/itests/src/test/resources/log4j.properties
Modified: servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java?rev=744137&r1=744136&r2=744137&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java Fri Feb 13 15:00:28 2009
@@ -18,9 +18,13 @@
import java.io.File;
import java.util.Properties;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.net.URL;
import java.net.URLConnection;
+import java.net.HttpURLConnection;
import javax.jbi.component.Component;
@@ -95,24 +99,32 @@
assertNotNull(cmp);
}
- public void testServiceAssembly() throws Exception {
+ public void testServiceAssembly() throws Throwable {
System.out.println("Waiting for NMR");
NMR nmr = getOsgiService(NMR.class);
assertNotNull(nmr);
installJbiBundle("org.apache.servicemix", "servicemix-shared", "installer", "zip");
installJbiBundle("org.apache.servicemix", "servicemix-jsr181", "installer", "zip");
installJbiBundle("org.apache.servicemix", "servicemix-http", "installer", "zip");
+
+ Thread.sleep(500);
+
Bundle saBundle = installJbiBundle("org.apache.servicemix.samples.wsdl-first", "wsdl-first-sa", null, "zip");
System.out.println("Waiting for JBI Service Assembly");
ServiceAssembly sa = getOsgiService(ServiceAssembly.class);
assertNotNull(sa);
- final CountDownLatch latch = new CountDownLatch(50);
- for (int i = 0; i < 2; i++) {
+ Thread.sleep(500);
+
+ final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
+ final int nbThreads = 2;
+ final int nbMessagesPerThread = 10;
+ final CountDownLatch latch = new CountDownLatch(nbThreads * nbMessagesPerThread);
+ for (int i = 0; i < nbThreads; i++) {
new Thread() {
public void run() {
- try {
- for (;;) {
+ for (int i = 0; i < nbMessagesPerThread; i++) {
+ try {
URL url = new URL("http://localhost:8192/PersonService/");
URLConnection connection = url.openConnection();
connection.setDoInput(true);
@@ -128,18 +140,28 @@
"</env:Envelope>").getBytes());
byte[] buffer = new byte[8192];
int len = connection.getInputStream().read(buffer);
+ if (len == -1) {
+ throw new Exception("No response available");
+ }
String result = new String(buffer, 0, len);
System.out.println(result);
+ } catch (Throwable t) {
+ errors.add(t);
+ t.printStackTrace();
+ } finally {
latch.countDown();
}
- } catch (Exception e) {
- e.printStackTrace();
}
}
}.start();
}
- latch.await();
+ if (!latch.await(60, TimeUnit.SECONDS)) {
+ fail("Test timed out");
+ }
+ if (!errors.isEmpty()) {
+ throw errors.get(0);
+ }
//Thread.sleep(500);
saBundle.uninstall();
//sa.stop();
Modified: servicemix/smx4/nmr/trunk/jbi/itests/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/src/test/resources/log4j.properties?rev=744137&r1=744136&r2=744137&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/src/test/resources/log4j.properties (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/src/test/resources/log4j.properties Fri Feb 13 15:00:28 2009
@@ -16,11 +16,11 @@
#
################################################################################
-log4j.rootLogger=DEBUG, stdout
+log4j.rootLogger=INFO, stdout
-log4j.logger.org.springframework.osgi=DEBUG
-log4j.logger.org.apache.camel=DEBUG
-log4j.logger.org.apache.servicemix=DEBUG
+#log4j.logger.org.springframework.osgi=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.servicemix=DEBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout