Return-Path: X-Original-To: apmail-helix-commits-archive@minotaur.apache.org Delivered-To: apmail-helix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 598AAD54A for ; Fri, 9 Nov 2012 01:03:10 +0000 (UTC) Received: (qmail 16615 invoked by uid 500); 9 Nov 2012 01:03:10 -0000 Delivered-To: apmail-helix-commits-archive@helix.apache.org Received: (qmail 16593 invoked by uid 500); 9 Nov 2012 01:03:10 -0000 Mailing-List: contact commits-help@helix.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@helix.incubator.apache.org Delivered-To: mailing list commits@helix.incubator.apache.org Received: (qmail 16581 invoked by uid 99); 9 Nov 2012 01:03:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 01:03:10 +0000 X-ASF-Spam-Status: No, hits=-2000.4 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 09 Nov 2012 01:03:04 +0000 Received: (qmail 16005 invoked by uid 99); 9 Nov 2012 01:02:42 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 01:02:42 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9386D45F8E; Fri, 9 Nov 2012 01:02:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kishoreg@apache.org To: commits@helix.incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [6/6] [HELIX-4] Removing file based implementation Message-Id: <20121109010242.9386D45F8E@tyr.zones.apache.org> Date: Fri, 9 Nov 2012 01:02:42 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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. 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 serializer = - new PropertyJsonSerializer(ZNRecord.class); - try - { - PropertyStoreFactory. getZKPropertyStore("localhost:1812", serializer, rootNamespace); - Assert.fail("Should fail since zkAddr is not connectable"); - } - catch (Exception e) - { - // OK - } - - PropertyStore store = - PropertyStoreFactory. getZKPropertyStore(ZK_ADDR, - serializer, - rootNamespace); - Assert.assertNotNull(store); - } - - @Test() - public void testFilePropertyStoreFactory() - { - final String rootNamespace = "/tmp/TestPropertyStoreFactory"; - PropertyJsonSerializer serializer = - new PropertyJsonSerializer(ZNRecord.class); - PropertyJsonComparator comparator = - new PropertyJsonComparator(ZNRecord.class); - PropertyStore store; - - boolean exceptionCaught = false; - try - { - store = PropertyStoreFactory. getFilePropertyStore(null, null, null); - } - catch (IllegalArgumentException e) - { - exceptionCaught = true; - } - AssertJUnit.assertTrue(exceptionCaught); - - store = - PropertyStoreFactory. 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 - { - public boolean _propertyChangeReceived = false; - - @Override - public void onPropertyChange(String key) - { - logger.info("property changed at " + key); - _propertyChangeReceived = true; - } - - } - - public class TestUpdater implements DataUpdater - { - - @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 serializer = new PropertyJsonSerializer(String.class); - PropertyJsonComparator comparator = new PropertyJsonComparator(String.class); - - FilePropertyStore store = new FilePropertyStore(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 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())); - } -}