Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
7d62b3af
Commit
7d62b3af
authored
Jun 15, 2021
by
Christina
Browse files
add simthreadstate to commandhandlertest
parent
8f00d2a9
Pipeline
#527719
passed with stages
in 137 minutes and 57 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereManager/src/org/vadere/manager/RemoteScenarioRun.java
View file @
7d62b3af
...
...
@@ -53,10 +53,13 @@ public class RemoteScenarioRun extends ScenarioRun implements RemoteRunListener
return
true
;
}
synchronized
public
SimThreadState
getCurrentSimThreadState
(){
synchronized
public
SimThreadState
getCurrentSimThreadState
(){
if
(
simulation
==
null
){
return
SimThreadState
.
INIT
;
}
else
if
(
simulation
.
getThreadState
()
==
null
){
return
SimThreadState
.
INIT
;
}
return
simulation
.
getThreadState
();
}
...
...
VadereManager/src/org/vadere/manager/traci/commandHandler/ControlCommandHandler.java
View file @
7d62b3af
...
...
@@ -57,7 +57,7 @@ public class ControlCommandHandler extends CommandHandler<ControlVar> {
TraCICloseCommand
cmd
=
(
TraCICloseCommand
)
rawCmd
;
remoteManager
.
setClientCloseCommandReceived
(
true
);
if
(
remoteManager
.
getCurrentSimThreadState
().
equals
(
SimThreadState
.
MAIN_LOOP
))
{
logger
.
info
(
"Current simulation run in main loop. Stop simulation."
);
...
...
VadereManager/tests/org/vadere/manager/traci/commandHandler/ControlCommandHandlerTest.java
View file @
7d62b3af
...
...
@@ -17,6 +17,7 @@ import org.vadere.manager.traci.response.TraCIGetVersionResponse;
import
org.vadere.manager.traci.response.TraCIResponse
;
import
org.vadere.manager.traci.response.TraCISimTimeResponse
;
import
org.vadere.manager.traci.response.TraCIStatusResponse
;
import
org.vadere.simulator.control.simulation.SimThreadState
;
import
java.util.HashMap
;
...
...
@@ -31,8 +32,7 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
private
ControlCommandHandler
ctrCmdHandler
=
ControlCommandHandler
.
instance
;
@Test
public
void
process_close
()
{
private
void
process_close_
(
SimThreadState
simThreadState
)
{
TraCICmd
traciCmd
=
TraCICmd
.
CLOSE
;
CmdType
cmdType
=
traciCmd
.
type
;
...
...
@@ -40,6 +40,7 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
TraCICloseCommand
rawCmd
=
(
TraCICloseCommand
)
getFirstCommand
(
TraCICloseCommand
.
build
());
RemoteManager
rm
=
mock
(
RemoteManager
.
class
,
Mockito
.
RETURNS_DEEP_STUBS
);
doNothing
().
when
(
rm
).
setClientCloseCommandReceived
(
true
);
when
(
rm
.
getCurrentSimThreadState
()).
thenReturn
(
simThreadState
);
TraCICommand
cmd
=
ctrCmdHandler
.
process_close
(
rawCmd
,
rm
);
testTraCICommand
(
cmd
,
traciCmd
,
cmdType
);
...
...
@@ -50,6 +51,23 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
TraCIResponse
res
=
closeCommand
.
getResponse
();
}
@Test
public
void
process_close
(){
process_close_
(
SimThreadState
.
INIT
);
}
@Test
public
void
process_close_mainLoop
(){
process_close_
(
SimThreadState
.
MAIN_LOOP
);
}
@Test
public
void
process_close_postLoop
(){
process_close_
(
SimThreadState
.
POST_LOOP
);
}
@Test
public
void
process_simStep
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment