streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [2/3] incubator-streams git commit: updates to resolve feedback: https://github.com/apache/incubator-streams/pull/216#discussion_r29957068
Date Fri, 19 Jun 2015 22:13:15 GMT
updates to resolve feedback: https://github.com/apache/incubator-streams/pull/216#discussion_r29957068


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

Branch: refs/heads/master
Commit: 8a9c6230f0fc24f4c718fbd0ad44e68535ab8adb
Parents: cb1aaea
Author: Steve Blackmon (@steveblackmon) <sblackmon@apache.org>
Authored: Mon May 11 13:04:39 2015 -0500
Committer: Steve Blackmon (@steveblackmon) <sblackmon@apache.org>
Committed: Mon May 11 13:04:39 2015 -0500

----------------------------------------------------------------------
 streams-contrib/streams-persist-graph/pom.xml   |  29 ---
 .../neo4j/Neo4jBinaryGraphPersistWriter.java    | 200 -------------------
 .../graph/neo4j/Neo4jBinaryGraphUtil.java       |  95 ---------
 .../graph/test/Neo4jHttpPersistWriterIT.java    | 102 ----------
 .../test/TestNeo4jBinaryPersistWriter.java      | 162 ---------------
 .../graph/test/TestNeo4jHttpVertexReader.java   |  81 ++++++++
 .../graph/test/TestNeo4jVertexReader.java       |  81 --------
 7 files changed, 81 insertions(+), 669 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/pom.xml b/streams-contrib/streams-persist-graph/pom.xml
index edbae7e..deb08b7 100644
--- a/streams-contrib/streams-persist-graph/pom.xml
+++ b/streams-contrib/streams-persist-graph/pom.xml
@@ -77,39 +77,10 @@
         </dependency>
 
         <dependency>
-            <groupId>org.neo4j</groupId>
-            <artifactId>neo4j-kernel</artifactId>
-            <version>2.2.1</version>
-            <scope>provided</scope>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.neo4j</groupId>
-            <artifactId>neo4j-lucene-index</artifactId>
-            <version>2.2.1</version>
-            <scope>provided</scope>
-            <optional>true</optional>
-        </dependency>
-
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.neo4j</groupId>
-            <artifactId>neo4j-kernel</artifactId>
-            <version>2.2.1</version>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.neo4j</groupId>
-            <artifactId>neo4j-io</artifactId>
-            <version>2.2.1</version>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
 
     </dependencies>
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphPersistWriter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphPersistWriter.java
b/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphPersistWriter.java
deleted file mode 100644
index 8ca5fff..0000000
--- a/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphPersistWriter.java
+++ /dev/null
@@ -1,200 +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.graph.neo4j;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import org.apache.commons.io.FileUtils;
-import org.apache.streams.config.ComponentConfigurator;
-import org.apache.streams.config.StreamsConfigurator;
-import org.apache.streams.core.StreamsDatum;
-import org.apache.streams.core.StreamsPersistWriter;
-import org.apache.streams.graph.GraphBinaryConfiguration;
-import org.apache.streams.jackson.StreamsJacksonMapper;
-import org.apache.streams.pojo.json.Activity;
-import org.apache.streams.pojo.json.ActivityObject;
-import org.javatuples.Pair;
-import org.javatuples.Quartet;
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.graphdb.Label;
-import org.neo4j.graphdb.factory.GraphDatabaseFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Adds activityobjects as vertices and activities as edges to a graph database file which
will be
- * loaded inside of neo4j
- */
-public class Neo4jBinaryGraphPersistWriter implements StreamsPersistWriter {
-
-    public static final String STREAMS_ID = Neo4jBinaryGraphPersistWriter.class.getCanonicalName();
-
-    private final static Logger LOGGER = LoggerFactory.getLogger(Neo4jBinaryGraphPersistWriter.class);
-    private final static long MAX_WRITE_LATENCY = 1000;
-
-    protected GraphBinaryConfiguration configuration;
-
-    private static ObjectMapper mapper;
-
-    public GraphDatabaseService graph;
-    private Neo4jBinaryGraphUtil graphutil;
-    private CypherQueryGraphHelper queryGraphHelper;
-    private BinaryGraphHelper binaryGraphHelper;
-
-    protected final ReadWriteLock lock = new ReentrantReadWriteLock();
-
-    public Neo4jBinaryGraphPersistWriter() {
-        this(new ComponentConfigurator<GraphBinaryConfiguration>(GraphBinaryConfiguration.class).detectConfiguration(StreamsConfigurator.config.getConfig("graph")));
-    }
-
-    public Neo4jBinaryGraphPersistWriter(GraphBinaryConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
-    @Override
-    public void prepare(Object configurationObject) {
-
-        mapper = StreamsJacksonMapper.getInstance();
-
-        boolean newGraph = true;
-        if( FileUtils.getFile(configuration.getFile()).canRead())
-            newGraph = false;
-
-        graph = new GraphDatabaseFactory().newEmbeddedDatabase(configuration.getFile());
-
-        graphutil = new Neo4jBinaryGraphUtil();
-
-        queryGraphHelper = new CypherQueryGraphHelper();
-
-        binaryGraphHelper = new BinaryGraphHelper();
-
-        String globalLabel = "streams";
-
-        if( newGraph ) {
-            graphutil.addUniqueIndex(graph, globalLabel, "id", false);
-            for( String field: configuration.getIndexFields()) {
-                graphutil.addUniqueIndex(graph, globalLabel, field, false);
-            }
-        }
-
-    }
-
-    @Override
-    public void cleanUp() {
-
-        LOGGER.info("exiting");
-
-    }
-
-    @Override
-    public void write(StreamsDatum entry) {
-
-        Activity activity = null;
-        ActivityObject activityObject = null;
-
-        if (entry.getDocument() instanceof Activity) {
-            activity = (Activity) entry.getDocument();
-        } if (entry.getDocument() instanceof ActivityObject) {
-            activityObject = (ActivityObject) entry.getDocument();
-        } else if (entry.getDocument() instanceof ObjectNode) {
-            try {
-                activity = mapper.convertValue(entry.getDocument(), Activity.class);
-            } catch( Exception e ) {
-                activityObject = mapper.convertValue(entry.getDocument(), ActivityObject.class);
-            }
-        } else if (entry.getDocument() instanceof String) {
-            try {
-                activity = mapper.readValue((String) entry.getDocument(), Activity.class);
-            } catch (Throwable e1) {
-                try {
-                    activityObject = mapper.readValue((String) entry.getDocument(), ActivityObject.class);
-                } catch( Exception e2 ) {
-                    LOGGER.error("Can't handle input: ", e2);
-                }
-            }
-        }
-
-        Preconditions.checkArgument(activity != null || activityObject != null);
-
-        List<String> labels = Lists.newArrayList("streams");
-
-        if( activityObject != null ) {
-            if (activityObject.getObjectType() != null)
-                labels.add(activityObject.getObjectType());
-            Pair<String, Map<String, Object>> addNode = binaryGraphHelper.createVertexRequest(activityObject);
-            graphutil.addNode(
-                    graph,
-                    labels,
-                    addNode);
-        } else if( activity != null ) {
-
-            // always add vertices first
-
-            if (activity.getProvider() != null &&
-                    !Strings.isNullOrEmpty(activity.getProvider().getId())) {
-                labels.add(activity.getProvider().getId());
-            }
-            if (activity.getActor() != null &&
-                    !Strings.isNullOrEmpty(activity.getActor().getId())) {
-                if (activity.getActor().getObjectType() != null)
-                    labels.add(activity.getActor().getObjectType());
-                Pair<String, Map<String, Object>> addNode = binaryGraphHelper.createVertexRequest(activity.getActor());
-                graphutil.addNode(
-                        graph,
-                        labels,
-                        addNode);
-            }
-
-            if (activity.getObject() != null &&
-                    !Strings.isNullOrEmpty(activity.getObject().getId())) {
-                if (activity.getObject().getObjectType() != null)
-                    labels.add(activity.getObject().getObjectType());
-                Pair<String, Map<String, Object>> addNode = binaryGraphHelper.createVertexRequest(activity.getObject());
-                graphutil.addNode(
-                        graph,
-                        labels,
-                        addNode);
-            }
-
-            // then add edge
-
-            if (!Strings.isNullOrEmpty(activity.getVerb())) {
-                if (activity.getVerb() != null)
-                    labels.add(activity.getVerb());
-                Quartet<String, String, String, Map<String, Object>> addRelationship
= binaryGraphHelper.createEdgeRequest(activity);
-                graphutil.addRelationship(
-                        graph,
-                        labels,
-                        addRelationship);
-            }
-
-        }
-
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphUtil.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphUtil.java
b/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphUtil.java
deleted file mode 100644
index 086b443..0000000
--- a/streams-contrib/streams-persist-graph/src/main/java/org/apache/streams/graph/neo4j/Neo4jBinaryGraphUtil.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.apache.streams.graph.neo4j;
-
-import com.google.common.collect.Lists;
-import org.javatuples.Pair;
-import org.javatuples.Quartet;
-import org.neo4j.graphdb.Direction;
-import org.neo4j.graphdb.DynamicLabel;
-import org.neo4j.graphdb.DynamicRelationshipType;
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.graphdb.Label;
-import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.Result;
-import org.neo4j.graphdb.Transaction;
-import org.neo4j.graphdb.schema.Schema;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-public class Neo4jBinaryGraphUtil {
-
-    CypherQueryGraphHelper queryGraphHelper = new CypherQueryGraphHelper();
-
-    protected void addUniqueIndex(GraphDatabaseService graph, String label, String property,
Boolean wait ) {
-        Transaction tx = graph.beginTx();
-        try {
-            Schema schema = graph.schema();
-            schema
-                .constraintFor(DynamicLabel.label(label))
-                .assertPropertyIsUnique(property)
-                .create();
-            if (wait)
-                schema.awaitIndexesOnline(2L, TimeUnit.HOURS);
-            tx.success();
-            tx.close();
-        } finally {
-            tx.failure();
-            tx.close();
-        }
-    }
-
-    protected void addIndex(GraphDatabaseService graph, String label, String property, Boolean
wait) {
-        Transaction tx = graph.beginTx();
-        try {
-            Schema schema = graph.schema();
-            schema
-                .indexFor(DynamicLabel.label(label))
-                .on(property)
-                .create();
-            if (wait)
-                schema.awaitIndexesOnline(2L, TimeUnit.HOURS);
-            tx.success();
-            tx.close();
-        } finally {
-            tx.failure();
-            tx.close();
-        }
-    }
-
-
-    protected void addNode(GraphDatabaseService graph, List<String> labelStringList,
Pair<String, Map<String, Object>> nodeIdPlusProperties) {
-        Transaction tx = graph.beginTx();
-        List<Label> labelList = Lists.newArrayList();
-        for( String labelString : labelStringList ) {
-            labelList.add(DynamicLabel.label(labelString));
-        }
-        try {
-            Node node = graph.createNode(labelList.toArray(new Label[0]));
-            node.setProperty("id", nodeIdPlusProperties.getValue0());
-            for( Map.Entry<String, Object> property : nodeIdPlusProperties.getValue1().entrySet())
{
-                node.setProperty(property.getKey(), property.getValue());
-            }
-            tx.success();
-        } catch(Exception e) {
-            tx.failure();
-        } finally {
-            tx.close();
-        }
-    }
-
-    protected void addRelationship(GraphDatabaseService graph, List<String> labelStringList,
Quartet<String, String, String, Map<String, Object>> relationshipIdsPlusProperties)
{
-        Transaction tx = graph.beginTx();
-        try {
-            Node source = graph.findNodesByLabelAndProperty(DynamicLabel.label(labelStringList.get(0)),
"id", relationshipIdsPlusProperties.getValue0()).iterator().next();
-            Node destination = graph.findNodesByLabelAndProperty(DynamicLabel.label(labelStringList.get(0)),
"id", relationshipIdsPlusProperties.getValue1()).iterator().next();
-            source.createRelationshipTo(destination, DynamicRelationshipType.withName(labelStringList.get(labelStringList.size()
- 1)));
-            tx.success();
-        } catch(Exception e) {
-            tx.failure();
-        } finally {
-            tx.close();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/Neo4jHttpPersistWriterIT.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/Neo4jHttpPersistWriterIT.java
b/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/Neo4jHttpPersistWriterIT.java
deleted file mode 100644
index d5105ec..0000000
--- a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/Neo4jHttpPersistWriterIT.java
+++ /dev/null
@@ -1,102 +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.graph.test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.Charsets;
-import org.apache.commons.io.IOUtils;
-import org.apache.streams.core.StreamsDatum;
-import org.apache.streams.graph.GraphHttpConfiguration;
-import org.apache.streams.graph.GraphHttpPersistWriter;
-import org.apache.streams.graph.GraphVertexReader;
-import org.apache.streams.jackson.StreamsJacksonMapper;
-import org.apache.streams.pojo.json.Activity;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.test.TestGraphDatabaseFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * Unit test for
- * @see {@link GraphVertexReader}
- *
- * Test that graph db http writes to neo4j rest API
- *
- *
- */
-@Ignore("Need to find a way to launch neo4j during verify step to use this")
-public class Neo4jHttpPersistWriterIT {
-
-    private final static Logger LOGGER = LoggerFactory.getLogger(Neo4jHttpPersistWriterIT.class);
-
-    private final static ObjectMapper mapper = StreamsJacksonMapper.getInstance();
-
-    private GraphHttpConfiguration testConfiguration;
-
-    private GraphHttpPersistWriter graphPersistWriter;
-
-    @Before
-    public void prepareTest() throws IOException {
-
-        testConfiguration = new GraphHttpConfiguration();
-        testConfiguration.setType(GraphHttpConfiguration.Type.NEO_4_J);
-        testConfiguration.setGraph("data");
-        testConfiguration.setHostname("localhost");
-        testConfiguration.setPort(7474l);
-        testConfiguration.setContentType("application/json");
-        testConfiguration.setProtocol("http");
-
-        graphPersistWriter = new GraphHttpPersistWriter(testConfiguration);
-
-        graphPersistWriter.prepare(testConfiguration);
-    }
-
-    @Test
-    public void testNeo4jHttpPersistWriter() throws IOException {
-
-        InputStream testActivityFolderStream = Neo4jHttpPersistWriterIT.class.getClassLoader()
-                .getResourceAsStream("activities");
-        List<String> files = IOUtils.readLines(testActivityFolderStream, Charsets.UTF_8);
-
-        for( String file : files) {
-            LOGGER.info("File: " + file );
-            InputStream testActivityFileStream = Neo4jHttpPersistWriterIT.class.getClassLoader()
-                    .getResourceAsStream("activities/" + file);
-            Activity activity = mapper.readValue(testActivityFileStream, Activity.class);
-            activity.getActor().setId(activity.getActor().getObjectType());
-            activity.getObject().setId(activity.getObject().getObjectType());
-            StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());
-            graphPersistWriter.write( datum );
-            LOGGER.info("Wrote: " + activity.getVerb() );
-        }
-
-        graphPersistWriter.cleanUp();
-
-        // hit neo with http and check vertex/edge counts
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jBinaryPersistWriter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jBinaryPersistWriter.java
b/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jBinaryPersistWriter.java
deleted file mode 100644
index 8295734..0000000
--- a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jBinaryPersistWriter.java
+++ /dev/null
@@ -1,162 +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.graph.test;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import junit.framework.Assert;
-import org.apache.commons.io.Charsets;
-import org.apache.commons.io.IOUtils;
-import org.apache.streams.core.StreamsDatum;
-import org.apache.streams.graph.GraphBinaryConfiguration;
-import org.apache.streams.graph.GraphReaderConfiguration;
-import org.apache.streams.graph.GraphVertexReader;
-import org.apache.streams.graph.neo4j.Neo4jBinaryGraphPersistWriter;
-import org.apache.streams.jackson.StreamsJacksonMapper;
-import org.apache.streams.pojo.json.Activity;
-import org.apache.streams.pojo.json.ActivityObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.neo4j.graphdb.Direction;
-import org.neo4j.graphdb.DynamicLabel;
-import org.neo4j.graphdb.DynamicRelationshipType;
-import org.neo4j.graphdb.GraphDatabaseService;
-import org.neo4j.graphdb.Node;
-import org.neo4j.graphdb.Relationship;
-import org.neo4j.graphdb.RelationshipType;
-import org.neo4j.graphdb.factory.GraphDatabaseFactory;
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Unit test for
- * @see {@link GraphVertexReader}
- *
- * Test that graph db responses can be converted to streams data
- */
-public class TestNeo4jBinaryPersistWriter {
-
-    private final static Logger LOGGER = LoggerFactory.getLogger(TestNeo4jBinaryPersistWriter.class);
-
-    private final static ObjectMapper mapper = StreamsJacksonMapper.getInstance();
-
-    private final String testGraphFile = "target/graph.neo4j";
-
-    private GraphBinaryConfiguration testConfiguration;
-
-    private Neo4jBinaryGraphPersistWriter graphPersistWriter;
-
-    @Before
-    public void prepareTest() throws IOException {
-
-        testConfiguration = new GraphBinaryConfiguration();
-        testConfiguration.setType(GraphBinaryConfiguration.Type.NEO_4_J);
-        testConfiguration.setFile(testGraphFile);
-
-        graphPersistWriter = new Neo4jBinaryGraphPersistWriter(testConfiguration);
-
-        graphPersistWriter.prepare(testConfiguration);
-
-        assert(graphPersistWriter.graph.isAvailable(5000));
-
-    }
-
-    @Test
-    public void testNeo4jBinaryPersistWriter() throws Exception {
-
-        InputStream testActivityFolderStream = TestNeo4jBinaryPersistWriter.class.getClassLoader()
-                .getResourceAsStream("activities");
-        List<String> files = IOUtils.readLines(testActivityFolderStream, Charsets.UTF_8);
-
-        for( String file : files) {
-            LOGGER.info("File: " + file);
-            InputStream testActivityFileStream = TestNeo4jBinaryPersistWriter.class.getClassLoader()
-                    .getResourceAsStream("activities/" + file);
-            Activity activity = mapper.readValue(testActivityFileStream, Activity.class);
-            activity.getActor().setId(activity.getActor().getObjectType());
-            activity.getObject().setId(activity.getObject().getObjectType());
-            if( !Strings.isNullOrEmpty((String)activity.getObject().getAdditionalProperties().get("verb")))
{
-                activity.getObject().setObjectType((String) activity.getObject().getAdditionalProperties().get("verb"));
-                activity.getObject().setId(activity.getObject().getObjectType());
-            }
-            if( !Strings.isNullOrEmpty(activity.getActor().getId())) {
-                StreamsDatum actorDatum = new StreamsDatum(activity.getActor(), activity.getActor().getId());
-                graphPersistWriter.write( actorDatum );
-            }
-            if( !Strings.isNullOrEmpty(activity.getObject().getId())) {
-                StreamsDatum objectDatum = new StreamsDatum(activity.getObject(), activity.getObject().getId());
-                graphPersistWriter.write( objectDatum );
-            }
-            if( !Strings.isNullOrEmpty(activity.getVerb()) &&
-                !Strings.isNullOrEmpty(activity.getActor().getId()) &&
-                !Strings.isNullOrEmpty(activity.getObject().getId())) {
-                StreamsDatum activityDatum = new StreamsDatum(activity, activity.getVerb());
-                graphPersistWriter.write( activityDatum );
-            }
-            LOGGER.info("Wrote: " + activity.getVerb());
-        }
-
-        graphPersistWriter.cleanUp();
-
-        graphPersistWriter.graph.beginTx();
-        Node organization = graphPersistWriter.graph.findNodes(DynamicLabel.label("streams"),
"id", "organization").next();
-        Node person = graphPersistWriter.graph.findNodes(DynamicLabel.label("streams"), "id",
"person").next();
-        Assert.assertNotNull(organization);
-        Assert.assertTrue(organization.hasLabel(DynamicLabel.label("streams")));
-        Assert.assertTrue(organization.hasLabel(DynamicLabel.label("organization")));
-        Assert.assertNotNull(person);
-        Assert.assertTrue(person.hasLabel(DynamicLabel.label("streams")));
-        Assert.assertTrue(person.hasLabel(DynamicLabel.label("person")));
-        Assert.assertTrue(person.hasRelationship());
-        Assert.assertTrue(person.hasRelationship(Direction.OUTGOING));
-        Assert.assertTrue(person.hasRelationship(DynamicRelationshipType.withName("join"),
Direction.OUTGOING));
-        Assert.assertTrue(person.hasRelationship(DynamicRelationshipType.withName("leave"),
Direction.OUTGOING));
-//        Iterable < Relationship > relationships = person.getRelationships(Direction.OUTGOING);
-//        List<Relationship> relationshipList = Lists.newArrayList(relationships);
-//        Assert.assertEquals(relationshipList.size(), 2);
-        Relationship joinRelationship = person.getSingleRelationship(DynamicRelationshipType.withName("join"),
Direction.OUTGOING);
-        Assert.assertNotNull(joinRelationship);
-        Node joinRelationshipStart = joinRelationship.getStartNode();
-        Node joinRelationshipEnd = joinRelationship.getEndNode();
-        Assert.assertEquals(joinRelationshipStart, person);
-        Assert.assertEquals(joinRelationshipEnd, organization);
-        Relationship leaveRelationship = person.getSingleRelationship(DynamicRelationshipType.withName("leave"),
Direction.OUTGOING);
-        Assert.assertNotNull(leaveRelationship);
-        Node leaveRelationshipStart = leaveRelationship.getStartNode();
-        Node leaveRelationshipEnd = leaveRelationship.getEndNode();
-        Assert.assertEquals(leaveRelationshipStart, person);
-        Assert.assertEquals(leaveRelationshipEnd, organization);
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jHttpVertexReader.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jHttpVertexReader.java
b/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jHttpVertexReader.java
new file mode 100644
index 0000000..eb7ce96
--- /dev/null
+++ b/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jHttpVertexReader.java
@@ -0,0 +1,81 @@
+/*
+ * 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.graph.test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.io.IOUtils;
+import org.apache.streams.graph.GraphHttpConfiguration;
+import org.apache.streams.graph.GraphReaderConfiguration;
+import org.apache.streams.graph.GraphVertexReader;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Unit test for
+ * @see {@link org.apache.streams.graph.GraphVertexReader}
+ *
+ * Test that graph db responses can be converted to streams data
+ */
+public class TestNeo4jHttpVertexReader {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(TestNeo4jHttpVertexReader.class);
+
+    private final static ObjectMapper mapper = StreamsJacksonMapper.getInstance();
+
+    private JsonNode sampleReaderResult;
+
+    private GraphReaderConfiguration testConfiguration;
+
+    private GraphVertexReader graphPersistReader;
+
+    @Before
+    public void prepareTest() throws IOException {
+
+        testConfiguration = new GraphReaderConfiguration();
+        testConfiguration.setType(GraphHttpConfiguration.Type.NEO_4_J);
+
+        graphPersistReader = new GraphVertexReader(testConfiguration);
+        InputStream testActivityFileStream = TestNeo4jHttpVertexReader.class.getClassLoader()
+                .getResourceAsStream("sampleReaderResult.json");
+        String sampleText = IOUtils.toString(testActivityFileStream, "utf-8");
+        sampleReaderResult = mapper.readValue(sampleText, JsonNode.class);
+
+    }
+
+    @Test
+    public void testParseNeoResult() throws IOException {
+
+        List<ObjectNode> result = graphPersistReader.parse(sampleReaderResult);
+
+        assert( result.size() == 10);
+
+        for( int i = 0 ; i < 10; i++ )
+            assert( result.get(i).get("extensions").size() == 5);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/8a9c6230/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jVertexReader.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jVertexReader.java
b/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jVertexReader.java
deleted file mode 100644
index 8d76e90..0000000
--- a/streams-contrib/streams-persist-graph/src/test/java/org/apache/streams/graph/test/TestNeo4jVertexReader.java
+++ /dev/null
@@ -1,81 +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.graph.test;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.commons.io.IOUtils;
-import org.apache.streams.graph.GraphHttpConfiguration;
-import org.apache.streams.graph.GraphReaderConfiguration;
-import org.apache.streams.graph.GraphVertexReader;
-import org.apache.streams.jackson.StreamsJacksonMapper;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * Unit test for
- * @see {@link org.apache.streams.graph.GraphVertexReader}
- *
- * Test that graph db responses can be converted to streams data
- */
-public class TestNeo4jVertexReader {
-
-    private final static Logger LOGGER = LoggerFactory.getLogger(TestNeo4jVertexReader.class);
-
-    private final static ObjectMapper mapper = StreamsJacksonMapper.getInstance();
-
-    private JsonNode sampleReaderResult;
-
-    private GraphReaderConfiguration testConfiguration;
-
-    private GraphVertexReader graphPersistReader;
-
-    @Before
-    public void prepareTest() throws IOException {
-
-        testConfiguration = new GraphReaderConfiguration();
-        testConfiguration.setType(GraphHttpConfiguration.Type.NEO_4_J);
-
-        graphPersistReader = new GraphVertexReader(testConfiguration);
-        InputStream testActivityFileStream = TestNeo4jVertexReader.class.getClassLoader()
-                .getResourceAsStream("sampleReaderResult.json");
-        String sampleText = IOUtils.toString(testActivityFileStream, "utf-8");
-        sampleReaderResult = mapper.readValue(sampleText, JsonNode.class);
-
-    }
-
-    @Test
-    public void testParseNeoResult() throws IOException {
-
-        List<ObjectNode> result = graphPersistReader.parse(sampleReaderResult);
-
-        assert( result.size() == 10);
-
-        for( int i = 0 ; i < 10; i++ )
-            assert( result.get(i).get("extensions").size() == 5);
-
-    }
-}


Mime
View raw message