From 2c683ac376b7e987534a47693963b07cb1ee331f Mon Sep 17 00:00:00 2001 From: Na Lee Ha Date: Mon, 9 Sep 2024 10:40:32 +0100 Subject: [PATCH] #1434 initialising lifecycle at start up so they are not shared across test classes --- .../java/org/finos/vuu/WebSocketApiJavaTestBase.java | 10 +++++++--- .../org/finos/vuu/wsapi/WebSocketApiTestBase.scala | 10 +++++++--- .../org/finos/vuu/wsapi/helpers/TestStartUp.scala | 5 +++-- .../org/finos/vuu/wsapi/helpers/TestVuuClient.scala | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/example/main-java/src/test/java/org/finos/vuu/WebSocketApiJavaTestBase.java b/example/main-java/src/test/java/org/finos/vuu/WebSocketApiJavaTestBase.java index bdf442f58..b8ada68b8 100644 --- a/example/main-java/src/test/java/org/finos/vuu/WebSocketApiJavaTestBase.java +++ b/example/main-java/src/test/java/org/finos/vuu/WebSocketApiJavaTestBase.java @@ -24,12 +24,16 @@ public abstract class WebSocketApiJavaTestBase { protected String tokenId; protected String sessionId; - protected Clock clock = new DefaultClock(); - protected LifecycleContainer lifecycle = new LifecycleContainer(clock); - protected TableDefContainer tableDefContainer = new TableDefContainer(); + protected Clock clock; + protected LifecycleContainer lifecycle; + protected TableDefContainer tableDefContainer; @BeforeAll public void setUp() { + clock = new DefaultClock(); + lifecycle = new LifecycleContainer(clock); + tableDefContainer = new TableDefContainer(); + vuuClient = testStartUp(); tokenId = vuuClient.createAuthToken(); var sessionOption = OptionConverters.toJava(vuuClient.login(tokenId, "testUser")); diff --git a/vuu/src/test/scala/org/finos/vuu/wsapi/WebSocketApiTestBase.scala b/vuu/src/test/scala/org/finos/vuu/wsapi/WebSocketApiTestBase.scala index 22882b2f3..679e78d9c 100644 --- a/vuu/src/test/scala/org/finos/vuu/wsapi/WebSocketApiTestBase.scala +++ b/vuu/src/test/scala/org/finos/vuu/wsapi/WebSocketApiTestBase.scala @@ -11,15 +11,19 @@ import org.scalatest.{BeforeAndAfterAll, GivenWhenThen} abstract class WebSocketApiTestBase extends AnyFeatureSpec with BeforeAndAfterAll with GivenWhenThen with Matchers { - implicit val timeProvider: Clock = new DefaultClock - implicit val lifecycle: LifecycleContainer = new LifecycleContainer - implicit val tableDefContainer: TableDefContainer = new TableDefContainer + implicit var timeProvider: Clock = _ + implicit var lifecycle: LifecycleContainer = _ + implicit var tableDefContainer: TableDefContainer = _ var viewServerClient: ViewServerClient = _ var vuuClient: TestVuuClient = _ var tokenId: String = _ var sessionId: String = _ override def beforeAll(): Unit = { + timeProvider = new DefaultClock + lifecycle = new LifecycleContainer + tableDefContainer = new TableDefContainer + vuuClient = testStartUp() tokenId = vuuClient.createAuthToken() diff --git a/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestStartUp.scala b/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestStartUp.scala index 8fe81d0fb..849ab1a98 100644 --- a/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestStartUp.scala +++ b/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestStartUp.scala @@ -1,5 +1,6 @@ package org.finos.vuu.wsapi.helpers +import com.typesafe.scalalogging.StrictLogging import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl} import org.finos.toolbox.lifecycle.LifecycleContainer import org.finos.toolbox.time.Clock @@ -14,7 +15,7 @@ import org.finos.vuu.net.ws.WebSocketClient class TestStartUp(moduleFactoryFunc: () => ViewServerModule)( implicit val timeProvider: Clock, implicit val lifecycle: LifecycleContainer, - implicit val tableDefContainer: TableDefContainer) { + implicit val tableDefContainer: TableDefContainer) extends StrictLogging { def startServerAndClient(): TestVuuClient = { @@ -61,7 +62,7 @@ class TestStartUp(moduleFactoryFunc: () => ViewServerModule)( //lifecycle registration is done in constructor of service classes, so sequence of create is important lifecycle.start() + logger.info(s"[TEST CLIENT] Starting vuu client at ${client.uri}") vuuClient } - } diff --git a/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestVuuClient.scala b/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestVuuClient.scala index fbbb4f3b1..c7035c2ea 100644 --- a/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestVuuClient.scala +++ b/vuu/src/test/scala/org/finos/vuu/wsapi/helpers/TestVuuClient.scala @@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap import scala.language.postfixOps import scala.reflect.ClassTag -class TestVuuClient(vsClient: ViewServerClient) extends StrictLogging{ +class TestVuuClient(vsClient: ViewServerClient) extends StrictLogging { type SessionId = String type Token = String