Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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());
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java mongodb find with multiple conditions 
Java :: java long to integer 
Java :: abs in java 
Java :: intent android 
Java :: android-edittext allow only characters and numbers 
Java :: java gitignore 
Java :: sort list java 8 
Java :: matrice java 
Java :: Java How to use Set? 
Java :: android sqlite select query 
Java :: car class java 
Java :: cmd java compile 
Java :: java insert at index 
Java :: how generate a random number in java between 3 and 5 
Java :: java run cmd 
Java :: start async task android 
Java :: spring filter exception handling 
Java :: how to clear text fields in java 
Java :: java get attributes from class 
Java :: render problem in android studio 
Java :: linkedhashmap in java 
Java :: how to get color from a hex string in android studio 
Java :: java vector push_back 
Java :: Add month to date in java 8 
Java :: apache csv get headers 
Java :: How to efficiently reverse a linked list, in Java? 
Java :: H2 enabling remote database creation first 
Java :: difference between class and interface 
Java :: bufferedinputstream 
Java :: button onclick java 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =