SGF-430 - Cleanup test failures on Windows due to incorrect Spring test context configuration resource resolution.

Fixes SnapshotServiceFactoryBeanTest.toSimpleFilenameUsingVariousPathnames(..) and the SnapshotServiceImportExportIntegrationTest failures on MS Windows due to file system path issues.
This commit is contained in:
John Blum
2015-09-11 19:21:46 -07:00
parent 3fdf6c3c82
commit 2f15b322ee
3 changed files with 15 additions and 7 deletions

View File

@@ -39,7 +39,6 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationListener;
import org.springframework.data.gemfire.snapshot.event.ExportSnapshotApplicationEvent;
import org.springframework.data.gemfire.snapshot.event.ImportSnapshotApplicationEvent;
import org.springframework.data.gemfire.snapshot.event.SnapshotApplicationEvent;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.util.Assert;

View File

@@ -124,6 +124,16 @@ public class SnapshotServiceFactoryBeanTest {
return metadata;
}
protected String toPathname(String... pathElements) {
StringBuilder pathname = new StringBuilder();
for (String pathElement : pathElements) {
pathname.append(File.separator).append(pathElement);
}
return pathname.toString();
}
@BeforeClass
public static void setupBeforeClass() throws Exception {
snapshotDat = mockFile("snapshot.dat");
@@ -915,11 +925,11 @@ public class SnapshotServiceFactoryBeanTest {
public void toSimpleFilenameUsingVariousPathnames() {
TestSnapshotServiceAdapter snapshotService = new TestSnapshotServiceAdapter();
assertThat(snapshotService.toSimpleFilename("/path/to/file.ext"), is(equalTo("file.ext")));
assertThat(snapshotService.toSimpleFilename("/path/to/file "), is(equalTo("file")));
assertThat(snapshotService.toSimpleFilename("/ file.ext"), is(equalTo("file.ext")));
assertThat(snapshotService.toSimpleFilename(toPathname("path", "to", "file.ext")), is(equalTo("file.ext")));
assertThat(snapshotService.toSimpleFilename(toPathname("path", "to", "file ")), is(equalTo("file")));
assertThat(snapshotService.toSimpleFilename(toPathname(" file.ext ")), is(equalTo("file.ext")));
assertThat(snapshotService.toSimpleFilename(" file.ext "), is(equalTo("file.ext")));
assertThat(snapshotService.toSimpleFilename("/ "), is(equalTo("")));
assertThat(snapshotService.toSimpleFilename(File.separator.concat(" ")), is(equalTo("")));
assertThat(snapshotService.toSimpleFilename(" "), is(equalTo("")));
assertThat(snapshotService.toSimpleFilename(""), is(equalTo("")));
assertThat(snapshotService.toSimpleFilename(null), is(nullValue()));

View File

@@ -105,8 +105,7 @@ public class SnapshotServiceImportExportIntegrationTest {
assertThat(importPeopleSnapshot.length() > 0, is(true));
applicationContext = new ClassPathXmlApplicationContext(
SnapshotServiceImportExportIntegrationTest.class.getName().replaceAll("\\.", File.separator)
.concat("-context.xml"));
SnapshotServiceImportExportIntegrationTest.class.getName().replace(".", "/").concat("-context.xml"));
applicationContext.registerShutdownHook();