Permalink
Browse files

Add Caldecott Java client

- Add library module for Caldecott Java client

- Add test module for integration tests for Caldecott Java client

- Add new profiles to CloudFoundry Java client to exclude integration test by default

- Add integration-test profile that executes all integration tests

Change-Id: I70437d5ab807fa307275f7007b2b7f858e80a10e
  • Loading branch information...
1 parent 0acb855 commit 1930bcddf043d4a2e525f67a314963ad8b118c3a @trisberg trisberg committed Mar 27, 2012
Showing with 5,544 additions and 21 deletions.
  1. +2 −0 .gitignore
  2. +4 −0 cloudfoundry-caldecott-lib/.gitignore
  3. +15 −0 cloudfoundry-caldecott-lib/README
  4. +135 −0 cloudfoundry-caldecott-lib/pom.xml
  5. +33 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/TunnelException.java
  6. +35 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/Client.java
  7. +215 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/HttpTunnel.java
  8. +61 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/HttpTunnelFactory.java
  9. +80 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/SocketClient.java
  10. +32 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/Tunnel.java
  11. +116 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/TunnelAcceptor.java
  12. +28 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/TunnelFactory.java
  13. +172 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/TunnelHandler.java
  14. +162 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/TunnelHelper.java
  15. +120 −0 cloudfoundry-caldecott-lib/src/main/java/org/cloudfoundry/caldecott/client/TunnelServer.java
  16. +35 −0 cloudfoundry-caldecott-lib/src/main/resources/log4j.xml
  17. +139 −0 cloudfoundry-caldecott-lib/src/test/java/org/cloudfoundry/caldecott/JavaTunnel.java
  18. +114 −0 cloudfoundry-caldecott-lib/src/test/java/org/cloudfoundry/caldecott/client/HttpTunnelTest.java
  19. +97 −0 cloudfoundry-caldecott-lib/src/test/java/org/cloudfoundry/caldecott/client/SocketClientTest.java
  20. +1 −0 cloudfoundry-caldecott-lib/tunnel.sh
  21. +2 −0 cloudfoundry-caldecott-test/.gitignore
  22. +1,602 −0 cloudfoundry-caldecott-test/data/load.json
  23. +1,611 −0 cloudfoundry-caldecott-test/data/load.xml
  24. +206 −0 cloudfoundry-caldecott-test/pom.xml
  25. +437 −0 cloudfoundry-caldecott-test/src/test/java/org/cloudfoundry/caldecott/client/HttpTunnelTest.java
  26. +29 −0 cloudfoundry-caldecott-test/src/test/resources/log4j.xml
  27. +37 −15 cloudfoundry-client-lib/pom.xml
  28. +2 −1 cloudfoundry-maven-plugin/.gitignore
  29. +22 −5 pom.xml
View
@@ -7,3 +7,5 @@ build/
.classpath
.project
.settings
+/*.DS_Store
+/*.iml
@@ -0,0 +1,4 @@
+/out/
+/caldecott.log*
+/target/
+/*.iml
@@ -0,0 +1,15 @@
+Java client for Caldecott
+
+This library is intended to be used from a Java application when tunneling into Cloud Foundry data services using the server side Caldecott application. It is similar to the tunnel feature of the command line client vmc. Once the tunnel is started you can connect with a local data client application using the appropriate connection parameters. This library provides functionality to run as a server for a specific Cloud Foundry data service. This server will listen for local connections on a specific port to provide tunneling via the server side Caldecott application.
+
+There is a Java class (JavaTunnel.java) under the src/test directory that starts up a tunnel server and will prompt for connection information needed. It offers equivalent functionality as 'vmc tunnel'. Currently such usage is intended for testing purpose. This JavaTunnel.java class also shows how to setup and start a tunnel so it can be used as a guide when building your own client code.
+
+How to run this Java tunnel program:
+
+You can use the 'tunnel.sh' shell script that uses the mvn exec target. You can provide the email to log in with using a system variable called vcap.email (example: -Dvcap.email=me@mycompany.com). Optionally override the VCAP target using vcap.target with a specific cloud url to run against a local cloud (example: -Dvcap.target=http://api.vcap.me).
+
+To build and run using Maven simply use:
+ mvn clean install
+ mvn --quiet exec:java -Dexec.mainClass="org.cloudfoundry.caldecott.JavaTunnel" -Dexec.classpathScope="test"
+
+NOTE: This implementation doesn't deploy the server side Caldecott app at this point so you should test the tunnel with 'vmc tunnel' first.
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.cloudfoundry</groupId>
+ <artifactId>cloudfoundry-caldecott-lib</artifactId>
+ <version>0.1.0.BUILD-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Client library to be used for Caldecott access</name>
+
+ <licenses>
+ <license>
+ <name>Apache 2.0 License</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <properties>
+ <spring.framework.version>3.0.5.RELEASE</spring.framework.version>
+ <cf.client.lib.version>0.7.2.BUILD-SNAPSHOT</cf.client.lib.version>
+ <junit.version>4.8.2</junit.version>
+ <mockito.version>1.8.5</mockito.version>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>fast</id>
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cloudfoundry</groupId>
+ <artifactId>cloudfoundry-client-lib</artifactId>
+ <version>${cf.client.lib.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.framework.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.springframework.build.aws</groupId>
+ <artifactId>org.springframework.build.aws.maven</artifactId>
+ <version>3.0.0.RELEASE</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <!--forkMode>pertest</forkMode-->
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Abstract*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <distributionManagement>
+ <repository>
+ <id>spring-milestone</id>
+ <name>Spring Milestone Repository</name>
+ <url>s3://maven.springframework.org/milestone</url>
+ </repository>
+ <snapshotRepository>
+ <id>spring-snapshot</id>
+ <name>Spring Snapshot Repository</name>
+ <url>s3://maven.springframework.org/snapshot</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009-2012 the original author or authors.
+ *
+ * Licensed 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.cloudfoundry.caldecott;
+
+/**
+ * Exception thrown as the result of an error condition during tunnel communications.
+ *
+ * @author Thomas Risberg
+ */
+public class TunnelException extends RuntimeException {
+
+ public TunnelException(String message) {
+ super(message);
+ }
+
+ public TunnelException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009-2012 the original author or authors.
+ *
+ * Licensed 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.cloudfoundry.caldecott.client;
+
+import java.io.IOException;
+
+/**
+ * The interface defining the client SPI.
+ *
+ * @author Thomas Risberg
+ */
+public interface Client {
+
+
+ byte[] read() throws IOException;
+
+ void write(byte[] data) throws IOException;
+
+ boolean isActive();
+
+}
Oops, something went wrong.

0 comments on commit 1930bcd

Please sign in to comment.