From 91403abb59349a02c64fe7b18d4b87445f4e77a9 Mon Sep 17 00:00:00 2001 From: Gavin Norman Date: Thu, 9 Aug 2018 17:26:55 +0200 Subject: [PATCH] Make restart work without calling stop first --- src/turtle/env/model/TestNode.d | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/turtle/env/model/TestNode.d b/src/turtle/env/model/TestNode.d index 477c3ab5..c2c6a63e 100644 --- a/src/turtle/env/model/TestNode.d +++ b/src/turtle/env/model/TestNode.d @@ -128,16 +128,25 @@ import ocean.task.Task; Restarts the fake node, reopening the listening socket on the same port determined in the initial call to start(). - Notes: - 1. Restarting the node *does not* clear any data in its storage - engine. To do that, call clear(). - 2. You must call stop() first, before calling restart(). + Note: Restarting the node *does not* clear any data in its storage + engine. To do that, call clear(). ***************************************************************************/ -// TODO: make this work without requiring stop first + public void restart ( ) { - verify(this.state == State.Stopped, "Node has not been stopped"); + with ( State ) switch ( this.state ) + { + case Stopped: + break; + case Running: + this.stop(); + break; + case Init: + default: + verify(false, "Node has not been started yet"); + break; + } this.restartListeners(); this.register(theScheduler.epoll);