Author: rlaidlaw
Date: Wed Aug 6 04:04:09 2014
New Revision: 1616087
URL: http://svn.apache.org/r1616087
Log:
OODT-737: fixed all but one test case in file manager cli package to find test
resources and reset system properties
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/cli/TestFileManagerCli.java
oodt/trunk/filemgr/src/test/resources/cmd-line-options.xml
Modified: oodt/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1616087&r1=1616086&r2=1616087&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed Aug 6 04:04:09 2014
@@ -4,6 +4,9 @@ Apache OODT Change Log
Release 0.7 - Current Development
--------------------------------------------
+* OODT-737 Fix File Manager unit tests (step 10) - fix test classes in 'cli'
+ package (rlaidlaw)
+
* OODT-735 Fix File Manager unit tests (step 9) - fix test classes in 'tools'
package (rlaidlaw)
Modified:
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/cli/TestFileManagerCli.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/cli/TestFileManagerCli.java?rev=1616087&r1=1616086&r2=1616087&view=diff
==============================================================================
---
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/cli/TestFileManagerCli.java
(original)
+++
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/cli/TestFileManagerCli.java
Wed Aug 6 04:04:09 2014
@@ -20,7 +20,8 @@ package org.apache.oodt.cas.filemgr.cli;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
-
+import java.net.URL;
+import java.util.Properties;
//JUnit imports
import junit.framework.TestCase;
@@ -53,20 +54,29 @@ import com.google.common.collect.Lists;
*/
public class TestFileManagerCli extends TestCase {
- static {
- System.setProperty("org.apache.oodt.cas.cli.debug", "true");
- System.setProperty("org.apache.oodt.cas.cli.action.spring.config",
- "src/main/resources/cmd-line-actions.xml");
- System.setProperty("org.apache.oodt.cas.cli.option.spring.config",
- "src/main/resources/cmd-line-options.xml");
- }
-
private CmdLineUtility cmdLineUtility;
private MockXmlRpcFileManagerClient client;
+ private Properties initialProperties = new Properties(
+ System.getProperties());
@Override
public void setUp() throws Exception {
super.setUp();
+
+ Properties properties = new Properties(System.getProperties());
+
+ properties.setProperty("org.apache.oodt.cas.cli.debug", "true");
+
+ URL actionsUrl = this.getClass().getResource("/cmd-line-actions.xml");
+ properties.setProperty("org.apache.oodt.cas.cli.action.spring.config",
+ "file:" + new File(actionsUrl.getFile()).getAbsolutePath());
+
+ URL optionsUrl = this.getClass().getResource("/cmd-line-options.xml");
+ properties.setProperty("org.apache.oodt.cas.cli.option.spring.config",
+ "file:" + new File(optionsUrl.getFile()).getAbsolutePath());
+
+ System.setProperties(properties);
+
cmdLineUtility = new CmdLineUtility();
UseMockClientCmdLineActionStore actionStore = new
UseMockClientCmdLineActionStore();
client = actionStore.getClient();
@@ -76,6 +86,7 @@ public class TestFileManagerCli extends
@Override
public void tearDown() throws Exception {
OptionPropertyRegister.clearRegister();
+ System.setProperties(initialProperties);
}
public void testAddProductType() throws MalformedURLException,
@@ -142,13 +153,15 @@ public class TestFileManagerCli extends
}
public void testGetFilePercentTransferred() {
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ String refPath = new File(refUrl.getFile()).getAbsolutePath();
cmdLineUtility
.run(("--url http://localhost:9000 --operation
--getFilePctTransferred"
- + " --origRef src/testdata/test.txt").split(" "));
+ + " --origRef " + refPath).split(" "));
MethodCallDetails methodCallDetails = client.getLastMethodCallDetails();
assertEquals("getRefPctTransferred", methodCallDetails.getMethodName());
assertTrue(((Reference) methodCallDetails.getArgs().get(0))
- .getOrigReference().endsWith("src/testdata/test.txt"));
+ .getOrigReference().endsWith("test.txt"));
}
public void testGetFirstPage() {
@@ -269,13 +282,16 @@ public class TestFileManagerCli extends
}
public void testIngestProduct() {
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
String productName = "TestProductName";
String structure = Product.STRUCTURE_FLAT;
String productTypeName = "TestProductType";
- String metadataFile = "src/testdata/ingest/test.txt.met";
+ String metadataFile = new File(metUrl.getFile()).getAbsolutePath();
String dataTransferer = InPlaceDataTransferFactory.class
.getCanonicalName();
- String ref = "src/testdata/test.txt";
+ String ref = new File(refUrl.getFile()).getAbsolutePath();
cmdLineUtility
.run(("--url http://localhost:9000 --operation --ingestProduct"
+ " --productName " + productName + " --productStructure "
Modified: oodt/trunk/filemgr/src/test/resources/cmd-line-options.xml
URL:
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/resources/cmd-line-options.xml?rev=1616087&r1=1616086&r2=1616087&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/resources/cmd-line-options.xml (original)
+++ oodt/trunk/filemgr/src/test/resources/cmd-line-options.xml Wed Aug 6
04:04:09 2014
@@ -117,30 +117,6 @@
</property>
</bean>
- <bean id="typeName"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption">
- <property name="shortOption" value="tn" />
- <property name="longOption" value="typeName" />
- <property name="description" value="ProductType name" />
- <property name="hasArgs" value="true" />
- <property name="argsDescription" value="product-type-name" />
- <property name="requirementRules">
- <list>
- <bean
class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule"
- p:actionName="addProductType" p:relation="REQUIRED" />
- </list>
- </property>
- <property name="handler">
- <bean
class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler">
- <property name="applyToActions">
- <list>
- <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction"
- p:actionName="addProductType" p:methodName="setProductTypeName"
/>
- </list>
- </property>
- </bean>
- </property>
- </bean>
-
<bean id="typeDesc"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption">
<property name="shortOption" value="td" />
<property name="longOption" value="typeDesc" />