testing the web layer without authentication spring
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class SecuredControllerRestTemplateIntegrationTest {
@Autowired
private TestRestTemplate template;
// ... other methods
@Test
public void givenAuthRequestOnPrivateService_shouldSucceedWith200() throws Exception {
ResponseEntity<String> result = template.withBasicAuth("spring", "secret")
.getForEntity("/private/hello", String.class);
assertEquals(HttpStatus.OK, result.getStatusCode());
}
}
Also in Java:
- java output length of each line in a text document
- java for loop add multiple declarations
- palindrome function java
- Java 2 dimensional array equals
- java final modifier on method
- number of matches regex java
- java.lang.UnsupportedOperationException
- java intercept ctrl c
- loop through array java
- how to create a list in java
- how to iterate hashmap in java
- convert date to calendar java
- substring java
- java create file if not exists
- int to long java
- java public private key encryption
- java timestamp
- java bucket sort
- what it means when create final variable in java
- java jaxb unmarshall xml to map
- rock paper scissors java
- keep jframe on top
- StringBuilder java pop back
- arraylist with values java