You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by rl...@apache.org on 2014/08/06 00:16:58 UTC
svn commit: r1616025 - in /oodt/trunk: ./
filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/
Author: rlaidlaw
Date: Tue Aug 5 22:16:57 2014
New Revision: 1616025
URL: http://svn.apache.org/r1616025
Log:
OODT-733: fixed test classes in file manager ingest 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/ingest/TestCachedIngester.java
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestLocalCache.java
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestRmiCache.java
oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestStdIngester.java
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1616025&r1=1616024&r2=1616025&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Tue Aug 5 22:16:57 2014
@@ -4,6 +4,9 @@ Apache OODT Change Log
Release 0.7 - Current Development
--------------------------------------------
+* OODT-733 Fix File Manager unit tests (step 6) - fix test classes in 'ingest'
+ package (rlaidlaw)
+
* OODT-732 Fix File Manager unit tests (step 6) - fix test classes in
'datatransfer' package (rlaidlaw)
Modified: oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestCachedIngester.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestCachedIngester.java?rev=1616025&r1=1616024&r2=1616025&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestCachedIngester.java (original)
+++ oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestCachedIngester.java Tue Aug 5 22:16:57 2014
@@ -25,6 +25,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.Vector;
//OODT imports
@@ -70,6 +71,9 @@ public class TestCachedIngester extends
private static List cachedProductTypes = new Vector();
+ private Properties initialProperties = new Properties(
+ System.getProperties());
+
static {
Date startDate = new Date();
Date endDate = new Date();
@@ -104,14 +108,18 @@ public class TestCachedIngester extends
Metadata prodMet = null;
try {
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
prodMet = new SerializableMetadata(new FileInputStream(
- "./src/testdata/ingest/test.txt.met"));
+ new File(metUrl.getFile())));
// now add the right file location
prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
- "./src/testdata/ingest").getCanonicalPath());
+ ingestUrl.getFile()).getCanonicalPath());
ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
- "./src/testdata/ingest/test.txt"), prodMet);
+ refUrl.getFile()), prodMet);
} catch (Exception e) {
fail(e.getMessage());
}
@@ -136,6 +144,7 @@ public class TestCachedIngester extends
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
+
startXmlRpcFileManager();
ingestTestFile();
Cache cache = null;
@@ -168,6 +177,9 @@ public class TestCachedIngester extends
// blow away test file
deleteAllFiles("/tmp/test.txt");
+
+ // Reset the System properties to initial values.
+ System.setProperties(initialProperties);
}
private void ingestTestFile() {
@@ -175,14 +187,18 @@ public class TestCachedIngester extends
StdIngester ingester = new StdIngester(transferServiceFacClass);
try {
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
prodMet = new SerializableMetadata(new FileInputStream(
- "./src/testdata/ingest/test.txt.met"));
+ new File(metUrl.getFile())));
// now add the right file location
prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
- "./src/testdata/ingest").getCanonicalPath());
+ ingestUrl.getFile()).getCanonicalPath());
ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
- "./src/testdata/ingest/test.txt"), prodMet);
+ refUrl.getFile()), prodMet);
} catch (Exception e) {
fail(e.getMessage());
}
@@ -203,56 +219,67 @@ public class TestCachedIngester extends
}
private void startXmlRpcFileManager() {
+
+ Properties properties = new Properties(System.getProperties());
+
// first make sure to load properties for the file manager
// and make sure to load logging properties as well
// set the log levels
- System.setProperty("java.util.logging.config.file", new File(
- "./src/main/resources/logging.properties").getAbsolutePath());
+ URL loggingPropertiesUrl = this.getClass().getResource(
+ "/test.logging.properties");
+ properties.setProperty("java.util.logging.config.file", new File(
+ loggingPropertiesUrl.getFile()).getAbsolutePath());
// first load the example configuration
try {
- System.getProperties().load(
- new FileInputStream("./src/main/resources/filemgr.properties"));
+ URL filemgrPropertiesUrl = this.getClass().getResource(
+ "/filemgr.properties");
+ properties.load(
+ new FileInputStream(new File(filemgrPropertiesUrl.getFile())));
} catch (Exception e) {
fail(e.getMessage());
}
// override the catalog to use: we'll use lucene
try {
- luceneCatLoc = new File("./src/testdata/ingest/cat")
- .getCanonicalPath();
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ luceneCatLoc = new File(ingestUrl.getFile()).getCanonicalPath()
+ + "/cat";
} catch (Exception e) {
fail(e.getMessage());
}
- System.setProperty("filemgr.catalog.factory",
+ properties.setProperty("filemgr.catalog.factory",
"org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory");
- System.setProperty(
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.catalog.lucene.idxPath",
luceneCatLoc);
// now override the repo mgr policy
try {
- System.setProperty(
+ URL fmpolicyUrl = this.getClass().getResource("/ingest/fmpolicy");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.repositorymgr.dirs",
"file://"
- + new File("./src/testdata/ingest/fmpolicy")
- .getCanonicalPath());
+ + new File(fmpolicyUrl.getFile()).getCanonicalPath());
} catch (Exception e) {
fail(e.getMessage());
}
// now override the val layer ones
- System.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
+ URL examplesCoreUrl = this.getClass().getResource("/examples/core");
+ properties.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
"file://"
- + new File("./src/main/resources/examples/core")
- .getAbsolutePath());
+ + new File(examplesCoreUrl.getFile()).getAbsolutePath());
// set up mime repo path
- System.setProperty(
+ URL mimeTypesUrl = this.getClass().getResource("/mime-types.xml");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.mime.type.repository", new File(
- "./src/main/resources/mime-types.xml").getAbsolutePath());
+ mimeTypesUrl.getFile()).getAbsolutePath());
+
+ System.setProperties(properties);
try {
fm = new XmlRpcFileManager(FM_PORT);
Modified: oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestLocalCache.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestLocalCache.java?rev=1616025&r1=1616024&r2=1616025&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestLocalCache.java (original)
+++ oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestLocalCache.java Tue Aug 5 22:16:57 2014
@@ -24,6 +24,7 @@ import java.io.FileInputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.Vector;
//OODT imports
@@ -79,6 +80,9 @@ public class TestLocalCache extends Test
private static List<String> cachedProductTypes = new Vector<String>();
+ private Properties initialProperties = new Properties(
+ System.getProperties());
+
static {
Date startDate = new Date();
Date endDate = new Date();
@@ -171,20 +175,27 @@ public class TestLocalCache extends Test
// blow away test file
deleteAllFiles("/tmp/test.txt");
+
+ // Reset the System properties to initial values.
+ System.setProperties(initialProperties);
}
private void doIngest() {
Metadata prodMet = null;
try {
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
prodMet = new SerializableMetadata(new FileInputStream(
- "./src/testdata/ingest/test.txt.met"));
+ new File(metUrl.getFile())));
// now add the right file location
prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
- "./src/testdata/ingest").getCanonicalPath());
+ ingestUrl.getFile()).getCanonicalPath());
ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
- "./src/testdata/ingest/test.txt"), prodMet);
+ refUrl.getFile()), prodMet);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
@@ -219,56 +230,67 @@ public class TestLocalCache extends Test
}
private void startXmlRpcFileManager() {
+
+ Properties properties = new Properties(System.getProperties());
+
// first make sure to load properties for the file manager
// and make sure to load logging properties as well
// set the log levels
- System.setProperty("java.util.logging.config.file", new File(
- "./src/main/resources/logging.properties").getAbsolutePath());
+ URL loggingPropertiesUrl = this.getClass().getResource(
+ "/test.logging.properties");
+ properties.setProperty("java.util.logging.config.file", new File(
+ loggingPropertiesUrl.getFile()).getAbsolutePath());
// first load the example configuration
try {
- System.getProperties().load(
- new FileInputStream("./src/main/resources/filemgr.properties"));
+ URL filemgrPropertiesUrl = this.getClass().getResource(
+ "/filemgr.properties");
+ properties.load(
+ new FileInputStream(new File(filemgrPropertiesUrl.getFile())));
} catch (Exception e) {
fail(e.getMessage());
}
// override the catalog to use: we'll use lucene
try {
- luceneCatLoc = new File("./src/testdata/ingest/cat")
- .getCanonicalPath();
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ luceneCatLoc = new File(ingestUrl.getFile()).getCanonicalPath()
+ + "/cat";
} catch (Exception e) {
fail(e.getMessage());
}
- System.setProperty("filemgr.catalog.factory",
+ properties.setProperty("filemgr.catalog.factory",
"org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory");
- System.setProperty(
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.catalog.lucene.idxPath",
luceneCatLoc);
// now override the repo mgr policy
try {
- System.setProperty(
+ URL fmpolicyUrl = this.getClass().getResource("/ingest/fmpolicy");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.repositorymgr.dirs",
"file://"
- + new File("./src/testdata/ingest/fmpolicy")
- .getCanonicalPath());
+ + new File(fmpolicyUrl.getFile()).getCanonicalPath());
} catch (Exception e) {
fail(e.getMessage());
}
// now override the val layer ones
- System.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
+ URL examplesCoreUrl = this.getClass().getResource("/examples/core");
+ properties.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
"file://"
- + new File("./src/main/resources/examples/core")
- .getAbsolutePath());
+ + new File(examplesCoreUrl.getFile()).getAbsolutePath());
// set up mime repo path
- System.setProperty(
+ URL mimeTypesUrl = this.getClass().getResource("/mime-types.xml");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.mime.type.repository", new File(
- "./src/main/resources/mime-types.xml").getAbsolutePath());
+ mimeTypesUrl.getFile()).getAbsolutePath());
+
+ System.setProperties(properties);
try {
fm = new XmlRpcFileManager(FM_PORT);
Modified: oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestRmiCache.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestRmiCache.java?rev=1616025&r1=1616024&r2=1616025&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestRmiCache.java (original)
+++ oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestRmiCache.java Tue Aug 5 22:16:57 2014
@@ -35,6 +35,7 @@ import java.io.FileInputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.Vector;
//Junit imports
@@ -86,6 +87,9 @@ public class TestRmiCache extends TestCa
private static List<String> cachedProductTypes = new Vector<String>();
+ private Properties initialProperties = new Properties(
+ System.getProperties());
+
static {
Date startDate = new Date();
Date endDate = new Date();
@@ -187,20 +191,27 @@ public class TestRmiCache extends TestCa
cacheServer = null;
cache = null;
+
+ // Reset the System properties to initial values.
+ System.setProperties(initialProperties);
}
private void doIngest() {
Metadata prodMet = null;
try {
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
prodMet = new SerializableMetadata(new FileInputStream(
- "./src/testdata/ingest/test.txt.met"));
+ new File(metUrl.getFile())));
// now add the right file location
prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
- "./src/testdata/ingest").getCanonicalPath());
+ ingestUrl.getFile()).getCanonicalPath());
ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
- "./src/testdata/ingest/test.txt"), prodMet);
+ refUrl.getFile()), prodMet);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
@@ -235,56 +246,67 @@ public class TestRmiCache extends TestCa
}
private void startXmlRpcFileManager() {
+
+ Properties properties = new Properties(System.getProperties());
+
// first make sure to load properties for the file manager
// and make sure to load logging properties as well
// set the log levels
- System.setProperty("java.util.logging.config.file", new File(
- "./src/main/resources/logging.properties").getAbsolutePath());
+ URL loggingPropertiesUrl = this.getClass().getResource(
+ "/test.logging.properties");
+ properties.setProperty("java.util.logging.config.file", new File(
+ loggingPropertiesUrl.getFile()).getAbsolutePath());
// first load the example configuration
try {
- System.getProperties().load(
- new FileInputStream("./src/main/resources/filemgr.properties"));
+ URL filemgrPropertiesUrl = this.getClass().getResource(
+ "/filemgr.properties");
+ properties.load(
+ new FileInputStream(new File(filemgrPropertiesUrl.getFile())));
} catch (Exception e) {
fail(e.getMessage());
}
// override the catalog to use: we'll use lucene
try {
- luceneCatLoc = new File("./src/testdata/ingest/cat")
- .getCanonicalPath();
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ luceneCatLoc = new File(ingestUrl.getFile()).getCanonicalPath()
+ + "/cat";
} catch (Exception e) {
fail(e.getMessage());
}
- System.setProperty("filemgr.catalog.factory",
+ properties.setProperty("filemgr.catalog.factory",
"org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory");
- System.setProperty(
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.catalog.lucene.idxPath",
luceneCatLoc);
// now override the repo mgr policy
try {
- System.setProperty(
+ URL fmpolicyUrl = this.getClass().getResource("/ingest/fmpolicy");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.repositorymgr.dirs",
"file://"
- + new File("./src/testdata/ingest/fmpolicy")
- .getCanonicalPath());
+ + new File(fmpolicyUrl.getFile()).getCanonicalPath());
} catch (Exception e) {
fail(e.getMessage());
}
// now override the val layer ones
- System.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
+ URL examplesCoreUrl = this.getClass().getResource("/examples/core");
+ properties.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
"file://"
- + new File("./src/main/resources/examples/core")
- .getAbsolutePath());
+ + new File(examplesCoreUrl.getFile()).getAbsolutePath());
// set up mime repo path
- System.setProperty(
+ URL mimeTypesUrl = this.getClass().getResource("/mime-types.xml");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.mime.type.repository", new File(
- "./src/main/resources/mime-types.xml").getAbsolutePath());
+ mimeTypesUrl.getFile()).getAbsolutePath());
+
+ System.setProperties(properties);
try {
fm = new XmlRpcFileManager(FM_PORT);
Modified: oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestStdIngester.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestStdIngester.java?rev=1616025&r1=1616024&r2=1616025&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestStdIngester.java (original)
+++ oodt/trunk/filemgr/src/test/java/org/apache/oodt/cas/filemgr/ingest/TestStdIngester.java Tue Aug 5 22:16:57 2014
@@ -22,7 +22,7 @@ package org.apache.oodt.cas.filemgr.inge
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
-
+import java.util.Properties;
//OODT imports
import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys;
import org.apache.oodt.cas.filemgr.structs.Product;
@@ -55,6 +55,9 @@ public class TestStdIngester extends Tes
private static final String transferServiceFacClass = "org.apache.oodt.cas."
+ "filemgr.datatransfer.LocalDataTransferFactory";
+ private Properties initialProperties = new Properties(
+ System.getProperties());
+
public TestStdIngester() {
ingester = new StdIngester(transferServiceFacClass);
}
@@ -63,14 +66,18 @@ public class TestStdIngester extends Tes
Metadata prodMet = null;
try {
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ URL refUrl = this.getClass().getResource("/ingest/test.txt");
+ URL metUrl = this.getClass().getResource("/ingest/test.txt.met");
+
prodMet = new SerializableMetadata(new FileInputStream(
- "./src/testdata/ingest/test.txt.met"));
+ new File(metUrl.getFile())));
// now add the right file location
prodMet.addMetadata(CoreMetKeys.FILE_LOCATION, new File(
- "./src/testdata/ingest").getCanonicalPath());
+ ingestUrl.getFile()).getCanonicalPath());
ingester.ingest(new URL("http://localhost:" + FM_PORT), new File(
- "./src/testdata/ingest/test.txt"), prodMet);
+ refUrl.getFile()), prodMet);
} catch (Exception e) {
fail(e.getMessage());
}
@@ -111,6 +118,9 @@ public class TestStdIngester extends Tes
// blow away test file
deleteAllFiles("/tmp/test.txt");
+
+ // Reset the System properties to initial values.
+ System.setProperties(initialProperties);
}
private void deleteAllFiles(String startDir) {
@@ -128,56 +138,67 @@ public class TestStdIngester extends Tes
}
private void startXmlRpcFileManager() {
+
+ Properties properties = new Properties(System.getProperties());
+
// first make sure to load properties for the file manager
// and make sure to load logging properties as well
// set the log levels
- System.setProperty("java.util.logging.config.file", new File(
- "./src/main/resources/logging.properties").getAbsolutePath());
+ URL loggingPropertiesUrl = this.getClass().getResource(
+ "/test.logging.properties");
+ properties.setProperty("java.util.logging.config.file", new File(
+ loggingPropertiesUrl.getFile()).getAbsolutePath());
// first load the example configuration
try {
- System.getProperties().load(
- new FileInputStream("./src/main/resources/filemgr.properties"));
+ URL filemgrPropertiesUrl = this.getClass().getResource(
+ "/filemgr.properties");
+ properties.load(
+ new FileInputStream(new File(filemgrPropertiesUrl.getFile())));
} catch (Exception e) {
fail(e.getMessage());
}
// override the catalog to use: we'll use lucene
try {
- luceneCatLoc = new File("./src/testdata/ingest/cat")
- .getCanonicalPath();
+ URL ingestUrl = this.getClass().getResource("/ingest");
+ luceneCatLoc = new File(ingestUrl.getFile()).getCanonicalPath()
+ + "/cat";
} catch (Exception e) {
fail(e.getMessage());
}
- System.setProperty("filemgr.catalog.factory",
+ properties.setProperty("filemgr.catalog.factory",
"org.apache.oodt.cas.filemgr.catalog.LuceneCatalogFactory");
- System.setProperty(
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.catalog.lucene.idxPath",
luceneCatLoc);
// now override the repo mgr policy
try {
- System.setProperty(
+ URL fmpolicyUrl = this.getClass().getResource("/ingest/fmpolicy");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.repositorymgr.dirs",
"file://"
- + new File("./src/testdata/ingest/fmpolicy")
- .getCanonicalPath());
+ + new File(fmpolicyUrl.getFile()).getCanonicalPath());
} catch (Exception e) {
fail(e.getMessage());
}
// now override the val layer ones
- System.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
+ URL examplesCoreUrl = this.getClass().getResource("/examples/core");
+ properties.setProperty("org.apache.oodt.cas.filemgr.validation.dirs",
"file://"
- + new File("./src/main/resources/examples/core")
- .getAbsolutePath());
+ + new File(examplesCoreUrl.getFile()).getAbsolutePath());
// set up mime repo path
- System.setProperty(
+ URL mimeTypesUrl = this.getClass().getResource("/mime-types.xml");
+ properties.setProperty(
"org.apache.oodt.cas.filemgr.mime.type.repository", new File(
- "./src/main/resources/mime-types.xml").getAbsolutePath());
+ mimeTypesUrl.getFile()).getAbsolutePath());
+
+ System.setProperties(properties);
try {
fm = new XmlRpcFileManager(FM_PORT);