From 53771fb73ec523e56e235a02b72f99bf5902e364 Mon Sep 17 00:00:00 2001 From: Mahmoud Mohammadi Date: Mon, 6 Jun 2016 16:25:13 -0400 Subject: [PATCH 1/2] FileBasedEventStorageCustomLocationTest compatible with Windows --- .../FileBasedEventStorageCustomLocationTest.java | 13 +++++++++---- .../test/resources/base-context-custom-files.xml | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java b/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java index bc75d0c5..c6472177 100644 --- a/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java +++ b/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java @@ -1,6 +1,8 @@ package org.owasp.appsensor.storage.file; import javax.inject.Inject; +import java.nio.file.Paths; +import java.nio.file.Path; import org.junit.Assert; import org.junit.Test; @@ -27,13 +29,16 @@ public class FileBasedEventStorageCustomLocationTest { @Test public void deleteTestFiles() throws Exception { + + Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); + FileBasedEventStore eventStore = (FileBasedEventStore)appSensorServer.getEventStore(); FileBasedAttackStore attackStore = (FileBasedAttackStore)appSensorServer.getAttackStore(); FileBasedResponseStore responseStore = (FileBasedResponseStore)appSensorServer.getResponseStore(); - - Assert.assertEquals("/tmp/as_events.txt", eventStore.getPath().toString()); - Assert.assertEquals("/tmp/as_attacks.txt", attackStore.getPath().toString()); - Assert.assertEquals("/tmp/as_responses.txt", responseStore.getPath().toString()); + + Assert.assertEquals(tempDir.resolve("as_events.txt").toString(), eventStore.getPath().toString()); + Assert.assertEquals(tempDir.resolve("as_attacks.txt").toString(), attackStore.getPath().toString()); + Assert.assertEquals(tempDir.resolve("as_responses.txt").toString(), responseStore.getPath().toString()); } } diff --git a/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml b/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml index f5e8f18e..fd80fd1a 100644 --- a/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml +++ b/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml @@ -7,17 +7,17 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> - + - + - + From 4222e55740d80aa9e3342fdfd6697111581ac5e5 Mon Sep 17 00:00:00 2001 From: Mahmoud Mohammadi Date: Mon, 6 Jun 2016 16:25:13 -0400 Subject: [PATCH 2/2] FileBasedEventStorageCustomLocationTest compatible with Windows --- .../FileBasedEventStorageCustomLocationTest.java | 13 +++++++++---- .../test/resources/base-context-custom-files.xml | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java b/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java index bc75d0c5..c6472177 100644 --- a/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java +++ b/storage-providers/appsensor-storage-file-based/src/test/java/org/owasp/appsensor/storage/file/FileBasedEventStorageCustomLocationTest.java @@ -1,6 +1,8 @@ package org.owasp.appsensor.storage.file; import javax.inject.Inject; +import java.nio.file.Paths; +import java.nio.file.Path; import org.junit.Assert; import org.junit.Test; @@ -27,13 +29,16 @@ public class FileBasedEventStorageCustomLocationTest { @Test public void deleteTestFiles() throws Exception { + + Path tempDir = Paths.get(System.getProperty("java.io.tmpdir")); + FileBasedEventStore eventStore = (FileBasedEventStore)appSensorServer.getEventStore(); FileBasedAttackStore attackStore = (FileBasedAttackStore)appSensorServer.getAttackStore(); FileBasedResponseStore responseStore = (FileBasedResponseStore)appSensorServer.getResponseStore(); - - Assert.assertEquals("/tmp/as_events.txt", eventStore.getPath().toString()); - Assert.assertEquals("/tmp/as_attacks.txt", attackStore.getPath().toString()); - Assert.assertEquals("/tmp/as_responses.txt", responseStore.getPath().toString()); + + Assert.assertEquals(tempDir.resolve("as_events.txt").toString(), eventStore.getPath().toString()); + Assert.assertEquals(tempDir.resolve("as_attacks.txt").toString(), attackStore.getPath().toString()); + Assert.assertEquals(tempDir.resolve("as_responses.txt").toString(), responseStore.getPath().toString()); } } diff --git a/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml b/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml index f5e8f18e..fd80fd1a 100644 --- a/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml +++ b/storage-providers/appsensor-storage-file-based/src/test/resources/base-context-custom-files.xml @@ -7,17 +7,17 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> - + - + - +