Refine search
@Test(timeout = 10000) public void testWriterClosed() throws Exception { server.stop().join(); assertThat(loggingService.closed).isOne(); } }
@Test public void returnsTasksFromAllPages() { ECSAsyncClient ecs = mock(FakeECSAsyncClient.class, Mockito.CALLS_REAL_METHODS); TaskLister tasks = new TaskLister(ecs, CLUSTER_ARN); List<ClusterSnapshot.Task> describe = tasks.describe().join(); assertThat( describe.stream().map(ClusterSnapshot.Task::getArn).collect(Collectors.toList()), containsInAnyOrder("1", "2", "3", "4", "5", "6")); }
private ArmeriaClientHttpResponse response(ArmeriaHttpClientResponseSubscriber subscriber, HttpHeaders expectedHttpHeaders) { await().until(() -> subscriber.httpHeadersFuture().isDone()); final HttpHeaders h = subscriber.httpHeadersFuture().join(); assertThat(h).isEqualTo(expectedHttpHeaders); return new ArmeriaClientHttpResponse(h, subscriber.toResponseBodyPublisher(), DataBufferFactoryWrapper.DEFAULT); } }
@Test public void returnsContainerInstancesFromAllPages() { ECSAsyncClient ecs = mock(FakeECSAsyncClient.class, Mockito.CALLS_REAL_METHODS); ContainerInstanceLister containerInstances = new ContainerInstanceLister(ecs, CLUSTER_1); List<ClusterSnapshot.ContainerInstance> describe = containerInstances.describe().join(); assertThat( describe .stream() .map(ClusterSnapshot.ContainerInstance::getArn) .collect(Collectors.toList()), containsInAnyOrder("1", "2", "3", "4", "5", "6")); }
@Test public void shouldRespondAuthnRequest_HttpRedirect() throws Exception { final AggregatedHttpMessage resp = client.get("/redirect").aggregate().join(); assertThat(resp.status()).isEqualTo(HttpStatus.FOUND); // Check the order of the parameters in the quest string. final String location = resp.headers().get(HttpHeaderNames.LOCATION); final Pattern p = Pattern.compile( "http://idp\\.example\\.com/saml/sso/redirect\\?" + "SAMLRequest=([^&]+)&RelayState=([^&]+)&SigAlg=([^&]+)&Signature=(.+)$"); assertThat(p.matcher(location).matches()).isTrue(); final QueryStringDecoder decoder = new QueryStringDecoder(location, true); assertThat(decoder.parameters().get(SIGNATURE_ALGORITHM).get(0)).isEqualTo(signatureAlgorithm); }
@Test public void testDeleteReservedNS() throws Exception { boolean exceptionCaught = false; try { admin.deleteNamespace(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR).join(); } catch (Exception exp) { LOG.warn(exp.toString(), exp); exceptionCaught = true; } finally { assertTrue(exceptionCaught); } try { admin.deleteNamespace(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR).join(); } catch (Exception exp) { LOG.warn(exp.toString(), exp); exceptionCaught = true; } finally { assertTrue(exceptionCaught); } }
@Test public void success() { final AggregatedHttpMessage response = client.get("/hello/Spring").aggregate().join(); assertThat(response.status()).isEqualTo(HttpStatus.OK); assertThat(response.content().toStringUtf8()) .isEqualTo("Hello, Spring! This message is from Armeria annotated service!"); }
@Test public void healthCheck() throws Exception { final AggregatedHttpMessage res = client.get("/internal/healthcheck").aggregate().join(); assertThat(res.status()).isEqualTo(HttpStatus.OK); assertThat(res.content().toStringUtf8()).isEqualTo("ok"); } }
@Test public void hello() throws Exception { final AggregatedHttpMessage res = client.get("/hello").aggregate().join(); assertThat(res.status()).isEqualTo(HttpStatus.OK); assertThat(res.content().toStringUtf8()).isEqualTo("Hello, World"); }
@Test public void index() { final AggregatedHttpMessage res = client.get("/").aggregate().join(); assertThat(res.status()).isEqualTo(HttpStatus.OK); assertThat(res.content().toStringUtf8()).isEqualTo("index"); }
@Test public void testDisableCatalogTable() throws Exception { try { this.admin.disableTable(TableName.META_TABLE_NAME).join(); fail("Expected to throw ConstraintException"); } catch (Exception e) { } // Before the fix for HBASE-6146, the below table creation was failing as the hbase:meta table // actually getting disabled by the disableTable() call. createTableWithDefaultConf(tableName); }
@Test public void shouldRespondAuthnRequest_HttpPost() throws Exception { final AggregatedHttpMessage resp = client.get("/post").aggregate().join(); assertThat(resp.status()).isEqualTo(HttpStatus.OK); assertThat(resp.headers().contentType()).isEqualTo(MediaType.HTML_UTF_8); final Document doc = Jsoup.parse(resp.content().toStringUtf8()); assertThat(doc.body().attr("onLoad")).isEqualTo("document.forms[0].submit()"); // SAMLRequest will be posted to the IdP's SSO URL. final Element form = doc.body().child(0); assertThat(form.attr("method")).isEqualTo("post"); assertThat(form.attr("action")).isEqualTo("http://idp.example.com/saml/sso/post"); assertThat(form.child(0).attr("name")).isEqualTo(SAML_REQUEST); assertThat(form.child(1).attr("name")).isEqualTo(RELAY_STATE); }
@Test public void shouldGetHelloFromRestController() throws Exception { protocols.forEach(scheme -> { final HttpClient client = HttpClient.of(clientFactory, scheme + "://example.com:" + port); final AggregatedHttpMessage response = client.get("/hello").aggregate().join(); assertThat(response.content().toStringUtf8()).isEqualTo("hello"); }); }
@Test public void testPathPatternService() { AggregatedHttpMessage res; res = client.get("/pathPattern/path/armeria").aggregate().join(); assertThat(res.content().toStringUtf8()).isEqualTo("path: armeria"); assertThat(res.status()).isEqualTo(HttpStatus.OK); res = client.get("/pathPattern/regex/armeria").aggregate().join(); assertThat(res.content().toStringUtf8()).isEqualTo("regex: armeria"); assertThat(res.status()).isEqualTo(HttpStatus.OK); res = client.get("/pathPattern/glob/armeria").aggregate().join(); assertThat(res.content().toStringUtf8()).isEqualTo("glob: armeria"); assertThat(res.status()).isEqualTo(HttpStatus.OK); }
@Test public void testCreateAndDelete() throws Exception { String testName = "testCreateAndDelete"; String nsName = prefix + "_" + testName; // create namespace and verify admin.createNamespace(NamespaceDescriptor.create(nsName).build()).join(); assertEquals(3, admin.listNamespaceDescriptors().get().size()); // delete namespace and verify admin.deleteNamespace(nsName).join(); assertEquals(2, admin.listNamespaceDescriptors().get().size()); }