Author: rmannibucau
Date: Thu Aug 23 18:47:15 2012
New Revision: 1376646
URL: http://svn.apache.org/viewvc?rev=1376646&view=rev
Log:
simplifying the client sample to avoid to bind any port
Removed:
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/main/
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/resources/
Modified:
openejb/trunk/openejb/examples/client-resource-lookup-preview/pom.xml
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
Modified: openejb/trunk/openejb/examples/client-resource-lookup-preview/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/client-resource-lookup-preview/pom.xml?rev=1376646&r1=1376645&r2=1376646&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/client-resource-lookup-preview/pom.xml
(original)
+++ openejb/trunk/openejb/examples/client-resource-lookup-preview/pom.xml Thu
Aug 23 18:47:15 2012
@@ -54,6 +54,8 @@
<version>6.0-4</version>
<scope>provided</scope>
</dependency>
+
+ <!-- here what is needed to use client lookup with jms resources -->
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-client</artifactId>
@@ -72,6 +74,7 @@
<scope>runtime</scope>
</dependency>
+ <!-- test deps -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -80,18 +83,6 @@
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
- <artifactId>arquillian-tomee-remote</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>1.0.1.Final</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openejb</groupId>
<artifactId>ziplock</artifactId>
<version>1.1.0-SNAPSHOT</version>
<scope>test</scope>
Modified:
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java?rev=1376646&r1=1376645&r2=1376646&view=diff
==============================================================================
---
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
(original)
+++
openejb/trunk/openejb/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
Thu Aug 23 18:47:15 2012
@@ -16,46 +16,19 @@
*/
package org.superbiz.client;
-import org.apache.ziplock.IO;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.container.test.api.RunAsClient;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.superbiz.client.app.Listener;
-import java.net.URL;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-@RunAsClient
-@RunWith(Arquillian.class)
public class SenderTest {
- private static final String APP_NAME = "app-server";
- private static final String MESSAGE = "sender test message";
-
- // this sample is just about configuration so
- // to avoid complicated code in this demo we use sleep
- // shouldn't be done this way in real life
- private static final int RETRY = 10;
- private static final int SLEEP_RETRY = 500;
-
- @ArquillianResource
- private URL url;
-
- @Deployment
- public static WebArchive war() {
- return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war")
- .addPackage(Listener.class.getPackage());
-
- }
-
@BeforeClass
public static void configureClientResources() {
// can be set this way or with the key Resource/<type>
@@ -67,23 +40,15 @@ public class SenderTest {
@Test
public void send() throws Exception {
- final String rawUrl = url.toExternalForm(); // app-server webapp url
- final String providerUrl = rawUrl.substring(0, rawUrl.length() -
APP_NAME.length() - 1) + "tomee/ejb";
-
- // send the message
- Sender.send(providerUrl, MESSAGE);
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
+ final Context context = new InitialContext(properties);
+
+ final Queue destination = (Queue) context.lookup("java:aQueue");
+ assertNotNull(destination);
+ assertEquals("LISTENER", destination.getQueueName());
- // check the message was received, we can need to wait a bit
- for (int i = 0; i < RETRY; i++) {
- final String message = IO.slurp(new URL(rawUrl + "messages")); //
the servlet URL
- System.out.println("Server received: " + message);
- try {
- assertThat(message, containsString(MESSAGE));
- return; // done!
- } catch (AssertionError ae) {
- Thread.sleep(SLEEP_RETRY); // wait a bit that the message was
received
- }
- }
- fail();
+ final ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup("java:aConnectionFactory");
+ assertNotNull(connectionFactory);
}
}