switch mongo-elasticsearch-sync to testng

Project: http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/commit/e7bcb0d1
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/tree/e7bcb0d1
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/diff/e7bcb0d1

Branch: refs/heads/master
Commit: e7bcb0d143e8b51900eedce32b60af25d3b5b209
Parents: e234e24
Author: Steve Blackmon @steveblackmon <sblack...@apache.org>
Authored: Thu Dec 15 12:50:11 2016 -0600
Committer: Steve Blackmon @steveblackmon <sblack...@apache.org>
Committed: Thu Dec 15 12:50:11 2016 -0600

----------------------------------------------------------------------
 local/mongo-elasticsearch-sync/pom.xml          | 19 +++++------
 .../streams/example/MongoElasticsearchSync.java | 21 ++++++------
 .../example/test/MongoElasticsearchSyncIT.java  | 26 ++++++++-------
 .../apache/streams/example/test/SyncITs.java    | 34 --------------------
 .../src/test/resources/testng.xml               | 18 +++++++++++
 .../test/resources/TwitterFollowGraphIT.conf    | 28 ----------------
 .../test/resources/TwitterFollowNeo4jIT.conf    | 28 ++++++++++++++++
 7 files changed, 82 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/mongo-elasticsearch-sync/pom.xml
----------------------------------------------------------------------
diff --git a/local/mongo-elasticsearch-sync/pom.xml 
b/local/mongo-elasticsearch-sync/pom.xml
index 25e0a21..7639011 100644
--- a/local/mongo-elasticsearch-sync/pom.xml
+++ b/local/mongo-elasticsearch-sync/pom.xml
@@ -58,6 +58,12 @@
             <type>test-jar</type>
         </dependency>
         <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>${testng.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest-all</artifactId>
             <version>1.3</version>
@@ -252,19 +258,14 @@
                 <artifactId>maven-failsafe-plugin</artifactId>
                 <configuration>
                     <!-- Run integration test suite rather than individual 
tests. -->
-                    <excludes>
-                        <exclude>**/*Test.java</exclude>
-                        <exclude>**/*Tests.java</exclude>
-                        <exclude>**/*IT.java</exclude>
-                    </excludes>
-                    <includes>
-                        <include>**/*ITs.java</include>
-                    </includes>
+                    <suiteXmlFiles>
+                        
<suiteXmlFile>target/test-classes/testng.xml</suiteXmlFile>
+                    </suiteXmlFiles>
                 </configuration>
                 <dependencies>
                     <dependency>
                         <groupId>org.apache.maven.surefire</groupId>
-                        <artifactId>surefire-junit47</artifactId>
+                        <artifactId>surefire-testng</artifactId>
                         <version>${failsafe.plugin.version}</version>
                     </dependency>
                 </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/mongo-elasticsearch-sync/src/main/java/org/apache/streams/example/MongoElasticsearchSync.java
----------------------------------------------------------------------
diff --git 
a/local/mongo-elasticsearch-sync/src/main/java/org/apache/streams/example/MongoElasticsearchSync.java
 
b/local/mongo-elasticsearch-sync/src/main/java/org/apache/streams/example/MongoElasticsearchSync.java
index e89318c..4527a6b 100644
--- 
a/local/mongo-elasticsearch-sync/src/main/java/org/apache/streams/example/MongoElasticsearchSync.java
+++ 
b/local/mongo-elasticsearch-sync/src/main/java/org/apache/streams/example/MongoElasticsearchSync.java
@@ -18,14 +18,16 @@
 
 package org.apache.streams.example;
 
-import com.google.common.collect.Maps;
 import org.apache.streams.config.ComponentConfigurator;
 import org.apache.streams.config.StreamsConfigurator;
-import org.apache.streams.elasticsearch.*;
 import org.apache.streams.core.StreamBuilder;
-import org.apache.streams.example.MongoElasticsearchSyncConfiguration;
+import org.apache.streams.elasticsearch.ElasticsearchPersistWriter;
+import org.apache.streams.local.LocalRuntimeConfiguration;
 import org.apache.streams.local.builders.LocalStreamBuilder;
 import org.apache.streams.mongo.MongoPersistReader;
+
+import com.google.common.collect.Maps;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,13 +69,14 @@ public class MongoElasticsearchSync implements Runnable {
 
         ElasticsearchPersistWriter elasticsearchPersistWriter = new 
ElasticsearchPersistWriter(config.getDestination());
 
-        Map<String, Object> streamConfig = Maps.newHashMap();
-        streamConfig.put(LocalStreamBuilder.STREAM_IDENTIFIER_KEY, STREAMS_ID);
-        streamConfig.put(LocalStreamBuilder.TIMEOUT_KEY, 7 * 24 * 60 * 1000);
-        StreamBuilder builder = new LocalStreamBuilder(1000, streamConfig);
+        LocalRuntimeConfiguration localRuntimeConfiguration = new 
LocalRuntimeConfiguration();
+        localRuntimeConfiguration.setIdentifier(STREAMS_ID);
+        localRuntimeConfiguration.setTaskTimeoutMs((long)(60 * 1000));
+        localRuntimeConfiguration.setQueueSize((long)1000);
+        StreamBuilder builder = new 
LocalStreamBuilder(localRuntimeConfiguration);
 
-        builder.newPerpetualStream(MongoPersistReader.STREAMS_ID, 
mongoPersistReader);
-        builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, 
elasticsearchPersistWriter, 1, MongoPersistReader.STREAMS_ID);
+        
builder.newPerpetualStream(MongoPersistReader.class.getCanonicalName(), 
mongoPersistReader);
+        
builder.addStreamsPersistWriter(ElasticsearchPersistWriter.class.getCanonicalName(),
 elasticsearchPersistWriter, 1, MongoPersistReader.class.getCanonicalName());
         builder.start();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/MongoElasticsearchSyncIT.java
----------------------------------------------------------------------
diff --git 
a/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/MongoElasticsearchSyncIT.java
 
b/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/MongoElasticsearchSyncIT.java
index f10947b..02af293 100644
--- 
a/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/MongoElasticsearchSyncIT.java
+++ 
b/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/MongoElasticsearchSyncIT.java
@@ -18,17 +18,17 @@
 
 package org.apache.streams.example.test;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import com.typesafe.config.ConfigParseOptions;
 import org.apache.streams.config.ComponentConfigurator;
-import org.apache.streams.config.StreamsConfiguration;
-import org.apache.streams.config.StreamsConfigurator;
 import org.apache.streams.elasticsearch.ElasticsearchClientManager;
 import org.apache.streams.example.MongoElasticsearchSync;
 import org.apache.streams.example.MongoElasticsearchSyncConfiguration;
 import org.apache.streams.jackson.StreamsJacksonMapper;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import com.typesafe.config.ConfigParseOptions;
+
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import 
org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
@@ -38,15 +38,17 @@ import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.client.Requests;
 import org.elasticsearch.cluster.health.ClusterHealthStatus;
-import org.junit.Before;
-import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
 
 import java.io.File;
 
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertTrue;
 
 /**
  * Test copying documents between two indexes on same cluster
@@ -60,7 +62,7 @@ public class MongoElasticsearchSyncIT {
     protected MongoElasticsearchSyncConfiguration testConfiguration;
     protected Client testClient;
 
-    @Before
+    @BeforeClass
     public void prepareTest() throws Exception {
 
         Config reference  = ConfigFactory.load();
@@ -69,7 +71,7 @@ public class MongoElasticsearchSyncIT {
         Config testResourceConfig  = 
ConfigFactory.parseFileAnySyntax(conf_file, 
ConfigParseOptions.defaults().setAllowMissing(false));
         Config typesafe  = 
testResourceConfig.withFallback(reference).resolve();
         testConfiguration = new 
ComponentConfigurator<>(MongoElasticsearchSyncConfiguration.class).detectConfiguration(typesafe);
-        testClient = new 
ElasticsearchClientManager(testConfiguration.getDestination()).getClient();
+        testClient = 
ElasticsearchClientManager.getInstance(testConfiguration.getDestination()).client();
 
         ClusterHealthRequest clusterHealthRequest = 
Requests.clusterHealthRequest();
         ClusterHealthResponse clusterHealthResponse = 
testClient.admin().cluster().health(clusterHealthRequest).actionGet();

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/SyncITs.java
----------------------------------------------------------------------
diff --git 
a/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/SyncITs.java
 
b/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/SyncITs.java
deleted file mode 100644
index 4968ebd..0000000
--- 
a/local/mongo-elasticsearch-sync/src/test/java/org/apache/streams/example/test/SyncITs.java
+++ /dev/null
@@ -1,34 +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
- *
- *   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.streams.example.test;
-
-import org.apache.streams.mongo.test.MongoPersistIT;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-        MongoPersistIT.class,
-        MongoElasticsearchSyncIT.class
-})
-
-public class SyncITs {
-    // the class remains empty,
-    // used only as a holder for the above annotations
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/mongo-elasticsearch-sync/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/local/mongo-elasticsearch-sync/src/test/resources/testng.xml 
b/local/mongo-elasticsearch-sync/src/test/resources/testng.xml
new file mode 100644
index 0000000..2abc29b
--- /dev/null
+++ b/local/mongo-elasticsearch-sync/src/test/resources/testng.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"; >
+
+<suite name="ExampleITs">
+
+    <test name="ElasticsearchPersistWriterIT">
+        <classes>
+            <class name="org.apache.streams.mongo.test.MongoPersistIT" />
+        </classes>
+    </test>
+
+    <test name="MongoElasticsearchSyncIT">
+        <classes>
+            <class 
name="org.apache.streams.example.test.MongoElasticsearchSyncIT" />
+        </classes>
+    </test>
+
+</suite>

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/twitter-follow-neo4j/src/test/resources/TwitterFollowGraphIT.conf
----------------------------------------------------------------------
diff --git 
a/local/twitter-follow-neo4j/src/test/resources/TwitterFollowGraphIT.conf 
b/local/twitter-follow-neo4j/src/test/resources/TwitterFollowGraphIT.conf
deleted file mode 100644
index d4b4aeb..0000000
--- a/local/twitter-follow-neo4j/src/test/resources/TwitterFollowGraphIT.conf
+++ /dev/null
@@ -1,28 +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
-#
-#   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.
-twitter {
-  endpoint = "friends"
-  info = [
-    18055613
-  ]
-  twitter.max_items = 1000
-}
-graph {
-  hostname = ${neo4j.http.host}
-  port = ${neo4j.http.port}
-  type = "neo4j"
-  graph = "data"
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/e7bcb0d1/local/twitter-follow-neo4j/src/test/resources/TwitterFollowNeo4jIT.conf
----------------------------------------------------------------------
diff --git 
a/local/twitter-follow-neo4j/src/test/resources/TwitterFollowNeo4jIT.conf 
b/local/twitter-follow-neo4j/src/test/resources/TwitterFollowNeo4jIT.conf
new file mode 100644
index 0000000..d4b4aeb
--- /dev/null
+++ b/local/twitter-follow-neo4j/src/test/resources/TwitterFollowNeo4jIT.conf
@@ -0,0 +1,28 @@
+# 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
+#
+#   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.
+twitter {
+  endpoint = "friends"
+  info = [
+    18055613
+  ]
+  twitter.max_items = 1000
+}
+graph {
+  hostname = ${neo4j.http.host}
+  port = ${neo4j.http.port}
+  type = "neo4j"
+  graph = "data"
+}
\ No newline at end of file

Reply via email to