You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2017/08/30 16:39:45 UTC

[16/52] [abbrv] oodt git commit: Minor improvements for configuration manager tests

Minor improvements for configuration manager tests


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

Branch: refs/heads/master
Commit: e697405223fe17c96739ae8f156639a0f5ef321c
Parents: a973c53
Author: Imesha Sudasingha <im...@gmail.com>
Authored: Sun Jul 9 22:18:40 2017 +0530
Committer: Imesha Sudasingha <im...@gmail.com>
Committed: Sun Jul 9 22:18:40 2017 +0530

----------------------------------------------------------------------
 .../src/main/resources/etc/config-publisher.xml |  1 +
 .../AbstractDistributedConfigurationTest.java   | 49 ++++++++++++++++++++
 .../config/distributed/AbstractTestCase.java    | 49 --------------------
 .../DistributedConfigurationManagerTest.java    | 10 ++--
 .../DistributedConfigurationPublisherTest.java  |  2 +-
 .../cas/filemgr/system/XmlRpcFileManager.java   | 32 +++----------
 6 files changed, 62 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/config/src/main/resources/etc/config-publisher.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/etc/config-publisher.xml b/config/src/main/resources/etc/config-publisher.xml
index 015d1f2..dab33c3 100644
--- a/config/src/main/resources/etc/config-publisher.xml
+++ b/config/src/main/resources/etc/config-publisher.xml
@@ -19,6 +19,7 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 
+    <!-- Configuration publisher for File Manager OODT Component -->
     <bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher">
         <constructor-arg value="filemgr"/>
         <property name="propertiesFiles">

http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/config/src/test/java/org/apache/oodt/config/distributed/AbstractDistributedConfigurationTest.java
----------------------------------------------------------------------
diff --git a/config/src/test/java/org/apache/oodt/config/distributed/AbstractDistributedConfigurationTest.java b/config/src/test/java/org/apache/oodt/config/distributed/AbstractDistributedConfigurationTest.java
new file mode 100644
index 0000000..e14d43a
--- /dev/null
+++ b/config/src/test/java/org/apache/oodt/config/distributed/AbstractDistributedConfigurationTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.oodt.config.distributed;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.test.TestingServer;
+import org.apache.oodt.config.distributed.utils.CuratorUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING;
+
+public abstract class AbstractDistributedConfigurationTest {
+
+    protected static TestingServer zookeeper;
+    protected static CuratorFramework client;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        zookeeper = new TestingServer();
+        zookeeper.start();
+
+        System.setProperty(ZK_CONNECT_STRING, zookeeper.getConnectString());
+
+        client = CuratorUtils.newCuratorFrameworkClient(zookeeper.getConnectString());
+        client.start();
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        client.close();
+        zookeeper.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java
----------------------------------------------------------------------
diff --git a/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java b/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java
deleted file mode 100644
index 5bd0651..0000000
--- a/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java
+++ /dev/null
@@ -1,49 +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 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.oodt.config.distributed;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.test.TestingServer;
-import org.apache.oodt.config.distributed.utils.CuratorUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING;
-
-public abstract class AbstractTestCase {
-
-    protected static TestingServer zookeeper;
-    protected static CuratorFramework client;
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        zookeeper = new TestingServer();
-        zookeeper.start();
-
-        System.setProperty(ZK_CONNECT_STRING, zookeeper.getConnectString());
-
-        client = CuratorUtils.newCuratorFrameworkClient(zookeeper.getConnectString());
-        client.start();
-    }
-
-    @AfterClass
-    public static void tearDown() throws Exception {
-        client.close();
-        zookeeper.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
----------------------------------------------------------------------
diff --git a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
index 5a75ff6..2aa855c 100644
--- a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
+++ b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java
@@ -44,13 +44,13 @@ import static org.apache.oodt.config.Constants.SEPARATOR;
  *
  * @author Imesha Sudasingha
  */
-public class DistributedConfigurationManagerTest extends AbstractTestCase {
+public class DistributedConfigurationManagerTest extends AbstractDistributedConfigurationTest {
 
-    private static List<DistributedConfigurationPublisher> publishers;
+    protected static List<DistributedConfigurationPublisher> publishers;
 
     @BeforeClass
     public static void setUp() throws Exception {
-        AbstractTestCase.setUp();
+        AbstractDistributedConfigurationTest.setUp();
 
         DistributedConfigurationPublisher.main(new String[]{
                 "-connectString", zookeeper.getConnectString(),
@@ -64,8 +64,6 @@ public class DistributedConfigurationManagerTest extends AbstractTestCase {
         for (Object bean : distributedConfigurationPublishers.values()) {
             DistributedConfigurationPublisher publisher = (DistributedConfigurationPublisher) bean;
             publishers.add(publisher);
-            ConfigurationManager configurationManager = new DistributedConfigurationManager(publisher.getComponentName());
-            configurationManager.loadConfiguration();
         }
     }
 
@@ -117,6 +115,6 @@ public class DistributedConfigurationManagerTest extends AbstractTestCase {
                 "-clear"
         });
 
-        AbstractTestCase.tearDown();
+        AbstractDistributedConfigurationTest.tearDown();
     }
 }

http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java
----------------------------------------------------------------------
diff --git a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java
index fbccbc7..4f1552b 100644
--- a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java
+++ b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java
@@ -36,7 +36,7 @@ import static org.apache.oodt.config.Constants.CONFIG_PUBLISHER_XML;
  *
  * @author Imesha Sudasingha
  */
-public class DistributedConfigurationPublisherTest extends AbstractTestCase{
+public class DistributedConfigurationPublisherTest extends AbstractDistributedConfigurationTest {
 
     @Test
     public void publishConfigurationTest() throws Exception {

http://git-wip-us.apache.org/repos/asf/oodt/blob/e6974052/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
----------------------------------------------------------------------
diff --git a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
index 261e93c..0b9501e 100644
--- a/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
+++ b/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManager.java
@@ -18,26 +18,15 @@
 package org.apache.oodt.cas.filemgr.system;
 
 
+import com.google.common.collect.Lists;
 import org.apache.oodt.cas.filemgr.catalog.Catalog;
 import org.apache.oodt.cas.filemgr.datatransfer.DataTransfer;
 import org.apache.oodt.cas.filemgr.datatransfer.TransferStatusTracker;
 import org.apache.oodt.cas.filemgr.metadata.ProductMetKeys;
 import org.apache.oodt.cas.filemgr.metadata.extractors.FilemgrMetExtractor;
 import org.apache.oodt.cas.filemgr.repository.RepositoryManager;
-import org.apache.oodt.cas.filemgr.structs.Element;
-import org.apache.oodt.cas.filemgr.structs.ExtractorSpec;
-import org.apache.oodt.cas.filemgr.structs.FileTransferStatus;
-import org.apache.oodt.cas.filemgr.structs.Product;
-import org.apache.oodt.cas.filemgr.structs.ProductPage;
-import org.apache.oodt.cas.filemgr.structs.ProductType;
-import org.apache.oodt.cas.filemgr.structs.Query;
-import org.apache.oodt.cas.filemgr.structs.Reference;
-import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException;
-import org.apache.oodt.cas.filemgr.structs.exceptions.DataTransferException;
-import org.apache.oodt.cas.filemgr.structs.exceptions.QueryFormulationException;
-import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException;
-import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException;
-import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.filemgr.structs.*;
+import org.apache.oodt.cas.filemgr.structs.exceptions.*;
 import org.apache.oodt.cas.filemgr.structs.query.ComplexQuery;
 import org.apache.oodt.cas.filemgr.structs.query.QueryFilter;
 import org.apache.oodt.cas.filemgr.structs.query.QueryResult;
@@ -56,13 +45,7 @@ import org.apache.oodt.config.ConfigurationManager;
 import org.apache.oodt.config.ConfigurationManagerFactory;
 import org.apache.xmlrpc.WebServer;
 
-import com.google.common.collect.Lists;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -71,6 +54,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import static org.apache.oodt.config.Constants.Components.FILE_MANAGER;
+
 
 /**
  * @author mattmann
@@ -81,9 +66,6 @@ import java.util.logging.Logger;
  */
 public class XmlRpcFileManager {
 
-  /** Name of this OODT component. TO be used by the configuration management */
-  private static final String componentName = "file-mgr";
-
   /* the port to run the XML RPC web server on, default is 1999 */
   private int webServerPort = 1999;
 
@@ -134,7 +116,7 @@ public class XmlRpcFileManager {
       propertiesFiles.add(System.getProperty("org.apache.oodt.cas.filemgr.properties"));
     }
 
-    configurationManager = ConfigurationManagerFactory.getConfigurationManager(componentName, propertiesFiles);
+    configurationManager = ConfigurationManagerFactory.getConfigurationManager(FILE_MANAGER, propertiesFiles);
 
     this.loadConfiguration();
     LOG.log(Level.INFO, "File Manager started by " + System.getProperty("user.name", "unknown"));