summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odcsim-core/build.gradle15
-rw-r--r--odcsim-engine-omega/build.gradle2
-rw-r--r--odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemFactoryTest.kt6
-rw-r--r--odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemTest.kt7
-rw-r--r--odcsim-engine-tests/build.gradle39
-rw-r--r--odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt (renamed from odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt)37
-rw-r--r--odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemFactoryContract.kt (renamed from odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemFactoryTest.kt)9
-rw-r--r--settings.gradle1
8 files changed, 79 insertions, 37 deletions
diff --git a/odcsim-core/build.gradle b/odcsim-core/build.gradle
index 83dfabec..a0cd8450 100644
--- a/odcsim-core/build.gradle
+++ b/odcsim-core/build.gradle
@@ -39,18 +39,3 @@ dependencies {
testImplementation "org.junit.platform:junit-platform-launcher:$junit_platform_version"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0"
}
-
-/* Create configuration for test suite used by implementors */
-task testJar(type: Jar, dependsOn: testClasses) {
- from sourceSets.test.output
-}
-
-configurations {
- tests
-}
-
-artifacts {
- tests testJar
-}
-
-
diff --git a/odcsim-engine-omega/build.gradle b/odcsim-engine-omega/build.gradle
index f60dbe89..cefd3e20 100644
--- a/odcsim-engine-omega/build.gradle
+++ b/odcsim-engine-omega/build.gradle
@@ -37,7 +37,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "io.github.microutils:kotlin-logging:1.6.20"
- testCompile project(path: ':odcsim-core', configuration: 'tests')
+ testApi project(':odcsim-engine-tests')
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_jupiter_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_jupiter_version"
testImplementation "org.junit.platform:junit-platform-launcher:$junit_platform_version"
diff --git a/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemFactoryTest.kt b/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemFactoryTest.kt
index 01574b7f..4e195e6e 100644
--- a/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemFactoryTest.kt
+++ b/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemFactoryTest.kt
@@ -25,13 +25,13 @@
package com.atlarge.odcsim.engine.omega
import com.atlarge.odcsim.ActorSystemFactory
-import com.atlarge.odcsim.ActorSystemFactoryTest
+import com.atlarge.odcsim.engine.tests.ActorSystemFactoryContract
import org.junit.jupiter.api.DisplayName
/**
- * The [ActorSystemFactoryTest] suite for the Omega engine implementation.
+ * The [ActorSystemFactory] test suite for the Omega engine implementation.
*/
@DisplayName("OmegaActorSystemFactory")
-class OmegaActorSystemFactoryTest : ActorSystemFactoryTest() {
+class OmegaActorSystemFactoryTest : ActorSystemFactoryContract() {
override fun createFactory(): ActorSystemFactory = OmegaActorSystemFactory()
}
diff --git a/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemTest.kt b/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemTest.kt
index ef7a5258..dc310d47 100644
--- a/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemTest.kt
+++ b/odcsim-engine-omega/src/test/kotlin/com/atlarge/odcsim/engine/omega/OmegaActorSystemTest.kt
@@ -24,13 +24,14 @@
package com.atlarge.odcsim.engine.omega
-import com.atlarge.odcsim.ActorSystemTest
+import com.atlarge.odcsim.ActorSystem
+import com.atlarge.odcsim.engine.tests.ActorSystemContract
import org.junit.jupiter.api.DisplayName
/**
- * The [ActorSystemTest] suite for the Omega engine implementation.
+ * The [ActorSystem] test suite for the Omega engine implementation.
*/
@DisplayName("OmegaActorSystem")
-class OmegaActorSystemTest : ActorSystemTest() {
+class OmegaActorSystemTest : ActorSystemContract() {
override val factory = OmegaActorSystemFactory()
}
diff --git a/odcsim-engine-tests/build.gradle b/odcsim-engine-tests/build.gradle
new file mode 100644
index 00000000..da568319
--- /dev/null
+++ b/odcsim-engine-tests/build.gradle
@@ -0,0 +1,39 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2019 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* Build configuration */
+apply from: '../gradle/kotlin.gradle'
+apply plugin: 'java-library'
+
+/* Project configuration */
+repositories {
+ jcenter()
+}
+
+dependencies {
+ api project(':odcsim-core')
+
+ implementation "org.jetbrains.kotlin:kotlin-stdlib"
+ implementation "org.junit.jupiter:junit-jupiter-api:$junit_jupiter_version"
+}
diff --git a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt
index e9cc3886..eb6d38f6 100644
--- a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt
+++ b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemContract.kt
@@ -1,7 +1,7 @@
/*
* MIT License
*
- * Copyright (c) 2018 atlarge-research
+ * Copyright (c) 2019 atlarge-research
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -22,8 +22,18 @@
* SOFTWARE.
*/
-package com.atlarge.odcsim
-
+package com.atlarge.odcsim.engine.tests
+
+import com.atlarge.odcsim.ActorPath
+import com.atlarge.odcsim.ActorRef
+import com.atlarge.odcsim.ActorSystemFactory
+import com.atlarge.odcsim.Behavior
+import com.atlarge.odcsim.empty
+import com.atlarge.odcsim.ignore
+import com.atlarge.odcsim.receiveMessage
+import com.atlarge.odcsim.same
+import com.atlarge.odcsim.setup
+import com.atlarge.odcsim.stopped
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
@@ -32,12 +42,10 @@ import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
-const val DELTA: Double = 0.0001
-
/**
* A conformance test suite for implementors of the [ActorSystem] interface.
*/
-abstract class ActorSystemTest {
+abstract class ActorSystemContract {
/**
* An [ActorSystemFactory] provided by implementors to create the [ActorSystem] to be tested.
*/
@@ -71,7 +79,7 @@ abstract class ActorSystemTest {
fun `should start at t=0`() {
val system = factory(empty<Unit>(), name = "test")
- assertTrue(Math.abs(system.time) < DELTA)
+ assertEquals(.0, system.time, DELTA)
}
/**
@@ -94,7 +102,7 @@ abstract class ActorSystemTest {
system.run(until = until)
system.run(until = until - 0.5)
- assertTrue(Math.abs(system.time - until) < DELTA)
+ assertEquals(until, system.time, DELTA)
}
/**
@@ -106,7 +114,7 @@ abstract class ActorSystemTest {
val system = factory(empty<Unit>(), name = "test")
system.run(until = until)
- assertTrue(Math.abs(system.time - until) < DELTA)
+ assertEquals(until, system.time, DELTA)
}
/**
@@ -152,6 +160,7 @@ abstract class ActorSystemTest {
factory(setup<Unit> { TODO() }, name = "test")
}
+
@Nested
@DisplayName("ActorRef")
inner class ActorRefTest {
@@ -174,7 +183,7 @@ abstract class ActorSystemTest {
@Test
fun `should pre-start at t=0 if root`() {
val behavior = setup<Unit> { ctx ->
- assertTrue(Math.abs(ctx.time) < DELTA)
+ assertEquals(.0, ctx.time, DELTA)
ignore()
}
@@ -310,7 +319,7 @@ abstract class ActorSystemTest {
}
/**
- * Test whether we cannot start an actor with the [same] behavior.
+ * Test whether we cannot start an actor with the [Behavior.Companion.same] behavior.
*/
@Test
fun `should not start with same behavior`() {
@@ -319,7 +328,7 @@ abstract class ActorSystemTest {
}
/**
- * Test whether we can start an actor with the [stopped] behavior.
+ * Test whether we can start an actor with the [Behavior.Companion.stopped] behavior.
*/
@Test
fun `should start with stopped behavior`() {
@@ -346,4 +355,8 @@ abstract class ActorSystemTest {
assertEquals(1, counter)
}
}
+
+ companion object {
+ private const val DELTA: Double = 0.0001
+ }
}
diff --git a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemFactoryTest.kt b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemFactoryContract.kt
index 11652606..55d70a84 100644
--- a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemFactoryTest.kt
+++ b/odcsim-engine-tests/src/main/kotlin/com/atlarge/odcsim/engine/tests/ActorSystemFactoryContract.kt
@@ -1,7 +1,7 @@
/*
* MIT License
*
- * Copyright (c) 2018 atlarge-research
+ * Copyright (c) 2019 atlarge-research
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -22,8 +22,11 @@
* SOFTWARE.
*/
-package com.atlarge.odcsim
+package com.atlarge.odcsim.engine.tests
+import com.atlarge.odcsim.ActorSystemFactory
+import com.atlarge.odcsim.empty
+import com.atlarge.odcsim.setup
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
@@ -31,7 +34,7 @@ import org.junit.jupiter.api.assertThrows
/**
* A conformance test suite for implementors of the [ActorSystemFactory] interface.
*/
-abstract class ActorSystemFactoryTest {
+abstract class ActorSystemFactoryContract {
/**
* Create an [ActorSystemFactory] instance to test.
*/
diff --git a/settings.gradle b/settings.gradle
index a7a78f90..9ae9a5ab 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -24,4 +24,5 @@
rootProject.name = 'opendc-simulator'
include 'odcsim-core'
+include 'odcsim-engine-tests'
include 'odcsim-engine-omega'