Skip to Content.
Sympa Menu

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

Subject: perfsonar development work

List archive

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


Chronological Thread 
  • From:
  • To:
  • Subject: [GEANT/SA2/ps-java-services] r5601 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration main/java/org/perfsonar/base2/service/configuration/migration/grammar/function test/java/org/perfsonar/base2/service/configuration/migration
  • Date: Tue, 27 Apr 2010 12:23:43 +0100

Author: psnc.pietrzak
Date: 2010-04-27 12:23:43 +0100 (Tue, 27 Apr 2010)
New Revision: 5601

Modified:

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

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/grammar/function/FunctionExpression.java

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

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/configuration.xml.template

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/expected.xml
Log:
Refactored test cases.

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
2010-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollection.java
2010-04-27 11:23:43 UTC (rev 5601)
@@ -7,7 +7,9 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
@@ -27,29 +29,41 @@

private static final String RENAME_SUFFIX = ".remove";
protected static final String DEFAULT_CONFIG_PATH = "perfsonar" +
File.separator + "conf";
- protected final String configPath;
+ protected final File configPath;
protected static final Pattern filenamePattern =
Pattern.compile(".*[.]properties");

- public ConfigFilesCollection(String configPath) {
+ public ConfigFilesCollection(File configPath) {
this.configPath = configPath;
}
public ConfigFilesCollection() {
- this.configPath = DEFAULT_CONFIG_PATH;
+ this.configPath = null;
}
-
+
+ private File getConfigPath() throws FileNotFoundException,
IOException {
+ if (configPath != null)
+ return configPath;
+
+ try {
+ return new File(getFullPath(DEFAULT_CONFIG_PATH));
+ } catch (URISyntaxException ex) {
+ throw new IOException(ex.getMessage(), ex);
+ }
+ }
+ private URI getFullPath(String path) throws URISyntaxException,
FileNotFoundException {
+ final URL result =
Thread.currentThread().getContextClassLoader().getResource(path);
+ if (result == null)
+ throw new FileNotFoundException("File: " + path + "
does not exist.");
+ return result.toURI();
+ }
+
/**
* @return a collection of psbase-1 configuration files
* @throws IOException if I/O error occurs.
*/
protected Collection<File> getFiles() throws IOException {
final Collection<File> result = new ArrayList<File>();
- //final File file = new File(configPath);
- File file;
- try {
- file = new
File(Thread.currentThread().getContextClassLoader().getResource(configPath).toURI());
- } catch (URISyntaxException ex) {
- throw new IOException(ex.getMessage(), ex);
- }
+ final File file = getConfigPath();
+
if (!file.exists())
throw new FileNotFoundException("File: " +
file.getAbsolutePath() + " does not exist.");
if (!file.isDirectory())

Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/grammar/function/FunctionExpression.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/grammar/function/FunctionExpression.java
2010-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/migration/grammar/function/FunctionExpression.java
2010-04-27 11:23:43 UTC (rev 5601)
@@ -27,9 +27,6 @@
*
*/
public class FunctionExpression extends BaseExpression {
- //private final Pattern functionPattern =
Pattern.compile("[#]([a-zA-Z0-9_]+)\\(([^()]*)\\)");
- //[^\"]*
- //([a-zA-Z]+\\s+\"\")*
private final Pattern functionPattern =
Pattern.compile("[#]([a-zA-Z0-9_]+)\\((([a-zA-Z]+\\s+\"[^\"]*\"\\s*)*)\\)");

protected Pattern getPattern() {

Modified:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollectionTest.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollectionTest.java
2010-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/ConfigFilesCollectionTest.java
2010-04-27 11:23:43 UTC (rev 5601)
@@ -6,8 +6,6 @@
import java.util.ArrayList;
import java.util.Collection;

-import
org.perfsonar.base2.service.configuration.migration.ConfigFilesCollection;
-
import junit.framework.TestCase;

/**
@@ -16,12 +14,12 @@
public class ConfigFilesCollectionTest extends TestCase {

private ConfigFilesCollection configCollection;
- private static final String CONFIG_PATH
- =
"src/test/java/org/perfsonar/base2/service/configuration/migration";
-
+ private static final String CONFIG_PATH =
"src/test/java/org/perfsonar/base2/service/configuration/migration";
+
protected void setUp() throws Exception {
super.setUp();
- configCollection = new ConfigFilesCollection(CONFIG_PATH);
+
+ configCollection = new ConfigFilesCollection(new
File(CONFIG_PATH));
}

protected void tearDown() throws Exception {
@@ -49,7 +47,7 @@
}

public void testGetFilesDirectoryDoesNotExist() throws IOException {
- configCollection = new ConfigFilesCollection(CONFIG_PATH +
File.separator + "does_not_exist");
+ configCollection = new ConfigFilesCollection(new
File(CONFIG_PATH + File.separator + "does_not_exist"));
try {
configCollection.getFiles();
fail("FileNotFoundException not thrown for non
existing directory.");
@@ -57,7 +55,7 @@
}

public void testGetFilesFilePath() {
- configCollection = new ConfigFilesCollection(CONFIG_PATH +
File.separator + "ConfigurationMigratorTest.class");
+ configCollection = new ConfigFilesCollection(new
File(CONFIG_PATH + File.separator + "ConfigurationMigratorTest.class"));
try {
configCollection.getFiles();
fail("IOException not thrown for invalid directory
path.");

Modified:
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-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/TemplateEngineTest.java
2010-04-27 11:23:43 UTC (rev 5601)
@@ -20,7 +20,7 @@

protected void setUp() throws Exception {
super.setUp();
- engine = new TemplateEngine(new
ConfigFilesCollection(getConfigPath()).loadProperties());
+ engine = new TemplateEngine(new ConfigFilesCollection(new
File(getConfigPath())).loadProperties());
}

private String getConfigPath() {

Modified:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/configuration.xml.template
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/configuration.xml.template
2010-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/configuration.xml.template
2010-04-27 11:23:43 UTC (rev 5601)
@@ -40,7 +40,7 @@
<auxiliaryComponents>
<component name="XMLDB"
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
<option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage" />
- <option name="uri" value="#replace(string
"${component.mp.xmldb.db_uri}" regexp "" with "")"/>
+ <option name="uri" value="#replace(string
"${component.mp.xmldb.db_uri}" regexp "xmldb:exist://(.+)/(xmlrpc)/db(.*)"
with "http://$1/rest/db$3";)"/>
<option name="username"
value="${component.mp.xmldb.db_username}"/>
<option name="password"
value="${component.mp.xmldb.db_password}"/>
</component>

Modified:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/expected.xml
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/expected.xml
2010-04-27 10:21:36 UTC (rev 5600)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/configuration/migration/expected.xml
2010-04-27 11:23:43 UTC (rev 5601)
@@ -40,7 +40,7 @@
<auxiliaryComponents>
<component name="XMLDB"
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
<option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage" />
- <option name="uri"
value="xmldb:exist://127.0.0.1:8080/exist/xmlrpc/db"/>
+ <option name="uri"
value="http://127.0.0.1:8080/exist/rest/db"/>
<option name="username" value="sshtelnet"/>
<option name="password" value="sshtelnet"/>
</component>



  • [GEANT/SA2/ps-java-services] r5601 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service/configuration/migration main/java/org/perfsonar/base2/service/configuration/migration/grammar/function test/java/org/perfsonar/base2/service/configuration/migration, svn-noreply, 04/27/2010

Archive powered by MHonArc 2.6.16.

Top of Page