summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-azure/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-20 22:04:23 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-20 22:04:23 +0200
commitc7fff03408ee3109d0a39a96c043584a2d8f67ca (patch)
tree8c4a877e0f00f14a9091f9c26fdb0e85cad94904 /opendc-trace/opendc-trace-azure/src/test
parent140aafdaa711b0fdeacf99b9c7e70b706b8490f4 (diff)
refactor(trace): Simplify TraceFormat SPI interface
This change simplifies the TraceFormat SPI interface by reducing the number of interfaces that implementors need to implement to only TraceFormat.
Diffstat (limited to 'opendc-trace/opendc-trace-azure/src/test')
-rw-r--r--opendc-trace/opendc-trace-azure/src/test/kotlin/org/opendc/trace/azure/AzureTraceFormatTest.kt50
1 files changed, 11 insertions, 39 deletions
diff --git a/opendc-trace/opendc-trace-azure/src/test/kotlin/org/opendc/trace/azure/AzureTraceFormatTest.kt b/opendc-trace/opendc-trace-azure/src/test/kotlin/org/opendc/trace/azure/AzureTraceFormatTest.kt
index 2c1a2125..b73bb728 100644
--- a/opendc-trace/opendc-trace-azure/src/test/kotlin/org/opendc/trace/azure/AzureTraceFormatTest.kt
+++ b/opendc-trace/opendc-trace-azure/src/test/kotlin/org/opendc/trace/azure/AzureTraceFormatTest.kt
@@ -26,8 +26,7 @@ import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opendc.trace.*
-import java.io.File
-import java.net.URL
+import java.nio.file.Paths
/**
* Test suite for the [AzureTraceFormat] class.
@@ -36,54 +35,29 @@ class AzureTraceFormatTest {
private val format = AzureTraceFormat()
@Test
- fun testTraceExists() {
- val url = File("src/test/resources/trace").toURI().toURL()
- assertDoesNotThrow {
- format.open(url)
- }
- }
-
- @Test
- fun testTraceDoesNotExists() {
- val url = File("src/test/resources/trace").toURI().toURL()
- assertThrows<IllegalArgumentException> {
- format.open(URL(url.toString() + "help"))
- }
- }
-
- @Test
fun testTables() {
- val url = File("src/test/resources/trace").toURI().toURL()
- val trace = format.open(url)
+ val path = Paths.get("src/test/resources/trace")
- assertEquals(listOf(TABLE_RESOURCES, TABLE_RESOURCE_STATES), trace.tables)
+ assertEquals(listOf(TABLE_RESOURCES, TABLE_RESOURCE_STATES), format.getTables(path))
}
@Test
fun testTableExists() {
- val url = File("src/test/resources/trace").toURI().toURL()
- val table = format.open(url).getTable(TABLE_RESOURCE_STATES)
+ val path = Paths.get("src/test/resources/trace")
- assertNotNull(table)
- assertDoesNotThrow { table!!.newReader() }
+ assertDoesNotThrow { format.getDetails(path, TABLE_RESOURCE_STATES) }
}
@Test
fun testTableDoesNotExist() {
- val url = File("src/test/resources/trace").toURI().toURL()
- val trace = format.open(url)
-
- assertFalse(trace.containsTable("test"))
- assertNull(trace.getTable("test"))
+ val path = Paths.get("src/test/resources/trace")
+ assertThrows<IllegalArgumentException> { format.getDetails(path, "test") }
}
@Test
fun testResources() {
- val url = File("src/test/resources/trace").toURI().toURL()
- val trace = format.open(url)
-
- val reader = trace.getTable(TABLE_RESOURCES)!!.newReader()
-
+ val path = Paths.get("src/test/resources/trace")
+ val reader = format.newReader(path, TABLE_RESOURCES)
assertAll(
{ assertTrue(reader.nextRow()) },
{ assertEquals("x/XsOfHO4ocsV99i4NluqKDuxctW2MMVmwqOPAlg4wp8mqbBOe3wxBlQo0+Qx+uf", reader.get(RESOURCE_ID)) },
@@ -96,10 +70,8 @@ class AzureTraceFormatTest {
@Test
fun testSmoke() {
- val url = File("src/test/resources/trace").toURI().toURL()
- val trace = format.open(url)
-
- val reader = trace.getTable(TABLE_RESOURCE_STATES)!!.newReader()
+ val path = Paths.get("src/test/resources/trace")
+ val reader = format.newReader(path, TABLE_RESOURCE_STATES)
assertAll(
{ assertTrue(reader.nextRow()) },