You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2012/08/22 02:51:56 UTC

svn commit: r829621 - in /websites/staging/openejb/trunk: cgi-bin/ content/ content/examples-trunk/ content/examples-trunk/client-resource-lookup-preview/ content/examples-trunk/client-resource-lookup-preview/src/ content/examples-trunk/client-resource...

Author: buildbot
Date: Wed Aug 22 00:51:54 2012
New Revision: 829621

Log:
Staging update by buildbot for openejb

Added:
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/pom.xml   (with props)
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/client/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/client/Sender.java
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/Listener.java
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/MessageServlet.java
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/resources/
    websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/resources/arquillian.xml   (with props)
Modified:
    websites/staging/openejb/trunk/cgi-bin/   (props changed)
    websites/staging/openejb/trunk/content/   (props changed)
    websites/staging/openejb/trunk/content/examples-trunk/pom.xml

Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 22 00:51:54 2012
@@ -1 +1 @@
-1375300
+1375867

Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 22 00:51:54 2012
@@ -1 +1 @@
-1375300
+1375867

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/pom.xml
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/client/Sender.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/client/Sender.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/main/java/org/superbiz/client/Sender.java Wed Aug 22 00:51:54 2012
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.client;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class Sender {
+    private Sender() {
+        // no-op
+    }
+
+    public static void send(final String providerUrl, final String message) throws Exception {
+        final Properties properties = new Properties();
+        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+        properties.setProperty(Context.PROVIDER_URL, providerUrl);
+        final Context context = new InitialContext(properties);
+
+        final Queue destination = (Queue) context.lookup("java:aQueue");
+        final ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:aConnectionFactory");
+
+        Connection connection = null;
+        Session session = null;
+        MessageProducer producer = null;
+        try {
+            connection = connectionFactory.createConnection();
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            producer = session.createProducer(destination);
+            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+            producer.send(session.createTextMessage(message));
+        } finally {
+            if (producer != null) {
+                producer.close();
+            }
+            if (session != null) {
+                session.close();
+            }
+            if (connection != null) {
+                connection.close();
+            }
+        }
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java Wed Aug 22 00:51:54 2012
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+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 static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+@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>
+        // in fact we create on client side a mini jndi tree
+        // the key is the jndi name (the one used for the lookup)
+        System.setProperty("aConnectionFactory", "connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:61616");
+        System.setProperty("aQueue", "queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
+    }
+
+    @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);
+
+        // 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();
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/Listener.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/Listener.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/Listener.java Wed Aug 22 00:51:54 2012
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.client.app;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.List;
+
+@MessageDriven(activationConfig = {
+        @ActivationConfigProperty(propertyName = "destination", propertyValue = "LISTENER"),
+        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
+})
+public class Listener implements MessageListener {
+    public static List<String> MESSAGES = new ArrayList<String>();
+
+    @Override
+    public void onMessage(final Message message) {
+        System.out.println(">>> Got '" + message + "'");
+        if (message instanceof TextMessage) {
+            try {
+                MESSAGES.add(((TextMessage) message).getText());
+            } catch (JMSException ignored) {
+                // no-op
+            }
+        }
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/MessageServlet.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/MessageServlet.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/java/org/superbiz/client/app/MessageServlet.java Wed Aug 22 00:51:54 2012
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.client.app;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(urlPatterns = "/messages")
+public class MessageServlet extends HttpServlet {
+    @Override
+    protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
+        resp.getWriter().write(Listener.MESSAGES.toString());
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/resources/arquillian.xml
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/openejb/trunk/content/examples-trunk/client-resource-lookup-preview/src/test/resources/arquillian.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Modified: websites/staging/openejb/trunk/content/examples-trunk/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/pom.xml (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/pom.xml Wed Aug 22 00:51:54 2012
@@ -17,7 +17,7 @@
     limitations under the License.
 -->
 <!--test 2-->
-<!-- $Rev: 1374076 $ $Date: 2012-08-16 21:52:48 +0000 (Thu, 16 Aug 2012) $ -->
+<!-- $Rev: 1375867 $ $Date: 2012-08-22 00:51:40 +0000 (Wed, 22 Aug 2012) $ -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
@@ -49,6 +49,7 @@
     <module>cdi-query</module>
     <module>change-jaxws-url</module>
     <module>component-interfaces</module>
+    <module>client-resource-lookup-preview</module>
     <module>cucumber-jvm</module>
     <module>custom-injection</module>
     <module>datasource-ciphered-password</module>