helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kisho...@apache.org
Subject [6/6] [HELIX-4] Removing file based implementation
Date Fri, 09 Nov 2012 01:02:42 GMT
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/99d394bf/helix-core/src/test/java/org/apache/helix/store/TestPropertyStoreFactory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/store/TestPropertyStoreFactory.java
b/helix-core/src/test/java/org/apache/helix/store/TestPropertyStoreFactory.java
deleted file mode 100644
index a511575..0000000
--- a/helix-core/src/test/java/org/apache/helix/store/TestPropertyStoreFactory.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.apache.helix.store;
-
-/*
- * 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.
- */
-
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.store.PropertyJsonComparator;
-import org.apache.helix.store.PropertyJsonSerializer;
-import org.apache.helix.store.PropertyStore;
-import org.apache.helix.store.PropertyStoreFactory;
-import org.testng.Assert;
-import org.testng.AssertJUnit;
-import org.testng.annotations.Test;
-
-
-public class TestPropertyStoreFactory extends ZkUnitTestBase
-{
-  @Test()
-  public void testZkPropertyStoreFactory()
-  {
-
-    try
-    {
-      PropertyStoreFactory.<ZNRecord> getZKPropertyStore(null, null, null);
-      Assert.fail("Should fail since zkAddr|serializer|root can't be null");
-    }
-    catch (IllegalArgumentException e)
-    {
-      // OK
-    }
-    
-    final String rootNamespace = "TestPropertyStoreFactory";
-    PropertyJsonSerializer<ZNRecord> serializer =
-        new PropertyJsonSerializer<ZNRecord>(ZNRecord.class);
-    try
-    {
-      PropertyStoreFactory.<ZNRecord> getZKPropertyStore("localhost:1812", serializer,
rootNamespace);
-      Assert.fail("Should fail since zkAddr is not connectable");
-    }
-    catch (Exception e)
-    {
-      // OK
-    }
-
-    PropertyStore<ZNRecord> store =
-        PropertyStoreFactory.<ZNRecord> getZKPropertyStore(ZK_ADDR,
-                                                           serializer,
-                                                           rootNamespace);
-    Assert.assertNotNull(store);
-  }
-
-  @Test()
-  public void testFilePropertyStoreFactory()
-  {
-    final String rootNamespace = "/tmp/TestPropertyStoreFactory";
-    PropertyJsonSerializer<ZNRecord> serializer =
-        new PropertyJsonSerializer<ZNRecord>(ZNRecord.class);
-    PropertyJsonComparator<ZNRecord> comparator =
-        new PropertyJsonComparator<ZNRecord>(ZNRecord.class);
-    PropertyStore<ZNRecord> store;
-
-    boolean exceptionCaught = false;
-    try
-    {
-      store = PropertyStoreFactory.<ZNRecord> getFilePropertyStore(null, null, null);
-    }
-    catch (IllegalArgumentException e)
-    {
-      exceptionCaught = true;
-    }
-    AssertJUnit.assertTrue(exceptionCaught);
-
-    store =
-        PropertyStoreFactory.<ZNRecord> getFilePropertyStore(serializer,
-                                                             rootNamespace,
-                                                             comparator);
-    Assert.assertNotNull(store);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/99d394bf/helix-core/src/test/java/org/apache/helix/store/file/TestFilePropertyStore.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/store/file/TestFilePropertyStore.java
b/helix-core/src/test/java/org/apache/helix/store/file/TestFilePropertyStore.java
deleted file mode 100644
index 74518ed..0000000
--- a/helix-core/src/test/java/org/apache/helix/store/file/TestFilePropertyStore.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.helix.store.file;
-
-/*
- * 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.
- */
-
-import java.util.Date;
-import java.util.List;
-
-import org.I0Itec.zkclient.DataUpdater;
-import org.apache.helix.store.PropertyChangeListener;
-import org.apache.helix.store.PropertyJsonComparator;
-import org.apache.helix.store.PropertyJsonSerializer;
-import org.apache.helix.store.file.FilePropertyStore;
-import org.apache.log4j.Logger;
-import org.testng.AssertJUnit;
-import org.testng.annotations.Test;
-
-
-public class TestFilePropertyStore
-{
-  private static Logger logger = Logger.getLogger(TestFilePropertyStore.class);
-  private static final String rootNamespace = "/tmp/TestFilePropertyStore";
-
-  public class TestPropertyChangeListener implements PropertyChangeListener<String>
-  {
-    public boolean _propertyChangeReceived = false;
-
-    @Override
-    public void onPropertyChange(String key)
-    {
-      logger.info("property changed at " + key);
-      _propertyChangeReceived = true;
-    }
-
-  }
-
-  public class TestUpdater implements DataUpdater<String>
-  {
-
-    @Override
-    public String update(String currentData)
-    {
-      return "new " + currentData;
-    }
-
-  }
-
-  @Test (groups = {"unitTest"})
-  public void testFilePropertyStore() throws Exception
-  {
-    System.out.println("START TestFilePropertyStore at " + new Date(System.currentTimeMillis()));
-
-    final int SLEEP_TIME = 2000;
-    PropertyJsonSerializer<String> serializer = new PropertyJsonSerializer<String>(String.class);
-    PropertyJsonComparator<String> comparator = new PropertyJsonComparator<String>(String.class);
-
-    FilePropertyStore<String> store = new FilePropertyStore<String>(serializer,
rootNamespace,
-        comparator);
-    // store.removeRootNamespace();
-    // store.createRootNamespace();
-    store.start();
-
-    // test set
-    store.createPropertyNamespace("/child1");
-    store.setProperty("/child1/grandchild1", "grandchild1\n");
-    store.setProperty("/child1/grandchild2", "grandchild2\n");
-    store.createPropertyNamespace("/child1/grandchild3");
-    store.setProperty("/child1/grandchild3/grandgrandchild1", "grandgrandchild1\n");
-
-    // test get-names
-    List<String> names = store.getPropertyNames("/child1");
-    AssertJUnit.assertEquals(names.size(), 3);
-    AssertJUnit.assertTrue(names.contains("/child1/grandchild1"));
-    AssertJUnit.assertTrue(names.contains("/child1/grandchild2"));
-    AssertJUnit.assertTrue(names.contains("/child1/grandchild3/grandgrandchild1"));
-
-    // test get
-    String value = store.getProperty("nonExist");
-    AssertJUnit.assertEquals(value, null);
-    value = store.getProperty("/child1/grandchild2");
-    AssertJUnit.assertEquals(value, "grandchild2\n");
-    Thread.sleep(SLEEP_TIME);
-
-    // test subscribe
-    TestPropertyChangeListener listener1 = new TestPropertyChangeListener();
-    TestPropertyChangeListener listener2 = new TestPropertyChangeListener();
-
-    store.subscribeForPropertyChange("/child1", listener1);
-    store.subscribeForPropertyChange("/child1", listener1);
-    store.subscribeForPropertyChange("/child1", listener2);
-
-    store.setProperty("/child1/grandchild2", "grandchild2-new\n");
-    Thread.sleep(SLEEP_TIME);
-    AssertJUnit.assertEquals(listener1._propertyChangeReceived, true);
-    AssertJUnit.assertEquals(listener2._propertyChangeReceived, true);
-
-    listener1._propertyChangeReceived = false;
-    listener2._propertyChangeReceived = false;
-
-    // test unsubscribe
-    store.unsubscribeForPropertyChange("/child1", listener1);
-    store.setProperty("/child1/grandchild3/grandgrandchild1", "grandgrandchild1-new\n");
-    Thread.sleep(SLEEP_TIME);
-
-    AssertJUnit.assertEquals(listener1._propertyChangeReceived, false);
-    AssertJUnit.assertEquals(listener2._propertyChangeReceived, true);
-
-    listener2._propertyChangeReceived = false;
-
-    // test update property
-    store.updatePropertyUntilSucceed("child1/grandchild2", new TestUpdater());
-    value = store.getProperty("child1/grandchild2");
-    AssertJUnit.assertEquals("new grandchild2-new\n", value);
-
-    // test remove
-    store.removeProperty("/child1/grandchild2");
-    value = store.getProperty("/child1/grandchild2");
-    AssertJUnit.assertEquals(value, null);
-    Thread.sleep(SLEEP_TIME);
-    AssertJUnit.assertEquals(listener2._propertyChangeReceived, true);
-    listener2._propertyChangeReceived = false;
-
-    // test compare and set
-    boolean success = store.compareAndSet("/child1/grandchild1", "grandchild1-old\n",
-                                          "grandchild1-new\n", comparator);
-    AssertJUnit.assertEquals(success, false);
-
-    success = store.compareAndSet("/child1/grandchild1", "grandchild1\n",
-                                  "grandchild1-new\n", comparator);
-    AssertJUnit.assertEquals(success, true);
-
-    store.stop();
-
-    // test stop
-    listener2._propertyChangeReceived = false;
-    store.setProperty("/child1/grandchild3/grandgrandchild1", "grandgrandchild1-new-new\n");
-    Thread.sleep(SLEEP_TIME);
-    AssertJUnit.assertEquals(listener2._propertyChangeReceived, false);
-
-    store.unsubscribeForPropertyChange("/child1", listener2);
-    // store.stop();
-    System.out.println("END TestFilePropertyStore at " + new Date(System.currentTimeMillis()));
-  }
-}


Mime
View raw message