Author: jstrachan
Date: Thu Sep 11 06:31:01 2008
New Revision: 694245
URL: http://svn.apache.org/viewvc?rev=694245&view=rev
Log:
improved unit tests for CAMEL-888 along with a basic HTML view as well
Added:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
(with props)
activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml
(with props)
activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml
(with props)
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
(with props)
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
(with props)
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
(with props)
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java
(contents, props changed)
- copied, changed from r693926,
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/CamelContextResourceTest.java
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java
(with props)
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java
(with props)
Modified:
activemq/camel/trunk/components/camel-rest/pom.xml
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/EndpointLink.java
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
activemq/camel/trunk/components/camel-rest/src/test/resources/log4j.properties
Modified: activemq/camel/trunk/components/camel-rest/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/pom.xml?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/pom.xml (original)
+++ activemq/camel/trunk/components/camel-rest/pom.xml Thu Sep 11 06:31:01 2008
@@ -136,8 +136,31 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
+
<plugins>
<plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ <excludes>
+ <!-- TODO FIXME ASAP -->
+ <exclude>**/RoutesTest.*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+
+ <plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-alpha-2</version>
<configuration>
@@ -152,14 +175,14 @@
<version>${jetty-version}</version>
<configuration>
-<!--
- <connectors>
- <connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
- <port>${jetty.port}</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
--->
+ <!--
+ <connectors>
+ <connector
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>${jetty.port}</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ -->
<webAppConfig>
<contextPath>/</contextPath>
@@ -180,6 +203,16 @@
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
</dependencies>
</plugin>
@@ -190,7 +223,8 @@
<!--<version>1.3-dev</version>-->
<executions>
<execution>
- <phase>process-sources</phase>
+ <!--<phase>process-sources</phase>-->
+ <phase>package</phase>
<configuration>
<destdir>${project.build.directory}/schema</destdir>
<srcdir>src/main/java/org/apache/camel/rest/model</srcdir>
@@ -210,6 +244,72 @@
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ <!--<phase>compile</phase>-->
+ <phase>package</phase>
+ </execution>
+ </executions>
+
+ <configuration>
+
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <show>public</show>
+
<subpackages>com.sun.jersey.samples.generatewadl.resources</subpackages>
+
+ <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
+ <docletArtifacts>
+ <docletArtifact>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>maven-wadl-plugin</artifactId>
+ <version>${jersey-version}</version>
+ </docletArtifact>
+ <!--
+ Also specify jersey and xerces as doclet artifacts as the
ResourceDoclet
+ uses classes provided by them to generate the resourcedoc.
+ -->
+ <docletArtifact>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jersey-version}</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.6.1</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>${jaxb-api-version}</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>${jaxb-version}</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>${stax-api-version}</version>
+ </docletArtifact>
+ </docletArtifacts>
+ <additionalparam>-output
${project.build.outputDirectory}/resourcedoc.xml</additionalparam>
+ </configuration>
+ </plugin>
+
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
Modified:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/EndpointLink.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/EndpointLink.java?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/EndpointLink.java
(original)
+++
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/EndpointLink.java
Thu Sep 11 06:31:01 2008
@@ -35,6 +35,14 @@
@XmlAttribute
private String href;
+ public EndpointLink() {
+ }
+
+ public EndpointLink(Endpoint endpoint) {
+ this();
+ load(endpoint);
+ }
+
@Override
public String toString() {
return "EndpointLink{href='" + href + "' uri='" + uri + "'}";
@@ -63,6 +71,6 @@
protected String createHref(String uri) {
// TODO how to encode as a href?
- return "/camel/endpoint/" + uri;
+ return "/endpoint/" + uri;
}
}
Modified:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java
(original)
+++
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java
Thu Sep 11 06:31:01 2008
@@ -37,6 +37,14 @@
@XmlElement(name = "endpoint")
private List<EndpointLink> endpoints = new ArrayList<EndpointLink>();
+ public Endpoints() {
+ }
+
+ public Endpoints(CamelContext camelContext) {
+ this();
+ load(camelContext);
+ }
+
@Override
public String toString() {
return "Endpoints" + endpoints;
Modified:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
(original)
+++
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
Thu Sep 11 06:31:01 2008
@@ -25,16 +25,18 @@
import org.apache.camel.model.RoutesType;
import org.apache.camel.rest.model.Endpoints;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.GET;
import java.util.List;
/**
+ * The resource for the CamelContext
+ *
* @version $Revision: 1.1 $
*/
[EMAIL PROTECTED]("camel")
[EMAIL PROTECTED]("/")
@Singleton
public class CamelContextResource {
@@ -48,19 +50,28 @@
return camelContext;
}
- @GET
- @Produces("text/plain")
- public String getValue() {
- return "Has CamelContext: " + camelContext;
+ public String getName() {
+ return camelContext.getName();
}
+ /*
+ @GET
+ @Produces("text/plain")
+ public String getValue() {
+ return "Has CamelContext: " + camelContext;
+ }
+
+ */
+ /**
+ * Returns a list of endpoints available in this context
+ *
+ * @return
+ */
@GET
@Path("endpoints")
@Produces({"application/json", "application/xml"})
public Endpoints getEndpoints() {
- Endpoints answer = new Endpoints();
- answer.load(camelContext);
- return answer;
+ return new Endpoints(camelContext);
}
@Path("endpoint/{id}")
@@ -74,6 +85,11 @@
}
}
+ /**
+ * Returns the routes currently active within this context
+ *
+ * @return
+ */
@GET
@Path("routes")
@Produces({"application/json", "application/xml"})
Modified:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
(original)
+++
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
Thu Sep 11 06:31:01 2008
@@ -18,6 +18,7 @@
package org.apache.camel.rest.resources;
import org.apache.camel.rest.model.Endpoints;
+import org.apache.camel.rest.model.EndpointLink;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
@@ -36,10 +37,10 @@
this.endpoint = endpoint;
}
-
- @GET
- @Produces("text/plain")
- public String getValue() {
+ public String getHref() {
+ return new EndpointLink(endpoint).getHref();
+ }
+ public String getUri() {
return endpoint.getEndpointUri();
}
}
Added:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
(added)
+++
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,61 @@
+/**
+ *
+ * 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.rest.util;
+
+import com.sun.jersey.api.json.JSONJAXBContext;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.RoutesType;
+import org.apache.camel.rest.model.EndpointLink;
+import org.apache.camel.rest.model.Endpoints;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Revision: 1.1 $
+ */
[EMAIL PROTECTED]
+public final class JAXBContextResolver implements ContextResolver<JAXBContext>
{
+
+ private final JAXBContext context;
+
+ public JAXBContextResolver() throws Exception {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(JSONJAXBContext.JSON_NOTATION, "MAPPED");
+ props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE);
+ props.put(JSONJAXBContext.JSON_NON_STRINGS, "[\"number\"]");
+
+ this.context = new JSONJAXBContext(getJaxbClasses(), props);
+ }
+
+ protected Class[] getJaxbClasses() {
+ return new Class[]{RoutesType.class, RouteType.class,
+ Endpoints.class, EndpointLink.class};
+ }
+
+ public JAXBContext getContext(Class<?> objectType) {
+ String name = objectType.getPackage().getName();
+ if (name.startsWith("org.apache.camel.model") ||
name.startsWith("org.apache.camel.rest.model")) {
+ return context;
+ }
+ return null;
+ }
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml
(added)
+++
activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<applicationDocs targetNamespace="http://research.sun.com/wadl/2006/10">
+
+ <doc xml:lang="en" title="Apache Camel REST API">
+ This is the WADL API for Apache Camel
+ </doc>
+
+ <doc xml:lang="de">
+ <p>
+ For more on the REST API please see<a
href="http://activemq.apache.org/camel/rest.html">the REST API
+ documentation</a>.
+ </p>
+ </doc>
+</applicationDocs>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rest/src/main/resources/application-doc.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml
(added)
+++
activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<grammars xmlns="http://research.sun.com/wadl/2006/10"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xi="http://www.w3.org/1999/XML/xinclude">
+ <include href="camel-rest.xsd" />
+</grammars>
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rest/src/main/resources/application-grammars.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
(original)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
Thu Sep 11 06:31:01 2008
@@ -64,15 +64,20 @@
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>org.apache.camel.rest.resources</param-value>
+ <param-value>org.apache.camel.rest</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.config.feature.Redirect</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
+ <param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Spring</servlet-name>
- <url-pattern>/*</url-pattern>
+ <url-pattern>/</url-pattern>
</servlet-mapping>
- <welcome-file-list>
- <welcome-file>/camel</welcome-file>
- </welcome-file-list>
</web-app>
Added:
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
(added)
+++
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,25 @@
+<[EMAIL PROTECTED] contentType="text/html" %>
+<[EMAIL PROTECTED] pageEncoding="UTF-8" %>
+<[EMAIL PROTECTED] uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Camel Context</title>
+</head>
+<body>
+
+<h1>Context: ${it.name}</h1>
+
+<h2>Endpoints</h2>
+
+<ul>
+ <c:forEach var="i" items="${it.endpoints.endpoints}">
+ <li><a href="${i.href}">${i.uri}</a>
+ </c:forEach>
+</ul>
+
+
+</body>
+</html>
Propchange:
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
(added)
+++
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,16 @@
+<[EMAIL PROTECTED] contentType="text/html"%>
+<[EMAIL PROTECTED] pageEncoding="UTF-8"%>
+<[EMAIL PROTECTED] uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Endpoint ${it.uri}</title>
+ </head>
+ <body>
+
+ <h1>Endpoint: ${it.uri}</h1>
+
+ </body>
+</html>
Propchange:
activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
(added)
+++
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,45 @@
+/**
+ *
+ * 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.rest.resources;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import junit.framework.TestCase;
+import org.apache.camel.rest.Main;
+import org.apache.camel.rest.model.EndpointLink;
+import org.apache.camel.rest.model.Endpoints;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class EndpointsTest extends TestSupport {
+
+ public void testEndpoints() throws Exception {
+ Endpoints endpoints =
resource.path("endpoints").accept("application/xml").get(Endpoints.class);
+ assertNotNull("Should have found endpoints", endpoints);
+
+ System.out.println("Found: " + endpoints.getEndpoints());
+
+ List<EndpointLink> list = endpoints.getEndpoints();
+ assertTrue("Should have received some endpoints!", !list.isEmpty());
+ }
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java
(from r693926,
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/CamelContextResourceTest.java)
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java?p2=activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java&p1=activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/CamelContextResourceTest.java&r1=693926&r2=694245&rev=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/CamelContextResourceTest.java
(original)
+++
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java
Thu Sep 11 06:31:01 2008
@@ -31,37 +31,19 @@
/**
* @version $Revision: 1.1 $
*/
-public class CamelContextResourceTest extends TestCase {
- protected int port = 9998;
+public class RoutesTest extends TestSupport {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Main.run(port);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- Main.stop();
- }
-
- public void testMain() throws Exception {
- ClientConfig cc = new DefaultClientConfig();
- // use the following jaxb context resolver
- //cc.getProviderClasses().add(JAXBContextResolver.class);
- Client c = Client.create(cc);
-
- WebResource wr = c.resource("http://localhost:" + port +
Main.WEBAPP_CTX);
-
- // get the initial representation
-
- Endpoints endpoints =
wr.path("camel/endpoints").accept("application/xml").get(Endpoints.class);
+ public void testRoutes() throws Exception {
- // and print it out
- System.out.println("Found: " + endpoints.getEndpoints());
+ String routes =
resource.path("routes").accept("application/xml").get(String.class);
+ System.out.println("Routes: " + routes);
+/*
+ RoutesType routes =
wr.path("routes").accept("application/xml").get(RoutesType.class);
+ assertNotNull("Should have found routes", routes);
+ List<RouteType> routeList = routes.getRoutes();
+ assertNotNull("Should have more than one route", routeList.size() > 0);
- List<EndpointLink> list = endpoints.getEndpoints();
- assertTrue("Should have received some endpoints!", !list.isEmpty());
+ System.out.println("Have routes: " + routeList);
+*/
}
}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/RoutesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java
(added)
+++
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,53 @@
+/**
+ *
+ * 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.rest.resources;
+
+import junit.framework.TestCase;
+import org.apache.camel.rest.Main;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class TestSupport extends TestCase {
+ protected int port = 9998;
+ protected ClientConfig clientConfig;
+ protected Client client;
+ protected WebResource resource;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ Main.run(port);
+
+ 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);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Main.stop();
+ }
+}
Propchange:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/TestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java?rev=694245&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java
(added)
+++
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java
Thu Sep 11 06:31:01 2008
@@ -0,0 +1,69 @@
+/**
+ *
+ * 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.rest.spring;
+
+import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.RoutesType;
+import org.apache.camel.rest.resources.CamelContextResource;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+import javax.xml.bind.JAXBContext;
+import java.util.List;
+import java.io.StringWriter;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class CamelRouteTest extends TestCase {
+ protected AbstractXmlApplicationContext applicationContext;
+ protected CamelContext camelContext;
+
+ public void testCanMarshalRoutes() throws Exception {
+ CamelContextResource resource = new CamelContextResource(camelContext);
+ RoutesType routes = resource.getRouteDefinitions();
+ List<RouteType> list = routes.getRoutes();
+ System.out.println("Found routes: " + list);
+
+ // now lets marshall to XML
+ JAXBContext context =
JAXBContext.newInstance(RoutesType.class.getPackage().getName());
+ StringWriter out = new StringWriter();
+ context.createMarshaller().marshal(routes, out);
+ String xml = out.toString();
+ System.out.println("XML is: " + xml);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ applicationContext = new
FileSystemXmlApplicationContext("src/main/webapp/WEB-INF/applicationContext.xml");
+ applicationContext.start();
+ camelContext = (CamelContext)
applicationContext.getBean("camelContext", CamelContext.class);
+ assertNotNull("camelContext", camelContext);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (applicationContext != null) {
+ applicationContext.stop();
+ }
+ super.tearDown();
+ }
+}
Propchange:
activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/spring/CamelRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
activemq/camel/trunk/components/camel-rest/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/resources/log4j.properties?rev=694245&r1=694244&r2=694245&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-rest/src/test/resources/log4j.properties
(original)
+++
activemq/camel/trunk/components/camel-rest/src/test/resources/log4j.properties
Thu Sep 11 06:31:01 2008
@@ -21,7 +21,7 @@
log4j.rootLogger=INFO, out
log4j.logger.org.springframework=WARN
-log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
# CONSOLE appender not used by default
log4j.appender.out=org.apache.log4j.ConsoleAppender