add a test for example activities
export example activities in test-jar for other modules to use


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

Branch: refs/heads/asf-master
Commit: a412b1936f9589e3ec87138a117bb19a5794d939
Parents: dc6c151
Author: sblackmon <sblack...@apache.org>
Authored: Tue Feb 17 15:38:13 2015 -0600
Committer: sblackmon <sblack...@apache.org>
Committed: Tue Feb 17 15:38:13 2015 -0600

----------------------------------------------------------------------
 streams-pojo/pom.xml                            | 28 ++++++++++
 .../data/data/util/ActivitySerDeTest.java       | 59 ++++++++++++++++++++
 .../src/test/resources/activities/append.json   |  2 +-
 3 files changed, 88 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/a412b193/streams-pojo/pom.xml
----------------------------------------------------------------------
diff --git a/streams-pojo/pom.xml b/streams-pojo/pom.xml
index 860a301..fea605a 100644
--- a/streams-pojo/pom.xml
+++ b/streams-pojo/pom.xml
@@ -98,7 +98,23 @@
             <version>${reflections.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>${logback.version}</version>
+        </dependency>
 
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>${logback.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
@@ -240,6 +256,18 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.2</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/a412b193/streams-pojo/src/test/java/org/apache/streams/data/data/util/ActivitySerDeTest.java
----------------------------------------------------------------------
diff --git 
a/streams-pojo/src/test/java/org/apache/streams/data/data/util/ActivitySerDeTest.java
 
b/streams-pojo/src/test/java/org/apache/streams/data/data/util/ActivitySerDeTest.java
new file mode 100644
index 0000000..a1c2abd
--- /dev/null
+++ 
b/streams-pojo/src/test/java/org/apache/streams/data/data/util/ActivitySerDeTest.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
+ *
+ *   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.data.data.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.Charsets;
+import org.apache.commons.io.IOUtils;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.apache.streams.pojo.json.Activity;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Test that Activity beans are compatible with the example activities in the 
spec.
+ */
+public class ActivitySerDeTest {
+
+    private final static Logger LOGGER = 
LoggerFactory.getLogger(ActivitySerDeTest.class);
+
+    private final static ObjectMapper MAPPER = 
StreamsJacksonMapper.getInstance();
+
+    @Test
+    public void testActivitySerDe() throws Exception {
+
+        InputStream testActivityFolderStream = 
ActivitySerDeTest.class.getClassLoader()
+                .getResourceAsStream("activities");
+        List<String> files = IOUtils.readLines(testActivityFolderStream, 
Charsets.UTF_8);
+
+        for( String file : files) {
+            LOGGER.info("Serializing: activities/" + file );
+            InputStream testActivityFileStream = 
ActivitySerDeTest.class.getClassLoader()
+                    .getResourceAsStream("activities/" + file);
+            Activity activity = MAPPER.readValue(testActivityFileStream, 
Activity.class);
+            String activityString = MAPPER.writeValueAsString(activity);
+            LOGGER.info("Deserialized: " + activityString );
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/a412b193/streams-pojo/src/test/resources/activities/append.json
----------------------------------------------------------------------
diff --git a/streams-pojo/src/test/resources/activities/append.json 
b/streams-pojo/src/test/resources/activities/append.json
index 159e064..d8fb3be 100644
--- a/streams-pojo/src/test/resources/activities/append.json
+++ b/streams-pojo/src/test/resources/activities/append.json
@@ -8,7 +8,7 @@
     "displayName": "Joe"
   },
   "verb": "append",
-  "object": {"content": "This is some text"}
+  "object": {"content": "This is some text"},
   "target": {
     "objectType": "file",
     "displayName": "log.txt"

Reply via email to