Skip to content

Commit

Permalink
[sre][tests] Reimplementing several tests with the new testing API.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Mar 24, 2020
1 parent 46d3ea4 commit b564fd5
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 220 deletions.
Expand Up @@ -57,36 +57,42 @@ import static extension org.junit.jupiter.api.Assertions.*
@Tag("run")
class OnMemberLeftTest {

@RepeatedTest(10)
@RepeatedTest(20)
@DisplayName("In default context")
def inDefaultContext(extension rc : SreRunContext) {
var kern = setupTheSreKernel(null, null)

val id0 = UUID::randomUUID
waitForAgentSpawned(id0) [
kern.startAgentWithID(typeof(MemberLeftAgent0), id0, buildAgentInitializationParameters(1))
kern.startAgentWithID(typeof(MemberLeftAgent0), id0, buildAgentInitializationParameters(1, false))
]

val id1 = UUID::randomUUID
waitForAgentSpawned(id1) [
kern.startAgentWithID(typeof(MemberLeftAgent0), id1, buildAgentInitializationParameters(2))
kern.startAgentWithID(typeof(MemberLeftAgent0), id1, buildAgentInitializationParameters(2, true))
]

val id2 = UUID::randomUUID
waitForAgentSpawned(id2) [
kern.startAgentWithID(typeof(MemberLeftAgent0), id2, buildAgentInitializationParameters(3))
kern.startAgentWithID(typeof(MemberLeftAgent0), id2, buildAgentInitializationParameters(3, false))
]

// Kill one agent to generate the MemberLeft event
waitForAgentKilled(id1) [
rootContext.defaultSpace.emit(UUID::randomUUID, new Bye)[it.UUID == id1]
]

rootContext.defaultSpace.emit(UUID::randomUUID, new Bye)

waitForTheKernel(STANDARD_TIMEOUT)

// There is no context joint for the default context.
// Consequently, no ContextJoined event is fired
allResults.assertContains()
allResults.assertContains(
"AG1: joined MemberLeftAgent0 " + id1 + " in default space",
"AG3: joined MemberLeftAgent0 " + id1 + " in default space"
)
}

@RepeatedTest(10)
@RepeatedTest(20)
@DisplayName("In other context")
def inOtherContext(extension rc : SreRunContext) {
var kern = setupTheSreKernel(null, null)
Expand Down
Expand Up @@ -30,6 +30,7 @@ import io.sarl.sre.test.framework.skills.TestingCapacity
import io.sarl.sre.test.framework.skills.TestingSkill

import static extension io.sarl.tests.api.tools.TestUtils.*
import static extension io.sarl.sre.tests.framework.SreTestUtilities.*

/**
* @author $Author: sgalland$
Expand All @@ -51,6 +52,10 @@ agent MemberLeftAgent0 {
}

on MemberLeft {
// The agent should be alive
val agentState = getAgentState
assert agentState !== null && agentState.alive
//
var msg : String
if (occurrence.inInnerDefaultSpace) {
msg = "inner"
Expand Down

0 comments on commit b564fd5

Please sign in to comment.