Fixed the CS error of camel-sjms
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2e9f45e3 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2e9f45e3 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2e9f45e3 Branch: refs/heads/master Commit: 2e9f45e3f3fbe20a10ef1f7917fb7ca8db3e8b56 Parents: 7c6de48 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Mon Mar 31 14:02:00 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Mon Mar 31 14:02:00 2014 +0800 ---------------------------------------------------------------------- .../component/sjms/CamelJmsTestHelper.java | 25 +++++- .../component/sjms/bugfixes/CAMEL6820Test.java | 88 ++++++++++++++++++++ .../component/sjms/bugfixes/CAMEL_6820Test.java | 88 -------------------- .../consumer/InOutConcurrentConsumerTest.java | 32 +++++-- 4 files changed, 136 insertions(+), 97 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2e9f45e3/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java index 00e3555..f816147 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/CamelJmsTestHelper.java @@ -1,13 +1,30 @@ +/** + * 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.component.sjms; +import java.io.File; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.jms.ConnectionFactory; + import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.pool.PooledConnectionFactory; import org.apache.camel.util.FileUtil; -import javax.jms.ConnectionFactory; -import java.io.File; -import java.util.concurrent.atomic.AtomicInteger; - /** * A helper for unit testing with Apache ActiveMQ as embedded JMS broker. * http://git-wip-us.apache.org/repos/asf/camel/blob/2e9f45e3/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java new file mode 100644 index 0000000..1add845 --- /dev/null +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL6820Test.java @@ -0,0 +1,88 @@ +/** + * 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.component.sjms.bugfixes; + +import java.io.File; +import java.io.InputStream; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.component.sjms.SjmsComponent; +import org.apache.camel.component.sjms.support.JmsTestSupport; +import org.apache.commons.io.FileUtils; +import org.junit.Test; + +/** + * Unit test for CAMEL_6820Test. This test is to verify the ability to + * support the Camel File Component more cleanly along with better support + * for ByteMessages. + */ +public class CAMEL6820Test extends JmsTestSupport { + + private static final String TEST_DATA_DIR = "target/testdata"; + private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR; + private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR; + private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue"; + private static final String MOCK_RESULT_URI = "mock:result"; + + @Test + public void testCamelGenericFileConverterMessage() throws Exception { + File f = new File(TEST_DATA_DIR); + + // First make sure the directories are empty or purged so we don't get bad data on a + // test that is run against an uncleaned target directory + if (f.exists()) { + FileUtils.deleteDirectory(new File(TEST_DATA_DIR)); + + } + + // Then add the directory back + f.mkdirs(); + + // Make sure the SjmsComponent is available + SjmsComponent component = context.getComponent("sjms", SjmsComponent.class); + assertNotNull(component); + + // Create the test String + final String expectedBody = "Hello World"; + + // Create the Mock endpoint + MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI); + mock.expectedMessageCount(1); + mock.expectedBodiesReceived(expectedBody); + + // Send the message to a file to be read by the file component + template.sendBody(FILE_OUTPUT_URI, expectedBody); + + // Verify that it is working correctly + mock.assertIsSatisfied(); + } + + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() throws Exception { + from(FILE_INPUT_URI) + .convertBodyTo(InputStream.class) + .to(SJMS_QUEUE_URI); + + from(SJMS_QUEUE_URI) + .convertBodyTo(String.class) + .to(MOCK_RESULT_URI); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/2e9f45e3/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.java deleted file mode 100644 index e6e0ce4..0000000 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/bugfixes/CAMEL_6820Test.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.component.sjms.bugfixes; - -import java.io.File; -import java.io.InputStream; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.sjms.SjmsComponent; -import org.apache.camel.component.sjms.support.JmsTestSupport; -import org.apache.commons.io.FileUtils; -import org.junit.Test; - -/** - * Unit test for CAMEL_6820Test. This test is to verify the ability to - * support the Camel File Component more cleanly along with better support - * for ByteMessages. - */ -public class CAMEL_6820Test extends JmsTestSupport { - - private static final String TEST_DATA_DIR = "target/testdata"; - private static final String FILE_OUTPUT_URI = "file:" + TEST_DATA_DIR; - private static final String FILE_INPUT_URI = "file:" + TEST_DATA_DIR; - private static final String SJMS_QUEUE_URI = "sjms:queue:file.converter.queue"; - private static final String MOCK_RESULT_URI = "mock:result"; - - @Test - public void testCamelGenericFileConverterMessage() throws Exception { - File f = new File(TEST_DATA_DIR); - - // First make sure the directories are empty or purged so we don't get bad data on a - // test that is run against an uncleaned target directory - if (f.exists()) { - FileUtils.deleteDirectory(new File(TEST_DATA_DIR)); - - } - - // Then add the directory back - f.mkdirs(); - - // Make sure the SjmsComponent is available - SjmsComponent component = context.getComponent("sjms", SjmsComponent.class); - assertNotNull(component); - - // Create the test String - final String expectedBody = "Hello World"; - - // Create the Mock endpoint - MockEndpoint mock = getMockEndpoint(MOCK_RESULT_URI); - mock.expectedMessageCount(1); - mock.expectedBodiesReceived(expectedBody); - - // Send the message to a file to be read by the file component - template.sendBody(FILE_OUTPUT_URI, expectedBody); - - // Verify that it is working correctly - mock.assertIsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from(FILE_INPUT_URI) - .convertBodyTo(InputStream.class) - .to(SJMS_QUEUE_URI); - - from(SJMS_QUEUE_URI) - .convertBodyTo(String.class) - .to(MOCK_RESULT_URI); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/2e9f45e3/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java index fc18efc..a364c8c 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/consumer/InOutConcurrentConsumerTest.java @@ -1,15 +1,37 @@ +/** + * 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.component.sjms.consumer; -import org.apache.camel.*; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.apache.camel.CamelContext; +import org.apache.camel.EndpointInject; +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.sjms.support.JmsTestSupport; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.*; - /** * Concurrent consumer with JMSReply test. */