Added:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java?rev=1188121&view=auto
==============================================================================
---
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java
(added)
+++
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java
Mon Oct 24 12:40:18 2011
@@ -0,0 +1,98 @@
+/**
+ * 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.krati;
+
+import java.io.File;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class KratiProducerTest extends CamelTestSupport {
+
+ @Test
+ public void testPut() throws InterruptedException {
+ ProducerTemplate template = context.createProducerTemplate();
+ template.sendBodyAndHeader("direct:put", "TEST1", KratiConstants.KEY,
"1");
+ template.sendBodyAndHeader("direct:put", "TEST2", KratiConstants.KEY,
"2");
+ template.sendBodyAndHeader("direct:put", "TEST3", KratiConstants.KEY,
"3");
+ MockEndpoint endpoint = (MockEndpoint)
context.getEndpoint("mock:results");
+ endpoint.expectedMessageCount(3);
+ endpoint.assertIsSatisfied();
+ }
+
+
+ @Test
+ public void testPutAndGet() throws InterruptedException {
+ ProducerTemplate template = context.createProducerTemplate();
+ template.sendBodyAndHeader("direct:put", "TEST1", KratiConstants.KEY,
"1");
+ template.sendBodyAndHeader("direct:put", "TEST2", KratiConstants.KEY,
"2");
+ template.sendBodyAndHeader("direct:put", "TEST3", KratiConstants.KEY,
"3");
+ Object result = template.requestBodyAndHeader("direct:get", null,
KratiConstants.KEY, "3");
+ assertEquals("TEST3", result);
+ }
+
+ @Test
+ public void testPutDeleteAndGet() throws InterruptedException {
+ ProducerTemplate template = context.createProducerTemplate();
+ template.sendBodyAndHeader("direct:put", "TEST1", KratiConstants.KEY,
"1");
+ template.sendBodyAndHeader("direct:put", "TEST2", KratiConstants.KEY,
"2");
+ template.sendBodyAndHeader("direct:put", "TEST3", KratiConstants.KEY,
"4");
+ template.requestBodyAndHeader("direct:delete", null,
KratiConstants.KEY, "4");
+ Object result = template.requestBodyAndHeader("direct:get", null,
KratiConstants.KEY, "4");
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testPutDeleteAllAndGet() throws InterruptedException {
+ ProducerTemplate template = context.createProducerTemplate();
+ template.sendBodyAndHeader("direct:put", "TEST1", KratiConstants.KEY,
"1");
+ template.sendBodyAndHeader("direct:put", "TEST2", KratiConstants.KEY,
"2");
+ template.sendBodyAndHeader("direct:put", "TEST3", KratiConstants.KEY,
"3");
+ template.requestBodyAndHeader("direct:deleteall", null,
KratiConstants.KEY, "3");
+ Object result = template.requestBodyAndHeader("direct:get", null,
KratiConstants.KEY, "1");
+ assertEquals(null, result);
+ result = template.requestBodyAndHeader("direct:get", null,
KratiConstants.KEY, "2");
+ assertEquals(null, result);
+ result = template.requestBodyAndHeader("direct:get", null,
KratiConstants.KEY, "3");
+ assertEquals(null, result);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:put")
+ .to("krati:target/test/producertest")
+ .to("mock:results");
+
+ from("direct:get").setHeader(KratiConstants.KRATI_OPERATION,
constant(KratiConstants.KRATI_OPERATION_GET))
+ .to("krati:target/test/producertest");
+
+
from("direct:delete").setHeader(KratiConstants.KRATI_OPERATION,
constant(KratiConstants.KRATI_OPERATION_DELETE))
+ .to("krati:target/test/producertest");
+
+
from("direct:deleteall").setHeader(KratiConstants.KRATI_OPERATION,
constant(KratiConstants.KRATI_OPERATION_DELETEALL))
+ .to("krati:target/test/producertest");
+ }
+ };
+ }
+}
Propchange:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/KratiProducerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java?rev=1188121&view=auto
==============================================================================
---
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
(added)
+++
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
Mon Oct 24 12:40:18 2011
@@ -0,0 +1,118 @@
+/**
+ * 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.krati.processor.idempotent;
+
+import krati.core.segment.ChannelSegmentFactory;
+import krati.io.Serializer;
+import krati.store.DataSet;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.krati.KratiHelper;
+import org.apache.camel.component.krati.serializer.KratiDefaultSerializer;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class KratiIdempotentRepositoryTest extends CamelTestSupport {
+
+ private String path = "target/test/idempotent";
+ private DataSet dataSet = KratiHelper.createDataSet(path, 2, new
ChannelSegmentFactory());
+ private Serializer serializer = new KratiDefaultSerializer();
+ private KratiIdempotentRepository repository;
+
+ private String key01 = "123";
+ private String key02 = "456";
+
+ public void setUp() throws Exception {
+ repository = new KratiIdempotentRepository("target/test/idempotent");
+ repository.setDataSet(dataSet);
+ dataSet.clear();
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ dataSet.clear();
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ // add first key
+ assertTrue(dataSet.add(serializer.serialize(key01)));
+ assertTrue(repository.contains(key01));
+
+ // try to add an other one
+ assertTrue(dataSet.add(serializer.serialize(key02)));
+ assertTrue(repository.contains(key02));
+ }
+
+
+ @Test
+ public void testContains() throws Exception {
+ assertFalse(repository.contains(key01));
+
+ // add key and check again
+ assertTrue(repository.add(key01));
+ assertTrue(repository.contains(key01));
+
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ // add key to remove
+ assertTrue(repository.add(key01));
+ // assertEquals(1, dataSet.size());
+
+ // remove key
+ assertTrue(repository.remove(key01));
+ //assertEquals(0, dataSet.size());
+
+ // try to remove a key that isn't there
+ assertFalse(repository.remove(key02));
+ }
+
+
+ @Test
+ public void testRepositoryInRoute() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:out");
+ mock.expectedBodiesReceived("a", "b");
+ // c is a duplicate
+
+ // should be started
+ assertEquals("Should be started", true,
repository.getStatus().isStarted());
+
+ // send 3 message with one duplicated key (key01)
+ template.sendBodyAndHeader("direct://in", "a", "messageId", key01);
+ template.sendBodyAndHeader("direct://in", "b", "messageId", key02);
+ template.sendBodyAndHeader("direct://in", "c", "messageId", key01);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct://in")
+ .idempotentConsumer(header("messageId"), repository)
+ .to("mock://out");
+ }
+ };
+ }
+
+
+}
Propchange:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-krati/src/test/java/org/apache/camel/component/krati/processor/idempotent/KratiIdempotentRepositoryTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml?rev=1188121&view=auto
==============================================================================
--- camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml
(added)
+++ camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml Mon
Oct 24 12:40:18 2011
@@ -0,0 +1,38 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://activemq.apache.org/camel/schema/spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:put"/>
+ <to uri="krati:target/test/consumerspringtest"/>
+ </route>
+
+ <route>
+ <from uri="krati:target/test/consumerspringtest"/>
+ <to uri="mock:results"/>
+ </route>
+
+ </camelContext>
+
+</beans>
Propchange:
camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-krati/src/test/resources/consumer-test.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/components/camel-krati/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-krati/src/test/resources/log4j.properties?rev=1188121&view=auto
==============================================================================
--- camel/trunk/components/camel-krati/src/test/resources/log4j.properties
(added)
+++ camel/trunk/components/camel-krati/src/test/resources/log4j.properties Mon
Oct 24 12:40:18 2011
@@ -0,0 +1,38 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, file
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.file.file=target/camel-krati-test.log
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
\ No newline at end of file
Propchange:
camel/trunk/components/camel-krati/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-krati/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-krati/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: camel/trunk/components/camel-krati/src/test/resources/producer-test.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-krati/src/test/resources/producer-test.xml?rev=1188121&view=auto
==============================================================================
--- camel/trunk/components/camel-krati/src/test/resources/producer-test.xml
(added)
+++ camel/trunk/components/camel-krati/src/test/resources/producer-test.xml Mon
Oct 24 12:40:18 2011
@@ -0,0 +1,48 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://activemq.apache.org/camel/schema/spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:put"/>
+ <to uri="krati:target/test/producerspringtest"/>
+ <to uri="mock:results"/>
+ </route>
+
+ <route>
+ <from uri="direct:get"/>
+ <to
uri="krati:target/test/producerspringtest?operation=CamelKratiGet"/>
+ </route>
+
+ <route>
+ <from uri="direct:delete"/>
+ <to
uri="krati:target/test/producerspringtest?operation=CamelKratiDelete"/>
+ </route>
+
+ <route>
+ <from uri="direct:deleteall"/>
+ <to
uri="krati:target/test/producerspringtest?operation=CamelKratiDeleteAll"/>
+ </route>
+ </camelContext>
+
+</beans>
Propchange:
camel/trunk/components/camel-krati/src/test/resources/producer-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-krati/src/test/resources/producer-test.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-krati/src/test/resources/producer-test.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: camel/trunk/components/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1188121&r1=1188120&r2=1188121&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Mon Oct 24 12:40:18 2011
@@ -97,6 +97,7 @@
<module>camel-juel</module>
<module>camel-jxpath</module>
<module>camel-kestrel</module>
+ <module>camel-krati</module>
<module>camel-ldap</module>
<module>camel-lucene</module>
<module>camel-mail</module>
Modified: camel/trunk/parent/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1188121&r1=1188120&r2=1188121&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Mon Oct 24 12:40:18 2011
@@ -114,6 +114,7 @@
<juel-version>2.1.2</juel-version>
<junit-version>4.8.1</junit-version>
<karaf-version>2.2.4</karaf-version>
+ <krati-version>0.4.1</krati-version>
<log4j-version>1.2.16</log4j-version>
<lucene-version>3.0.3</lucene-version>
<mina-version>1.1.7</mina-version>
@@ -518,6 +519,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-krati</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-lucene</artifactId>
<version>${project.version}</version>
</dependency>
@@ -1450,7 +1456,15 @@
<artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version>
</dependency>
-
+
+
+ <!-- optional krati dependency -->
+ <dependency>
+ <groupId>com.sna-projects.krati</groupId>
+ <artifactId>krati</artifactId>
+ <version>${krati-version}</version>
+ </dependency>
+
<!-- blueprint -->
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
Modified: camel/trunk/platforms/karaf/features/src/main/resources/features.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/features.xml?rev=1188121&r1=1188120&r2=1188121&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/src/main/resources/features.xml
(original)
+++ camel/trunk/platforms/karaf/features/src/main/resources/features.xml Mon
Oct 24 12:40:18 2011
@@ -423,6 +423,10 @@
<feature version='${pom.version}'>camel-core</feature>
<bundle>mvn:org.apache.camel/camel-kestrel/${pom.version}</bundle>
</feature>
+ <feature name='camel-krati' version='${pom.version}' resolver='(obr)'
start-level='50'>
+ <bundle
dependency="true">mvn:com.sna-projects.krati/krati/${krati-version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-krati/${pom.version}</bundle>
+ </feature>
<feature name='camel-ldap' version='${pom.version}' resolver='(obr)'
start-level='50'>
<feature version='${pom.version}'>camel-core</feature>
<bundle>mvn:org.apache.camel/camel-ldap/${pom.version}</bundle>