From 6ddc91e6681877ba1f131641042f175bd63d6334 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 13 Nov 2009 14:43:27 +0000 Subject: Add itest for the servlet sample git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835862 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/distribution/pom.xml | 1 + .../distribution/webapp-helloworld-servlet/pom.xml | 188 +++++++++++++++++++++ .../src/test/java/itest/HelloworldTestCase.java | 60 +++++++ 3 files changed, 249 insertions(+) create mode 100644 java/sca/itest/distribution/webapp-helloworld-servlet/pom.xml create mode 100644 java/sca/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java (limited to 'java') diff --git a/java/sca/itest/distribution/pom.xml b/java/sca/itest/distribution/pom.xml index 506b981f64..f8809b5ab2 100644 --- a/java/sca/itest/distribution/pom.xml +++ b/java/sca/itest/distribution/pom.xml @@ -43,6 +43,7 @@ webapp-helloworld-bpel webapp-helloworld-js-client webapp-helloworld-jsp + webapp-helloworld-servlet webapp-helloworld-stripes diff --git a/java/sca/itest/distribution/webapp-helloworld-servlet/pom.xml b/java/sca/itest/distribution/webapp-helloworld-servlet/pom.xml new file mode 100644 index 0000000000..2b5915ca88 --- /dev/null +++ b/java/sca/itest/distribution/webapp-helloworld-servlet/pom.xml @@ -0,0 +1,188 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-servlet + Apache Tuscany SCA iTest Distribution Webapp helloworld-servlet + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-servlet + war + 2.0-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + org.mortbay.jetty + jsp-2.0 + 6.1.19 + pom + compile + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + + latest-jetty6x + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer + + embedded + + + + org.mortbay.jetty + jetty + + + org.mortbay.jetty + jetty-util + + + javax.servlet + servlet-api + + + org.mortbay.jetty + jsp-2.0 + + + tomcat + jasper-runtime + + + tomcat + jasper-compiler + + + commons-logging + commons-logging + + + tomcat + jasper-compiler-jdt + + + org.mortbay.jetty + jsp-api-2.0 + + + commons-el + commons-el + + + + + + + + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-jsp + + + + org.apache.tuscany.sca + helloworld-servlet + war + + helloworld-servlet + + + + + + + + + + diff --git a/java/sca/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java b/java/sca/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..bed840b44a --- /dev/null +++ b/java/sca/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java @@ -0,0 +1,60 @@ +/* + * 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.assertTrue; + +import java.io.IOException; +import java.net.MalformedURLException; + +import org.junit.Test; + +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.UnexpectedPage; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlButton; +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlInput; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +/** + */ +public class HelloworldTestCase { + + @Test + public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException { + HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-servlet"); + + HtmlForm form = (HtmlForm) page.getForms().get(0); + + HtmlInput textField = form.getInputByName("name"); + textField.setValueAttribute("petra"); + + HtmlButton button = (HtmlButton) form.getButtonsByName("submit").get(0); + + Object foo = button.click(); + + // TODO: something up with getting the response but this works: + UnexpectedPage p = (UnexpectedPage) foo; + String s = new String(p.getWebResponse().getResponseBody()); + + assertTrue(s.endsWith("Hello petra")); + } + +} -- cgit v1.2.3