You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2009/02/24 18:52:03 UTC

svn commit: r747460 - in /camel/trunk/components/camel-web: ./ src/main/webapp/org/apache/camel/web/resources/EndpointResource/ src/main/webapp/org/apache/camel/web/resources/EndpointsResource/ src/test/java/org/apache/camel/web/ src/test/java/org/apac...

Author: jstrachan
Date: Tue Feb 24 17:52:03 2009
New Revision: 747460

URL: http://svn.apache.org/viewvc?rev=747460&view=rev
Log:
CAMEL-1355 added some nice literate HTML based test cases (which can be used to power an embedded browser too, like Selenium!) to test the functionality of the web application (as opposed to the REST API)  using WebDriver

Added:
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java   (with props)
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java   (with props)
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java   (with props)
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java   (with props)
Modified:
    camel/trunk/components/camel-web/pom.xml
    camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/index.jsp
    camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/send.jsp
    camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointsResource/index.jsp
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/Main.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/resources/TestSupport.java

Modified: camel/trunk/components/camel-web/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/pom.xml?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/pom.xml (original)
+++ camel/trunk/components/camel-web/pom.xml Tue Feb 24 17:52:03 2009
@@ -35,6 +35,7 @@
     <camel.osgi.export.pkg>org.apache.camel.web.*</camel.osgi.export.pkg>
     <jersey-version>1.0.3-SNAPSHOT</jersey-version>
     <jetty-port>8080</jetty-port>
+    <webdriver-version>685</webdriver-version>
   </properties>
 
   <repositories>
@@ -43,6 +44,17 @@
       <name>java.net Maven 2 Repo</name>
       <url>http://download.java.net/maven/2</url>
     </repository>
+    <repository>
+      <id>openqa-releases</id>
+      <name>OpenQA Releases</name>
+      <url>http://archiva.openqa.org/repository/releases</url>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
   </repositories>
 
   <pluginRepositories>
@@ -88,15 +100,41 @@
       <optional>true</optional>
     </dependency>
 
-    <!-- testing -->
+    <!-- testing web framework -->
+    <!--
+        <dependency>
+          <groupId>com.google</groupId>
+          <artifactId>jetty</artifactId>
+          <version>${webdriver-version}</version>
+          <scope>test</scope>
+        </dependency>
+    -->
+    <!--
+        <dependency>
+          <groupId>net.sourceforge.htmlunit</groupId>
+          <artifactId>htmlunit</artifactId>
+          <version>2.4</version>
+        </dependency>
+        <dependency>
+          <groupId>net.sourceforge.htmlunit</groupId>
+          <artifactId>htmlunit-core-js</artifactId>
+          <version>2.4</version>
+        </dependency>
+    -->
+    <dependency>
+      <groupId>org.openqa.selenium.webdriver</groupId>
+      <artifactId>webdriver-htmlunit</artifactId>
+      <version>0.6.685</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-client</artifactId>
-      <version>${jersey-version}</version>
+      <groupId>org.openqa.selenium.webdriver</groupId>
+      <artifactId>webdriver-support</artifactId>
+      <version>0.6.685</version>
       <scope>test</scope>
     </dependency>
 
-    <!-- web container -->
+    <!-- testing web container -->
     <dependency>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty</artifactId>
@@ -126,7 +164,6 @@
       <artifactId>standard</artifactId>
       <version>1.1.2</version>
     </dependency>
-
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
@@ -135,6 +172,14 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
     </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-client</artifactId>
+      <version>${jersey-version}</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>

Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/index.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/index.jsp?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/index.jsp (original)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/index.jsp Tue Feb 24 17:52:03 2009
@@ -8,7 +8,7 @@
         <h1>Endpoint: ${it.uri}</h1>
 
         <ul>
-          <li><a href='<c:url value="${it.href}/send"/>'>Send to this endpoint</a></li>
+          <li><a class='send' href='<c:url value="${it.href}/send"/>'>Send to this endpoint</a></li>
         </ul>
 
         <c:if test="${it.browsableEndpoint != null}">
@@ -18,7 +18,7 @@
             </tr>
           <c:forEach items="${it.browsableEndpoint.exchanges}" var="exchange">
             <tr>
-              <td><a href='<c:url value="${it.href}/messages/${exchange.exchangeId}"/>' title="View this message">${exchange.exchangeId}</a></td>
+              <td><a class='message' href='<c:url value="${it.href}/messages/${exchange.exchangeId}"/>' title="View this message">${exchange.exchangeId}</a></td>
             </tr>
           </c:forEach>
           </table>

Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/send.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/send.jsp?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/send.jsp (original)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointResource/send.jsp Tue Feb 24 17:52:03 2009
@@ -7,7 +7,7 @@
 
 <h1>Endpoint: ${it.uri}</h1>
 
-<form action='<c:url value="${it.href}"/>' method="post">
+<form action='<c:url value="${it.href}"/>' method="post" name="sendMessage">
   <input type="submit" value="Send"> <input type="reset"> <br>
   <textarea name="body" rows="30" cols="80"></textarea>
 </form>

Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointsResource/index.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointsResource/index.jsp?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointsResource/index.jsp (original)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/EndpointsResource/index.jsp Tue Feb 24 17:52:03 2009
@@ -9,13 +9,13 @@
 
 <ul>
   <c:forEach var="i" items="${it.endpoints}">
-    <li><a href='<c:url value="${i.href}"/>'>${i.uri}</a>
+    <li><a class='endpoint' href='<c:url value="${i.href}"/>'>${i.uri}</a>
   </c:forEach>
 </ul>
 
 <h2>Create New Endpoint</h2>
 
-<form action="<c:url value="/endpoints"/>" method="post">
+<form action="<c:url value="/endpoints"/>" method="post" name="createEndpoint">
   <table>
     <c:if test="${not empty it.error}">
       <tr>

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/Main.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/Main.java?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/Main.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/Main.java Tue Feb 24 17:52:03 2009
@@ -30,11 +30,12 @@
  */
 public final class Main {
 
-    public static final int PORT = 8080;
+    public static int PORT = 9998;
 
     public static final String WEBAPP_DIR = "src/main/webapp";
 
     public static final String WEBAPP_CTX = "/";
+
     protected static Server server = new Server();
 
     private Main() {
@@ -42,18 +43,21 @@
 
     public static void main(String[] args) throws Exception {
         // now lets start the web server
-        int port = PORT;
         if (args.length > 0) {
             String text = args[0];
-            port = Integer.parseInt(text);
+            int port = Integer.parseInt(text);
+            if (port > 0) {
+                PORT = port;
+            }
         }
-        System.out.println("Starting Web Server on port: " + port);
-        run(port);
+        start();
     }
 
-    public static void run(int port) throws Exception {
+    public static void start() throws Exception {
+        System.out.println("Starting Web Server on port: " + PORT);
+
         SelectChannelConnector connector = new SelectChannelConnector();
-        connector.setPort(port);
+        connector.setPort(PORT);
         connector.setServer(server);
         WebAppContext context = new WebAppContext();
 
@@ -61,13 +65,13 @@
         context.setContextPath(WEBAPP_CTX);
         context.setServer(server);
 
-        server.setHandlers(new Handler[] {context});
-        server.setConnectors(new Connector[] {connector});
+        server.setHandlers(new Handler[]{context});
+        server.setConnectors(new Connector[]{connector});
         server.start();
 
         System.out.println();
         System.out.println("==============================================================================");
-        System.out.println("Started the Camel REST Console: point your web browser at http://localhost:" + port + "/");
+        System.out.println("Started the Camel REST Console: point your web browser at " + getRootUrl());
         System.out.println("==============================================================================");
         System.out.println();
     }
@@ -75,4 +79,11 @@
     public static void stop() throws Exception {
         server.stop();
     }
+
+    /**
+     * Returns the root URL of the application
+     */
+    public static String getRootUrl() {
+        return "http://localhost:" + PORT + WEBAPP_CTX;
+    }
 }

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java?rev=747460&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java Tue Feb 24 17:52:03 2009
@@ -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.apache.camel.web.htmlunit;
+
+import org.apache.camel.web.htmlunit.pages.EndpointsPage;
+import org.apache.camel.web.htmlunit.pages.SendMessagePage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.openqa.selenium.lift.Finders.link;
+import static org.openqa.selenium.lift.Finders.links;
+import static org.openqa.selenium.lift.Finders.title;
+import static org.openqa.selenium.lift.Matchers.atLeast;
+import static org.openqa.selenium.lift.Matchers.text;
+import org.openqa.selenium.WebElement;
+import static org.openqa.selenium.By.xpath;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class CreateEndpointTest extends HtmlTestSupport {
+    private static final transient Log LOG = LogFactory.getLog(CreateEndpointTest.class);
+
+    protected String newEndpointUri = "mock:myNewlyCreatedEndpoint";
+    protected String messageBody = "hello world!";
+
+    public void testCreateEndpoint() throws Exception {
+
+        goToRootPage();
+
+        assertPresenceOf(atLeast(4), links().with(text(not(equalTo("Images")))));
+
+        // TODO one day we should do this
+        //clickOn(xpath("//a[text() = 'Endpoints']"));
+        WebElement element = findElement(xpath("//a[text() = 'Endpoints']"));
+        element.click();
+
+        assertThat(getTitle(), containsString("Endpoints"));
+
+        List<WebElement> endpointLinks = findElements(xpath("//a[@class='endpoint']"));
+        assertTrue("Should be several endpoint links!", endpointLinks.size() > 0);
+
+        LOG.info("Found " + endpointLinks.size() + " endpoints links!");
+
+
+        // lets create a new endpoint
+        new EndpointsPage(getWebDriver()).createEndpoint(newEndpointUri);
+
+        assertThat(getTitle(), containsString(newEndpointUri));
+
+
+        // now lets send a message to it
+        findElement(xpath("//a[@class='send']")).click();
+
+        new SendMessagePage(getWebDriver()).sendMessage(messageBody);
+
+        // now lets view the message
+        // TODO can we force the last link to be clicked via xpath?
+        findElement(xpath("//a[@class='message']")).click();
+
+        String actualMessage = findElement(xpath("//div[@class='message']")).getText();
+        LOG.info("Found message body: " +actualMessage);
+
+        assertThat(actualMessage, containsString(messageBody));
+
+        LOG.debug("Source: " + getPageSource());
+    }
+
+}

Propchange: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/CreateEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java?rev=747460&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java Tue Feb 24 17:52:03 2009
@@ -0,0 +1,109 @@
+/**
+ *
+ * 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.camel.web.htmlunit;
+
+import org.apache.camel.web.Main;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.By;
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
+import org.openqa.selenium.lift.HamcrestWebDriverTestCase;
+import com.gargoylesoftware.htmlunit.WebClient;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public abstract class HtmlTestSupport extends HamcrestWebDriverTestCase {
+    protected WebDriver webDriver;
+
+    /**
+     * Go to the home page of the web application
+     */
+    protected void goToRootPage() {
+        goTo(Main.getRootUrl());
+    }
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Main.start();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        Main.stop();
+    }
+
+    @Override
+    protected WebDriver createDriver() {
+        if (webDriver == null) {
+            webDriver = new HtmlUnitDriver() {
+                @Override
+                protected WebClient modifyWebClient(WebClient webClient) {
+                    WebClient answer = super.modifyWebClient(webClient);
+                    answer.addRequestHeader("Accept", "text/html");
+                    answer.getCookieManager().setCookiesEnabled(true);
+                    return answer;
+                }
+            };
+        }
+        return webDriver;
+    }
+
+    // TODO remove these methods if/when they are available in the base class!!!
+    //-------------------------------------------------------------------------
+    protected WebDriver getWebDriver() {
+        return webDriver;
+    }
+
+    public WebElement findElement(By by) {
+        return getWebDriver().findElement(by);
+    }
+
+    public List<WebElement> findElements(By by) {
+        return getWebDriver().findElements(by);
+    }
+
+    public void get(String s) {
+        getWebDriver().get(s);
+    }
+
+    public String getCurrentUrl() {
+        return getWebDriver().getCurrentUrl();
+    }
+
+    public String getPageSource() {
+        return getWebDriver().getPageSource();
+    }
+
+    public String getTitle() {
+        return getWebDriver().getTitle();
+    }
+
+    public String getWindowHandle() {
+        return getWebDriver().getWindowHandle();
+    }
+
+    public WebDriver.TargetLocator switchTo() {
+        return getWebDriver().switchTo();
+    }
+
+}

Propchange: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/HtmlTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java?rev=747460&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java Tue Feb 24 17:52:03 2009
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.camel.web.htmlunit.pages;
+
+import static org.openqa.selenium.By.name;
+import static org.openqa.selenium.By.xpath;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class EndpointsPage {
+    private final WebDriver webDriver;
+
+    public EndpointsPage(WebDriver webDriver) {
+        this.webDriver = webDriver;
+    }
+
+    public void createEndpoint(String uri) {
+        WebElement form = getCreateEndpointForm();
+        form.findElement(name("uri")).sendKeys(uri);
+        form.submit();
+    }
+
+    public WebElement getCreateEndpointForm() {
+        return webDriver.findElement(xpath("//form[@name = 'createEndpoint']"));
+    }
+}

Propchange: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/EndpointsPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java?rev=747460&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java Tue Feb 24 17:52:03 2009
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.camel.web.htmlunit.pages;
+
+import static org.openqa.selenium.By.name;
+import static org.openqa.selenium.By.xpath;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class SendMessagePage {
+    private final WebDriver webDriver;
+
+    public SendMessagePage(WebDriver webDriver) {
+        this.webDriver = webDriver;
+    }
+
+    public void sendMessage(String data) {
+        WebElement form = getSendMessage();
+        form.findElement(name("body")).sendKeys(data);
+        form.submit();
+    }
+
+    public WebElement getSendMessage() {
+        return webDriver.findElement(xpath("//form[@name = 'sendMessage']"));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/htmlunit/pages/SendMessagePage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/resources/TestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/resources/TestSupport.java?rev=747460&r1=747459&r2=747460&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/resources/TestSupport.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/resources/TestSupport.java Tue Feb 24 17:52:03 2009
@@ -24,12 +24,15 @@
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 
 import org.apache.camel.web.Main;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Revision$
  */
 public class TestSupport extends TestCase {
-    protected int port = 9998;
+    private static final transient Log LOG = LogFactory.getLog(TestSupport.class);
+
     protected ClientConfig clientConfig;
     protected Client client;
     protected WebResource resource;
@@ -37,26 +40,27 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        Main.run(port);
+        Main.start();
 
         clientConfig = new DefaultClientConfig();
         // use the following jaxb context resolver
         //cc.getProviderClasses().add(JAXBContextResolver.class);
         client = Client.create(clientConfig);
-        resource = client.resource("http://localhost:" + port + Main.WEBAPP_CTX);
-    }
-
-    protected WebResource resource(String uri) {
-        System.out.println("About to test URI: " + uri);
-        return resource.path(uri);
+        resource = client.resource(Main.getRootUrl());
     }
 
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
+
         Main.stop();
     }
 
+
+    protected WebResource resource(String uri) {
+        LOG.info("About to test URI: " + uri);
+        return resource.path(uri);
+    }
     protected void assertHtmlResponse(String response) {
         assertNotNull("No text returned!", response);