streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject svn commit: r1556893 [6/25] - in /incubator/streams/branches/sblackmon: ./ streams-config-graph/ streams-config-graph/src/ streams-config-graph/src/main/ streams-config-graph/src/main/java/ streams-config-graph/src/main/java/org/ streams-config-graph/s...
Date Thu, 09 Jan 2014 17:27:58 GMT
Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/pom.xml?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/pom.xml
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/pom.xml
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>streams-provider-gnip</artifactId>
+        <groupId>org.apache.streams</groupId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>gnip-edc-flickr</artifactId>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jsonschema2pojo</groupId>
+            <artifactId>jsonschema2pojo-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streams</groupId>
+            <artifactId>streams-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streams</groupId>
+            <artifactId>streams-pojo</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streams</groupId>
+            <artifactId>gnip-powertrack</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml</groupId>
+            <artifactId>aalto-xml</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <sourceDirectory>src/main/java</sourceDirectory>
+        <testSourceDirectory>src/test/java</testSourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>src/test/resources</directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source-jaxb2</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>target/generated-sources/jaxb2</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jvnet.jaxb2.maven2</groupId>
+                <artifactId>maven-jaxb2-plugin</artifactId>
+                <configuration>
+                    <schemaDirectory>src/main/xmlschema/com/flickr/</schemaDirectory>
+                    <generateDirectory>target/generated-sources/jaxb2</generateDirectory>
+                    <verbose>true</verbose>
+                    <debug>true</debug>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                    <forceRegenerate>true</forceRegenerate>
+                    <removeOldOutput>false</removeOldOutput>
+                    <generatePackage>com.flickr.api</generatePackage>
+                    <plugins>
+                        <plugin>
+                            <groupId>org.jvnet.jaxb2_commons</groupId>
+                            <artifactId>jaxb2-basics</artifactId>
+                            <version>0.6.5</version>
+                        </plugin>
+                    </plugins>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+
+    </build>
+</project>
\ No newline at end of file

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCAsActivityTest.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCAsActivityTest.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCAsActivityTest.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCAsActivityTest.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,104 @@
+/*
+ * 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.gnip.flickr.test;
+
+//import org.codehaus.jackson.map.ObjectMapper;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import org.apache.streams.gnip.powertrack.GnipActivityFixer;
+import org.apache.streams.pojo.json.Activity;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+//import com.fasterxml.jackson.xml.XmlMapper;
+//import com.gnip.xmlpojo.generated.FacebookEDC;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: rebanks
+ * Date: 8/21/13
+ * Time: 11:53 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class FlickrEDCAsActivityTest {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(FlickrEDCAsActivityTest.class);
+
+    private ObjectMapper mapper = new ObjectMapper();
+//    XmlMapper mapper = new XmlMapper();
+
+    @Ignore
+    @Test
+    public void Tests()   throws Exception
+    {
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+        mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+        InputStream is = FlickrEDCAsActivityTest.class.getResourceAsStream("/FlickrEDC.xml");
+        if(is == null) System.out.println("null");
+        InputStreamReader isr = new InputStreamReader(is);
+        BufferedReader br = new BufferedReader(isr);
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+        xmlMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+        xmlMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+        ObjectMapper jsonMapper = new ObjectMapper();
+
+        try {
+            while (br.ready()) {
+                String line = br.readLine();
+                //LOGGER.debug(line);
+
+                Object activityObject = xmlMapper.readValue(line, Object.class);
+
+                String jsonString = jsonMapper.writeValueAsString(activityObject);
+
+                JSONObject jsonObject = new JSONObject(jsonString);
+
+                JSONObject fixedObject = GnipActivityFixer.fix(jsonObject);
+
+                Activity activity = null;
+                try {
+                    activity = jsonMapper.readValue(fixedObject.toString(), Activity.class);
+                } catch( Exception e ) {
+                    LOGGER.error(jsonObject.toString());
+                    LOGGER.error(fixedObject.toString());
+                    e.printStackTrace();
+                    Assert.fail();
+                }
+                //LOGGER.debug(des);
+            }
+        } catch( Exception e ) {
+            e.printStackTrace();
+            Assert.fail();
+        }
+    }
+}

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCSerDeTest.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCSerDeTest.java?rev=1556893&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCSerDeTest.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-gnip/gnip-edc-flickr/src/test/java/org/apache/streams/gnip/flickr/test/FlickrEDCSerDeTest.java
Thu Jan  9 17:27:50 2014
@@ -0,0 +1,69 @@
+package org.apache.streams.gnip.flickr.test;
+
+//import org.codehaus.jackson.map.ObjectMapper;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+//import com.fasterxml.jackson.xml.XmlMapper;
+//import com.gnip.xmlpojo.generated.FacebookEDC;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: rebanks
+ * Date: 8/21/13
+ * Time: 11:53 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class FlickrEDCSerDeTest {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(FlickrEDCSerDeTest.class);
+
+    private ObjectMapper mapper = new ObjectMapper();
+//    XmlMapper mapper = new XmlMapper();
+
+    @Test
+    public void Tests()   throws Exception
+    {
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+        mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+
+        InputStream is = FlickrEDCSerDeTest.class.getResourceAsStream("/FlickrEDC.xml");
+        if(is == null) System.out.println("null");
+        InputStreamReader isr = new InputStreamReader(is);
+        BufferedReader br = new BufferedReader(isr);
+        XmlMapper xmlMapper = new XmlMapper();
+        xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+        xmlMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE);
+        xmlMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE);
+        xmlMapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, Boolean.FALSE);
+
+        ObjectMapper jsonMapper = new ObjectMapper();
+
+        try {
+            while (br.ready()) {
+                String line = br.readLine();
+                //LOGGER.debug(line);
+
+                Object activityObject = xmlMapper.readValue(line, Object.class);
+
+                String jsonObject = jsonMapper.writeValueAsString(activityObject);
+
+                //LOGGER.debug(jsonObject);
+            }
+        } catch( Exception e ) {
+            e.printStackTrace();
+            Assert.fail();
+        }
+    }
+}



Mime
View raw message