You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2011/09/26 22:48:21 UTC

svn commit: r1176047 - in /openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote: ./ src/main/tomcat/ src/main/tomcat/conf/ src/test/java/org/apache/openejb/arquillian/remote/ src/test/java/org/apache/openejb/arquillian/remote/util/

Author: rmannibucau
Date: Mon Sep 26 20:48:20 2011
New Revision: 1176047

URL: http://svn.apache.org/viewvc?rev=1176047&view=rev
Log:
starting tomcat from pom in remote arquillian tomee artifact | adding a starting rest it test

Added:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/logging.properties
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/RestIT.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/TstRestService.java
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/RemoteUtil.java
Modified:
    openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/pom.xml

Modified: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/pom.xml?rev=1176047&r1=1176046&r2=1176047&view=diff
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/pom.xml (original)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/pom.xml Mon Sep 26 20:48:20 2011
@@ -354,6 +354,13 @@
           <tomcatHttpPort>8080</tomcatHttpPort>
           <tomcatShutdownPort>8181</tomcatShutdownPort>
           <tomcatVersion>${version.org.apache.tomcat}</tomcatVersion>
+          <libs>
+            <jarArtifact>
+              <groupId>org.apache.openejb</groupId>
+              <artifactId>openejb-logging</artifactId>
+              <version>${version.org.apache.openejb}</version>
+            </jarArtifact>
+          </libs>
           <webapps>
             <webappArtifact>
               <groupId>org.apache.openejb</groupId>

Added: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/logging.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/logging.properties?rev=1176047&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/logging.properties (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/main/tomcat/conf/logging.properties Mon Sep 26 20:48:20 2011
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2010 Joerg Bellmann <jo...@googlemail.com>
+#
+# Licensed 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.
+#
+
+#
+# OpenEJB logs
+#
+log4j.rootLogger = INFO, stdout
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout = org.apache.openejb.logging.SimpleJULLikeLayout

Added: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/RestIT.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/RestIT.java?rev=1176047&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/RestIT.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/RestIT.java Mon Sep 26 20:48:20 2011
@@ -0,0 +1,47 @@
+/**
+ * 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.apache.openejb.arquillian.remote;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.spec.servlet.web.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static junit.framework.Assert.assertTrue;
+import static org.apache.openejb.arquillian.remote.util.RemoteUtil.readContent;
+
+@RunWith(Arquillian.class)
+public class RestIT {
+    @Deployment(testable = false) public static WebArchive createDeployment() {
+        return ShrinkWrap.create(WebArchive.class, "test-rest.war")
+                .addClass(TstRestService.class)
+                .setWebXML(new StringAsset(
+                    Descriptors.create(WebAppDescriptor.class)
+                        .version("3.0").displayName("Rest Test").exportAsString()));
+    }
+
+    @Test public void helloRestService() throws Exception {
+        final String content = readContent("http://localhost:8080/test-rest/rest/foo");
+        assertTrue(content.contains("hello, foo"));
+    }
+
+}

Added: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/TstRestService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/TstRestService.java?rev=1176047&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/TstRestService.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/TstRestService.java Mon Sep 26 20:48:20 2011
@@ -0,0 +1,17 @@
+package org.apache.openejb.arquillian.remote;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @author rmannibucau
+ */
+@Path("/rest")
+public class TstRestService {
+    @Path("{name}") @GET @Produces(MediaType.TEXT_PLAIN) public String hello(@PathParam("name") String name) {
+        return "hello, " + name;
+    }
+}

Added: openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/RemoteUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/RemoteUtil.java?rev=1176047&view=auto
==============================================================================
--- openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/RemoteUtil.java (added)
+++ openejb/trunk/sandbox/arquillian-tomee/arquillian-tomee-remote/src/test/java/org/apache/openejb/arquillian/remote/util/RemoteUtil.java Mon Sep 26 20:48:20 2011
@@ -0,0 +1,33 @@
+package org.apache.openejb.arquillian.remote.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author rmannibucau
+ */
+public class RemoteUtil {
+    private RemoteUtil() {
+        // no-op
+    }
+
+    public static String readContent(String url) throws MalformedURLException, IOException, UnsupportedEncodingException {
+        InputStream is = new URL(url).openStream();
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        int bytesRead;
+        byte[] buffer = new byte[1024];
+        while ((bytesRead = is.read(buffer)) > -1) {
+            os.write(buffer, 0, bytesRead);
+        }
+
+        is.close();
+        os.close();
+
+        return new String(os.toByteArray(), "UTF-8");
+    }
+}