http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/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 3a0212a..21aef23 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 @@ -17,11 +17,11 @@ package org.apache.oodt.config.distributed; -import org.apache.commons.io.FileUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryNTimes; import org.apache.curator.test.TestingServer; +import org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -29,16 +29,12 @@ import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import java.io.File; import java.io.IOException; -import java.net.URI; import java.util.Map; -import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING; - public class DistributedConfigurationPublisherTest { - private static final String DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG = "distributed-config-publisher.xml"; + private static final String DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG = "etc/config-publisher.xml"; private static TestingServer zookeeper; private static CuratorFramework client; @@ -53,52 +49,22 @@ public class DistributedConfigurationPublisherTest { .retryPolicy(new RetryNTimes(3, 1000)) .build(); client.start(); - - System.setProperty(ZK_CONNECT_STRING, zookeeper.getConnectString()); } @Test - public void publishConfiguration() throws Exception { - DistributedConfigurationPublisher.main(new String[]{DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG}); + public void publishConfigurationTest() throws Exception { + DistributedConfigurationPublisher.main(new String[]{ + "-connectString", zookeeper.getConnectString(), + "-publish" + }); ApplicationContext applicationContext = new ClassPathXmlApplicationContext(DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG); - Map distributedConfigurationPublisher = applicationContext.getBeansOfType(DistributedConfigurationPublisher.class); + Map distributedConfigurationPublishers = applicationContext.getBeansOfType(DistributedConfigurationPublisher.class); - for (Object bean : distributedConfigurationPublisher.values()) { + for (Object bean : distributedConfigurationPublishers.values()) { DistributedConfigurationPublisher publisher = (DistributedConfigurationPublisher) bean; - ZNodePaths zNodePaths = publisher.getZNodePaths(); - - // Checking for configuration files - for (Map.Entry<String, String> entry : publisher.getPropertiesFiles().entrySet()) { - String zNodePath = zNodePaths.getPropertiesZNodePath(entry.getValue()); - - Assert.assertNotNull(client.checkExists().forPath(zNodePath)); - - String storedContent = new String(client.getData().forPath(zNodePath)); - - URI file = Thread.currentThread().getContextClassLoader().getResource(entry.getKey()).toURI(); - String fileContent = FileUtils.readFileToString(new File(file)); - - Assert.assertEquals(fileContent, storedContent); - } - - // Checking for configuration files - for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) { - String zNodePath = zNodePaths.getConfigurationZNodePath(entry.getValue()); - - Assert.assertNotNull(client.checkExists().forPath(zNodePath)); - - String storedContent = new String(client.getData().forPath(zNodePath)); - - URI file = Thread.currentThread().getContextClassLoader().getResource(entry.getKey()).toURI(); - String fileContent = FileUtils.readFileToString(new File(file)); - - Assert.assertEquals(fileContent, storedContent); - } + Assert.assertTrue(publisher.verifyPublishedConfiguration()); } - -// DistributedConfigurationManager configurationManager = new DistributedConfigurationManager(Constants.Components.FILE_MANAGER); -// configurationManager.loadConfiguration(); } @AfterClass
http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/config/src/test/java/org/apache/oodt/config/distributed/TestServer.java ---------------------------------------------------------------------- diff --git a/config/src/test/java/org/apache/oodt/config/distributed/TestServer.java b/config/src/test/java/org/apache/oodt/config/distributed/TestServer.java new file mode 100644 index 0000000..fa09f3d --- /dev/null +++ b/config/src/test/java/org/apache/oodt/config/distributed/TestServer.java @@ -0,0 +1,45 @@ +/* + * 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.test.TestingServer; + +import java.io.IOException; + +public class TestServer { + + public static void main(String[] args) throws Exception { + final TestingServer zookeeper = new TestingServer(2181); + zookeeper.start(); + System.out.printf(zookeeper.getConnectString()); + + zookeeper.start(); + + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + try { + zookeeper.stop(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + + Thread.currentThread().join(); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/config/src/test/resources/distributed-config-publisher.xml ---------------------------------------------------------------------- diff --git a/config/src/test/resources/distributed-config-publisher.xml b/config/src/test/resources/distributed-config-publisher.xml deleted file mode 100644 index d938b6d..0000000 --- a/config/src/test/resources/distributed-config-publisher.xml +++ /dev/null @@ -1,56 +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. - --> - -<beans xmlns="http://www.springframework.org/schema/beans" - 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"> - - <bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher"> - - <constructor-arg value="filemgr"/> - - <property name="propertiesFiles"> - <map> - <entry key="filemgr.properties" value="/etc/filemgr.properties"/> - </map> - </property> - - <property name="configFiles"> - <map> - <entry key="mime-types.xml" value="/etc/mime-types.xml"/> - </map> - </property> - </bean> - - <bean id="resmgr-config-publisher" class="org.apache.oodt.config.distributed.DistributedConfigurationPublisher"> - - <constructor-arg value="resmgr"/> - - <property name="propertiesFiles"> - <map> - <entry key="filemgr.properties" value="/etc/resmgr.properties"/> - </map> - </property> - - <property name="configFiles"> - <map> - <entry key="mime-types.xml" value="/etc/mime-types.xml"/> - </map> - </property> - </bean> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/config/src/test/resources/etc/config-publisher.xml ---------------------------------------------------------------------- diff --git a/config/src/test/resources/etc/config-publisher.xml b/config/src/test/resources/etc/config-publisher.xml new file mode 100644 index 0000000..109f48f --- /dev/null +++ b/config/src/test/resources/etc/config-publisher.xml @@ -0,0 +1,50 @@ +<!-- + ~ 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. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + 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"> + + <bean id="filemgr-config-publisher" class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher"> + <constructor-arg value="filemgr"/> + <property name="propertiesFiles"> + <map key-type="java.lang.String" value-type="java.lang.String"> + <entry key="src/main/resources/examples/filemgr.properties" value="/etc/filemgr.properties"/> + </map> + </property> + <property name="configFiles"> + <map key-type="java.lang.String" value-type="java.lang.String"> + <entry key="src/main/resources/examples/mime-types.xml" value="/etc/mime-types.xml"/> + </map> + </property> + </bean> + + <bean id="resmgr-config-publisher" class="org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher"> + <constructor-arg value="resmgr"/> + <property name="propertiesFiles"> + <map key-type="java.lang.String" value-type="java.lang.String"> + <entry key="src/main/resources/examples/filemgr.properties" value="/etc/resmgr.properties"/> + </map> + </property> + <property name="configFiles"> + <map key-type="java.lang.String" value-type="java.lang.String"> + <entry key="src/main/resources/examples/mime-types.xml" value="/etc/mime-types.xml"/> + </map> + </property> + </bean> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/config/src/test/resources/filemgr.properties ---------------------------------------------------------------------- diff --git a/config/src/test/resources/filemgr.properties b/config/src/test/resources/filemgr.properties deleted file mode 100644 index 4d8d957..0000000 --- a/config/src/test/resources/filemgr.properties +++ /dev/null @@ -1,114 +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. -# - -# Configuration properties for the File Manager - -# repository factory -filemgr.repository.factory=org.apache.oodt.cas.filemgr.repository.XMLRepositoryManagerFactory - -# Lucene catalog factory -filemgr.catalog.factory=org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory - -# data transfer factory -filemgr.datatransfer.factory=org.apache.oodt.cas.filemgr.datatransfer.LocalDataTransferFactory - -# validation layer factory -filemgr.validationLayer.factory=org.apache.oodt.cas.filemgr.validation.XMLValidationLayerFactory - -# xml rpc client configuration -org.apache.oodt.cas.filemgr.system.xmlrpc.connectionTimeout.minutes=20 -org.apache.oodt.cas.filemgr.system.xmlrpc.requestTimeout.minutes=60 -#org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retries=0 -#org.apache.oodt.cas.filemgr.system.xmlrpc.connection.retry.interval.seconds=3 - -# mapped data source catalog configuration -#org.apache.oodt.cas.filemgr.catalog.mappeddatasource.mapFile=/path/to/ops.catalog.typemap.properties - -# lucene catalog configuration -org.apache.oodt.cas.filemgr.catalog.lucene.idxPath=[OODT_HOME]/data/catalog -org.apache.oodt.cas.filemgr.catalog.lucene.pageSize=20 -org.apache.oodt.cas.filemgr.catalog.lucene.commitLockTimeout.seconds=60 -org.apache.oodt.cas.filemgr.catalog.lucene.writeLockTimeout.seconds=60 -org.apache.oodt.cas.filemgr.catalog.lucene.mergeFactor=20 - -# XML repository manager configuration -org.apache.oodt.cas.filemgr.repositorymgr.dirs=file:[FILEMGR_HOME]/policy/oodt - -# XML validation layer configuration -org.apache.oodt.cas.filemgr.validation.dirs=file:[FILEMGR_HOME]/policy/oodt - -# remote data transfer configuration -org.apache.oodt.cas.filemgr.datatransfer.remote.chunkSize=1024 - -# location of Mime-Type repository -org.apache.oodt.cas.filemgr.mime.type.repository=[FILEMGR_HOME]/etc/mime-types.xml - - -############ data source configuration ################################## -# -# These 3 blocks of config properties can be used to setup a catalog, -# repository manager, and validation layer based on a RDBMS such as -# Oracle, MySQL, PostgreSQL, or any others that support a jdbc connection. -# Just un-comment the following blocks of properties and configure as -# needed. -# -######################################################################### - -# datasource catalog config -#org.apache.oodt.cas.filemgr.catalog.datasource.jdbc.url=some_jdbc_url -#org.apache.oodt.cas.filemgr.catalog.datasource.jdbc.user=user -#org.apache.oodt.cas.filemgr.catalog.datasource.jdbc.pass=pass -#org.apache.oodt.cas.filemgr.catalog.datasource.jdbc.driver=driver.class.name -#org.apache.oodt.cas.filemgr.catalog.datasource.quoteFields=false -#org.apache.oodt.cas.filemgr.catalog.datasource.pageSize=20 -#org.apache.oodt.cas.filemgr.catalog.datasource.cacheUpdateMinutes=5 - -# data source repository manager configuration -#org.apache.oodt.cas.filemgr.repositorymgr.datasource.jdbc.url=some_jdbc_url -#org.apache.oodt.cas.filemgr.repositorymgr.datasource.jdbc.user=user -#org.apache.oodt.cas.filemgr.repositorymgr.datasource.jdbc.pass=pass -#org.apache.oodt.cas.filemgr.repositorymgr.datasource.jdbc.driver=driver.class.name - -# data source validation layer configuration -#org.apache.oodt.cas.filemgr.validation.datasource.jdbc.url=some_jdbc_url -#org.apache.oodt.cas.filemgr.validation.datasource.jdbc.user=user -#org.apache.oodt.cas.filemgr.validation.datasource.jdbc.pass=pass -#org.apache.oodt.cas.filemgr.validation.datasource.jdbc.driver=driver.class.name -#org.apache.oodt.cas.filemgr.validation.datasource.quoteFields=false - - -# tells the file manager system layer to include product instance metadata -# NOTE: here are the expected field mappings -# -# product.getProductId() -> ProductId -# product.getProductName() -> ProductName -# product.getProductStructure() -> ProductStructure -# product.getTransferStatus() -> ProductTransferStatus -# product.getRootRef() -> ProductRootReference - -# for the references returned by product.getProductReferences() the following -# metadata fields will be added (order will be maintained, such that data store -# ref at index 0 will map to orig ref at index 0, etc.) -# -# ProductDataStoreReferences (list of all data store references: -# note already translated into path, not URI) -# ProductOrigReferences (list of all orig references: -# note already translated into path, not URI) -# ProductMimeType (list of all references' mime-types) -# ProductFileSize (list of all references' file sizes) - -org.apache.oodt.cas.filemgr.metadata.expandProduct=false \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/27a28daa/config/src/test/resources/log4j.xml ---------------------------------------------------------------------- diff --git a/config/src/test/resources/log4j.xml b/config/src/test/resources/log4j.xml deleted file mode 100644 index 8f49451..0000000 --- a/config/src/test/resources/log4j.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - ~ 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. - --> - -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - <appender name="console" class="org.apache.log4j.ConsoleAppender"> - <param name="Target" value="System.out"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/> - </layout> - </appender> - - <root> - <priority value="INFO"/> - <appender-ref ref="console"/> - </root> - -</log4j:configuration> \ No newline at end of file