diff --git a/core-java/src/main/java/com/baeldung/serialization/Address.java b/core-java/src/main/java/com/baeldung/serialization/Address.java index 524ecb1ffc..055b53e70e 100644 --- a/core-java/src/main/java/com/baeldung/serialization/Address.java +++ b/core-java/src/main/java/com/baeldung/serialization/Address.java @@ -1,4 +1,4 @@ -package com.baeuldung.serialization; +package com.baeldung.serialization; public class Address { diff --git a/core-java/src/main/java/com/baeldung/serialization/Employee.java b/core-java/src/main/java/com/baeldung/serialization/Employee.java index 69beeb0b49..0fa3ad2fc8 100644 --- a/core-java/src/main/java/com/baeldung/serialization/Employee.java +++ b/core-java/src/main/java/com/baeldung/serialization/Employee.java @@ -1,4 +1,4 @@ -package com.baeuldung.serialization; +package com.baeldung.serialization; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/core-java/src/main/java/com/baeldung/serialization/Person.java b/core-java/src/main/java/com/baeldung/serialization/Person.java index 23d0601e03..4fd1a943c1 100644 --- a/core-java/src/main/java/com/baeldung/serialization/Person.java +++ b/core-java/src/main/java/com/baeldung/serialization/Person.java @@ -1,4 +1,4 @@ -package com.baeuldung.serialization; +package com.baeldung.serialization; import java.io.Serializable; public class Person implements Serializable { diff --git a/core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureUnitTest.java b/core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java similarity index 98% rename from core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureUnitTest.java rename to core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java index 501cb1afa0..51b9e5338b 100644 --- a/core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureUnitTest.java +++ b/core-java/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java @@ -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 diff --git a/core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDITest.java b/core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java similarity index 92% rename from core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDITest.java rename to core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java index 1f31cbade9..1ec703f0f6 100644 --- a/core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDITest.java +++ b/core-java/src/test/java/com/baeldung/filesystem/jndi/test/LookupFSJNDIIntegrationTest.java @@ -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) { diff --git a/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java b/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java index 86bd3f9c8d..748898ff3e 100644 --- a/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java +++ b/core-java/src/test/java/com/baeldung/serialization/PersonUnitTest.java @@ -1,4 +1,4 @@ -package com.baeuldung.serialization; +package com.baeldung.serialization; import static org.junit.Assert.assertTrue; diff --git a/core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueUnitTest.java b/core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java similarity index 97% rename from core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueUnitTest.java rename to core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java index 79339d1680..76df3c6450 100644 --- a/core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueUnitTest.java +++ b/core-java/src/test/java/com/baeldung/synchronousqueue/SynchronousQueueIntegrationTest.java @@ -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 diff --git a/spring-5-mvc/src/test/java/com/baeldung/test/Spring5ApplicationIntegrationTest.java b/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java similarity index 84% rename from spring-5-mvc/src/test/java/com/baeldung/test/Spring5ApplicationIntegrationTest.java rename to spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java index c3790333ff..cf28d54385 100644 --- a/spring-5-mvc/src/test/java/com/baeldung/test/Spring5ApplicationIntegrationTest.java +++ b/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java @@ -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 { diff --git a/spring-5-mvc/src/test/java/com/baeldung/test/LiveTest.java b/spring-5-mvc/src/test/kotlin/com/baeldung/LiveTest.java similarity index 82% rename from spring-5-mvc/src/test/java/com/baeldung/test/LiveTest.java rename to spring-5-mvc/src/test/kotlin/com/baeldung/LiveTest.java index f6dd921b25..1b52f89117 100644 --- a/spring-5-mvc/src/test/java/com/baeldung/test/LiveTest.java +++ b/spring-5-mvc/src/test/kotlin/com/baeldung/LiveTest.java @@ -1,54 +1,52 @@ -package com.baeldung.test; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.springframework.http.MediaType; - -import com.jayway.restassured.RestAssured; -import com.jayway.restassured.response.Response; -import com.jayway.restassured.specification.RequestSpecification; - -public class LiveTest { - - private static String APP_ROOT = "http://localhost:8081"; - - - @Test - public void givenUser_whenResourceCreatedWithNullName_then400BadRequest() { - final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceWithNullName()).post(APP_ROOT + "/foos"); - assertEquals(400, response.getStatusCode()); - } - - @Test - public void givenUser_whenResourceCreated_then201Created() { - final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceString()).post(APP_ROOT + "/foos"); - assertEquals(201, response.getStatusCode()); - } - - /*@Test - public void givenUser_whenGetAllFoos_thenOK() { - final Response response = givenAuth("user", "pass").get(APP_ROOT + "/foos"); - assertEquals(200, response.getStatusCode()); - }*/ - - - - // - - private final String resourceWithNullName() { - final String roleData = "{\"name\":null}"; - return roleData; - } - - private final String resourceString() { - final String roleData = "{\"name\":\"" + randomAlphabetic(8) + "\"}"; - return roleData; - } - - private final RequestSpecification givenAuth(String username, String password) { - return RestAssured.given().auth().preemptive().basic(username, password); - } - +package com.baeldung; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.springframework.http.MediaType; + +import com.jayway.restassured.RestAssured; +import com.jayway.restassured.response.Response; +import com.jayway.restassured.specification.RequestSpecification; + +public class LiveTest { + + private static String APP_ROOT = "http://localhost:8081"; + + + @Test + public void givenUser_whenResourceCreatedWithNullName_then400BadRequest() { + final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceWithNullName()).post(APP_ROOT + "/foos"); + assertEquals(400, response.getStatusCode()); + } + + @Test + public void givenUser_whenResourceCreated_then201Created() { + final Response response = givenAuth("user", "pass").contentType(MediaType.APPLICATION_JSON.toString()).body(resourceString()).post(APP_ROOT + "/foos"); + assertEquals(201, response.getStatusCode()); + } + + /*@Test + public void givenUser_whenGetAllFoos_thenOK() { + final Response response = givenAuth("user", "pass").get(APP_ROOT + "/foos"); + assertEquals(200, response.getStatusCode()); + }*/ + + + + // + + private final String resourceWithNullName() { + return "{\"name\":null}"; + } + + private final String resourceString() { + return "{\"name\":\"" + randomAlphabetic(8) + "\"}"; + } + + private final RequestSpecification givenAuth(String username, String password) { + return RestAssured.given().auth().preemptive().basic(username, password); + } + } \ No newline at end of file diff --git a/spring-5-mvc/src/test/kotlin/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt b/spring-5-mvc/src/test/kotlin/com/baeldung/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt similarity index 86% rename from spring-5-mvc/src/test/kotlin/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt rename to spring-5-mvc/src/test/kotlin/com/baeldung/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt index 397204251c..d0667177c8 100644 --- a/spring-5-mvc/src/test/kotlin/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt +++ b/spring-5-mvc/src/test/kotlin/com/baeldung/springbootkotlin/KotlinDemoApplicationIntegrationTest.kt @@ -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 diff --git a/spring-security-mvc-boot/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationTests.java b/spring-security-mvc-boot/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationTests.java deleted file mode 100644 index 0d70cd64e4..0000000000 --- a/spring-security-mvc-boot/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationTests.java +++ /dev/null @@ -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 result = makeRestCallToGetPing("memuser", "pass"); - - assertThat(result.getStatusCodeValue()).isEqualTo(200); - assertThat(result.getBody()).isEqualTo("OK"); - } - - @Test - public void givenExternalUsers_whenGetPingWithValidUser_thenOK() { - ResponseEntity result = makeRestCallToGetPing("externaluser", "pass"); - - assertThat(result.getStatusCodeValue()).isEqualTo(200); - assertThat(result.getBody()).isEqualTo("OK"); - } - - @Test - public void givenAuthProviders_whenGetPingWithNoCred_then401() { - ResponseEntity result = makeRestCallToGetPing(); - - assertThat(result.getStatusCodeValue()).isEqualTo(401); - } - - @Test - public void givenAuthProviders_whenGetPingWithBadCred_then401() { - ResponseEntity result = makeRestCallToGetPing("user", "bad_password"); - - assertThat(result.getStatusCodeValue()).isEqualTo(401); - } - - private ResponseEntity makeRestCallToGetPing(String username, String password) { - return restTemplate.withBasicAuth(username, password) - .getForEntity("/api/ping", String.class, Collections.emptyMap()); - } - - private ResponseEntity makeRestCallToGetPing() { - return restTemplate.getForEntity("/api/ping", String.class, Collections.emptyMap()); - } -}