You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by sb...@apache.org on 2014/10/07 14:21:05 UTC

git commit: added test cases as discussed: https://github.com/apache/incubator-streams/pull/85

Repository: incubator-streams
Updated Branches:
  refs/heads/STREAMS-173 6016a7740 -> dc6833402


added test cases as discussed:
https://github.com/apache/incubator-streams/pull/85


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

Branch: refs/heads/STREAMS-173
Commit: dc68334029dba329b0efa2a60d44820d4b9ed907
Parents: 6016a77
Author: Steve Blackmon <sb...@w2odigital.com>
Authored: Tue Oct 7 07:21:02 2014 -0500
Committer: Steve Blackmon <sb...@w2odigital.com>
Committed: Tue Oct 7 07:21:02 2014 -0500

----------------------------------------------------------------------
 streams-contrib/streams-persist-hdfs/pom.xml    |  12 ++
 .../hdfs/test/HdfsPersistConfigTest.java        | 169 +++++++++++++++++++
 2 files changed, 181 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/dc683340/streams-contrib/streams-persist-hdfs/pom.xml
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-hdfs/pom.xml b/streams-contrib/streams-persist-hdfs/pom.xml
index 5fe33b3..8148cd0 100644
--- a/streams-contrib/streams-persist-hdfs/pom.xml
+++ b/streams-contrib/streams-persist-hdfs/pom.xml
@@ -66,6 +66,18 @@
         </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>

http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/dc683340/streams-contrib/streams-persist-hdfs/src/test/java/org/apache/streams/hdfs/test/HdfsPersistConfigTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-hdfs/src/test/java/org/apache/streams/hdfs/test/HdfsPersistConfigTest.java b/streams-contrib/streams-persist-hdfs/src/test/java/org/apache/streams/hdfs/test/HdfsPersistConfigTest.java
new file mode 100644
index 0000000..819414a
--- /dev/null
+++ b/streams-contrib/streams-persist-hdfs/src/test/java/org/apache/streams/hdfs/test/HdfsPersistConfigTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.streams.hdfs.test;
+
+import org.apache.streams.hdfs.*;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for checking that strings append to FS paths as expected
+ */
+public class HdfsPersistConfigTest {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(HdfsPersistConfigTest.class);
+
+    @Test
+    public void getWriterFileUriTest()
+    {
+        HdfsWriterConfiguration writerConfiguration = new HdfsWriterConfiguration();
+        writerConfiguration.setScheme(HdfsConfiguration.Scheme.FILE);
+        writerConfiguration.setPath("path");
+        writerConfiguration.setWriterPath("writerPath");
+        writerConfiguration.setUser("cloudera");
+
+        WebHdfsPersistWriter webHdfsPersistWriter = new WebHdfsPersistWriter(writerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistWriter.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("file:///").toCharArray());
+        webHdfsPersistWriter.prepare(null);
+        assertTrue(webHdfsPersistWriter.isConnected());
+    }
+
+    @Test
+    public void getWriterHdfsUriTest()
+    {
+        HdfsWriterConfiguration writerConfiguration = new HdfsWriterConfiguration();
+        writerConfiguration.setScheme(HdfsConfiguration.Scheme.HDFS);
+        writerConfiguration.setHost("localhost");
+        writerConfiguration.setPort(9000l);
+        writerConfiguration.setPath("path");
+        writerConfiguration.setWriterPath("writerPath");
+        writerConfiguration.setUser("cloudera");
+
+        WebHdfsPersistWriter webHdfsPersistWriter = new WebHdfsPersistWriter(writerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistWriter.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("hdfs://localhost:9000").toCharArray());
+
+    }
+
+    @Test
+    public void getWriterWebHdfsUriTest()
+    {
+        HdfsWriterConfiguration writerConfiguration = new HdfsWriterConfiguration();
+        writerConfiguration.setScheme(HdfsConfiguration.Scheme.WEBHDFS);
+        writerConfiguration.setHost("localhost");
+        writerConfiguration.setPort(57000l);
+        writerConfiguration.setPath("path");
+        writerConfiguration.setWriterPath("writerPath");
+        writerConfiguration.setUser("cloudera");
+
+        WebHdfsPersistWriter webHdfsPersistWriter = new WebHdfsPersistWriter(writerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistWriter.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("webhdfs://localhost:57000").toCharArray());
+
+    }
+
+    @Test
+    public void getReaderFileUriTest()
+    {
+        HdfsReaderConfiguration readerConfiguration = new HdfsReaderConfiguration();
+        readerConfiguration.setScheme(HdfsConfiguration.Scheme.FILE);
+        readerConfiguration.setPath("path");
+        readerConfiguration.setReaderPath("readerPath");
+
+        WebHdfsPersistReader webHdfsPersistReader = new WebHdfsPersistReader(readerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistReader.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("file:///").toCharArray());
+    }
+
+    @Test
+    public void getReaderHdfsUriTest()
+    {
+        HdfsReaderConfiguration readerConfiguration = new HdfsReaderConfiguration();
+        readerConfiguration.setScheme(HdfsConfiguration.Scheme.HDFS);
+        readerConfiguration.setHost("localhost");
+        readerConfiguration.setPort(9000l);
+        readerConfiguration.setPath("path");
+        readerConfiguration.setReaderPath("readerPath");
+
+        WebHdfsPersistReader webHdfsPersistReader = new WebHdfsPersistReader(readerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistReader.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("hdfs://localhost:9000").toCharArray());
+
+    }
+
+    @Test
+    public void getReaderWebHdfsUriTest()
+    {
+        HdfsReaderConfiguration readerConfiguration = new HdfsReaderConfiguration();
+        readerConfiguration.setScheme(HdfsConfiguration.Scheme.WEBHDFS);
+        readerConfiguration.setHost("localhost");
+        readerConfiguration.setPort(57000l);
+        readerConfiguration.setPath("path");
+        readerConfiguration.setReaderPath("readerPath");
+
+        WebHdfsPersistReader webHdfsPersistReader = new WebHdfsPersistReader(readerConfiguration);
+
+        String uri = null;
+        try {
+            uri = webHdfsPersistReader.getURI().toString();
+        } catch (URISyntaxException e) {
+            fail("URI Syntax");
+        }
+        assertArrayEquals(uri.toCharArray(), ("webhdfs://localhost:57000").toCharArray());
+
+    }
+
+}