oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject svn commit: r965279 - in /incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors: TestExternMetExtractor.java TestExternMetExtractorConfigReader.java
Date Sun, 18 Jul 2010 20:13:57 GMT
Author: mattmann
Date: Sun Jul 18 20:13:56 2010
New Revision: 965279

URL: http://svn.apache.org/viewvc?rev=965279&view=rev
Log:
- OODT-15: WIP: phew! all metadata tests pass no matter where now!

Modified:
    incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractor.java
    incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractorConfigReader.java

Modified: incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractor.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractor.java?rev=965279&r1=965278&r2=965279&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractor.java
(original)
+++ incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractor.java
Sun Jul 18 20:13:56 2010
@@ -23,6 +23,7 @@ import org.apache.oodt.cas.metadata.Meta
 import org.apache.oodt.cas.metadata.MetadataTestCase;
 import org.apache.oodt.cas.metadata.exceptions.MetExtractionException;
 import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.commons.exec.ExecHelper;
 import org.apache.oodt.commons.exec.ExecUtils;
 
 //JDK imports
@@ -121,7 +122,7 @@ public class TestExternMetExtractor exte
     // make it executable
     // yes this is ghetto
     String chmodCmd = "chmod +x "+extractorFile.getAbsolutePath();
-    ExecUtils.callProgram(chmodCmd, extractorFile.getParentFile());
+    ExecHelper.execUsingShell(chmodCmd);
     
     // replace the FileLocation met field in the sample met file
     // with the actual file location of the extractFile

Modified: incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractorConfigReader.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractorConfigReader.java?rev=965279&r1=965278&r2=965279&view=diff
==============================================================================
--- incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractorConfigReader.java
(original)
+++ incubator/oodt/trunk/metadata/src/test/org/apache/oodt/cas/metadata/extractors/TestExternMetExtractorConfigReader.java
Sun Jul 18 20:13:56 2010
@@ -19,7 +19,10 @@
 package org.apache.oodt.cas.metadata.extractors;
 
 // Metadata imports
+import org.apache.commons.io.FileUtils;
+import org.apache.oodt.cas.metadata.Metadata;
 import org.apache.oodt.cas.metadata.MetadataTestCase;
+import org.apache.oodt.cas.metadata.util.PathUtils;
 
 //JDK imports
 import java.io.File;
@@ -46,10 +49,10 @@ public class TestExternMetExtractorConfi
     public TestExternMetExtractorConfigReader(String name) {
         super(name);
     }
-
+    
     private static final String configFilePath = "extern-config.xml";
 
-    private static final String expectedBinPathEnding = "testdata/testExtractor";
+    private static final String expectedBinPathEnding = "/testExtractor";
 
     private static final String arg1 = ExternMetExtractorMetKeys.DATA_FILE_PLACE_HOLDER;
 
@@ -62,11 +65,13 @@ public class TestExternMetExtractorConfi
     private static final String arg5 = "bar";
 
     private static final String arg5ending = "/test\\ boo";
+    
+    private File confFile;
 
     public void testReadConfig() {
         ExternalMetExtractorConfig config = null;
         try {
-            config = (ExternalMetExtractorConfig) new ExternConfigReader().parseConfigFile(getTestDataFile(configFilePath));
+            config = (ExternalMetExtractorConfig) new ExternConfigReader().parseConfigFile(this.confFile);
         } catch (Exception e) {
             fail(e.getMessage());
         }
@@ -87,4 +92,21 @@ public class TestExternMetExtractorConfi
         assertTrue(config.getArgList()[5].endsWith(arg5ending));
 
     }
+
+    /* (non-Javadoc)
+     * @see org.apache.oodt.cas.metadata.MetadataTestCase#setUp()
+     */
+    @Override
+    public void setUp() throws Exception {
+      super.setUp();
+      this.confFile = getTestDataFile(configFilePath);
+      
+      // replace path in confFile named TEST_PATH
+      String testPathKey = "TEST_PATH";
+      String confFileContents = FileUtils.readFileToString(this.confFile);
+      Metadata replaceMet = new Metadata();
+      replaceMet.addMetadata(testPathKey, this.confFile.getParent());
+      confFileContents = PathUtils.replaceEnvVariables(confFileContents, replaceMet);
+      FileUtils.writeStringToFile(this.confFile, confFileContents);
+    }
 }



Mime
View raw message