You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2011/03/21 21:26:14 UTC
svn commit: r1083936 - in /tuscany/sandbox/rfeng/sca-java-2.x: ./
implementation-spring/ implementation-spring/helloworld-spring-webapp/
implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/
implementation-spring/helloworld-spring-web...
Author: rfeng
Date: Mon Mar 21 20:26:14 2011
New Revision: 1083936
URL: http://svn.apache.org/viewvc?rev=1083936&view=rev
Log:
Adding Spring integration sample back to my sandbox
Added:
tuscany/sandbox/rfeng/sca-java-2.x/
tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/
- copied from r1083899, tuscany/sca-java-2.x/contrib/samples/learning-more/implementation-spring/
Modified:
tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/pom.xml
tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/web.xml
tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/java/sample/HelloworldClientTestCase.java
tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/resources/test-web.xml
Modified: tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/pom.xml?rev=1083936&r1=1083899&r2=1083936&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/pom.xml (original)
+++ tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/pom.xml Mon Mar 21 20:26:14 2011
@@ -33,7 +33,14 @@
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-base-runtime</artifactId>
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
Modified: tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/web.xml?rev=1083936&r1=1083899&r2=1083936&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/main/webapp/WEB-INF/web.xml Mon Mar 21 20:26:14 2011
@@ -33,7 +33,7 @@
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
-
+
<listener>
<listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
</listener>
@@ -48,4 +48,33 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <servlet>
+ <servlet-name>dispatcher</servlet-name>
+ <servlet-class>org.apache.tuscany.sca.host.webapp.spring.TuscanyDispatcherServlet</servlet-class>
+
+ <!-- Spring MVC DispatcherServlet config -->
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>
+ /WEB-INF/spring/appServlet/servlet-context.xml
+ </param-value>
+ </init-param>
+
+ <!-- SCA contribution -->
+ <init-param>
+ <param-name>contribution</param-name>
+ <param-value>
+ /WEB-INF/sca
+ </param-value>
+ </init-param>
+
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>dispatcher</servlet-name>
+ <url-pattern>/mvc/*</url-pattern>
+ </servlet-mapping>
+
+
</web-app>
Modified: tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/java/sample/HelloworldClientTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/java/sample/HelloworldClientTestCase.java?rev=1083936&r1=1083899&r2=1083936&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/java/sample/HelloworldClientTestCase.java (original)
+++ tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/java/sample/HelloworldClientTestCase.java Mon Mar 21 20:26:14 2011
@@ -26,12 +26,12 @@ import junit.framework.Assert;
import org.json.JSONObject;
import org.junit.Test;
+import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
-
/**
*
*/
@@ -39,6 +39,9 @@ public class HelloworldClientTestCase {
private static final String SERVICE_URL =
"http://localhost:8085/helloworld/HelloworldClientComponent/HelloworldClientBean";
+ private static final String SERVELT_SERVICE_URL =
+ "http://localhost:8085/helloworld/GreetingComponent/greetingService";
+
@Test
public void testJSONRPCBinding() throws Exception {
JSONObject jsonRequest = new JSONObject("{ \"method\": \"sayHello\", \"params\": [\"Ray\"], \"id\": 1}");
@@ -55,4 +58,34 @@ public class HelloworldClientTestCase {
String text = jsonResp.getString("result");
Assert.assertTrue(text.endsWith("Hello Ray"));
}
+
+ @Test
+ public void testServletJSONRPCBinding() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{ \"method\": \"greet\", \"params\": [\"Ray\"], \"id\": 1}");
+
+ WebConversation wc = new WebConversation();
+ WebRequest request =
+ new PostMethodWebRequest(SERVELT_SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString()
+ .getBytes("UTF-8")), "application/json");
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+
+ JSONObject jsonResp = new JSONObject(response.getText());
+ String text = jsonResp.getString("result");
+ Assert.assertTrue(text.endsWith("Hello RAY"));
+ }
+
+ @Test
+ public void testSpringMVC() throws Exception {
+ String url = "http://localhost:8085/helloworld/mvc/account";
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(url);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ String html = response.getText();
+ Assert.assertTrue(html.contains("<title>Create Account</title>"));
+
+ }
}
Modified: tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/resources/test-web.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/resources/test-web.xml?rev=1083936&r1=1083899&r2=1083936&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/resources/test-web.xml (original)
+++ tuscany/sandbox/rfeng/sca-java-2.x/implementation-spring/helloworld-spring-webapp/src/test/resources/test-web.xml Mon Mar 21 20:26:14 2011
@@ -1,25 +1,25 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<web-app version="2.4"
- xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
-
-</web-app>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
+
+</web-app>