Skip to content

Commit

Permalink
finos#1434 initialising lifecycle at start up so they are not shared …
Browse files Browse the repository at this point in the history
…across test classes
  • Loading branch information
naleeha committed Sep 9, 2024
1 parent b92b210 commit 2c683ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2c683ac

Please sign in to comment.