@Test public void testReadConfigWithValidEndpoints() throws Exception { List<String> endPoint1Services = ImmutableList.of("do.something", "delete.someting"); JSONObject service1 = new JSONObject(); service1.put("result", endPoint1Services); List<String> endPoint2Services = ImmutableList.of("weather.get"); JSONObject service2 = new JSONObject(); service2.put("result", endPoint2Services); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service1.toString())); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service2.toString())); replay(); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); Multimap<String, String> mergedServices = LinkedHashMultimap.create(configuredServices); mergedServices.putAll(endPoint1, endPoint1Services); mergedServices.putAll(endPoint2, endPoint2Services); assertEquals(mergedServices, LinkedHashMultimap.create(services)); }
@Test public void testReadConfigWithValidEndpoints() throws Exception { List<String> endPoint1Services = ImmutableList.of("do.something", "delete.someting"); JSONObject service1 = new JSONObject(); service1.put("result", endPoint1Services); List<String> endPoint2Services = ImmutableList.of("weather.get"); JSONObject service2 = new JSONObject(); service2.put("result", endPoint2Services); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service1.toString())); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service2.toString())); replay(); fetcher.setSecurityTokenCodec( new BasicSecurityTokenCodec() ); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); Multimap<String, String> mergedServices = LinkedHashMultimap.create(configuredServices); mergedServices.putAll(endPoint1, endPoint1Services); mergedServices.putAll(endPoint2, endPoint2Services); assertEquals(mergedServices, LinkedHashMultimap.create(services)); }
@Test public void testReadConfigWithValidEndpoints() throws Exception { List<String> endPoint1Services = ImmutableList.of("do.something", "delete.someting"); JSONObject service1 = new JSONObject(); service1.put("result", endPoint1Services); List<String> endPoint2Services = ImmutableList.of("weather.get"); JSONObject service2 = new JSONObject(); service2.put("result", endPoint2Services); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service1.toString())); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse(service2.toString())); replay(); fetcher.setSecurityTokenCodec( new BasicSecurityTokenCodec() ); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); Multimap<String, String> mergedServices = LinkedHashMultimap.create(configuredServices); mergedServices.putAll(endPoint1, endPoint1Services); mergedServices.putAll(endPoint2, endPoint2Services); assertEquals(mergedServices, LinkedHashMultimap.create(services)); }
@Test public void testReadConfigEndpointsDown() throws Exception { EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }
@Test public void testReadConfigEndpointsDown() throws Exception { EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); fetcher.setSecurityTokenCodec( new BasicSecurityTokenCodec() ); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }
@Test public void testReadConfigEndpointsDown() throws Exception { EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); fetcher.setSecurityTokenCodec( new BasicSecurityTokenCodec() ); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }
@Test public void testReadConfigNoEndpoints() throws Exception { JSONObject config = createConfig(); config.getJSONObject("default"). getJSONObject(DefaultServiceFetcher.GADGETS_FEATURES_CONFIG) .remove(DefaultServiceFetcher.OSAPI_FEATURE_CONFIG); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }
@Test public void testReadConfigNoEndpoints() throws Exception { JSONObject config = createConfig(); config.getJSONObject("default"). getJSONObject(DefaultServiceFetcher.GADGETS_FEATURES_CONFIG) .remove(DefaultServiceFetcher.OSAPI_FEATURE_CONFIG); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }
@Test public void testReadConfigNoEndpoints() throws Exception { JSONObject config = createConfig(); config.getJSONObject("default"). getJSONObject(DefaultServiceFetcher.GADGETS_FEATURES_CONFIG) .remove(DefaultServiceFetcher.OSAPI_FEATURE_CONFIG); JsonContainerConfig containerConfig = new JsonContainerConfig(config, Expressions.forTesting(new Functions())); fetcher = new DefaultServiceFetcher(containerConfig, mockFetcher); EasyMock.expect(mockFetcher.fetch(EasyMock.isA(HttpRequest.class))).andReturn( new HttpResponse("")).anyTimes(); replay(); Multimap<String, String> services = fetcher.getServicesForContainer("default", "dontcare"); verify(); assertEquals(configuredServices, services); }