Work around "/" issue in FileSystemResourceLoader.

This commit is contained in:
dsyer
2007-08-16 07:29:49 +00:00
parent 2803e62178
commit 33377582bf
2 changed files with 14 additions and 10 deletions

View File

@@ -70,7 +70,7 @@ public class BatchResourceFactoryBean extends AbstractFactoryBean implements Res
private String filePattern = DEFAULT_PATTERN;
private String jobName = "";
private String jobName = null;
private String jobStream = "";
@@ -138,7 +138,7 @@ public class BatchResourceFactoryBean extends AbstractFactoryBean implements Res
// TODO consider refactoring to void replacePattern() method and
// collecting variable fileName
fileName = replacePattern(fileName, BATCH_ROOT_PATTERN, rootDirectory);
fileName = replacePattern(fileName, JOB_NAME_PATTERN, jobName);
fileName = replacePattern(fileName, JOB_NAME_PATTERN, jobName==null?"job":jobName);
fileName = replacePattern(fileName, STEP_NAME_PATTERN, stepName);
fileName = replacePattern(fileName, STREAM_PATTERN, jobStream);
fileName = replacePattern(fileName, JOB_RUN_PATTERN, String.valueOf(jobRun));

View File

@@ -43,11 +43,7 @@ public class BatchResourceFactoryBeanTests extends TestCase {
private char pathsep = File.separatorChar;
private String PATTERN_STRING = "%BATCH_ROOT%"+pathsep+"%JOB_NAME%-%SCHEDULE_DATE%-%JOB_RUN%-%STREAM_NAME%";
private String EXPECTED_ABSOLUTE_PATH = rootDir+pathsep+"testJob-20070730-0-testStream";
private String NULL_JOB_NAME_PATH = rootDir+pathsep+"%JOB_NAME%-20070730-0-testStream";
private String PATTERN_STRING = "/%BATCH_ROOT%"+pathsep+"%JOB_NAME%-%SCHEDULE_DATE%-%JOB_RUN%-%STREAM_NAME%";
/**
* mock step context
@@ -89,9 +85,11 @@ public class BatchResourceFactoryBeanTests extends TestCase {
String returnedPath = resource.getFile().getAbsolutePath();
System.err.println(EXPECTED_ABSOLUTE_PATH);
String absolutePath = new File("/"+rootDir+pathsep+"testJob-20070730-0-testStream").getAbsolutePath();
System.err.println(absolutePath);
System.err.println(returnedPath);
assertEquals(EXPECTED_ABSOLUTE_PATH, returnedPath);
assertEquals(absolutePath, returnedPath);
}
/**
@@ -106,7 +104,13 @@ public class BatchResourceFactoryBeanTests extends TestCase {
Resource resource = (Resource) resourceFactory.getObject();
assertEquals(NULL_JOB_NAME_PATH, resource.getFile().getAbsolutePath());
String returnedPath = resource.getFile().getAbsolutePath();
String absolutePath = new File("/"+rootDir+pathsep+"job-20070730-0-testStream").getAbsolutePath();
System.err.println(absolutePath);
System.err.println(returnedPath);
assertEquals(absolutePath, returnedPath);
}
public void testObjectType() throws Exception {