You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/11 13:20:44 UTC
[03/11] git commit: camel-cmis should unit test with dynamic port
number assigned.
camel-cmis should unit test with dynamic port number assigned.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c8df239
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c8df239
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c8df239
Branch: refs/heads/master
Commit: 7c8df239d7a390ba5d9665a7a44c07ea3bf53cce
Parents: c2de561
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Sep 11 13:04:39 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Sep 11 13:04:39 2013 +0200
----------------------------------------------------------------------
.../apache/camel/component/cmis/CMISConsumerTest.java | 4 ++--
.../apache/camel/component/cmis/CMISProducerTest.java | 4 ++--
.../camel/component/cmis/CMISQueryProducerTest.java | 8 ++++----
.../apache/camel/component/cmis/CMISTestSupport.java | 13 ++++++++++---
4 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7c8df239/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java
index 007822a..41c3351 100644
--- a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java
+++ b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java
@@ -38,7 +38,7 @@ public class CMISConsumerTest extends CMISTestSupport {
public void getAllContentFromServerOrderedFromRootToLeaves() throws Exception {
resultEndpoint.expectedMessageCount(5);
- Consumer treeBasedConsumer = createConsumerFor(CMIS_ENDPOINT_TEST_SERVER);
+ Consumer treeBasedConsumer = createConsumerFor(getUrl());
treeBasedConsumer.start();
resultEndpoint.assertIsSatisfied();
@@ -57,7 +57,7 @@ public class CMISConsumerTest extends CMISTestSupport {
resultEndpoint.expectedMessageCount(2);
Consumer queryBasedConsumer = createConsumerFor(
- CMIS_ENDPOINT_TEST_SERVER + "?query=SELECT * FROM cmis:document");
+ getUrl() + "?query=SELECT * FROM cmis:document");
queryBasedConsumer.start();
resultEndpoint.assertIsSatisfied();
queryBasedConsumer.stop();
http://git-wip-us.apache.org/repos/asf/camel/blob/7c8df239/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISProducerTest.java b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISProducerTest.java
index b8d5d78..10fc7ce 100644
--- a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISProducerTest.java
+++ b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISProducerTest.java
@@ -126,7 +126,7 @@ public class CMISProducerTest extends CMISTestSupport {
@Test(expected = ResolveEndpointFailedException.class)
public void failConnectingToNonExistingRepository() throws Exception {
- Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER
+ Endpoint endpoint = context.getEndpoint("cmis://" + getUrl()
+ "?username=admin&password=admin&repositoryId=NON_EXISTING_ID");
Producer producer = endpoint.createProducer();
@@ -172,7 +172,7 @@ public class CMISProducerTest extends CMISTestSupport {
return new RouteBuilder() {
public void configure() {
from("direct:start")
- .to("cmis://" + CMIS_ENDPOINT_TEST_SERVER);
+ .to("cmis://" + getUrl());
}
};
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7c8df239/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISQueryProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISQueryProducerTest.java b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISQueryProducerTest.java
index db6af6a..7c31abc 100644
--- a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISQueryProducerTest.java
+++ b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISQueryProducerTest.java
@@ -39,7 +39,7 @@ public class CMISQueryProducerTest extends CMISTestSupport {
@Test
public void queryServerForDocumentWithSpecificName() throws Exception {
- Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+ Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody(
@@ -54,7 +54,7 @@ public class CMISQueryProducerTest extends CMISTestSupport {
@Test
public void getResultCountFromHeader() throws Exception {
- Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+ Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody(
@@ -69,7 +69,7 @@ public class CMISQueryProducerTest extends CMISTestSupport {
@Test
public void limitNumberOfResultsWithReadSizeHeader() throws Exception {
- Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+ Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody(
@@ -85,7 +85,7 @@ public class CMISQueryProducerTest extends CMISTestSupport {
@Test
public void retrieveAlsoDocumentContent() throws Exception {
- Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+ Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody(
http://git-wip-us.apache.org/repos/asf/camel/blob/7c8df239/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISTestSupport.java b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISTestSupport.java
index a466a01..6f2bd32 100644
--- a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISTestSupport.java
+++ b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISTestSupport.java
@@ -27,6 +27,7 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.Document;
@@ -50,11 +51,16 @@ import org.junit.BeforeClass;
public class CMISTestSupport extends CamelTestSupport {
protected static final String CMIS_ENDPOINT_TEST_SERVER
- = "http://localhost:9090/chemistry-opencmis-server-inmemory/atom";
+ = "http://localhost:%s/chemistry-opencmis-server-inmemory/atom";
protected static final String OPEN_CMIS_SERVER_WAR_PATH
= "target/dependency/chemistry-opencmis-server-inmemory-0.8.0.war";
protected static Server cmisServer;
+ protected static int port;
+
+ protected String getUrl() {
+ return String.format(CMIS_ENDPOINT_TEST_SERVER, port);
+ }
protected Exchange createExchangeWithInBody(String body) {
DefaultExchange exchange = new DefaultExchange(context);
@@ -90,7 +96,7 @@ public class CMISTestSupport extends CamelTestSupport {
protected Session createSession() {
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
- parameter.put(SessionParameter.ATOMPUB_URL, CMIS_ENDPOINT_TEST_SERVER);
+ parameter.put(SessionParameter.ATOMPUB_URL, getUrl());
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
Repository repository = sessionFactory.getRepositories(parameter).get(0);
@@ -143,7 +149,8 @@ public class CMISTestSupport extends CamelTestSupport {
@BeforeClass
public static void startServer() throws Exception {
- cmisServer = new Server(9090);
+ port = AvailablePortFinder.getNextAvailable(26500);
+ cmisServer = new Server(port);
cmisServer.setHandler(new WebAppContext(OPEN_CMIS_SERVER_WAR_PATH, "/chemistry-opencmis-server-inmemory"));
cmisServer.start();
}