Skip to Content.
Sympa Menu

perfsonar-dev - [GEANT/SA2/ps-java-services] r5622 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration test/java/org/perfsonar/base2/service/configuration/migration

Subject: perfsonar development work

List archive

[GEANT/SA2/ps-java-services] r5622 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration test/java/org/perfsonar/base2/service/configuration/migration


Chronological Thread 
  • From:
  • To:
  • Subject: [GEANT/SA2/ps-java-services] r5622 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration test/java/org/perfsonar/base2/service/configuration/migration
  • Date: Wed, 12 May 2010 12:58:22 +0100

Author: psnc.pietrzak
Date: 2010-05-12 12:58:22 +0100 (Wed, 12 May 2010)
New Revision: 5622

Added:

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngine.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/MigratorComponentTest.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngineTest.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/emptydir/
Removed:

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java
Modified:

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/AllMigrationTests.java
Log:
Added logs to the MigratorComponent class.
Added test cases for the MigratorComponent class.
Renamed the TemplateEngine class to SimpleTemplateEngine.
Extracted the interface from SimpleTemplateEngine.

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
2010-05-11 15:15:39 UTC (rev 5621)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/MigratorComponent.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.net.URL;

import org.apache.log4j.Logger;
import org.perfsonar.base2.service.configuration.Component;
@@ -31,26 +32,36 @@
*/
@Override
public void init() throws PerfSONARException {
- if (getConfigDirectory() == null)
+ if (getConfigDirectory() == null) {
configFiles = new ConfigFilesCollection();
- else
+ logger.info("The directory for configuration files
that should be "
+ + "rewritten to the new format was not
specified. The directory "
+ + getDefaultConfigDirectory() + " will be
used instead.");
+ } else {
configFiles = new
ConfigFilesCollection(getConfigDirectory());
+ logger.debug("Configuration files from " +
getConfigDirectory().getAbsolutePath()
+ + " will be rewritten to the new format.");
+ }

try {
- engine = new
TemplateEngine(configFiles.loadProperties());
+ setTemplateEngine(new
SimpleTemplateEngine(configFiles.loadProperties()));
} catch (IOException ex) {
logger.error(ex.getMessage(), ex);
throw new PerfSONARException(ex.getMessage());
}
}

- private File getConfigDirectory() {
+ protected File getConfigDirectory() {
if (getOption("config-directory") == null)
return null;
if (getOption("config-directory").getValue().length() <= 0)
return null;
return new File(getOption("config-directory").getValue());
}
+
+ protected void setTemplateEngine(TemplateEngine engine) {
+ this.engine = engine;
+ }

/**
* Converts psbase-1 configuration files to psbase-2 format.
@@ -95,4 +106,7 @@
private String getFullPath(String fileName) throws URISyntaxException
{
return
Thread.currentThread().getContextClassLoader().getResource("perfsonar" +
File.separator + "conf" + File.separator + fileName).getPath();
}
+ private URL getDefaultConfigDirectory() {
+ return
Thread.currentThread().getContextClassLoader().getResource("perfsonar" +
File.separator + "conf");
+ }
}

Copied:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngine.java
(from rev 5598,
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java)
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngine.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngine.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -0,0 +1,107 @@
+package org.perfsonar.base2.service.configuration.migration;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Properties;
+
+import
org.perfsonar.base2.service.configuration.migration.grammar.Interpreter;
+
+/**
+ * Used to create a file from the template.
+ *
+ * The following expressions are implemented in the template engine:
+ * <ul>
+ * <li>property expressions <code>${property_name}</code></li>
+ * <li>function expressions <code>#function-name(arg1 "value1" arg2
"value2" .. argN "valueN")</code></li>
+ * <li>loop expressions <code>#for(var variable string "string" split
"regular expression")...#end()</code></li>
+ * </ul>
+ *
+ * <p>Property expressions are expressions where the variable is substituted
by its value.
+ * Properties are provided in the constructor of TemplateEngine class.</p>
+ *
+ * <p>Function expressions are used to perform a function.
+ * The following functions are supported:<br />
+ * <ul>
+ * <li><code>replace</code> - replaces a substring specified with regular
expression with another string</li>
+ * <li><code>indexer</code> - writes a current index value and increments
the index</li>
+ * </ul>
+ *
+ * <i>Replace</i> function is represented with the following syntax:<br />
+ * <code>#replace(string </code><i>"string"</i><code> regexp
</code><i>"regexp"</i><code> with </code><i>"replacement
string"</i><code>)</code><br />
+ * where:<br />
+ * <ul>
+ * <li><i>string</i> - the string on which the replace function will be
performed</li>
+ * <li><i>regexp</i> - the regular expression describing the substring to
replace</li>
+ * <li><i>with</i> - the replacement string</li>
+ * </ul>
+ * Example:<br />
+ * #replace(string "http://somewhere"; regexp "http" with "https")<br />
+ * <br />
+ * <i>Indexer</i> function is represented with the following syntax:<br />
+ * <code>#indexer()</code><br />
+ * </p>
+ *
+ * <p>Loop expression is used to iterate substrings that are a result of
+ * a string split.<br />
+ * Loop expression is represented by the following expression:<br />
+ * <code>#for(var </code><i>variable-name</i><code> string </code><i>"string
to be splited"</i><code> split </code><i>"regular
expression"</i><code>)</code><br />
+ * <code> ... </code><br />
+ * <code>#end()</code><br />
+ * <br />
+ * where: <br />
+ * <ul>
+ * <li><i>variable-name</i> is a name of the property that stores the
substring<br /></li>
+ * <li><i>string to be splited</i> is the string on which the split
function will be executed<br /></li>
+ * <li><i>regular expression</i> is a regexp used to split the string<br
/></li>
+ * </ul>
+ * <br />
+ * Example:<br />
+ * <code>#for(var lsAddress string "${service.r.ls_url}" split
",")</code><br />
+ * <code>&lt;option name="lsAddress-#indexer()" value="${lsAddress}"
/&gt;</code><br />
+ * <code>#end()</code><br />
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ *
+ */
+public class SimpleTemplateEngine implements TemplateEngine {
+ private final Interpreter interpreter;
+
+ /**
+ * Creates the engine.
+ *
+ * @param props properties store the variables and their values
+ */
+ public SimpleTemplateEngine(Properties props) {
+ interpreter = new Interpreter(props);
+ }
+
+ /**
+ * @see
org.perfsonar.base2.service.configuration.migration.TemplateEngine#createFileFromTemplate(java.io.File,
java.lang.String)
+ */
+ public File createFileFromTemplate(File template, String newFileName)
throws IOException {
+ if (!template.exists())
+ throw new FileNotFoundException("File: " +
template.getAbsolutePath() + " does not exist.");
+ if (!template.isFile())
+ throw new IOException("Template must be an existing
file.");
+ final File result = new File(newFileName);
+ if (result.exists() && !result.isFile())
+ throw new IOException("Output must be a file.");
+
+ final BufferedReader reader = new BufferedReader(new
FileReader(template));
+ final BufferedWriter writer = new BufferedWriter(new
FileWriter(result));
+ for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
+ interpreter.interpret(writer, line);
+ writer.newLine();
+ }
+ writer.flush();
+ writer.close();
+ reader.close();
+
+ return result;
+ }
+}

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
2010-05-11 15:15:39 UTC (rev 5621)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/TemplateEngine.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -1,85 +1,16 @@
package org.perfsonar.base2.service.configuration.migration;

-import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
-import java.util.Properties;

-import
org.perfsonar.base2.service.configuration.migration.grammar.Interpreter;
-
/**
- * Used to create a file from the template.
- *
- * The following expressions are implemented in the template engine:
- * <ul>
- * <li>property expressions <code>${property_name}</code></li>
- * <li>function expressions <code>#function-name(arg1 "value1" arg2
"value2" .. argN "valueN")</code></li>
- * <li>loop expressions <code>#for(var variable string "string" split
"regular expression")...#end()</code></li>
- * </ul>
- *
- * <p>Property expressions are expressions where the variable is substituted
by its value.
- * Properties are provided in the constructor of TemplateEngine class.</p>
- *
- * <p>Function expressions are used to perform a function.
- * The following functions are supported:<br />
- * <ul>
- * <li><code>replace</code> - replaces a substring specified with regular
expression with another string</li>
- * <li><code>indexer</code> - writes a current index value and increments
the index</li>
- * </ul>
- *
- * <i>Replace</i> function is represented with the following syntax:<br />
- * <code>#replace(string </code><i>"string"</i><code> regexp
</code><i>"regexp"</i><code> with </code><i>"replacement
string"</i><code>)</code><br />
- * where:<br />
- * <ul>
- * <li><i>string</i> - the string on which the replace function will be
performed</li>
- * <li><i>regexp</i> - the regular expression describing the substring to
replace</li>
- * <li><i>with</i> - the replacement string</li>
- * </ul>
- * Example:<br />
- * #replace(string "http://somewhere"; regexp "http" with "https")<br />
- * <br />
- * <i>Indexer</i> function is represented with the following syntax:<br />
- * <code>#indexer()</code><br />
- * </p>
- *
- * <p>Loop expression is used to iterate substrings that are a result of
- * a string split.<br />
- * Loop expression is represented by the following expression:<br />
- * <code>#for(var </code><i>variable-name</i><code> string </code><i>"string
to be splited"</i><code> split </code><i>"regular
expression"</i><code>)</code><br />
- * <code> ... </code><br />
- * <code>#end()</code><br />
- * <br />
- * where: <br />
- * <ul>
- * <li><i>variable-name</i> is a name of the property that stores the
substring<br /></li>
- * <li><i>string to be splited</i> is the string on which the split
function will be executed<br /></li>
- * <li><i>regular expression</i> is a regexp used to split the string<br
/></li>
- * </ul>
- * <br />
- * Example:<br />
- * <code>#for(var lsAddress string "${service.r.ls_url}" split
",")</code><br />
- * <code>&lt;option name="lsAddress-#indexer()" value="${lsAddress}"
/&gt;</code><br />
- * <code>#end()</code><br />
- *
+ * Interface for template engines that are used to create a file
+ * from the template.
+ *
* @author <a
href="mailto:">Blazej
Pietrzak</a>
- *
*/
-public class TemplateEngine {
- private final Interpreter interpreter;
-
- /**
- * Creates the engine.
- *
- * @param props properties store the variables and their values
- */
- public TemplateEngine(Properties props) {
- interpreter = new Interpreter(props);
- }
-
+public interface TemplateEngine {
+
/**
* Creates a file from the template.
*
@@ -88,25 +19,7 @@
* @return file created from the template
* @throws IOException if I/O error occurs
*/
- public File createFileFromTemplate(File template, String newFileName)
throws IOException {
- if (!template.exists())
- throw new FileNotFoundException("File: " +
template.getAbsolutePath() + " does not exist.");
- if (!template.isFile())
- throw new IOException("Template must be an existing
file.");
- final File result = new File(newFileName);
- if (result.exists() && !result.isFile())
- throw new IOException("Output must be a file.");
-
- final BufferedReader reader = new BufferedReader(new
FileReader(template));
- final BufferedWriter writer = new BufferedWriter(new
FileWriter(result));
- for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
- interpreter.interpret(writer, line);
- writer.newLine();
- }
- writer.flush();
- writer.close();
- reader.close();
-
- return result;
- }
-}
+ public File createFileFromTemplate(File template, String newFileName)
+ throws IOException;
+
+}
\ No newline at end of file

Modified:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/AllMigrationTests.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/AllMigrationTests.java
2010-05-11 15:15:39 UTC (rev 5621)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/AllMigrationTests.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -14,9 +14,10 @@
TestSuite suite = new TestSuite(
"Migration tool from base-1 to base-2 test cases");
//$JUnit-BEGIN$
+ suite.addTest(AllGrammarTests.suite());
+ suite.addTestSuite(SimpleTemplateEngineTest.class);
suite.addTestSuite(ConfigFilesCollectionTest.class);
- suite.addTestSuite(TemplateEngineTest.class);
- suite.addTest(AllGrammarTests.suite());
+ suite.addTestSuite(MigratorComponentTest.class);
//$JUnit-END$
return suite;
}

Added:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/MigratorComponentTest.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/MigratorComponentTest.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/MigratorComponentTest.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -0,0 +1,61 @@
+package org.perfsonar.base2.service.configuration.migration;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.perfsonar.base2.service.configuration.Option;
+import org.perfsonar.base2.service.exceptions.PerfSONARException;
+
+/**
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class MigratorComponentTest extends TestCase {
+
+ private MigratorComponent migrator;
+ protected void setUp() throws Exception {
+ super.setUp();
+ migrator = new MigratorComponent();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testInitWithConfigDirectoryNotSet() {
+ assertNull(migrator.getConfigDirectory());
+ }
+
+ public void testInitWithConfigDirectorySet() {
+ setConfigDirectory(getCurrentDirectory());
+ assertEquals(getCurrentDirectory(),
migrator.getConfigDirectory().getAbsolutePath());
+ }
+
+ private void setConfigDirectory(String path) {
+ migrator.addOption(new Option("config-directory", path));
+ }
+
+ private String getCurrentDirectory() {
+ return new File(".").getAbsolutePath();
+ }
+
+ public void testRunWithEmptyConfigDirectory() throws
PerfSONARException {
+ setConfigDirectory(getAbsolutePath("emptydir"));
+ migrator.init();
+ migrator.setTemplateEngine(new TemplateEngine() {
+ @Override
+ public File createFileFromTemplate(File template,
String newFileName)
+ throws IOException {
+ fail("There are no configuration files, so
new File should not be created.");
+ return null;
+ }
+ });
+ migrator.run();
+ }
+
+ private String getAbsolutePath(String path) {
+ return "src" + File.separator + "test" + File.separator +
"java" + File.separator +
MigratorComponentTest.class.getPackage().getName().replace(".",
File.separator) + File.separator + path;
+ }
+
+}

Copied:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngineTest.java
(from rev 5608,
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java)
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngineTest.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/SimpleTemplateEngineTest.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -0,0 +1,79 @@
+package org.perfsonar.base2.service.configuration.migration;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import
org.perfsonar.base2.service.configuration.migration.ConfigFilesCollection;
+import
org.perfsonar.base2.service.configuration.migration.SimpleTemplateEngine;
+import
org.perfsonar.base2.service.configuration.migration.grammar.function.IndexerFunction;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class SimpleTemplateEngineTest extends TestCase {
+
+ TemplateEngine engine;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ engine = new SimpleTemplateEngine(new
ConfigFilesCollection(new File(getConfigPath())).loadProperties());
+ }
+
+ private String getConfigPath() {
+ return "src" + File.separator + "test" + File.separator +
"java" + File.separator +
SimpleTemplateEngine.class.getPackage().getName().replace(".",
File.separator);
+ }
+
+ public void testCreateFromTemplateWhereTemplateIsaDirectory() {
+ try {
+ engine.createFileFromTemplate(new
File(getConfigPath()), "configuration.xml");
+ fail("IOException not thrown.");
+ } catch (IOException ex) { }
+ }
+ public void testCreateFromTemplateWhereTemplateDoesNotExist() throws
IOException {
+ try {
+ engine.createFileFromTemplate(new
File(getConfigPath() + File.separator + "does_not_exist"),
"configuration.xml");
+ fail("FileNotFoundException not thrown.");
+ } catch (FileNotFoundException ex) { }
+ }
+ public void testCreateFromTemplateWhereFileIsaDirectory() {
+ try {
+ engine.createFileFromTemplate(new
File(getConfigPath() + File.separator + "configuration.xml.template"),
getConfigPath());
+ fail("IOException not thrown.");
+ } catch (IOException ex) { }
+ }
+ public void testCreateFromTemplate() throws IOException {
+ new IndexerFunction().reset();
+ assertEquals(new File(getConfigPath() + File.separator +
"expected.xml"), engine.createFileFromTemplate(new File(getConfigPath() +
File.separator + "configuration.xml.template"), getConfigPath() +
File.separator + "configuration.xml"));
+ assertTrue(new File(getConfigPath() + File.separator +
"configuration.xml").delete());
+ }
+
+ private void assertEquals(File expected, File actual) throws
IOException {
+ assertEquals(toString(expected), toString(actual));
+ }
+
+ private String toString(File file) throws IOException {
+ final BufferedReader reader = new BufferedReader(new
FileReader(file));
+ final StringBuffer result = new StringBuffer();
+ boolean first = true;
+ for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
+ if (first == false)
+ result.append("\n");
+ else
+ first = false;
+ result.append(line);
+ }
+ reader.close();
+
+ return result.toString();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}

Deleted:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java
2010-05-11 15:15:39 UTC (rev 5621)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java
2010-05-12 11:58:22 UTC (rev 5622)
@@ -1,79 +0,0 @@
-package org.perfsonar.base2.service.configuration.migration;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-import
org.perfsonar.base2.service.configuration.migration.ConfigFilesCollection;
-import org.perfsonar.base2.service.configuration.migration.TemplateEngine;
-import
org.perfsonar.base2.service.configuration.migration.grammar.function.IndexerFunction;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a
href="mailto:">Blazej
Pietrzak</a>
- */
-public class TemplateEngineTest extends TestCase {
-
- TemplateEngine engine;
-
- protected void setUp() throws Exception {
- super.setUp();
- engine = new TemplateEngine(new ConfigFilesCollection(new
File(getConfigPath())).loadProperties());
- }
-
- private String getConfigPath() {
- return "src" + File.separator + "test" + File.separator +
"java" + File.separator +
TemplateEngine.class.getPackage().getName().replace(".", File.separator);
- }
-
- public void testCreateFromTemplateWhereTemplateIsaDirectory() {
- try {
- engine.createFileFromTemplate(new
File(getConfigPath()), "configuration.xml");
- fail("IOException not thrown.");
- } catch (IOException ex) { }
- }
- public void testCreateFromTemplateWhereTemplateDoesNotExist() throws
IOException {
- try {
- engine.createFileFromTemplate(new
File(getConfigPath() + File.separator + "does_not_exist"),
"configuration.xml");
- fail("FileNotFoundException not thrown.");
- } catch (FileNotFoundException ex) { }
- }
- public void testCreateFromTemplateWhereFileIsaDirectory() {
- try {
- engine.createFileFromTemplate(new
File(getConfigPath() + File.separator + "configuration.xml.template"),
getConfigPath());
- fail("IOException not thrown.");
- } catch (IOException ex) { }
- }
- public void testCreateFromTemplate() throws IOException {
- new IndexerFunction().reset();
- assertEquals(new File(getConfigPath() + File.separator +
"expected.xml"), engine.createFileFromTemplate(new File(getConfigPath() +
File.separator + "configuration.xml.template"), getConfigPath() +
File.separator + "configuration.xml"));
- assertTrue(new File(getConfigPath() + File.separator +
"configuration.xml").delete());
- }
-
- private void assertEquals(File expected, File actual) throws
IOException {
- assertEquals(toString(expected), toString(actual));
- }
-
- private String toString(File file) throws IOException {
- final BufferedReader reader = new BufferedReader(new
FileReader(file));
- final StringBuffer result = new StringBuffer();
- boolean first = true;
- for (String line = reader.readLine(); line != null; line =
reader.readLine()) {
- if (first == false)
- result.append("\n");
- else
- first = false;
- result.append(line);
- }
- reader.close();
-
- return result.toString();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}



  • [GEANT/SA2/ps-java-services] r5622 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration test/java/org/perfsonar/base2/service/configuration/migration, svn-noreply, 05/12/2010

Archive powered by MHonArc 2.6.16.

Top of Page