You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/07/23 11:29:38 UTC

[camel] branch master updated (9de7d6b -> e979ad4)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 9de7d6b  Fixed CS
     new 24a47b3  Camel-Nats: Add test for consuming also on Auth configuration
     new e979ad4  Camel-Nats: Add Auth Token test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...umerLoadTest.java => NatsAuthConsumerLoadTest.java} |  7 +++----
 ...oadTest.java => NatsAuthTokenConsumerLoadTest.java} |  7 +++----
 ...roducerTest.java => NatsAuthTokenProducerTest.java} |  2 +-
 ...hTestSupport.java => NatsAuthTokenTestSupport.java} | 18 +++++++-----------
 4 files changed, 14 insertions(+), 20 deletions(-)
 copy components/camel-nats/src/test/java/org/apache/camel/component/nats/{NatsConsumerLoadTest.java => NatsAuthConsumerLoadTest.java} (88%)
 copy components/camel-nats/src/test/java/org/apache/camel/component/nats/{NatsConsumerLoadTest.java => NatsAuthTokenConsumerLoadTest.java} (88%)
 copy components/camel-nats/src/test/java/org/apache/camel/component/nats/{NatsAuthProducerTest.java => NatsAuthTokenProducerTest.java} (95%)
 copy components/camel-nats/src/test/java/org/apache/camel/component/nats/{NatsAuthTestSupport.java => NatsAuthTokenTestSupport.java} (79%)


[camel] 02/02: Camel-Nats: Add Auth Token test

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e979ad4515e09cdcde08d6fa7dc1979d537d729a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jul 23 13:26:00 2018 +0200

    Camel-Nats: Add Auth Token test
---
 .../nats/NatsAuthTokenConsumerLoadTest.java        | 59 ++++++++++++++++++++++
 .../component/nats/NatsAuthTokenProducerTest.java  | 39 ++++++++++++++
 .../component/nats/NatsAuthTokenTestSupport.java   | 53 +++++++++++++++++++
 3 files changed, 151 insertions(+)

diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenConsumerLoadTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenConsumerLoadTest.java
new file mode 100644
index 0000000..55493be
--- /dev/null
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenConsumerLoadTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.nats;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import io.nats.client.Connection;
+import io.nats.client.Nats;
+import io.nats.client.Options;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class NatsAuthTokenConsumerLoadTest extends NatsAuthTokenTestSupport {
+    
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+
+    @Test
+    public void testLoadConsumer() throws InterruptedException, IOException, TimeoutException {
+        mockResultEndpoint.setExpectedMessageCount(100);
+        Options options = new Options.Builder().server("nats://" + getNatsUrl()).build();
+        Connection connection = Nats.connect(options);
+
+        for (int i = 0; i < 100; i++) {
+            connection.publish("test", ("test" + i).getBytes());
+        }
+
+        mockResultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("nats://"  + getNatsUrl() + "?topic=test").to(mockResultEndpoint);
+            }
+        };
+    }
+
+}
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenProducerTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenProducerTest.java
new file mode 100644
index 0000000..1a9e11a
--- /dev/null
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenProducerTest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.nats;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NatsAuthTokenProducerTest extends NatsAuthTestSupport {
+    
+    @Test
+    public void sendTest() throws Exception {
+        
+        template.sendBody("direct:send", "pippo");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:send").to("nats://" + getNatsUrl() + "?topic=test");
+            }
+        };
+    }
+}
diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenTestSupport.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenTestSupport.java
new file mode 100644
index 0000000..1e482cc
--- /dev/null
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthTokenTestSupport.java
@@ -0,0 +1,53 @@
+/**
+ * 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.nats;
+
+import org.apache.camel.test.testcontainers.ContainerAwareTestSupport;
+import org.apache.camel.test.testcontainers.Wait;
+import org.testcontainers.containers.GenericContainer;
+
+public class NatsAuthTokenTestSupport extends ContainerAwareTestSupport {
+
+    public static final String CONTAINER_IMAGE = "nats:1.2.0";
+    public static final String CONTAINER_NAME = "nats-auth-token";
+    public static final String TOKEN = "!admin23456";
+    
+    @Override
+    protected GenericContainer<?> createContainer() {
+        return natsContainer();
+    }
+
+    public static GenericContainer natsContainer() {
+        return new GenericContainer(CONTAINER_IMAGE)
+            .withNetworkAliases(CONTAINER_NAME)
+            .waitingFor(Wait.forLogMessageContaining("Server is ready", 1))
+            .withCommand(
+                         "-DV",
+                         "-auth",
+                         TOKEN           
+                     );
+    }
+    
+    public String getNatsUrl() {
+        return String.format(
+            "%s@%s:%d",
+            TOKEN,
+            getContainerHost(CONTAINER_NAME),
+            getContainerPort(CONTAINER_NAME, 4222)
+        );
+    }
+}


[camel] 01/02: Camel-Nats: Add test for consuming also on Auth configuration

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 24a47b3d1d3679838bd10b717317edaccb9c74ce
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jul 23 13:24:44 2018 +0200

    Camel-Nats: Add test for consuming also on Auth configuration
---
 .../component/nats/NatsAuthConsumerLoadTest.java   | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthConsumerLoadTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthConsumerLoadTest.java
new file mode 100644
index 0000000..5bb5ffc
--- /dev/null
+++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsAuthConsumerLoadTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.nats;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import io.nats.client.Connection;
+import io.nats.client.Nats;
+import io.nats.client.Options;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class NatsAuthConsumerLoadTest extends NatsAuthTestSupport {
+    
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+
+    @Test
+    public void testLoadConsumer() throws InterruptedException, IOException, TimeoutException {
+        mockResultEndpoint.setExpectedMessageCount(100);
+        Options options = new Options.Builder().server("nats://" + getNatsUrl()).build();
+        Connection connection = Nats.connect(options);
+
+        for (int i = 0; i < 100; i++) {
+            connection.publish("test", ("test" + i).getBytes());
+        }
+
+        mockResultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("nats://"  + getNatsUrl() + "?topic=test").to(mockResultEndpoint);
+            }
+        };
+    }
+
+}