@Override public void doFilter(HttpServletRequest wrappedRequest) { String id = wrappedRequest.getSession().getId(); assertThat(id).isNotNull(); assertThat(wrappedRequest.getSession().getId()).isEqualTo(id); SessionRepositoryFilterTests.this.request.setAttribute(ID_ATTR, id); } });
@Test public void deserializeGrantedAuthorityTest() throws IOException { SimpleGrantedAuthority authority = mapper.readValue(AUTHORITY_JSON, SimpleGrantedAuthority.class); assertThat(authority).isNotNull(); assertThat(authority.getAuthority()).isNotNull().isEqualTo("ROLE_USER"); }
@Test public void testToStringDoesntAttach() { assertThat(onDemand.toString()).isNotNull(); verify(mockExtensionFactory, never()).attach(any(), any()); }
@Test public void testGetAuthority() throws Exception { assertThat(authority.getAuthority()).isNotNull(); assertThat(authority.getAuthority()).isEqualTo("testRole"); } }
@Test public void text() { CryptoAssumptions.assumeCBCJCE(); TextEncryptor encryptor = Encryptors.text("password", "5c0744940b5c369b"); String result = encryptor.encrypt("text"); assertThat(result).isNotNull(); assertThat(result.equals("text")).isFalse(); assertThat(encryptor.decrypt(result)).isEqualTo("text"); assertThat(result.equals(encryptor.encrypt("text"))).isFalse(); }
@Test public void preferred() { CryptoAssumptions.assumeGCMJCE(); TextEncryptor encryptor = Encryptors.delux("password", "5c0744940b5c369b"); String result = encryptor.encrypt("text"); assertThat(result).isNotNull(); assertThat(result.equals("text")).isFalse(); assertThat(encryptor.decrypt(result)).isEqualTo("text"); assertThat(result.equals(encryptor.encrypt("text"))).isFalse(); }
@Test public void queryableText() { CryptoAssumptions.assumeCBCJCE(); TextEncryptor encryptor = Encryptors.queryableText("password", "5c0744940b5c369b"); String result = encryptor.encrypt("text"); assertThat(result).isNotNull(); assertThat(result.equals("text")).isFalse(); assertThat(encryptor.decrypt(result)).isEqualTo("text"); assertThat(result.equals(encryptor.encrypt("text"))).isTrue(); }
@Test void installer() { ResponseEntity<String> response = getRestTemplate() .getForEntity(createUrl("install.sh"), String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getBody()).isNotNull(); }
@Test public void shouldReturnBoltUrl() { String actual = neo4jContainer.getBoltUrl(); assertThat(actual).isNotNull(); assertThat(actual).startsWith("bolt://"); }
@Test public void shouldReturnHttpUrl() { String actual = neo4jContainer.getHttpUrl(); assertThat(actual).isNotNull(); assertThat(actual).startsWith("http://"); } }
@Test public void nullScenarioEmpty() { assertThat(new ErrorFormatter(null).scenarioPrefix) .isNotNull() .isEmpty(); }
@Test public void noScenarioEmpty() { assertThat(new ErrorFormatter("").scenarioPrefix) .isNotNull() .isEmpty(); }
@Test public void execHostNameShouldNeverReturnNull() throws IOException { String result = new HostName().execHostName(); assertThat(result).isNotNull(); }
private void validateHttpIeHelpContent(ResponseEntity<String> response) { validateContentType(response, MediaType.TEXT_PLAIN); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); assertThat(response.getBody()).contains("Spring Initializr", "Examples:", "http") .doesNotContain("curl"); }
private void validateSpringBootHelpContent(ResponseEntity<String> response) { validateContentType(response, MediaType.TEXT_PLAIN); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); assertThat(response.getBody()) .contains("Service capabilities", "Supported dependencies") .doesNotContain("Examples:", "curl"); }
@Test public void buildWhenAuthorizationUriIncludesQueryParameterThenAuthorizationRequestUrlIncludesIt() { OAuth2AuthorizationRequest authorizationRequest = TestOAuth2AuthorizationRequests.request() .authorizationUri(AUTHORIZATION_URI + "?param1=value1¶m2=value2").build(); assertThat(authorizationRequest.getAuthorizationRequestUri()).isNotNull(); assertThat(authorizationRequest.getAuthorizationRequestUri()) .isEqualTo("https://provider.com/oauth2/authorize?" + "param1=value1¶m2=value2&" + "response_type=code&client_id=client-id&state=state&" + "redirect_uri=https://example.com/authorize/oauth2/code/registration-id"); } }
@Test void metadataWithHalAcceptHeader() { ResponseEntity<String> response = invokeHome(null, "application/hal+json"); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); validateContentType(response, MainController.HAL_JSON_CONTENT_TYPE); validateCurrentMetadata(response.getBody()); }
@Test @Parameters({MAC_OSX_NAME, LINUX_OS_NAME, SOLARIS_OS_NAME, WINDOWS_OS_NAME}) public void shouldExecHostNameIfEnvValueNotAvailableOnOS(String osName) throws IOException { setHostNamePropertiesNull(osName); String result = new HostName().determineHostName(); assertThat(result).isNotNull(); }
@Test void metadataWithCurrentAcceptHeader() { getRequests().setFields("_links.maven-project", "dependencies.values[0]", "type.values[0]", "javaVersion.values[0]", "packaging.values[0]", "bootVersion.values[0]", "language.values[0]"); ResponseEntity<String> response = invokeHome(null, "application/vnd.initializr.v2.1+json"); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); validateContentType(response, AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE); validateCurrentMetadata(response.getBody()); }