@Before public void setUp() throws Throwable { waitForServiceAvailability(PKSEndpointFactoryService.SELF_LINK, PKSCreateEndpointService.SELF_LINK); sender = host.getTestRequestSender(); }
private List<ExampleServiceState> populateData(String factoryLink) { List<Operation> ops = new ArrayList<>(); for (int i = 0; i < this.count; i++) { ExampleServiceState state = new ExampleServiceState(); state.name = "foo-" + i; state.documentSelfLink = state.name; Operation post = Operation.createPost(this.host, factoryLink).setBody(state); ops.add(post); } return this.host.getTestRequestSender().sendAndWait(ops, ExampleServiceState.class); }
private List<ExampleService.ExampleServiceState> getExampleServices(List<ExampleService.ExampleServiceState> exampleStates) { List<Operation> ops = new ArrayList<>(); for (ExampleService.ExampleServiceState st : exampleStates) { URI serviceUri = UriUtils.buildUri(this.host.getPeerHost(), st.documentSelfLink); Operation get = Operation.createGet(serviceUri); ops.add(get); } return this.host.getTestRequestSender().sendAndWait(ops, ExampleService.ExampleServiceState.class); }
@Override @Before public void setUp() throws Throwable { sender = host.getTestRequestSender(); startServices(host); host.waitForServiceAvailable(LongURIGetService.SELF_LINK, ElasticPlacementZoneConfigurationService.SELF_LINK); }
private void updateExampleServices(List<ExampleService.ExampleServiceState> exampleStates) { List<Operation> ops = new ArrayList<>(); for (ExampleService.ExampleServiceState st : exampleStates) { ExampleService.ExampleServiceState s = new ExampleService.ExampleServiceState(); s.counter = ++st.counter; URI serviceUri = UriUtils.buildUri(this.host.getPeerHost(), st.documentSelfLink); Operation patch = Operation.createPatch(serviceUri).setBody(s); ops.add(patch); } this.host.getTestRequestSender().sendAndWait(ops); }
@Before public void setup() { ServiceConfigUpdateRequest body = ServiceConfigUpdateRequest.create(); body.addOptions = EnumSet.of(ServiceOption.INSTRUMENTATION); this.host.getTestRequestSender().sendAndWait( Operation.createPatch(UriUtils.buildConfigUri(this.host, ServiceUriPaths.CORE_DOCUMENT_INDEX)).setBody( body )); }
private void setRequestLogging(VerificationHost newHost, boolean enabled) { ServiceHost.RequestLoggingInfo loggingInfo = new ServiceHost.RequestLoggingInfo(); loggingInfo.enabled = enabled; ServiceHostManagementService.ConfigureInboundRequestLogging request = new ServiceHostManagementService.ConfigureInboundRequestLogging(); request.kind = ServiceHostManagementService.ConfigureInboundRequestLogging.KIND; request.loggingInfo = loggingInfo; this.host.getTestRequestSender().sendAndWait(Operation.createPatch( newHost, ServiceUriPaths.CORE_MANAGEMENT).setBody(request)); }
private void setRequestLogging(VerificationHost newHost, boolean enabled) { ServiceHost.RequestLoggingInfo loggingInfo = new ServiceHost.RequestLoggingInfo(); loggingInfo.enabled = enabled; ServiceHostManagementService.ConfigureInboundRequestLogging request = new ServiceHostManagementService.ConfigureInboundRequestLogging(); request.kind = ServiceHostManagementService.ConfigureInboundRequestLogging.KIND; request.loggingInfo = loggingInfo; this.host.getTestRequestSender().sendAndWait(Operation.createPatch( newHost, ServiceUriPaths.CORE_MANAGEMENT).setBody(request)); }
@Test public void testNonExistentFile() { String badFile = "/wikipedia.docx"; FailureResponse response = this.host.getTestRequestSender() .sendAndWaitFailure(Operation.createGet(this.host, SELF_LINK + badFile)); assertEquals(Operation.STATUS_CODE_NOT_FOUND, response.op.getStatusCode()); }
@Test public void testSimpleServe() { String existingFile = "/serviceHostState.json"; Operation re = this.host.getTestRequestSender() .sendAndWait(Operation.createGet(this.host, SELF_LINK + existingFile)); ServiceHostState hs = re.getBody(ServiceHostState.class); assertEquals(this.host.getId(), hs.id); }
@Test public void returnsLocalizedServiceResponseTestWithOperationProcessingChain() throws Throwable { URI uri = UriUtils.buildUri(host, TestFailingStatefulService.FACTORY_LINK); Operation post = Operation .createDelete(uri) .setReferer(host.getReferer()) .addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER, Locale.GERMAN.getLanguage()); TestRequestSender sender = this.host.getTestRequestSender(); FailureResponse result = sender.sendAndWaitFailure(post); ServiceErrorResponse response = result.op.getErrorResponseBody(); assertEquals(ERROR_MESSAGE_GERMAN, response.message); }
@Test public void returnsLocalizedServiceResponseTestWithInnerOperation() throws Throwable { URI uri = UriUtils.buildUri(host, TestFailingStatefulService.FACTORY_LINK); Operation post = Operation .createPost(uri) .setReferer(host.getReferer()) .addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER, Locale.GERMAN.getLanguage()); TestRequestSender sender = this.host.getTestRequestSender(); FailureResponse result = sender.sendAndWaitFailure(post); ServiceErrorResponse response = result.op.getErrorResponseBody(); assertEquals(ERROR_MESSAGE_GERMAN, response.message); }
@Test public void returnsLocalizedServiceResponseTestWithInnerOperation() throws Throwable { URI uri = UriUtils.buildUri(host, TestFailingStatefulService.FACTORY_LINK); Operation post = Operation .createPost(uri) .setReferer(host.getReferer()) .addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER, Locale.GERMAN.getLanguage()); TestRequestSender sender = this.host.getTestRequestSender(); FailureResponse result = sender.sendAndWaitFailure(post); ServiceErrorResponse response = result.op.getErrorResponseBody(); assertEquals(ERROR_MESSAGE_GERMAN, response.message); }
@Test public void returnsLocalizedServiceResponseTestWithOperationProcessingChain() throws Throwable { URI uri = UriUtils.buildUri(host, TestFailingStatefulService.FACTORY_LINK); Operation post = Operation .createDelete(uri) .setReferer(host.getReferer()) .addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER, Locale.GERMAN.getLanguage()); TestRequestSender sender = this.host.getTestRequestSender(); FailureResponse result = sender.sendAndWaitFailure(post); ServiceErrorResponse response = result.op.getErrorResponseBody(); assertEquals(ERROR_MESSAGE_GERMAN, response.message); }
@Before public void setUp() throws Throwable { waitForServiceAvailability(PKSEndpointFactoryService.SELF_LINK); sender = host.getTestRequestSender(); host.startService(Operation.createPost(UriUtils.buildUri(host, MockKubernetesHostAdapterService.class)), new MockKubernetesHostAdapterService()); waitForServiceAvailability(MockKubernetesHostAdapterService.SELF_LINK); }
@Test public void childOptionsInConfigGetRequest() throws Throwable { EnumSet<ServiceOption> exampleOptions = new ExampleService().getOptions(); URI configUri = UriUtils.buildConfigUri(this.host, ExampleService.FACTORY_LINK); Operation get = Operation.createGet(configUri); FactoryServiceConfiguration config = this.host.getTestRequestSender().sendAndWait(get, FactoryServiceConfiguration.class); assertEquals(exampleOptions, config.childOptions); }
@Test public void testFactoryPostHandling() throws Throwable { startFactoryService(); TestRequestSender sender = host.getTestRequestSender(); idempotentPostReturnsUpdatedOpBody(sender); checkDerivedSelfLinkWhenProvidedSelfLinkIsJustASuffix(sender); checkDerivedSelfLinkWhenProvidedSelfLinkAlreadyContainsAPath(sender); checkSelfLinkWithAcceptableChars(sender); failPostWhenProvidedSelfLinkContainsUriPathChar(sender); failPostWhenProvidedSelfLinkContainsInvalidPathChar(sender); }
@Test public void testFactoryPostHandling() throws Throwable { startFactoryService(); TestRequestSender sender = host.getTestRequestSender(); idempotentPostReturnsUpdatedOpBody(sender); checkDerivedSelfLinkWhenProvidedSelfLinkIsJustASuffix(sender); checkDerivedSelfLinkWhenProvidedSelfLinkAlreadyContainsAPath(sender); checkSelfLinkWithAcceptableChars(sender); failPostWhenProvidedSelfLinkContainsUriPathChar(sender); failPostWhenProvidedSelfLinkContainsInvalidPathChar(sender); }
@Before public void setUp() throws Throwable { sender = host.getTestRequestSender(); host.startServiceAndWait(ConfigurationFactoryService.class, ConfigurationFactoryService.SELF_LINK); manager = new ExtensibilitySubscriptionManager(); host.startServiceAndWait(manager, ExtensibilitySubscriptionManager.SELF_LINK, null); host.startServiceAndWait(ExtensibilitySubscriptionFactoryService.class, ExtensibilitySubscriptionFactoryService.SELF_LINK); host.startFactory(new EventTopicService()); waitForServiceAvailability(EventTopicService.FACTORY_LINK); }
@Before public void setUp() throws Throwable { HostInitKubernetesAdapterServiceConfig.startServices(host, true); host.startService(Operation.createPost(UriUtils.buildUri(host, PKSPlanListService.class)), new PKSPlanListService()); waitForServiceAvailability(MockPKSAdapterService.SELF_LINK); waitForServiceAvailability(PKSPlanListService.SELF_LINK); waitForServiceAvailability(PKSEndpointFactoryService.SELF_LINK); waitForServiceAvailability(ComputeService.FACTORY_LINK); sender = host.getTestRequestSender(); }