parent
25c476a09b
commit
dc43aec4d3
|
@ -1,4 +1,4 @@
|
|||
package com.baeuldung.serialization;
|
||||
package com.baeldung.serialization;
|
||||
|
||||
public class Address {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeuldung.serialization;
|
||||
package com.baeldung.serialization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeuldung.serialization;
|
||||
package com.baeldung.serialization;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Person implements Serializable {
|
||||
|
|
|
@ -11,9 +11,9 @@ import java.util.stream.Stream;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CompletableFutureUnitTest {
|
||||
public class CompletableFutureLongRunningUnitTest {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CompletableFutureUnitTest.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CompletableFutureLongRunningUnitTest.class);
|
||||
|
||||
|
||||
@Test
|
|
@ -11,13 +11,12 @@ import org.junit.Test;
|
|||
|
||||
import com.baeldung.filesystem.jndi.LookupFSJNDI;
|
||||
|
||||
public class LookupFSJNDITest {
|
||||
public class LookupFSJNDIIntegrationTest {
|
||||
LookupFSJNDI fsjndi;
|
||||
File file;
|
||||
InitialContext ctx = null;
|
||||
final String FILENAME = "test.find";
|
||||
|
||||
public LookupFSJNDITest() {
|
||||
public LookupFSJNDIIntegrationTest() {
|
||||
try {
|
||||
fsjndi = new LookupFSJNDI();
|
||||
} catch (NamingException e) {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeuldung.serialization;
|
||||
package com.baeldung.serialization;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class SynchronousQueueUnitTest {
|
||||
public class SynchronousQueueIntegrationTest {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SynchronousQueueUnitTest.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SynchronousQueueIntegrationTest.class);
|
||||
|
||||
|
||||
@Test
|
|
@ -1,12 +1,10 @@
|
|||
package com.baeldung.test;
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.Spring5Application;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class)
|
||||
public class Spring5ApplicationIntegrationTest {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.test;
|
||||
package com.baeldung;
|
||||
|
||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -38,13 +38,11 @@ public class LiveTest {
|
|||
//
|
||||
|
||||
private final String resourceWithNullName() {
|
||||
final String roleData = "{\"name\":null}";
|
||||
return roleData;
|
||||
return "{\"name\":null}";
|
||||
}
|
||||
|
||||
private final String resourceString() {
|
||||
final String roleData = "{\"name\":\"" + randomAlphabetic(8) + "\"}";
|
||||
return roleData;
|
||||
return "{\"name\":\"" + randomAlphabetic(8) + "\"}";
|
||||
}
|
||||
|
||||
private final RequestSpecification givenAuth(String username, String password) {
|
|
@ -1,7 +1,5 @@
|
|||
package springbootkotlin
|
||||
package com.baeldung.springbootkotlin
|
||||
|
||||
import com.baeldung.springbootkotlin.HelloDto
|
||||
import com.baeldung.springbootkotlin.KotlinDemoApplication
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Test
|
||||
|
@ -14,8 +12,8 @@ import org.springframework.test.context.junit4.SpringRunner
|
|||
|
||||
@RunWith(SpringRunner::class)
|
||||
@SpringBootTest(
|
||||
classes = arrayOf(KotlinDemoApplication::class),
|
||||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
classes = arrayOf(KotlinDemoApplication::class),
|
||||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class KotlinDemoApplicationIntegrationTest {
|
||||
|
||||
@Autowired
|
|
@ -1,61 +0,0 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.baeldung.multipleauthproviders.MultipleAuthProvidersApplication;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = MultipleAuthProvidersApplication.class)
|
||||
public class MultipleAuthProvidersApplicationTests {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void givenMemUsers_whenGetPingWithValidUser_thenOk() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("memuser", "pass");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(200);
|
||||
assertThat(result.getBody()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenExternalUsers_whenGetPingWithValidUser_thenOK() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("externaluser", "pass");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(200);
|
||||
assertThat(result.getBody()).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAuthProviders_whenGetPingWithNoCred_then401() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing();
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(401);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAuthProviders_whenGetPingWithBadCred_then401() {
|
||||
ResponseEntity<String> result = makeRestCallToGetPing("user", "bad_password");
|
||||
|
||||
assertThat(result.getStatusCodeValue()).isEqualTo(401);
|
||||
}
|
||||
|
||||
private ResponseEntity<String> makeRestCallToGetPing(String username, String password) {
|
||||
return restTemplate.withBasicAuth(username, password)
|
||||
.getForEntity("/api/ping", String.class, Collections.emptyMap());
|
||||
}
|
||||
|
||||
private ResponseEntity<String> makeRestCallToGetPing() {
|
||||
return restTemplate.getForEntity("/api/ping", String.class, Collections.emptyMap());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue