public ServiceImpersonator(String serviceName) throws Exception { this(serviceName, new ServiceProperties()); }
public ServiceUnderTestModule(String serviceName) { this(serviceName, new ServiceProperties()); }
public RpcHandlerTest_RpcHandlerMock(MethodHandlerDictionary handlers, MetricRegistry registry, RpcHandlerMetrics handlerMetrics) { super(handlers, registry, handlerMetrics, new ServiceProperties(), null); }
public void setConfigurationManager(ConfigurationManager cm) { //we need to share the instance created by the config plugin injector if (cm == null) { logger.info("ConfigurationManager was null!"); if (serviceProperties == null) { logger.info("serviceProperties was null!"); serviceProperties = new ServiceProperties(); } this.configurationManager = new ConfigurationManager(serviceProperties); } else { this.configurationManager = cm; } }
protected HttpClientWrapper createHttpClientWrapper() { int port = locateTargetServicePort(); serviceEndpoint = new ServiceEndpoint(new ScheduledThreadPoolExecutor(1), "localhost:" + port, "", dependencyHealthCheck); HttpClientWrapper retval = new HttpClientWrapper(new ServiceProperties(), createHttpClient(), null, NoopTracerFactory.create()); retval.setLoadBalancer(this); return retval; }
@Before public void setup() { props = new ServiceProperties(); }
@Test public void testConfigure() { OrangeServletModule module = new OrangeServletModule(); Injector injector = Guice.createInjector(module, new TracingModule(new ServiceProperties())); assertThat(injector.getInstance(HealthServlet.class)).isNotNull(); assertThat(injector.getInstance(RpcServlet.class)).isNotNull(); } }
@Before public void setup() throws RpcCallException { handlerDictionary = new MethodHandlerDictionary(); handlerDictionary.put("a", null); ServiceMethodHandlerUnderTest mockHandlerThrowsRpcCallEx = new ServiceMethodHandlerUnderTest(); handlerDictionary.put("jsonRpcWithException", mockHandlerThrowsRpcCallEx); metricRegistry = mock(MetricRegistry.class); when(metricRegistry.counter(anyString())).thenReturn(mock(Counter.class)); when(metricRegistry.timer(anyString())).thenReturn(mock(Timer.class)); handlerMetrics = mock(RpcHandlerMetrics.class); when(handlerMetrics.getMethodTimer(any(), any(), any())).thenReturn(mock(GoTimer.class)); servlet = new JsonHandler(handlerDictionary, metricRegistry, handlerMetrics, new ServiceProperties(), null); }
@Test public void testSetterAndGetter() { InjectionModule module = new InjectionModule(new ServiceProperties()); MethodHandlerDictionary dict = new MethodHandlerDictionary(); module.setMethodHandlerDictionary(dict); assertThat(module.getMethodHandlers()).isEqualTo(dict); }
@Before public void setup() { ServiceProperties properties = new ServiceProperties(); HttpClient httpClient = mock(HttpClient.class); HttpClientWrapper wrapper = new HttpClientWrapper(properties, httpClient, null, null); lb = new LoadBalancerImpl(properties, wrapper); dependencyHealthCheck = mock(ServiceDependencyHealthCheck.class); }
@Before public void setup() { ServiceProperties props = new ServiceProperties(); InjectionModule module = new InjectionModule(props); Injector injector = Guice.createInjector(module, new TracingModule(props)); manager = injector.getInstance(HealthCheckManager.class); }
@Before public void setup() { ServiceProperties props = new ServiceProperties(); manager = new RegistrationManager(props, null); Map<String, ServiceMethodHandler<? extends Message, ? extends Message>> handlers = new HashMap<>(); handlers.put("test", new DummyMethodHandler()); manager.setRegisteredHandlers(handlers); }
@Before public void setup() throws Exception { HttpClient httpClient = mock(HttpClient.class); response = mock(ContentResponse.class); when(response.getStatus()).thenReturn(200); when(response.getContentAsString()).thenReturn(healthInfo); HttpFields headers = new HttpFields(); headers.add(CONSUL_INDEX, "42"); when(response.getHeaders()).thenReturn(headers); Request request = mock(Request.class); when(httpClient.newRequest(anyString())).thenReturn(request); when(request.send()).thenReturn(response); props = new ServiceProperties(); props.addProperty(ServiceProperties.REGISTRY_SERVER_KEY, "localhost:1234"); worker = new RegistrationMonitorWorker(httpClient, props, mock(ServiceDependencyHealthCheck.class)); worker.setServiceName("foobar"); }
@Before public void setup() { props = new ServiceProperties(); healthcheck = new DatabaseMigrationContributor(props); connectionVerifier = mock(ConnectionVerifier.class); migrator = new SchemaMigrator(props, healthcheck, connectionVerifier, new Flyway()); }
@Test public void buildSubscriber() throws Exception { ServiceProperties properties = new ServiceProperties(); KafkaSubscriberFactory<String> factory = new KafkaSubscriberFactory<>(properties, null, null); subscriber = factory.newBuilder("test", this).build(); }
@Before public void setup() { props = new ServiceProperties(); props.addProperty("prop1", "val1"); props.addProperty("prop2", "val2"); cm = new ConfigurationManager(props); }
@Test public void buildSubscriber() throws Exception { ServiceProperties properties = new ServiceProperties(); KafkaSubscriberFactory factory = new KafkaSubscriberFactory(properties, null, null); subscriber = factory.newBuilder("test", this).build(); }
private ServiceProperties fillServiceProperties() { DockerPort kafka1 = docker.containers().container("kafka1").port(9092); DockerPort kafka2 = docker.containers().container("kafka2").port(9092); DockerPort kafka3 = docker.containers().container("kafka2").port(9092); StringBuilder kafkaServer = new StringBuilder(); kafkaServer.append(kafka2.inFormat("$HOST:$EXTERNAL_PORT")); kafkaServer.append(","); kafkaServer.append(kafka1.inFormat("$HOST:$EXTERNAL_PORT")); kafkaServer.append(","); kafkaServer.append(kafka3.inFormat("$HOST:$EXTERNAL_PORT")); String[] args = new String[2]; args[0] = "-" + ServiceProperties.KAFKA_SERVER_KEY; args[1] = kafkaServer.toString(); ServiceProperties serviceProperties = new ServiceProperties(); serviceProperties.initialize(args); return serviceProperties; }
public RpcClientIntegrationTest(String featureFlag) { this.featureFlag = featureFlag; TestInjectionModule module = new TestInjectionModule(featureFlag); ServiceProperties props = new ServiceProperties(); props.addProperty(FeatureFlags.FLAG_EXPOSE_ERRORS_HTTP, featureFlag); props.addProperty(FeatureFlags.DISABLE_RPC_INSTANCE_RETRY, "true"); props.addProperty(ServiceProperties.REGISTRY_SERVER_KEY, "localhost:65432"); props.addProperty("registry", "consul"); module.setServiceProperties(props); Injector injector = Guice.createInjector(module, new ServiceRegistryModule(props), new TracingModule(props)); httpClient = (MockHttpClient)injector.getInstance(HttpClient.class); clientFactory = injector.getInstance(RpcClientFactory.class); loadBalancerFactory = injector.getInstance(LoadBalancerFactory.class); rpcClient = clientFactory.newClient(serviceName, "testing", FrameworkTest.Foobar.class).build(); loadBalancer = (LoadBalancerImpl) loadBalancerFactory.getLoadBalancer(serviceName); dependencyHealthCheck = mock(ServiceDependencyHealthCheck.class); }
@Before public void setUp() throws Exception { ServiceProperties properties = new ServiceProperties(); properties.addProperty("kafkaServer", "localhost:9092"); KafkaSubscriberFactory<String> kafkaFactory = new KafkaSubscriberFactory<>(properties, null, null); eventHandler = new ServiceTestEventHandler(kafkaFactory); eventHandler.initialize("events"); }