BAEL-1931 rename SampleService to SampleClient (#6682)
* BAEL-1931 rename SampleService to SampleClient * remove not null assertion * remove fixed method order * disable usage of local kerberos ticket cache
This commit is contained in:
parent
7fc7e61674
commit
ce09990056
@ -12,6 +12,8 @@ class KerberosClientApp {
|
||||
System.setProperty("java.security.krb5.conf",
|
||||
Paths.get(".\\krb-test-workdir\\krb5.conf").normalize().toAbsolutePath().toString());
|
||||
System.setProperty("sun.security.krb5.debug", "true");
|
||||
// disable usage of local kerberos ticket cache
|
||||
System.setProperty("http.use.global.creds", "false");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -5,14 +5,14 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
class SampleService {
|
||||
class SampleClient {
|
||||
|
||||
@Value("${app.access-url}")
|
||||
private String endpoint;
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
public SampleService(RestTemplate restTemplate) {
|
||||
public SampleClient(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package kerberos.client;
|
||||
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -10,7 +9,6 @@ import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
@ -23,21 +21,19 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@FixMethodOrder
|
||||
public class SampleServiceManualTest {
|
||||
public class SampleClientManualTest {
|
||||
|
||||
@Autowired
|
||||
private SampleService sampleService;
|
||||
private SampleClient sampleClient;
|
||||
|
||||
@Test
|
||||
public void a_givenKerberizedRestTemplate_whenServiceCall_thenSuccess() {
|
||||
assertNotNull(sampleService);
|
||||
assertEquals("data from kerberized server", sampleService.getData());
|
||||
public void givenKerberizedRestTemplate_whenServiceCall_thenSuccess() {
|
||||
assertEquals("data from kerberized server", sampleClient.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void b_givenRestTemplate_whenServiceCall_thenFail() {
|
||||
sampleService.setRestTemplate(new RestTemplate());
|
||||
assertThrows(RestClientException.class, sampleService::getData);
|
||||
public void givenRestTemplate_whenServiceCall_thenFail() {
|
||||
sampleClient.setRestTemplate(new RestTemplate());
|
||||
assertThrows(RestClientException.class, sampleClient::getData);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user