Author: antelder
Date: Sat Apr 24 06:53:10 2010
New Revision: 937597

URL: http://svn.apache.org/viewvc?rev=937597&view=rev
Log:
Add testcase for JAX-RS helloworld sample

Added:
    tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/
    tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/
    
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/
    
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
Modified:
    tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/pom.xml
    
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java

Modified: tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/pom.xml?rev=937597&r1=937596&r2=937597&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/pom.xml 
(original)
+++ tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/pom.xml Sat Apr 
24 06:53:10 2010
@@ -35,7 +35,7 @@
         <!-- Tuscany dependency -->
         <dependency>
             <groupId>org.apache.tuscany.sca.shades</groupId>
-            <artifactId>tuscany-base</artifactId>
+            <artifactId>tuscany-base-nodep</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
 
@@ -51,6 +51,20 @@
             <version>1.0-incubating</version>
         </dependency>
 
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <artifactId>htmlunit</artifactId>
+            <version>2.6</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>

Modified: 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java?rev=937597&r1=937596&r2=937597&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/main/java/sample/HelloWorldResource.java
 Sat Apr 24 06:53:10 2010
@@ -32,12 +32,12 @@ import org.oasisopen.sca.annotation.Refe
  * Simple example - Hello World!
  * <p/>
  * The SDK dispatches HTTP requests for URI
- * <code>http://[host]:[port]/HelloWorld/rest/world</code>, where
- * <code>HelloWorld</code> is the context root, to this class. A simple Atom
- * entry is returned in HTTP response.
+ * <code>http://[host]:[port]/helloworld-jaxrs/rest/world</code>, where
+ * <code>helloworld-jaxrs</code> is the context root, to this class. A simple 
+ * plain text entry is returned in HTTP response.
  * <p/>
  * The service document is available at URI
- * <code>http://[host]:[port]/HelloWorld/rest</code> but it is empty because
+ * <code>http://[host]:[port]/helloworld-jaxrs/rest</code> but it is empty 
because
  * this simple demo doesn't contain any collection of resources.
  * <p/>
  * This resource must be registered within a JAX-RS application, this example

Added: 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java?rev=937597&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/samples/webapps/helloworld-jaxrs/src/test/java/itest/HelloworldTestCase.java
 Sat Apr 24 06:53:10 2010
@@ -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 itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlParagraph;
+
+/**
+ */
+public class HelloworldTestCase {
+
+    @Test
+    public void testA() throws FailingHttpStatusCodeException, 
MalformedURLException, IOException {
+        TextPage page = (TextPage)new 
WebClient().getPage("http://localhost:8085/helloworld-jaxrs/rest/world";);
+        assertEquals("Hello World", page.getContent());
+    }
+
+}


Reply via email to