public synchronized void dispose() { for (Map.Entry<String, Iterable<GivenSpecRule>> blade : givenRulesPerBlade.entrySet()) { for (GivenSpecRule givenSpecRule : blade.getValue()) { givenSpecRule.onTearDown(contextLocal(bladeContextId(blade.getKey()))); } } }
public synchronized void dispose() { for (Map.Entry<String, Iterable<GivenSpecRule>> blade : givenRulesPerBlade.entrySet()) { for (GivenSpecRule givenSpecRule : blade.getValue()) { givenSpecRule.onTearDown(contextLocal(bladeContextId(blade.getKey()))); } } }
private synchronized Iterable<GivenSpecRule> getSpecRulesForCurrentBlade() { String currentBlade = Blade.current(); Iterable<GivenSpecRule> givenSpecRules = givenRulesPerBlade.get(currentBlade); if (givenSpecRules == null) { givenSpecRules = newArrayList(transform(givenSpecRuleSuppliers, Suppliers.<GivenSpecRule>supplierFunction())); for (GivenSpecRule givenSpecRule : givenSpecRules) { givenSpecRule.onSetup(contextLocal(bladeContextId(currentBlade))); } givenRulesPerBlade.put(currentBlade, givenSpecRules); } return givenSpecRules; }
private static Factory.Builder newFactoryBuilder(String serverId) { Factory.Builder builder = newFactoryBuilder(); if (serverId != null) { builder.addLocalMachines(Factory.LocalMachines.contextLocal(serverId)); // make server id and base url accessible in the factory components Optional<WebServer> serverById = WebServers.getServerById(serverId); builder .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.id", serverId))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.baseUrl", serverById.isPresent() ? serverById.get().baseUrl() : ""))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.port", serverById.isPresent() ? String.valueOf(serverById.get().getPort()) : ""))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.type", serverById.isPresent() ? serverById.get().getServerType() : ""))) ; } return builder; }
private static Factory.Builder newFactoryBuilder(String serverId) { Factory.Builder builder = newFactoryBuilder(); if (serverId != null) { builder.addLocalMachines(Factory.LocalMachines.contextLocal(serverId)); // make server id and base url accessible in the factory components Optional<WebServer> serverById = WebServers.getServerById(serverId); builder .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.id", serverId))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.baseUrl", serverById.isPresent() ? serverById.get().baseUrl() : ""))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.port", serverById.isPresent() ? String.valueOf(serverById.get().getPort()) : ""))) .addMachine(new SingletonFactoryMachine<>( 0, NamedComponent.of(String.class, "restx.server.type", serverById.isPresent() ? serverById.get().getServerType() : ""))) ; } return builder; }
public RunningServer(WebServer server, RestxSpecRunner runner, RestxSpecRepository repository, UUIDGenerator uuidGenerator, RestxErrors errors, RunningServerSettings settings) { this.server = server; this.runner = runner; this.repository = repository; this.uuidGenerator = uuidGenerator; this.errors = errors; storeLocation = Paths.get(settings.targetTestsRoot()); objectMapper = new ObjectMapper(); objectMapper.registerModule(new JodaModule()); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); lastResults = loadLastResults(); System.setOut(out); System.setErr(err); Factory.LocalMachines.contextLocal(server.getServerId()).addMachine( new SingletonFactoryMachine<>(0, NamedComponent.of(RunningServer.class, "RunningServer", this))); }
public RunningServer(WebServer server, RestxSpecRunner runner, RestxSpecRepository repository, UUIDGenerator uuidGenerator, RestxErrors errors, RunningServerSettings settings) { this.server = server; this.runner = runner; this.repository = repository; this.uuidGenerator = uuidGenerator; this.errors = errors; storeLocation = Paths.get(settings.targetTestsRoot()); objectMapper = new ObjectMapper(); objectMapper.registerModule(new JodaModule()); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); lastResults = loadLastResults(); System.setOut(out); System.setErr(err); Factory.LocalMachines.contextLocal(server.getServerId()).addMachine( new SingletonFactoryMachine<>(0, NamedComponent.of(RunningServer.class, "RunningServer", this))); }
private static Factory.Builder newFactoryBuilder(String serverId, Optional<String> bladeId, Optional<String> threadLocalId, String mode) { Factory.Builder builder = newFactoryBuilder(serverId); if (threadLocalId.isPresent()) { builder.addLocalMachines(Factory.LocalMachines.threadLocalFrom(threadLocalId.get())); } if (bladeId.isPresent()) { builder.addLocalMachines(Factory.LocalMachines.contextLocal(Blade.contextId(serverId, bladeId.get()))); } builder.addMachine(new SingletonFactoryMachine<>( -100000, NamedComponent.of(String.class, "restx.mode", mode))); return builder; }
private static Factory.Builder newFactoryBuilder(String serverId, Optional<String> bladeId, Optional<String> threadLocalId, String mode) { Factory.Builder builder = newFactoryBuilder(serverId); if (threadLocalId.isPresent()) { builder.addLocalMachines(Factory.LocalMachines.threadLocalFrom(threadLocalId.get())); } if (bladeId.isPresent()) { builder.addLocalMachines(Factory.LocalMachines.contextLocal(Blade.contextId(serverId, bladeId.get()))); } builder.addMachine(new SingletonFactoryMachine<>( -100000, NamedComponent.of(String.class, "restx.mode", mode))); return builder; }
private synchronized Iterable<GivenSpecRule> getSpecRulesForCurrentBlade() { String currentBlade = Blade.current(); Iterable<GivenSpecRule> givenSpecRules = givenRulesPerBlade.get(currentBlade); if (givenSpecRules == null) { givenSpecRules = newArrayList(transform(givenSpecRuleSuppliers, Suppliers.<GivenSpecRule>supplierFunction())); for (GivenSpecRule givenSpecRule : givenSpecRules) { givenSpecRule.onSetup(contextLocal(bladeContextId(currentBlade))); } givenRulesPerBlade.put(currentBlade, givenSpecRules); } return givenSpecRules; }
public static Factory.LocalMachines bladeLocalMachines(String serverId) { return Factory.LocalMachines.contextLocal(contextId(serverId, current())); } }
public void setup() throws Exception { System.out.println("starting server"); server = webServerSupplier.newWebServer(WebServers.findAvailablePort()); contextLocal(server.getServerId()).set("restx.mode", getMode()); afterServerCreated(); server.start(); afterServerStarted(); System.out.println("server started"); }
public static Factory.LocalMachines bladeLocalMachines(String serverId) { return Factory.LocalMachines.contextLocal(contextId(serverId, current())); } }
public void setup() throws Exception { System.out.println("starting server"); server = webServerSupplier.newWebServer(WebServers.findAvailablePort()); contextLocal(server.getServerId()).set("restx.mode", getMode()); afterServerCreated(); server.start(); afterServerStarted(); System.out.println("server started"); }