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 2016/04/18 13:40:14 UTC
[08/20] camel git commit: Delete all the old karaf osgi tests that do
not work. We should use the new camel-test-karaf module as base for testing.
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/bean/SpringBeanRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/bean/SpringBeanRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/bean/SpringBeanRouteTest.java
deleted file mode 100644
index f1bf75c..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/bean/SpringBeanRouteTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.itest.osgi.spring.bean;
-
-import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
-@RunWith(PaxExam.class)
-public class SpringBeanRouteTest extends OSGiIntegrationSpringTestSupport {
-
- @Test
- public void testBean() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected OsgiBundleXmlApplicationContext createApplicationContext() {
- return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/spring/bean/CamelContext.xml"});
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/event/EventRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/event/EventRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/event/EventRouteTest.java
deleted file mode 100644
index fd30c04..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/spring/event/EventRouteTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.itest.osgi.spring.event;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.event.CamelEvent;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
-@RunWith(PaxExam.class)
-public class EventRouteTest extends OSGiIntegrationSpringTestSupport {
-
- protected Object expectedBody = "Hello there!";
- protected String uri = "spring-event:default";
-
- @Override
- protected OsgiBundleXmlApplicationContext createApplicationContext() {
- return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/spring/event/CamelContext.xml"});
- }
-
- @Test
- public void testSendingCamelExchangeToEndpointResultsInValidApplicationEventAfterTheRefreshEvent() throws Exception {
- MockEndpoint result = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
- result.expectedMessageCount(2);
-
- template.sendBodyAndHeader(uri, expectedBody, "cheese", 123);
-
- result.assertIsSatisfied();
-
- // lets test we receive the context refreshed event
- Exchange exchange = result.getReceivedExchanges().get(0);
- Object body = exchange.getIn().getBody(ContextRefreshedEvent.class);
- log.info("Received body: " + body);
- assertNotNull(body);
-
- // lets test we receive the camel event
- exchange = result.getReceivedExchanges().get(1);
- body = exchange.getIn().getBody();
- log.info("Received body: " + body);
- CamelEvent event = assertIsInstanceOf(CamelEvent.class, body);
- Object actualBody = event.getExchange().getIn().getBody();
- assertEquals("Received event body", expectedBody, actualBody);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/DatabaseManager.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/DatabaseManager.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/DatabaseManager.java
deleted file mode 100644
index 08386c7..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/DatabaseManager.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.itest.osgi.sql;
-
-import javax.sql.DataSource;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public class DatabaseManager {
-
- private DataSource dataSource;
-
- public DatabaseManager(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- public void init() {
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
- jdbcTemplate.execute("create table projects (id integer primary key,"
- + "project varchar(10), license varchar(5))");
- jdbcTemplate.execute("insert into projects values (1, 'Camel', 'ASF')");
- jdbcTemplate.execute("insert into projects values (2, 'AMQ', 'ASF')");
- jdbcTemplate.execute("insert into projects values (3, 'Linux', 'XXX')");
- }
-
- public void destroy() {
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
- jdbcTemplate.execute("drop table projects");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlBlueprintRoute.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlBlueprintRoute.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlBlueprintRoute.java
deleted file mode 100644
index 5ef84bf..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlBlueprintRoute.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * 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.itest.osgi.sql;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.sql.DataSource;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.sql.SqlConstants;
-import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Constants;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class SqlBlueprintRoute extends OSGiBlueprintTestSupport {
-
-
- @Test
- public void testListBody() throws Exception {
- getInstalledBundle("CamelBlueprintSqlTestBundle").start();
- CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintSqlTestBundle)", 10000);
-
- MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
- mock.expectedMessageCount(1);
- List<Object> body = new ArrayList<Object>();
- body.add("ASF");
- body.add("Camel");
- ProducerTemplate template = ctx.createProducerTemplate();
- template.sendBody("direct:list", body);
- mock.assertIsSatisfied();
- List<?> received = assertIsInstanceOf(List.class, mock.getReceivedExchanges().get(0).getIn().getBody());
- Map<?, ?> firstRow = assertIsInstanceOf(Map.class, received.get(0));
- assertEquals(1, firstRow.get("ID"));
-
- // unlikely to have accidental ordering with 3 rows x 3 columns
- for (Object obj : received) {
- Map<?, ?> row = assertIsInstanceOf(Map.class, obj);
- assertTrue("not preserving key ordering for a given row keys: " + row.keySet(), isOrdered(row.keySet()));
- }
- }
-
- @Test
- public void testLowNumberOfParameter() throws Exception {
- getInstalledBundle("CamelBlueprintSqlTestBundle").start();
- CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintSqlTestBundle)", 10000);
-
- try {
- ProducerTemplate template = ctx.createProducerTemplate();
- template.sendBody("direct:list", "ASF");
- fail();
- } catch (RuntimeCamelException e) {
- // should have DataAccessException thrown
- assertTrue("Exception thrown is wrong", e.getCause() instanceof DataAccessException);
- }
- }
-
-
- @Test
- public void testInsert() throws Exception {
- getInstalledBundle("CamelBlueprintSqlTestBundle").start();
- CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintSqlTestBundle)", 10000);
- DataSource ds = getOsgiService(DataSource.class, 10000);
- JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
- ProducerTemplate template = ctx.createProducerTemplate();
- MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
- mock.expectedMessageCount(1);
-
- template.sendBody("direct:insert", new Object[]{10, "test", "test"});
- mock.assertIsSatisfied();
- try {
- String projectName = jdbcTemplate.queryForObject("select project from projects where id = 10", String.class);
- assertEquals("test", projectName);
- } catch (EmptyResultDataAccessException e) {
- fail("no row inserted");
- }
-
- Integer actualUpdateCount = mock.getExchanges().get(0).getIn().getHeader(SqlConstants.SQL_UPDATE_COUNT, Integer.class);
- assertEquals((Integer) 1, actualUpdateCount);
- }
-
-
- private boolean isOrdered(Set<?> keySet) {
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("id"));
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("project"));
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("license"));
-
- // the implementation uses a case insensitive Map
- final Iterator<?> it = keySet.iterator();
- return "id".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()))
- && "project".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()))
- && "license".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()));
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
-
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe(InputStream testProbe) {
- return TinyBundles.bundle().read(testProbe)
- .add("OSGI-INF/blueprint/test.xml", SqlBlueprintRoute.class.getResource("blueprintSqlCamelContext.xml"))
- .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintSqlTestBundle")
- .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
- .build();
- }
- },
- scanFeatures(getKarafFeatureUrl(), "spring"),
- mavenBundle("org.apache.derby", "derby", "10.4.2.0"),
- // using the features to install the camel components
- scanFeatures(getCamelKarafFeatureUrl(),
- "camel-blueprint", "camel-sql"),
- felix(), equinox());
-
- return options;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlRouteTest.java
deleted file mode 100644
index 0711d8a..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/sql/SqlRouteTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * 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.itest.osgi.sql;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.sql.DataSource;
-import org.apache.camel.CamelContext;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.sql.SqlConstants;
-import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.util.IOHelper;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class SqlRouteTest extends OSGiIntegrationTestSupport {
-
- String driverClass = "org.apache.derby.jdbc.EmbeddedDriver";
- OsgiBundleXmlApplicationContext applicationContext;
-
- private DataSource ds;
- private JdbcTemplate jdbcTemplate;
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- IOHelper.close(applicationContext);
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- setThreadContextClassLoader();
- applicationContext = new OsgiBundleXmlApplicationContext(
- new String[]{"org/apache/camel/itest/osgi/sql/springSqlRouteContext.xml"});
- if (bundleContext != null) {
- applicationContext.setBundleContext(bundleContext);
- applicationContext.refresh();
- }
- ds = applicationContext.getBean("dataSource", DataSource.class);
- jdbcTemplate = new JdbcTemplate(ds);
- return SpringCamelContext.springCamelContext(applicationContext);
- }
-
- @Test
- public void testListBody() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- List<Object> body = new ArrayList<Object>();
- body.add("ASF");
- body.add("Camel");
- template.sendBody("direct:list", body);
- mock.assertIsSatisfied();
- List<?> received = assertIsInstanceOf(List.class, mock.getReceivedExchanges().get(0).getIn().getBody());
- Map<?, ?> firstRow = assertIsInstanceOf(Map.class, received.get(0));
- assertEquals(1, firstRow.get("ID"));
-
- // unlikely to have accidental ordering with 3 rows x 3 columns
- for (Object obj : received) {
- Map<?, ?> row = assertIsInstanceOf(Map.class, obj);
- assertTrue("not preserving key ordering for a given row keys: " + row.keySet(), isOrdered(row.keySet()));
- }
- }
-
- @Test
- public void testLowNumberOfParameter() throws Exception {
- try {
- template.sendBody("direct:list", "ASF");
- fail();
- } catch (RuntimeCamelException e) {
- // should have DataAccessException thrown
- assertTrue("Exception thrown is wrong", e.getCause() instanceof DataAccessException);
- }
- }
-
-
- @Test
- public void testInsert() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
-
- template.sendBody("direct:insert", new Object[]{10, "test", "test"});
- mock.assertIsSatisfied();
- try {
- String projectName = jdbcTemplate.queryForObject("select project from projects where id = 10", String.class);
- assertEquals("test", projectName);
- } catch (EmptyResultDataAccessException e) {
- fail("no row inserted");
- }
-
- Integer actualUpdateCount = mock.getExchanges().get(0).getIn().getHeader(SqlConstants.SQL_UPDATE_COUNT, Integer.class);
- assertEquals((Integer) 1, actualUpdateCount);
- }
-
-
- private boolean isOrdered(Set<?> keySet) {
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("id"));
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("project"));
- assertTrue("isOrdered() requires the following keys: id, project, license", keySet.contains("license"));
-
- // the implementation uses a case insensitive Map
- final Iterator<?> it = keySet.iterator();
- return "id".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()))
- && "project".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()))
- && "license".equalsIgnoreCase(assertIsInstanceOf(String.class, it.next()));
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- // using the features to install the camel components
- loadCamelFeatures("camel-sql"),
-
- // and use derby as the database
- mavenBundle().groupId("org.apache.derby").artifactId("derby").version("10.4.2.0"));
-
- return options;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/stream/StreamTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/stream/StreamTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/stream/StreamTest.java
deleted file mode 100644
index 4c5bc73..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/stream/StreamTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.itest.osgi.stream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class StreamTest extends OSGiIntegrationTestSupport {
-
- @Test
- public void testStream() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start")
- .to("stream:out")
- .to("mock:result");
- }
- };
- }
- @Configuration
- public static Option[] configure() {
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- // using the features to install the other camel components
- loadCamelFeatures("camel-stream"));
-
- return options;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/syslog/SyslogTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/syslog/SyslogTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/syslog/SyslogTest.java
deleted file mode 100644
index 37ebec8..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/syslog/SyslogTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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.itest.osgi.syslog;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.syslog.SyslogDataFormat;
-import org.apache.camel.component.syslog.SyslogMessage;
-import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
-import org.apache.camel.spi.DataFormat;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-
-@RunWith(PaxExam.class)
-public class SyslogTest extends OSGiIntegrationTestSupport {
-
- private final int serverPort = 10514;
- private final int messageCount = 1;
- private final String message =
- "<165>Aug 4 05:34:00 mymachine myproc[10]: %% It's\n time to make the do-nuts. %% Ingredients: Mix=OK, Jelly=OK #\n"
- + " Devices: Mixer=OK, Jelly_Injector=OK, Frier=OK # Transport:\n" + " Conveyer1=OK, Conveyer2=OK # %%";
-
- @Test
- public void testSendingRawUDP() throws IOException, InterruptedException {
-
- MockEndpoint mock = getMockEndpoint("mock:syslogReceiver");
- MockEndpoint mock2 = getMockEndpoint("mock:syslogReceiver2");
- mock.expectedMessageCount(1);
- mock2.expectedMessageCount(1);
- mock2.expectedBodiesReceived(message);
-
- DatagramSocket socket = new DatagramSocket();
- try {
- InetAddress address = InetAddress.getByName("127.0.0.1");
- for (int i = 0; i < messageCount; i++) {
-
- byte[] data = message.getBytes();
-
- DatagramPacket packet = new DatagramPacket(data, data.length, address, serverPort);
- socket.send(packet);
- Thread.sleep(100);
- }
- } finally {
- socket.close();
- }
-
- assertMockEndpointsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
-
- //context.setTracing(true);
- DataFormat syslogDataFormat = new SyslogDataFormat();
-
- // we setup a Syslog listener on a random port.
- from("mina:udp://127.0.0.1:" + serverPort).unmarshal(syslogDataFormat).process(new Processor() {
- public void process(Exchange ex) {
- assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
- }
- }).to("mock:syslogReceiver").
- marshal(syslogDataFormat).to("mock:syslogReceiver2");
- }
- };
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- // using the features to install the other camel components
- loadCamelFeatures("camel-mina", "camel-netty", "camel-syslog"));
-
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
deleted file mode 100644
index a067056..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.itest.osgi.util.jsse;
-
-import java.io.File;
-import java.net.URL;
-import java.security.KeyStore;
-
-import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
-import org.apache.camel.util.jsse.KeyStoreParameters;
-import org.apache.camel.util.jsse.SSLContextParameters;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-
-@RunWith(PaxExam.class)
-public class JsseUtilTest extends OSGiIntegrationSpringTestSupport {
-
- @Test
- public void testSslContextParameters() throws Exception {
- SSLContextParameters scp = this.applicationContext.getBean(SSLContextParameters.class);
-
- assertEquals("TLS", scp.getSecureSocketProtocol());
-
- assertNotNull(scp.getKeyManagers());
- assertEquals("changeit", scp.getKeyManagers().getKeyPassword());
- assertNull(scp.getKeyManagers().getProvider());
- assertNotNull(scp.getKeyManagers().getKeyStore());
- assertNull(scp.getKeyManagers().getKeyStore().getType());
-
- assertNotNull(scp.getTrustManagers());
- assertNull(scp.getTrustManagers().getProvider());
- assertNotNull(scp.getTrustManagers().getKeyStore());
- assertNull(scp.getTrustManagers().getKeyStore().getType());
-
- assertNull(scp.getSecureRandom());
-
- assertNull(scp.getClientParameters());
-
- assertNull(scp.getServerParameters());
-
- // Test that the instantiation will work when running in OSGi and using
- // class path resources.
- scp.createSSLContext();
- }
-
- @Test
- public void testKeyStoreParametersResourceLoading() throws Exception {
- KeyStoreParameters ksp = new KeyStoreParameters();
- ksp.setPassword("changeit");
- ksp.setResource("org/apache/camel/itest/osgi/util/jsse/localhost.ks");
-
- KeyStore ks = ksp.createKeyStore();
- assertNotNull(ks.getCertificate("server"));
-
- URL resourceUrl = this.getClass().getResource("/org/apache/camel/itest/osgi/util/jsse/localhost.ks");
- ksp.setResource(resourceUrl.toExternalForm());
- ks = ksp.createKeyStore();
- assertNotNull(ks.getCertificate("server"));
-
- File file = new File("../../../test-classes/org/apache/camel/itest/osgi/util/jsse/localhost.ks");
- LOG.info("the file is {}", file.getAbsolutePath());
- ksp.setResource(file.getAbsolutePath());
- ks = ksp.createKeyStore();
- assertNotNull(ks.getCertificate("server"));
- }
-
- @Override
- protected OsgiBundleXmlApplicationContext createApplicationContext() {
- return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml"});
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityBlueprintTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityBlueprintTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityBlueprintTest.java
deleted file mode 100644
index 6a681fe..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityBlueprintTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.itest.osgi.velocity;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Constants;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class VelocityBlueprintTest extends OSGiBlueprintTestSupport {
- private CamelContext camelContext;
- private ProducerTemplate mytemplate;
-
- @Test
- public void testReceivesResponse() throws Exception {
- assertRespondsWith("foo", "<header>foo</header><hello>foo</hello>");
- assertRespondsWith("bar", "<header>bar</header><hello>bar</hello>");
- }
-
- protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException {
- Exchange response = mytemplate.request("direct:start", new Processor() {
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- in.setBody("answer");
- in.setHeader("cheese", value);
- }
- });
- assertOutMessageBodyEquals(response, expectedBody);
- }
-
- protected void doPostSetup() throws Exception {
- getInstalledBundle("VelocityBlueprintRouterTest").start();
- camelContext = getOsgiService(CamelContext.class, "(camel.context.symbolicname=VelocityBlueprintRouterTest)", 10000);
- mytemplate = camelContext.createProducerTemplate();
- mytemplate.start();
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- // using the features to install the camel components
- loadCamelFeatures(
- "camel-blueprint", "camel-velocity"),
-
- bundle(TinyBundles.bundle()
- .add("OSGI-INF/blueprint/test.xml", VelocityBlueprintTest.class.getResource("VelocityBlueprintRouter.xml"))
- .add("example.vm", VelocityBlueprintTest.class.getResource("example.vm"))
- .set(Constants.BUNDLE_SYMBOLICNAME, "VelocityBlueprintRouterTest")
- .build(TinyBundles.withBnd())).noStart()
-
- );
-
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityFileTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityFileTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityFileTest.java
deleted file mode 100644
index 97a9b5c..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityFileTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.itest.osgi.velocity;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.util.IOHelper;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-
-@RunWith(PaxExam.class)
-public class VelocityFileTest extends VelocityTest {
-
- @Override
- public void setUp() throws Exception {
- deleteDirectory("mydir");
- createDirectory("mydir");
-
- InputStream is = VelocityFileTest.class.getResourceAsStream("/org/apache/camel/itest/osgi/velocity/example.vm");
- File dest = new File("mydir/example.vm");
- FileOutputStream fos = new FileOutputStream(dest, false);
- IOHelper.copyAndCloseInput(is, fos);
- fos.close();
-
- super.setUp();
- }
-
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:a").
- to("velocity:file:mydir/example.vm");
- }
- };
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java
deleted file mode 100644
index 4041417..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/velocity/VelocityTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.itest.osgi.velocity;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class VelocityTest extends OSGiIntegrationTestSupport {
-
- @Test
- public void testReceivesResponse() throws Exception {
- assertRespondsWith("foo", "<header>foo</header><hello>foo</hello>");
- assertRespondsWith("bar", "<header>bar</header><hello>bar</hello>");
- }
-
- protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException {
- Exchange response = template.request("direct:a", new Processor() {
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- in.setBody("answer");
- in.setHeader("cheese", value);
- }
- });
- assertOutMessageBodyEquals(response, expectedBody);
- }
-
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:a").
- to("velocity:org/apache/camel/itest/osgi/velocity/example.vm");
- }
- };
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- // using the features to install the other camel components
- loadCamelFeatures("camel-velocity"));
-
- return options;
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonBlueprintRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonBlueprintRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonBlueprintRouteTest.java
deleted file mode 100644
index ea9e870..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonBlueprintRouteTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.itest.osgi.xmljson;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Constants;
-
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-/**
- * OSGi integration test for camel-xmljson
- */
-@Ignore("see CAMEL-8029 and the <details> XML tag of camel-xmljson Karaf feature about running this test")
-@RunWith(PaxExam.class)
-public class XmlJsonBlueprintRouteTest extends OSGiBlueprintTestSupport {
-
- @Test
- public void testUnmarshal() throws Exception {
- getInstalledBundle("CamelBlueprintXmlJsonTestBundle").start();
- CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintXmlJsonTestBundle)", 10000);
-
- MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
- mock.expectedMessageCount(1);
-
- String body = "<hello>\n"
- + " <name>Raul</name>\n"
- + " <surname>Kripalani</surname>\n"
- + "</hello>";
-
- ProducerTemplate template = ctx.createProducerTemplate();
- template.sendBody("direct:start", body);
- mock.assertIsSatisfied();
- String result = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
- String spacesRemoved = result.replaceAll("\\s+", result);
- assertEquals("{\"name\":\"Raul\",\"surname\":\"Kripalani\"}", spacesRemoved);
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
-
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- provision(TinyBundles.bundle()
- .add(XmlJsonRouteBuilder.class)
- .add("OSGI-INF/blueprint/test.xml", XmlJsonBlueprintRouteTest.class.getResource("xmlJsonBlueprintCamelContext.xml"))
- .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintXmlJsonTestBundle")
- .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
- .build()),
-
- // using the features to install the camel components
- loadCamelFeatures("xml-specs-api", "camel-blueprint", "camel-xmljson"));
- //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
-
-
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonRouteBuilder.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonRouteBuilder.java
deleted file mode 100644
index bb0974d..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xmljson/XmlJsonRouteBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.itest.osgi.xmljson;
-
-import org.apache.camel.builder.RouteBuilder;
-
-/**
- * Simple route for testing camel-xmljson
- */
-public class XmlJsonRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
-
- from("direct:start").marshal().xmljson()
- .to("mock:result");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/SampleObject.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/SampleObject.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/SampleObject.java
deleted file mode 100644
index 63201e4..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/SampleObject.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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.itest.osgi.xstream;
-
-public class SampleObject {
-
- String id;
- String value;
-
- public SampleObject() {
- }
-
- public SampleObject(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- SampleObject that = (SampleObject) o;
-
- if (!id.equals(that.id)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamBlueprintRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamBlueprintRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamBlueprintRouteTest.java
deleted file mode 100644
index 2e99137..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamBlueprintRouteTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.itest.osgi.xstream;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.ProbeBuilder;
-import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Constants;
-
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-@RunWith(PaxExam.class)
-public class XstreamBlueprintRouteTest extends OSGiBlueprintTestSupport {
-
- @Test
- public void testUnmarshal() throws Exception {
- getInstalledBundle("CamelBlueprintXstreamTestBundle").start();
- CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintXstreamTestBundle)", 10000);
-
- MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
- mock.expectedMessageCount(1);
-
- String body = "<org.apache.camel.itest.osgi.xstream.SampleObject>\n"
- + " <id>1</id>\n"
- + " <value>test</value>\n"
- + "</org.apache.camel.itest.osgi.xstream.SampleObject>";
-
- ProducerTemplate template = ctx.createProducerTemplate();
- template.sendBody("direct:start", body);
- mock.assertIsSatisfied();
- Object result = mock.getReceivedExchanges().get(0).getIn().getBody();
- assertEquals(new SampleObject("1"), result);
- }
-
- @ProbeBuilder
- public TestProbeBuilder probeConfiguration(TestProbeBuilder builder) {
- builder.setHeader(Constants.EXPORT_PACKAGE, SampleObject.class.getPackage().getName());
- return builder;
- }
-
- @Configuration
- public static Option[] configure() throws Exception {
-
- Option[] options = combine(
- getDefaultCamelKarafOptions(),
- provision(TinyBundles.bundle()
- .add(XstreamRouteBuilder.class)
- .add("OSGI-INF/blueprint/test.xml", XstreamBlueprintRouteTest.class.getResource("blueprintCamelContext.xml"))
- .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintXstreamTestBundle")
- .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
- .build()),
-
- // using the features to install the camel components
- loadCamelFeatures("xml-specs-api", "camel-blueprint", "camel-xstream"));
- //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
-
-
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamRouteBuilder.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamRouteBuilder.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamRouteBuilder.java
deleted file mode 100644
index dadda35..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/xstream/XstreamRouteBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.itest.osgi.xstream;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class XstreamRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
-
-
- from("direct:start").unmarshal().xstream()
- .to("mock:result");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTest.java
deleted file mode 100644
index affea26..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * 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.itest.osgi.zookeeper;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Message;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.zookeeper.ZooKeeperMessage;
-import org.apache.camel.component.zookeeper.operations.GetChildrenOperation;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.data.Stat;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.ops4j.pax.exam.junit.PaxExam;
-
-import static org.apache.camel.component.zookeeper.ZooKeeperMessage.ZOOKEEPER_CREATE_MODE;
-import static org.apache.camel.component.zookeeper.ZooKeeperMessage.ZOOKEEPER_NODE;
-
-@RunWith(PaxExam.class)
-
-@Ignore("Causes processes to not cleanly shutdown. "
-+ "And There is an issue with the zookeeper bundle, so the server cannot be started in pax-exam karaf container")
-public class ZookeeperOSGiTest extends ZookeeperOSGiTestSupport {
-
- // TODO: Should not use hardcoded port numbers, but the AvailablePortFinder
-
- private String zookeeperUri;
-
- private String testPayload = "TestPayload";
-
- @Override
- protected RouteBuilder[] createRouteBuilders() throws Exception {
- return new RouteBuilder[] {new RouteBuilder() {
- public void configure() throws Exception {
- zookeeperUri = "zookeeper://localhost:39913/node?create=true";
- from("direct:roundtrip").to(zookeeperUri).to("mock:producer-out");
- from(zookeeperUri).to("mock:consumed-from-node");
- }
- }, new RouteBuilder() {
- public void configure() throws Exception {
- from("direct:no-create-fails-set").to("zookeeper://localhost:39913/doesnotexist");
- }
- }, new RouteBuilder() {
- public void configure() throws Exception {
- from("direct:node-from-header").to("zookeeper://localhost:39913/notset?create=true");
- from("zookeeper://localhost:39913/set?create=true").to("mock:consumed-from-set-node");
- }
- }, new RouteBuilder() {
- public void configure() throws Exception {
- from("direct:create-mode").to("zookeeper://localhost:39913/persistent?create=true&createMode=PERSISTENT").to("mock:create-mode");
- }
- }};
- }
-
- @Test
- public void testRoundtripOfDataToAndFromZnode() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:consumed-from-node");
- MockEndpoint pipeline = getMockEndpoint("mock:producer-out");
- mock.expectedMessageCount(1);
- pipeline.expectedMessageCount(1);
-
- Exchange e = createExchangeWithBody(testPayload);
- e.setPattern(ExchangePattern.InOut);
- template.send("direct:roundtrip", e);
-
- mock.await(2, TimeUnit.SECONDS);
- mock.assertIsSatisfied();
- pipeline.assertIsSatisfied();
- }
-
- @Test
- public void testAsyncRoundtripOfDataToAndFromZnode() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:consumed-from-node");
- mock.expectedMessageCount(1);
-
- Exchange e = createExchangeWithBody(testPayload);
- template.send("direct:roundtrip", e);
-
- mock.await(2, TimeUnit.SECONDS);
- mock.assertIsSatisfied();
- }
-
- @Test
- public void setUsingNodeFromHeader() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:consumed-from-set-node");
- mock.expectedMessageCount(1);
-
- Exchange e = createExchangeWithBody(testPayload);
- e.setPattern(ExchangePattern.InOut);
- template.sendBodyAndHeader("direct:node-from-header", e, ZOOKEEPER_NODE, "/set");
-
- mock.await(5, TimeUnit.SECONDS);
- mock.assertIsSatisfied();
- }
-
- @Test
- public void setUsingCreateModeFromHeader() throws Exception {
- if (client == null) {
- client = new TestZookeeperClient(getServerPort(), getTestClientSessionTimeout());
- }
- client.createPersistent("/modes-test", "parent for modes");
- for (CreateMode mode : CreateMode.values()) {
- Exchange exchange = createExchangeWithBody(testPayload);
- exchange.getIn().setHeader(ZOOKEEPER_CREATE_MODE, mode);
- exchange.getIn().setHeader(ZOOKEEPER_NODE, "/modes-test/" + mode);
- exchange.setPattern(ExchangePattern.InOut);
- template.send("direct:node-from-header", exchange);
- }
- GetChildrenOperation listing = new GetChildrenOperation(
- getConnection(), "/modes-test");
- assertEquals(CreateMode.values().length, listing.get().getResult().size());
- }
-
- @Test
- public void createWithOtherCreateMode() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:create-mode");
- mock.expectedMessageCount(1);
-
- Exchange e = createExchangeWithBody(testPayload);
- e.setPattern(ExchangePattern.InOut);
-
- template.send("direct:create-mode", e);
- mock.await(5, TimeUnit.SECONDS);
-
- Stat s = mock.getReceivedExchanges().get(0).getIn().getHeader(ZooKeeperMessage.ZOOKEEPER_STATISTICS, Stat.class);
- assertEquals(s.getEphemeralOwner(), 0);
- }
-
- @Test
- public void setAndGetListing() throws Exception {
- if (client == null) {
- client = new TestZookeeperClient(getServerPort(), getTestClientSessionTimeout());
- }
- client.createPersistent("/set-listing", "parent for set and list test");
-
- Exchange exchange = createExchangeWithBody(testPayload);
- exchange.getIn().setHeader(ZOOKEEPER_NODE, "/set-listing/firstborn");
- exchange.setPattern(ExchangePattern.InOut);
- template.send("zookeeper://localhost:39913/set-listing?create=true&listChildren=true", exchange);
- List<?> children = exchange.getOut().getMandatoryBody(List.class);
- assertEquals(1, children.size());
- assertEquals("firstborn", children.get(0));
- }
-
- @Test
- public void testZookeeperMessage() throws Exception {
-
- MockEndpoint mock = getMockEndpoint("mock:consumed-from-node");
- mock.expectedMessageCount(1);
-
- Exchange exchange = createExchangeWithBody(testPayload);
- template.send("direct:roundtrip", exchange);
- mock.await();
- mock.assertIsSatisfied();
-
- Message received = mock.getReceivedExchanges().get(0).getIn();
- assertEquals("/node", ZooKeeperMessage.getPath(received));
- assertNotNull(ZooKeeperMessage.getStatistics(received));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
deleted file mode 100644
index 2796100..0000000
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/zookeeper/ZookeeperOSGiTestSupport.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/**
- * 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.itest.osgi.zookeeper;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.zookeeper.ZooKeeperMessage;
-import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
-import org.apache.camel.util.FileUtil;
-import org.apache.camel.util.IOHelper;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.server.NIOServerCnxnFactory;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.ops4j.pax.exam.OptionUtils.combine;
-
-
-public class ZookeeperOSGiTestSupport extends OSGiIntegrationTestSupport {
-
- protected static final Logger LOG = LoggerFactory.getLogger(ZookeeperOSGiTestSupport.class);
- protected static TestZookeeperServer server;
- protected static TestZookeeperClient client;
-
- @BeforeClass
- public static void setupTestServer() throws Exception {
- LOG.info("Starting Zookeeper Test Infrastructure");
- server = new TestZookeeperServer(getServerPort(), clearServerData());
- waitForServerUp("localhost:" + getServerPort(), 1000);
- client = new TestZookeeperClient(getServerPort(), getTestClientSessionTimeout());
- LOG.info("Started Zookeeper Test Infrastructure on port {}", getServerPort());
- }
-
- public ZooKeeper getConnection() {
- return client.getConnection();
- }
-
- @AfterClass
- public static void shutdownServer() throws Exception {
- LOG.info("Stopping Zookeeper Test Infrastructure");
- client.shutdown();
- server.shutdown();
- waitForServerDown("localhost:" + getServerPort(), 1000);
- LOG.info("Stopped Zookeeper Test Infrastructure");
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] options = combine(
-
- getDefaultCamelKarafOptions(),
- // using the features to install the camel components
- loadCamelFeatures("jetty", "camel-zookeeper"));
-
- return options;
- }
-
-
- protected static int getServerPort() {
- return 39913;
- }
-
- protected static int getTestClientSessionTimeout() {
- return 100000;
- }
-
- protected static boolean clearServerData() {
- return true;
- }
-
- public static class TestZookeeperServer {
- private NIOServerCnxnFactory connectionFactory;
- private ZooKeeperServer zkServer;
-
- public TestZookeeperServer(int clientPort, boolean clearServerData) throws Exception {
-
- if (clearServerData) {
- File working = new File("./target/zookeeper");
- deleteDir(working);
- if (working.exists()) {
- throw new Exception("Could not delete Test Zookeeper Server working dir ./target/zookeeper");
- }
- }
- zkServer = new ZooKeeperServer();
- File dataDir = new File("./target/zookeeper/log");
- File snapDir = new File("./target/zookeeper/data");
- FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
- zkServer.setTxnLogFactory(ftxn);
- zkServer.setTickTime(1000);
- connectionFactory = new NIOServerCnxnFactory();
- connectionFactory.configure(new InetSocketAddress("localhost", clientPort), 0);
- connectionFactory.startup(zkServer);
- }
-
- public void shutdown() throws Exception {
- connectionFactory.shutdown();
- connectionFactory.join();
- while (zkServer.isRunning()) {
- zkServer.shutdown();
- Thread.sleep(100);
- }
- }
- }
-
- public static class TestZookeeperClient implements Watcher {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final CountDownLatch connected = new CountDownLatch(1);
- private ZooKeeper zk;
-
- public TestZookeeperClient(int port, int timeout) throws Exception {
- zk = new ZooKeeper("localhost:" + port, timeout, this);
- connected.await();
- }
-
- public ZooKeeper getConnection() {
- return zk;
- }
-
- public void shutdown() throws Exception {
- zk.close();
- }
-
- public byte[] waitForNodeChange(String node) throws Exception {
- Stat stat = new Stat();
- return zk.getData(node, this, stat);
- }
-
- public void create(String node, String data) throws Exception {
- log.debug(String.format("Creating node '%s' with data '%s' ", node, data));
- create(node, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-
- }
-
- public void createPersistent(String node, String data) throws Exception {
- log.debug(String.format("Creating node '%s' with data '%s' ", node, data));
- create(node, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
- }
-
- public void create(String znode, String data, List<ACL> access, CreateMode mode) throws Exception {
- delay(200);
- String created = zk.create(znode, data != null ? data.getBytes() : null, access, mode);
- if (log.isInfoEnabled()) {
- log.info(String.format("Created znode named '%s'", created));
- }
- }
-
- public Stat setData(String node, String data, int version) throws Exception {
- log.debug(String.format("TestClient Updating data of node %s to %s", node, data));
- return zk.setData(node, data.getBytes(), version);
- }
-
- public byte[] getData(String znode) throws Exception {
- return zk.getData(znode, false, new Stat());
- }
-
- public void process(WatchedEvent event) {
- if (event.getState() == KeeperState.SyncConnected) {
- log.info("TestClient connected");
- connected.countDown();
- } else {
- if (event.getState() == KeeperState.Disconnected) {
- log.info("TestClient connected ?" + zk.getState());
- }
- }
- }
-
- public void delete(String node) throws Exception {
- delay(200);
- log.debug("Deleting node " + node);
- zk.delete(node, -1);
- }
- }
-
- // Wait methods are taken directly from the Zookeeper tests. A tests jar
- // would be nice! Another good reason the keeper folks should move to maven.
- protected static boolean waitForServerUp(String hp, long timeout) {
- long start = System.currentTimeMillis();
- while (true) {
- try {
- // if there are multiple hostports, just take the first one
- hp = hp.split(",")[0];
- String result = send4LetterWord(hp, "stat");
- if (result.startsWith("Zookeeper version:")) {
- return true;
- }
- } catch (IOException e) {
- LOG.info("server {} not up {}", hp, e);
- }
-
- if (System.currentTimeMillis() > start + timeout) {
- break;
- }
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- return false;
- }
-
- private static String send4LetterWord(String hp, String cmd) throws IOException {
- String split[] = hp.split(":");
- String host = split[0];
- int port;
- try {
- port = Integer.parseInt(split[1]);
- } catch (RuntimeException e) {
- throw new RuntimeException("Problem parsing " + hp + e.toString());
- }
-
- Socket sock = new Socket(host, port);
- BufferedReader reader = null;
- try {
- OutputStream outstream = sock.getOutputStream();
- outstream.write(cmd.getBytes());
- outstream.flush();
-
- reader = IOHelper.buffered(new InputStreamReader(sock.getInputStream()));
- StringBuilder sb = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- sb.append(line + "\n");
- }
- return sb.toString();
- } finally {
- sock.close();
- if (reader != null) {
- reader.close();
- }
- }
- }
-
- protected static boolean waitForServerDown(String hp, long timeout) {
- long start = System.currentTimeMillis();
- while (true) {
- try {
- send4LetterWord(hp, "stat");
- } catch (IOException e) {
- return true;
- }
-
- if (System.currentTimeMillis() > start + timeout) {
- break;
- }
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- // ignore
- }
- }
- return false;
- }
-
- public static void deleteDir(File f) {
- LinkedList<File> deleteStack = new LinkedList<File>();
- deleteStack.addLast(f);
- deleteDir(deleteStack);
- }
-
- private static void deleteDir(Deque<File> deleteStack) {
- File f = deleteStack.pollLast();
- if (f != null) {
- if (f.isDirectory()) {
- for (File child : f.listFiles()) {
- deleteStack.addLast(child);
- }
- }
- deleteDir(deleteStack);
- FileUtil.deleteFile(f);
- }
- }
-
- public static void delay(int wait) throws InterruptedException {
- Thread.sleep(wait);
- }
-
- protected List<String> createChildListing(String... children) {
- return Arrays.asList(children);
- }
-
- protected void validateExchangesReceivedInOrderWithIncreasingVersion(MockEndpoint mock) {
- int lastVersion = -1;
- List<Exchange> received = mock.getReceivedExchanges();
- for (int x = 0; x < received.size(); x++) {
- Message zkm = mock.getReceivedExchanges().get(x).getIn();
- int version = ZooKeeperMessage.getStatistics(zkm).getVersion();
- assertTrue("Version did not increase", lastVersion < version);
- lastVersion = version;
- }
- }
-
- protected void verifyAccessControlList(String node, List<ACL> expected) throws Exception {
- getConnection().getACL(node, new Stat());
- }
-
- protected void verifyNodeContainsData(String node, byte[] expected) throws Exception {
- if (expected == null) {
- assertNull(client.getData(node));
- } else {
- assertEquals(new String(expected), new String(client.getData(node)));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/resources/commons-logging.properties
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/commons-logging.properties b/tests/camel-itest-osgi/src/test/resources/commons-logging.properties
deleted file mode 100644
index ce4b52e..0000000
--- a/tests/camel-itest-osgi/src/test/resources/commons-logging.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/constraints-car.xml b/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
deleted file mode 100644
index d3fd84b..0000000
--- a/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
- xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
- <default-package>org.apache.camel.itest.osgi.bean.validator</default-package>
-
- <bean class="CarWithoutAnnotations" ignore-annotations="true">
- <field name="manufacturer">
- <constraint annotation="javax.validation.constraints.NotNull" />
- </field>
-
- <field name="licensePlate">
- <constraint annotation="javax.validation.constraints.NotNull" />
-
- <constraint annotation="javax.validation.constraints.Size">
- <groups>
- <value>org.apache.camel.itest.osgi.bean.validator.OptionalChecks</value>
- </groups>
- <element name="min">5</element>
- <element name="max">14</element>
- </constraint>
- </field>
- </bean>
-</constraint-mappings>
\ No newline at end of file