incubator-s4-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [22/50] [abbrv] renamed test packages
Date Tue, 03 Jan 2012 14:03:28 GMT
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCountTest.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCountTest.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCountTest.java
deleted file mode 100644
index 26a0936..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCountTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package test.s4.wordcount;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-import junit.framework.Assert;
-
-import org.apache.s4.core.App;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.server.NIOServerCnxn.Factory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import test.s4.fixtures.TestUtils;
-
-public class WordCountTest {
-    
-    public static final String SENTENCE_1 = "to be or not to be doobie doobie da";
-    public static final int SENTENCE_1_TOTAL_WORDS = SENTENCE_1.split(" ").length;
-    public static final String SENTENCE_2 = "doobie doobie da";
-    public static final int SENTENCE_2_TOTAL_WORDS = SENTENCE_2.split(" ").length;
-    public static final String SENTENCE_3 = "doobie";
-    public static final int SENTENCE_3_TOTAL_WORDS = SENTENCE_3.split(" ").length;
-    public static final String FLAG = ";";
-    public static int TOTAL_WORDS = SENTENCE_1_TOTAL_WORDS
-            + SENTENCE_2_TOTAL_WORDS + SENTENCE_3_TOTAL_WORDS;
-    private static Factory zookeeperServerConnectionFactory;
-    
-    @Before
-    public void prepare() throws IOException, InterruptedException, KeeperException {
-        TestUtils.cleanupTmpDirs();
-        zookeeperServerConnectionFactory = TestUtils.startZookeeperServer();
-
-    }
-
-    /**
-     * A simple word count application:
-     * 
-     * 
-     * 
-     * 
-     *           sentences                      words                    word counts
-     * Adapter ------------> WordSplitterPE -----------> WordCounterPE ------------->
WordClassifierPE 
-     *                       key = "sentence"             key = word                   key="classifier"
-     *                       (should be *)               
-     * 
-     * 
-     * The test consists in checking that words are correctly counted.
-     * 
-     * 
-     */
-    @Test
-    public void testSimple() throws Exception {
-        
-        final ZooKeeper zk = TestUtils.createZkClient();
-        
-        App.main(new String[]{WordCountModule.class.getName(), WordCountApp.class.getName()});
-        
-
-        CountDownLatch signalTextProcessed = new CountDownLatch(1);
-        TestUtils.watchAndSignalCreation("/textProcessed", signalTextProcessed,
-                zk);
-        
-        // add authorizations for processing
-        for (int i = 1; i <= SENTENCE_1_TOTAL_WORDS + SENTENCE_2_TOTAL_WORDS
-                + 1; i++) {
-            zk.create("/continue_" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.EPHEMERAL);
-        }
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_1);
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_2);
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_3);
-        signalTextProcessed.await();
-        File results = new File(TestUtils.DEFAULT_TEST_OUTPUT_DIR
-                + File.separator + "wordcount");
-        String s = TestUtils.readFile(results);
-        Assert.assertEquals("be=2;da=2;doobie=5;not=1;or=1;to=2;", s);
-        
-    }
-
-    @After
-    public void cleanup() throws IOException, InterruptedException {
-        TestUtils.stopZookeeperServer(zookeeperServerConnectionFactory);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCounterPE.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCounterPE.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCounterPE.java
deleted file mode 100644
index d5cacc7..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordCounterPE.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package test.s4.wordcount;
-
-import org.apache.s4.core.App;
-import org.apache.s4.core.ProcessingElement;
-import org.apache.s4.core.Stream;
-
-public class WordCounterPE extends ProcessingElement {
-    
-    int wordCounter;
-    transient Stream<WordCountEvent> wordClassifierStream;
-
-    private WordCounterPE() {}
-    
-    public WordCounterPE(App app) {
-        super(app);
-    }
-    
-    public void setWordClassifierStream(Stream<WordCountEvent> stream) {
-        this.wordClassifierStream = stream;
-    }
-
-    public void onEvent(WordSeenEvent event) { 
-        wordCounter++;
-        System.out.println("seen word " + event.getWord());
-        // NOTE: it seems the id is the key for now...     
-        wordClassifierStream.put(new WordCountEvent(getId(), wordCounter));
-    }
-
-    @Override
-    protected void onCreate() {
-        // TODO Auto-generated method stub
-        
-    }
-
-    @Override
-    protected void onRemove() {
-        // TODO Auto-generated method stub
-        
-    }
-
-   
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenEvent.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenEvent.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenEvent.java
deleted file mode 100644
index 1527691..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenEvent.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.s4.wordcount;
-
-import org.apache.s4.base.Event;
-
-public class WordSeenEvent extends Event {
-    
-    private String word;
-    
-    protected WordSeenEvent() {}
-
-    public WordSeenEvent(String word) {
-        super();
-        this.word = word;
-    }
-
-    public String getWord() {
-        return word;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenKeyFinder.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenKeyFinder.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenKeyFinder.java
deleted file mode 100644
index 1cac201..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSeenKeyFinder.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package test.s4.wordcount;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.s4.core.KeyFinder;
-
-public class WordSeenKeyFinder implements KeyFinder<WordSeenEvent> {
-
-    @Override
-    public List<String> get(WordSeenEvent event) {
-        List<String> key = new ArrayList<String>();
-        key.add(event.getWord());
-        return key;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSplitterPE.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSplitterPE.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSplitterPE.java
deleted file mode 100644
index bae0fcd..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/WordSplitterPE.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package test.s4.wordcount;
-
-import org.apache.s4.core.App;
-import org.apache.s4.core.ProcessingElement;
-import org.apache.s4.core.Stream;
-
-
-public class WordSplitterPE extends ProcessingElement {
-    
-    private Stream<WordSeenEvent> wordSeenStream;
-
-    public WordSplitterPE(App app) {
-        super(app);
-    }
-
-    public void onEvent(StringEvent event) {
-        StringEvent sentence = event;
-        String[] split = sentence.getString().split(" ");
-        for (String word : split) {
-            wordSeenStream.put(new WordSeenEvent(word));
-        }
-    }
-    
-    public void setWordSeenStream(Stream<WordSeenEvent> stream) {
-        this.wordSeenStream = stream;
-    }
-
-    @Override
-    protected void onCreate() {
-        // TODO Auto-generated method stub
-        
-    }
-
-    @Override
-    protected void onRemove() {
-        // TODO Auto-generated method stub
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountModuleZk.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountModuleZk.java
b/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountModuleZk.java
deleted file mode 100644
index 8f87b8e..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountModuleZk.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test.s4.wordcount.zk;
-
-import test.s4.fixtures.ZkBasedClusterManagementTestModule;
-import test.s4.wordcount.WordCountApp;
-
-public class WordCountModuleZk extends ZkBasedClusterManagementTestModule<WordCountApp>
{
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/90f68b42/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountTestZk.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountTestZk.java b/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountTestZk.java
deleted file mode 100644
index 23db369..0000000
--- a/subprojects/s4-core/src/test/java/test/s4/wordcount/zk/WordCountTestZk.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package test.s4.wordcount.zk;
-
-import static org.junit.Assert.*;
-import static test.s4.wordcount.WordCountTest.*;
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-
-import junit.framework.Assert;
-
-import org.I0Itec.zkclient.IDefaultNameSpace;
-import org.I0Itec.zkclient.ZkClient;
-import org.I0Itec.zkclient.ZkServer;
-import org.apache.s4.comm.tools.TaskSetup;
-import org.apache.s4.comm.topology.AssignmentFromZK;
-import org.apache.s4.comm.topology.ClusterNode;
-import org.apache.s4.core.App;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.junit.Before;
-import org.junit.Test;
-
-import test.s4.fixtures.TestUtils;
-import test.s4.wordcount.WordCountApp;
-import test.s4.wordcount.WordCountModule;
-
-public class WordCountTestZk {
-
-    private ZkServer zkServer;
-    private ZkClient zkClient;
-
-    @Before
-    public void prepare() {
-
-        String dataDir = TestUtils.DEFAULT_TEST_OUTPUT_DIR + File.separator + "zookeeper"
+ File.separator + "data";
-        String logDir = TestUtils.DEFAULT_TEST_OUTPUT_DIR + File.separator + "zookeeper"
+ File.separator + "logs";
-        TestUtils.cleanupTmpDirs();
-
-        IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
-
-            @Override
-            public void createDefaultNameSpace(ZkClient zkClient) {
-
-            }
-        };
-
-        zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, TestUtils.ZK_PORT);
-        zkServer.start();
-
-        // zkClient = zkServer.getZkClient();
-        String zookeeperAddress = "localhost:" + TestUtils.ZK_PORT;
-        zkClient = new ZkClient(zookeeperAddress, 10000, 10000);
-
-        ZkClient zkClient2 = new ZkClient(zookeeperAddress, 10000, 10000);
-        zkClient2.getCreationTime("/");
-        TaskSetup taskSetup = new TaskSetup(zookeeperAddress);
-        final String clusterName = "s4-test-cluster";
-        taskSetup.clean(clusterName);
-        taskSetup.setup(clusterName, 1);
-        // final CountDownLatch latch = new CountDownLatch(10);
-        // for (int i = 0; i < 10; i++) {
-        // Runnable runnable = new Runnable() {
-        //
-        // @Override
-        // public void run() {
-        // AssignmentFromZK assignmentFromZK;
-        // try {
-        // assignmentFromZK = new AssignmentFromZK(clusterName, zookeeperAddress, 30000,
30000);
-        // ClusterNode assignClusterNode = assignmentFromZK.assignClusterNode();
-        // latch.countDown();
-        // } catch (Exception e) {
-        // e.printStackTrace();
-        // }
-        // }
-        // };
-        // Thread t = new Thread(runnable);
-        // t.start();
-        // }
-    }
-
-    @Test
-    public void test() throws Exception {
-
-        final ZooKeeper zk = TestUtils.createZkClient();
-
-        App.main(new String[] { WordCountModuleZk.class.getName(), WordCountApp.class.getName()
});
-
-        CountDownLatch signalTextProcessed = new CountDownLatch(1);
-        TestUtils.watchAndSignalCreation("/textProcessed", signalTextProcessed, zk);
-
-        // add authorizations for processing
-        for (int i = 1; i <= SENTENCE_1_TOTAL_WORDS + SENTENCE_2_TOTAL_WORDS + 1; i++)
{
-            zk.create("/continue_" + i, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-        }
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_1);
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_2);
-        TestUtils.injectIntoStringSocketAdapter(SENTENCE_3);
-        signalTextProcessed.await();
-        File results = new File(TestUtils.DEFAULT_TEST_OUTPUT_DIR + File.separator + "wordcount");
-        String s = TestUtils.readFile(results);
-        Assert.assertEquals("be=2;da=2;doobie=5;not=1;or=1;to=2;", s);
-
-    }
-}


Mime
View raw message