From 220a0bffe06107362ff6aa7aeb978bea5b91d624 Mon Sep 17 00:00:00 2001 From: DOHA Date: Tue, 19 Feb 2019 20:18:13 +0200 Subject: [PATCH 01/56] add user-info endpoint live test --- .../org/baeldung/config/AuthServerConfig.java | 2 +- .../org/baeldung/config/SecurityConfig.java | 3 +- .../baeldung/UserInfoEndpointLiveTest.java | 51 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java diff --git a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java index 07057c3875..0835f3d721 100644 --- a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java +++ b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/AuthServerConfig.java @@ -30,7 +30,7 @@ public class AuthServerConfig extends AuthorizationServerConfigurerAdapter { .authorizedGrantTypes("authorization_code") .scopes("user_info") .autoApprove(true) - .redirectUris("http://localhost:8082/ui/login","http://localhost:8083/ui2/login","http://localhost:8082/login") + .redirectUris("http://localhost:8082/ui/login","http://localhost:8083/ui2/login","http://localhost:8082/login","http://www.example.com/") // .accessTokenValiditySeconds(3600) ; // 1 hour } diff --git a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java index 5cebf4f4d2..2254de8e39 100644 --- a/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java +++ b/spring-security-sso/spring-security-sso-auth-server/src/main/java/org/baeldung/config/SecurityConfig.java @@ -22,7 +22,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .authenticated() .and() .formLogin() - .permitAll(); + .permitAll() + .and().csrf().disable(); } // @formatter:on @Override diff --git a/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java b/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java new file mode 100644 index 0000000000..ffdb1df8fe --- /dev/null +++ b/spring-security-sso/spring-security-sso-auth-server/src/test/java/org/baeldung/UserInfoEndpointLiveTest.java @@ -0,0 +1,51 @@ +package org.baeldung; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + +public class UserInfoEndpointLiveTest { + + @Test + public void givenAccessToken_whenAccessUserInfoEndpoint_thenSuccess() { + String accessToken = obtainAccessTokenUsingAuthorizationCodeFlow("john","123"); + Response response = RestAssured.given().header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken).get("http://localhost:8081/auth/user/me"); + + assertEquals(HttpStatus.OK.value(), response.getStatusCode()); + assertEquals("john", response.jsonPath().get("name")); + } + + private String obtainAccessTokenUsingAuthorizationCodeFlow(String username, String password) { + final String authServerUri = "http://localhost:8081/auth"; + final String redirectUrl = "http://www.example.com/"; + final String authorizeUrl = authServerUri + "/oauth/authorize?response_type=code&client_id=SampleClientId&redirect_uri=" + redirectUrl; + final String tokenUrl = authServerUri + "/oauth/token"; + + // user login + Response response = RestAssured.given().formParams("username", username, "password", password).post(authServerUri + "/login"); + final String cookieValue = response.getCookie("JSESSIONID"); + + // get authorization code + RestAssured.given().cookie("JSESSIONID", cookieValue).get(authorizeUrl); + response = RestAssured.given().cookie("JSESSIONID", cookieValue).post(authorizeUrl); + assertEquals(HttpStatus.FOUND.value(), response.getStatusCode()); + final String location = response.getHeader(HttpHeaders.LOCATION); + final String code = location.substring(location.indexOf("code=") + 5); + + // get access token + Map params = new HashMap(); + params.put("grant_type", "authorization_code"); + params.put("code", code); + params.put("client_id", "SampleClientId"); + params.put("redirect_uri", redirectUrl); + response = RestAssured.given().auth().basic("SampleClientId", "secret").formParams(params).post(tokenUrl); + return response.jsonPath().getString("access_token"); + } +} From 3cfedd04944c92af8d2f1b463670d0c3d0171320 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 24 Feb 2019 13:44:34 +0200 Subject: [PATCH 02/56] keycloak - change server port --- spring-boot-keycloak/src/main/resources/application.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-keycloak/src/main/resources/application.properties b/spring-boot-keycloak/src/main/resources/application.properties index f667d3b27e..6e7da2cb90 100644 --- a/spring-boot-keycloak/src/main/resources/application.properties +++ b/spring-boot-keycloak/src/main/resources/application.properties @@ -1,3 +1,6 @@ +### server port +server.port=8081 + #Keycloak Configuration keycloak.auth-server-url=http://localhost:8180/auth keycloak.realm=SpringBootKeycloak From 51be79991023cbc8d1a7ca2ed400eb2659fbf2ca Mon Sep 17 00:00:00 2001 From: Anurag Date: Fri, 22 Mar 2019 17:13:00 +0530 Subject: [PATCH 03/56] [BAEL-1951] Guide to FileChannel --- .../filechannel/FileChannelUnitTest.java | 181 ++++++++++++++++++ .../src/test/resources/test_truncate.txt | 1 + .../test_write_using_filechannel.txt | 1 + 3 files changed, 183 insertions(+) create mode 100644 core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java create mode 100644 core-java-io/src/test/resources/test_truncate.txt create mode 100644 core-java-io/src/test/resources/test_write_using_filechannel.txt diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java new file mode 100644 index 0000000000..497ce33f0d --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -0,0 +1,181 @@ +package com.baeldung.filechannel; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; + +import org.junit.Test; + +public class FileChannelUnitTest { + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, out.toString()); + out.close(); + channel.close(); + reader.close(); + } + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream(file); + FileChannel channel = fin.getChannel(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, out.toString()); + channel.close(); + fin.close(); + } + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String input = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + while (buff.hasRemaining()) { + channel.write(buff); + } + channel.close(); + writer.close(); + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(input, reader.readLine()); + reader.close(); + } + + @Test + public void whenWriteWithFileChannelUsingFileOutputStream_thenCorrect() throws IOException { + String input = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + while (buff.hasRemaining()) { + channel.write(buff); + } + + channel.close(); + fout.close(); + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(input, reader.readLine()); + reader.close(); + } + + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + long expected_value = 11; + String file = "src/test/resources/test_read.in"; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int noOfBytesRead = channel.read(buff); + + while (noOfBytesRead != -1) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + noOfBytesRead = channel.read(buff); + } + } + + assertEquals(expected_value, channel.position()); + + channel.position(4); + assertEquals(4, channel.position()); + + channel.close(); + reader.close(); + } + + @Test + public void whenGetFileSize_thenCorrect() throws IOException { + long expectedSize = 11; + String file = "src/test/resources/test_read.in"; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + + long imageFileSize = channel.size(); + assertEquals(expectedSize, imageFileSize); + + channel.close(); + reader.close(); + } + + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + long expectedSize = 5; + String input = "this is a test input"; + String file = "src/test/resources/test_truncate.txt"; + + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); + + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); + + channel = channel.truncate(5); + assertEquals(expectedSize, channel.size()); + + fout.close(); + channel.close(); + } +} diff --git a/core-java-io/src/test/resources/test_truncate.txt b/core-java-io/src/test/resources/test_truncate.txt new file mode 100644 index 0000000000..26d3b38cdd --- /dev/null +++ b/core-java-io/src/test/resources/test_truncate.txt @@ -0,0 +1 @@ +this \ No newline at end of file diff --git a/core-java-io/src/test/resources/test_write_using_filechannel.txt b/core-java-io/src/test/resources/test_write_using_filechannel.txt new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/core-java-io/src/test/resources/test_write_using_filechannel.txt @@ -0,0 +1 @@ +Hello world \ No newline at end of file From 0a542104143cbaccb2990e3c684bb45f0b729fc5 Mon Sep 17 00:00:00 2001 From: Anurag Date: Fri, 22 Mar 2019 17:48:47 +0530 Subject: [PATCH 04/56] minor fix --- .../test/java/com/baeldung/filechannel/FileChannelUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 497ce33f0d..312ec7a459 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -66,6 +66,7 @@ public class FileChannelUnitTest { } assertEquals(expected_value, out.toString()); + out.close(); channel.close(); fin.close(); } @@ -141,6 +142,7 @@ public class FileChannelUnitTest { channel.position(4); assertEquals(4, channel.position()); + out.close(); channel.close(); reader.close(); } From 19ec10a6306c56846f2ad18c957c57d1b9f78007 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 23 Mar 2019 19:04:55 +0100 Subject: [PATCH 05/56] BAEL-1970 spring logging level while testing --- .../java/com/baeldung/testlog/TestLog.java | 22 ++++++ .../testloglevel/TestLogLevelApplication.java | 15 ++++ .../testloglevel/TestLogLevelController.java | 29 ++++++++ ...ltiProfileTestLogLevelIntegrationTest.java | 70 +++++++++++++++++++ .../LogbackTestLogLevelIntegrationTest.java | 70 +++++++++++++++++++ ...estLogLevelWithProfileIntegrationTest.java | 68 ++++++++++++++++++ .../application-logback-test2.properties | 1 + ...pplication-logback-testloglevel.properties | 1 + .../application-testloglevel.properties | 2 + .../test/resources/logback-multiprofile.xml | 18 +++++ .../test/resources/logback-testloglevel.xml | 13 ++++ 11 files changed, 309 insertions(+) create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java create mode 100644 spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java create mode 100644 spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java create mode 100644 spring-boot-testing/src/test/resources/application-logback-test2.properties create mode 100644 spring-boot-testing/src/test/resources/application-logback-testloglevel.properties create mode 100644 spring-boot-testing/src/test/resources/application-testloglevel.properties create mode 100644 spring-boot-testing/src/test/resources/logback-multiprofile.xml create mode 100644 spring-boot-testing/src/test/resources/logback-testloglevel.xml diff --git a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java new file mode 100644 index 0000000000..bc5d5700e5 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java @@ -0,0 +1,22 @@ +package com.baeldung.testlog; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestLog { + + Logger LOG = LoggerFactory.getLogger(this.getClass()); + + public void info(String msg) { + LOG.info(msg); + } + + public void error(String msg) { + LOG.error(msg); + } + + public void trace(String msg) { + LOG.trace(msg); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java new file mode 100644 index 0000000000..315bd735b9 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.testloglevel; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import com.baeldung.boot.Application; + +@SpringBootApplication +public class TestLogLevelApplication { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java new file mode 100644 index 0000000000..7349c20b65 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java @@ -0,0 +1,29 @@ +package com.baeldung.testloglevel; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.testlog.TestLog; + +@RestController +public class TestLogLevelController { + + Logger LOG = LoggerFactory.getLogger(this.getClass()); + + @GetMapping("/testLogLevel") + public String testLogLevel() { + LOG.trace("This is a TRACE log"); + LOG.debug("This is a DEBUG log"); + LOG.info("This is an INFO log"); + LOG.error("This is an ERROR log"); + + new TestLog().trace("This is a TRACE log in another package"); + new TestLog().info("This is an INFO log in another package"); + new TestLog().error("This is an ERROR log in another package"); + + return "Added some log output to console..."; + } + +} \ No newline at end of file diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java new file mode 100644 index 0000000000..5192a1f00e --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.testloglevel; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("logback-test2") +public class LogbackMultiProfileTestLogLevelIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + private String baseUrl = "/testLogLevel"; + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("TRACE"); + } + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("TRACE"); + } + + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java new file mode 100644 index 0000000000..c0571265a9 --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.testloglevel; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("logback-testloglevel") +public class LogbackTestLogLevelIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + private String baseUrl = "/testLogLevel"; + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } + + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java new file mode 100644 index 0000000000..976e7d5f76 --- /dev/null +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -0,0 +1,68 @@ +package com.baeldung.testloglevel; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.rule.OutputCapture; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) +@ActiveProfiles("testloglevel") +public class TestLogLevelWithProfileIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Rule + public OutputCapture outputCapture = new OutputCapture(); + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } + + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { + ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("INFO"); + assertThatOutputContainsLogForOtherPackages("INFO"); + } + + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } + + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } + +} diff --git a/spring-boot-testing/src/test/resources/application-logback-test2.properties b/spring-boot-testing/src/test/resources/application-logback-test2.properties new file mode 100644 index 0000000000..aeed46e3ca --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-test2.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-multiprofile.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties new file mode 100644 index 0000000000..81d9b2e7c6 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-testloglevel.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-testloglevel.properties b/spring-boot-testing/src/test/resources/application-testloglevel.properties new file mode 100644 index 0000000000..b5adb4cc11 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-testloglevel.properties @@ -0,0 +1,2 @@ +logging.level.com.baeldung.testloglevel=DEBUG +logging.level.root=INFO \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml new file mode 100644 index 0000000000..3711f1ec71 --- /dev/null +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -0,0 +1,18 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/logback-testloglevel.xml b/spring-boot-testing/src/test/resources/logback-testloglevel.xml new file mode 100644 index 0000000000..b02462a155 --- /dev/null +++ b/spring-boot-testing/src/test/resources/logback-testloglevel.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file From 92b67b36a68ff098532cfaa2546791cfb91b3aed Mon Sep 17 00:00:00 2001 From: Anurag Date: Sun, 24 Mar 2019 16:12:45 +0530 Subject: [PATCH 06/56] changes in read code. --- .../baeldung/filechannel/FileChannelUnitTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 312ec7a459..c3d7e5610c 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -26,17 +27,15 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } - assertEquals(expected_value, out.toString()); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); out.close(); channel.close(); reader.close(); @@ -55,13 +54,11 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } @@ -127,13 +124,11 @@ public class FileChannelUnitTest { bufferSize = (int) channel.size(); } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int noOfBytesRead = channel.read(buff); - while (noOfBytesRead != -1) { + while (channel.read(buff) > 0) { if (buff.hasArray()) { out.write(buff.array(), 0, buff.position()); buff.clear(); - noOfBytesRead = channel.read(buff); } } From 8054742acba0410da7d599ddace1c18121aa1fad Mon Sep 17 00:00:00 2001 From: Anurag Date: Sun, 24 Mar 2019 16:20:10 +0530 Subject: [PATCH 07/56] minor fix. --- .../test/java/com/baeldung/filechannel/FileChannelUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index c3d7e5610c..35ba9aca65 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -62,7 +62,7 @@ public class FileChannelUnitTest { } } - assertEquals(expected_value, out.toString()); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); out.close(); channel.close(); fin.close(); From f0797a0c04e6526f4b0067d13084d0b51a423d08 Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 28 Mar 2019 07:19:55 +0100 Subject: [PATCH 08/56] Multi set --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java new file mode 100644 index 0000000000..4f28f8ebfc --- /dev/null +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -0,0 +1,20 @@ +package org.baeldung.guava; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GuavaMultiSetUnitTest { + + @Test + public void add_multipleValues() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(2); + } +} From af98a10b23067e486ca7d149e5e93bad55801a2f Mon Sep 17 00:00:00 2001 From: Sushant Date: Thu, 28 Mar 2019 07:33:31 +0100 Subject: [PATCH 09/56] Fix --- .../src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 4f28f8ebfc..faadc349d0 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -15,6 +15,6 @@ public class GuavaMultiSetUnitTest { bookStore.add("Potter"); assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(2); + assertThat(bookStore.count("Potter")).isEqualTo(3); } } From 72d38fd1cac1b61fabbbdb6aa903dd5666a583ce Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 31 Mar 2019 15:10:04 +0300 Subject: [PATCH 10/56] Add unit test --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 69 ++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index faadc349d0..b3f097cf9a 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -4,17 +4,70 @@ import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import org.junit.Test; +import java.util.HashMap; +import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; public class GuavaMultiSetUnitTest { - @Test - public void add_multipleValues() { - Multiset bookStore = HashMultiset.create(); - bookStore.add("Potter"); - bookStore.add("Potter"); + @Test + public void givenMultiSet_whenAddAndRemoveValues_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + bookStore.add("Potter"); - assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(3); - } + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(3); + + bookStore.remove("Potter"); + assertThat(bookStore.contains("Potter")).isTrue(); + assertThat(bookStore.count("Potter")).isEqualTo(2); + } + + @Test + public void givenMultiSet_whenSetCount_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.setCount("Potter", 50); //add 50 to the count + assertThat(bookStore.count("Potter")).isEqualTo(50); + } + + @Test + public void givenMultiSet_whenSettingNegativeCount_shouldThrowException() { + Multiset bookStore = HashMultiset.create(); + assertThatThrownBy(() -> bookStore.setCount("Potter", -1)).isInstanceOf(IllegalArgumentException.class); + } + + @Test + public void givenMultiSet_whenSettingCountWithOldCount_shouldReturnCorrectValue() { + Multiset bookStore = HashMultiset.create(); + assertThat(bookStore.setCount("Potter", 0, 2)).isTrue(); + assertThat(bookStore.setCount("Potter", 50, 5)).isFalse(); + } + + @Test + public void givenMap_compareMultiSetOperations() { + Map bookStore = new HashMap<>(); + bookStore.put("Potter", 1); + bookStore.put("Potter", 2); + bookStore.put("Potter", 3); + + assertThat(bookStore.containsKey("Potter")).isTrue(); + assertThat(bookStore.get("Potter")).isEqualTo(3); + + bookStore.put("Potter", null); + assertThat(bookStore.containsKey("Potter")).isTrue(); + + bookStore.put("Potter", -1); + assertThat(bookStore.containsKey("Potter")).isTrue(); + + bookStore.put("Potter", 2); + assertThat(bookStore.containsKey("Potter")).isTrue(); + assertThat(bookStore.get("Potter")).isEqualTo(2); + + bookStore.put("Potter", 52); + assertThat(bookStore.get("Potter")).isEqualTo(52); + } } From 45bf5898d5128b12ca2d5d3a1c3323dd0bf1dab9 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 31 Mar 2019 17:26:08 +0300 Subject: [PATCH 11/56] Remove comment --- .../org/baeldung/guava/GuavaMultiSetUnitTest.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index b3f097cf9a..3d75cc38a3 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -30,7 +30,7 @@ public class GuavaMultiSetUnitTest { @Test public void givenMultiSet_whenSetCount_shouldReturnCorrectCount() { Multiset bookStore = HashMultiset.create(); - bookStore.setCount("Potter", 50); //add 50 to the count + bookStore.setCount("Potter", 50); assertThat(bookStore.count("Potter")).isEqualTo(50); } @@ -50,24 +50,18 @@ public class GuavaMultiSetUnitTest { @Test public void givenMap_compareMultiSetOperations() { Map bookStore = new HashMap<>(); - bookStore.put("Potter", 1); - bookStore.put("Potter", 2); bookStore.put("Potter", 3); assertThat(bookStore.containsKey("Potter")).isTrue(); assertThat(bookStore.get("Potter")).isEqualTo(3); + bookStore.put("Potter", 2); + assertThat(bookStore.get("Potter")).isEqualTo(2); + bookStore.put("Potter", null); assertThat(bookStore.containsKey("Potter")).isTrue(); bookStore.put("Potter", -1); assertThat(bookStore.containsKey("Potter")).isTrue(); - - bookStore.put("Potter", 2); - assertThat(bookStore.containsKey("Potter")).isTrue(); - assertThat(bookStore.get("Potter")).isEqualTo(2); - - bookStore.put("Potter", 52); - assertThat(bookStore.get("Potter")).isEqualTo(52); } } From 5957f65495b2a15a41f61465006862056817928f Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 6 Apr 2019 20:42:44 +0200 Subject: [PATCH 12/56] BAEL-1970 improved examples after code review --- .../baeldung/component/OtherComponent.java | 19 +++++ .../java/com/baeldung/testlog/TestLog.java | 22 ------ .../testloglevel/TestLogLevelApplication.java | 8 +-- .../testloglevel/TestLogLevelController.java | 30 ++++---- .../LogbackTestLogLevelIntegrationTest.java | 4 +- ...estLogLevelWithProfileIntegrationTest.java | 70 ++++++++++--------- .../application-logback-test.properties | 1 + ...pplication-logback-testloglevel.properties | 1 - ...es => application-logging-test.properties} | 0 ...back-testloglevel.xml => logback-test.xml} | 2 +- 10 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java delete mode 100644 spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java create mode 100644 spring-boot-testing/src/test/resources/application-logback-test.properties delete mode 100644 spring-boot-testing/src/test/resources/application-logback-testloglevel.properties rename spring-boot-testing/src/test/resources/{application-testloglevel.properties => application-logging-test.properties} (100%) rename spring-boot-testing/src/test/resources/{logback-testloglevel.xml => logback-test.xml} (95%) diff --git a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java new file mode 100644 index 0000000000..61f5b440c3 --- /dev/null +++ b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java @@ -0,0 +1,19 @@ +package com.baeldung.component; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class OtherComponent { + + private static final Logger LOG = LoggerFactory.getLogger(OtherComponent.class); + + public void processData() { + LOG.trace("This is a TRACE log from OtherComponent"); + LOG.debug("This is a DEBUG log from OtherComponent"); + LOG.info("This is an INFO log from OtherComponent"); + LOG.error("This is an ERROR log from OtherComponent"); + } + +} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java b/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java deleted file mode 100644 index bc5d5700e5..0000000000 --- a/spring-boot-testing/src/main/java/com/baeldung/testlog/TestLog.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.testlog; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestLog { - - Logger LOG = LoggerFactory.getLogger(this.getClass()); - - public void info(String msg) { - LOG.info(msg); - } - - public void error(String msg) { - LOG.error(msg); - } - - public void trace(String msg) { - LOG.trace(msg); - } - -} diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java index 315bd735b9..ed8218c6a3 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java @@ -5,11 +5,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import com.baeldung.boot.Application; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"com.baeldung.testloglevel", "com.baeldung.component"}) public class TestLogLevelApplication { - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } } diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java index 7349c20b65..22078562b4 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java +++ b/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java @@ -2,28 +2,30 @@ package com.baeldung.testloglevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.testlog.TestLog; +import com.baeldung.component.OtherComponent; @RestController public class TestLogLevelController { - Logger LOG = LoggerFactory.getLogger(this.getClass()); + private static final Logger LOG = LoggerFactory.getLogger(TestLogLevelController.class); - @GetMapping("/testLogLevel") - public String testLogLevel() { - LOG.trace("This is a TRACE log"); - LOG.debug("This is a DEBUG log"); - LOG.info("This is an INFO log"); - LOG.error("This is an ERROR log"); + @Autowired + private OtherComponent otherComponent; - new TestLog().trace("This is a TRACE log in another package"); - new TestLog().info("This is an INFO log in another package"); - new TestLog().error("This is an ERROR log in another package"); + @GetMapping("/testLogLevel") + public String testLogLevel() { + LOG.trace("This is a TRACE log"); + LOG.debug("This is a DEBUG log"); + LOG.info("This is an INFO log"); + LOG.error("This is an ERROR log"); - return "Added some log output to console..."; - } + otherComponent.processData(); -} \ No newline at end of file + return "Added some log output to console..."; + } + +} diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index c0571265a9..5fb40a2f36 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -17,9 +17,9 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) -@ActiveProfiles("logback-testloglevel") +@ActiveProfiles("logback-test") public class LogbackTestLogLevelIntegrationTest { @Autowired diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java index 976e7d5f76..5609ce6c01 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -17,52 +17,54 @@ import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = TestLogLevelApplication.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) -@ActiveProfiles("testloglevel") +@ActiveProfiles("logging-test") public class TestLogLevelWithProfileIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + private String baseUrl = "/testLogLevel"; - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("DEBUG"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - @Test - public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/testLogLevel", String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("INFO"); - assertThatOutputContainsLogForOtherPackages("INFO"); - } + @Test + public void givenInfoRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintInfoLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("INFO"); + assertThatOutputContainsLogForOtherPackages("INFO"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } + + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } diff --git a/spring-boot-testing/src/test/resources/application-logback-test.properties b/spring-boot-testing/src/test/resources/application-logback-test.properties new file mode 100644 index 0000000000..587302fa01 --- /dev/null +++ b/spring-boot-testing/src/test/resources/application-logback-test.properties @@ -0,0 +1 @@ +logging.config=classpath:logback-test.xml diff --git a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties deleted file mode 100644 index 81d9b2e7c6..0000000000 --- a/spring-boot-testing/src/test/resources/application-logback-testloglevel.properties +++ /dev/null @@ -1 +0,0 @@ -logging.config=classpath:logback-testloglevel.xml \ No newline at end of file diff --git a/spring-boot-testing/src/test/resources/application-testloglevel.properties b/spring-boot-testing/src/test/resources/application-logging-test.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-testloglevel.properties rename to spring-boot-testing/src/test/resources/application-logging-test.properties diff --git a/spring-boot-testing/src/test/resources/logback-testloglevel.xml b/spring-boot-testing/src/test/resources/logback-test.xml similarity index 95% rename from spring-boot-testing/src/test/resources/logback-testloglevel.xml rename to spring-boot-testing/src/test/resources/logback-test.xml index b02462a155..9c6df17024 100644 --- a/spring-boot-testing/src/test/resources/logback-testloglevel.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -10,4 +10,4 @@ - \ No newline at end of file + From fe53a23d41bb69d36f2ea5e7885d214b461cbd81 Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Sun, 7 Apr 2019 16:48:07 +0530 Subject: [PATCH 13/56] updated post review comments --- .../filechannel/FileChannelUnitTest.java | 288 ++++++++++-------- 1 file changed, 156 insertions(+), 132 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 35ba9aca65..37b203241b 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.filechannel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; @@ -8,171 +9,194 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.channels.OverlappingFileLockException; import java.nio.charset.StandardCharsets; import org.junit.Test; public class FileChannelUnitTest { - @Test - public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; + + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - out.close(); - channel.close(); - reader.close(); - } + while (channel.read(buff) > 0) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + } - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream(file); - FileChannel channel = fin.getChannel(); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); + } + } - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + String expected_value = "Hello world"; + String file = "src/test/resources/test_read.in"; - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream(file); + FileChannel channel = fin.getChannel();) { - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - out.close(); - channel.close(); - fin.close(); - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String input = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; + while (channel.read(buff) > 0) { + if (buff.hasArray()) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + } - RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel(); + assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - while (buff.hasRemaining()) { - channel.write(buff); - } - channel.close(); - writer.close(); + } + } + + + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + String expected_value = "world"; + String file = "src/test/resources/test_read.in"; - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(input, reader.readLine()); - reader.close(); - } + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - @Test - public void whenWriteWithFileChannelUsingFileOutputStream_thenCorrect() throws IOException { - String input = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - FileOutputStream fout = new FileOutputStream(file); - FileChannel channel = fout.getChannel(); + if(buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals(expected_value, new String(data, StandardCharsets.UTF_8)); + + } + + } + } + + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() + throws IOException { + String expected = "Hello world"; + String file = "src/test/resources/test_write_using_filechannel.txt"; + + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();){ + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + + if (buff.hasRemaining()) { + channel.write(buff); + } + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals(expected, reader.readLine()); + reader.close(); + } + } + + + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + String file = "src/test/resources/test_read.in"; - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - while (buff.hasRemaining()) { - channel.write(buff); - } + try (RandomAccessFile reader = new RandomAccessFile(file, "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE );){ + + + assertNotNull(fileLock); + + }catch(OverlappingFileLockException | IOException ex) { + + + } + + } + - channel.close(); - fout.close(); + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + long expected_value = 11; + String file = "src/test/resources/test_read.in"; - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(input, reader.readLine()); - reader.close(); - } + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel();) { - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - long expected_value = 11; - String file = "src/test/resources/test_read.in"; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } + assertEquals(expected_value, channel.position()); - assertEquals(expected_value, channel.position()); + channel.position(4); + assertEquals(4, channel.position()); - channel.position(4); - assertEquals(4, channel.position()); + } + } - out.close(); - channel.close(); - reader.close(); - } + + @Test + public void whenGetFileSize_thenCorrect() throws IOException { + long expectedSize = 11; + String file = "src/test/resources/test_read.in"; + + try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + FileChannel channel = reader.getChannel();) { - @Test - public void whenGetFileSize_thenCorrect() throws IOException { - long expectedSize = 11; - String file = "src/test/resources/test_read.in"; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); + long imageFileSize = channel.size(); + assertEquals(expectedSize, imageFileSize); + } - long imageFileSize = channel.size(); - assertEquals(expectedSize, imageFileSize); + } - channel.close(); - reader.close(); - } + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + long expectedSize = 5; + String input = "this is a test input"; + String file = "src/test/resources/test_truncate.txt"; - @Test - public void whenTruncateFile_thenCorrect() throws IOException { - long expectedSize = 5; - String input = "this is a test input"; - String file = "src/test/resources/test_truncate.txt"; + FileOutputStream fout = new FileOutputStream(file); + FileChannel channel = fout.getChannel(); - FileOutputStream fout = new FileOutputStream(file); - FileChannel channel = fout.getChannel(); + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - channel.write(buff); - buff.flip(); + channel = channel.truncate(5); + assertEquals(expectedSize, channel.size()); - channel = channel.truncate(5); - assertEquals(expectedSize, channel.size()); - - fout.close(); - channel.close(); - } + fout.close(); + channel.close(); + } } From 27559b3a7fab1bd1e97e5d3690eb07a76afe2ed0 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 7 Apr 2019 15:14:30 +0300 Subject: [PATCH 14/56] Split into separate test cases --- .../baeldung/guava/GuavaMultiSetUnitTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 3d75cc38a3..47411031b9 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; public class GuavaMultiSetUnitTest { @Test - public void givenMultiSet_whenAddAndRemoveValues_shouldReturnCorrectCount() { + public void givenMultiSet_whenAddingValues_shouldReturnCorrectCount() { Multiset bookStore = HashMultiset.create(); bookStore.add("Potter"); bookStore.add("Potter"); @@ -21,10 +21,17 @@ public class GuavaMultiSetUnitTest { assertThat(bookStore.contains("Potter")).isTrue(); assertThat(bookStore.count("Potter")).isEqualTo(3); + } + + @Test + public void givenMultiSet_whenRemovingValues_shouldReturnCorrectCount() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); bookStore.remove("Potter"); assertThat(bookStore.contains("Potter")).isTrue(); - assertThat(bookStore.count("Potter")).isEqualTo(2); + assertThat(bookStore.count("Potter")).isEqualTo(1); } @Test @@ -37,14 +44,32 @@ public class GuavaMultiSetUnitTest { @Test public void givenMultiSet_whenSettingNegativeCount_shouldThrowException() { Multiset bookStore = HashMultiset.create(); - assertThatThrownBy(() -> bookStore.setCount("Potter", -1)).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> bookStore.setCount("Potter", -1)) + .isInstanceOf(IllegalArgumentException.class); } @Test - public void givenMultiSet_whenSettingCountWithOldCount_shouldReturnCorrectValue() { + public void givenMultiSet_whenSettingCountWithEmptySet_shouldBeSuccessful() { Multiset bookStore = HashMultiset.create(); assertThat(bookStore.setCount("Potter", 0, 2)).isTrue(); - assertThat(bookStore.setCount("Potter", 50, 5)).isFalse(); + } + + @Test + public void givenMultiSet_whenSettingCountWithCorrectValue_shouldBeSuccessful() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.setCount("Potter", 2, 52)).isTrue(); + } + + @Test + public void givenMultiSet_whenSettingCountWithIncorrectValue_shouldFail() { + Multiset bookStore = HashMultiset.create(); + bookStore.add("Potter"); + bookStore.add("Potter"); + + assertThat(bookStore.setCount("Potter", 5, 52)).isFalse(); } @Test From bbce155a78d28db6d5bf334a01ffce43f309c365 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Tue, 9 Apr 2019 22:44:45 +0530 Subject: [PATCH 15/56] BAEL-2841 spring data jpa populators --- persistence-modules/spring-data-jpa-2/pom.xml | 56 +++++++++++-------- .../com/baeldung/config/JpaPopulators.java | 33 +++++++++++ .../main/java/com/baeldung/entity/Fruit.java | 2 + .../src/main/resources/fruit-data.json | 14 +++++ .../src/main/resources/fruit-data.xml | 7 +++ .../repository/FruitPopulatorTest.java | 53 ++++++++++++++++++ 6 files changed, 142 insertions(+), 23 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java diff --git a/persistence-modules/spring-data-jpa-2/pom.xml b/persistence-modules/spring-data-jpa-2/pom.xml index 8e46112659..5080ad9bd3 100644 --- a/persistence-modules/spring-data-jpa-2/pom.xml +++ b/persistence-modules/spring-data-jpa-2/pom.xml @@ -1,30 +1,40 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 com.baeldung - spring-data-jpa-2 + spring-data-jpa-2 spring-data-jpa - - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - com.h2database - h2 - - - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + + + + com.fasterxml.jackson.core + jackson-databind + + + + org.springframework + spring-oxm + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java new file mode 100644 index 0000000000..cb4b32aabc --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -0,0 +1,33 @@ +package com.baeldung.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; +import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +import com.baeldung.entity.Fruit; + +@Configuration +public class JpaPopulators { + + @Bean + public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { + Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); + factory.setResources(new Resource[] { (Resource) new ClassPathResource("fruit-data.json") }); + return factory; + } + + @Bean + public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); + factory.setUnmarshaller(marshaller); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + return factory; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java index f82022e67e..d45ac33db8 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/entity/Fruit.java @@ -2,7 +2,9 @@ package com.baeldung.entity; import javax.persistence.Entity; import javax.persistence.Id; +import javax.xml.bind.annotation.XmlRootElement; +@XmlRootElement @Entity public class Fruit { diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json new file mode 100644 index 0000000000..214ea18e4d --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json @@ -0,0 +1,14 @@ +[ + { + "_class": "com.baeldung.entity.Fruit", + "name": "apple", + "color": "red", + "id": 1 + }, + { + "_class": "com.baeldung.entity.Fruit", + "name": "guava", + "color": "green", + "id": 2 + } +] \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml new file mode 100644 index 0000000000..fe6eb71faf --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -0,0 +1,7 @@ + + + + 3 + mango + yellow + diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java new file mode 100644 index 0000000000..8760c69ce8 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java @@ -0,0 +1,53 @@ +package com.baeldung.repository; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +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.test.context.junit4.SpringRunner; + +import com.baeldung.entity.Fruit; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class FruitPopulatorTest { + + @Autowired + private FruitRepository fruitRepository; + + @Test + public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 3, fruits.size()); + + fruits.forEach(fruit -> { + if (1 == fruit.getId()) { + assertEquals("This is not an apple", "apple", fruit.getName()); + assertEquals("It is not a red colored fruit", "red", fruit.getColor()); + } else if (2 == fruit.getId()) { + assertEquals("This is not a guava", "guava", fruit.getName()); + assertEquals("It is not a green colored fruit", "green", fruit.getColor()); + } + }); + } + + @Test + public void givenFruitXmlPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 3, fruits.size()); + + fruits.forEach(fruit -> { + if (3 == fruit.getId()) { + assertEquals("This is not a mango", "mango", fruit.getName()); + assertEquals("It is not a yellow colored fruit", "yellow", fruit.getColor()); + } + }); + } + +} From 2674f7abff53137b5680ac2d9ecc5c86bbc3e9cb Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 6 Apr 2019 20:45:08 +0200 Subject: [PATCH 16/56] BAEL-1970 minor log message correction --- .../main/java/com/baeldung/component/OtherComponent.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java index 61f5b440c3..97f001a9e5 100644 --- a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java +++ b/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java @@ -10,10 +10,10 @@ public class OtherComponent { private static final Logger LOG = LoggerFactory.getLogger(OtherComponent.class); public void processData() { - LOG.trace("This is a TRACE log from OtherComponent"); - LOG.debug("This is a DEBUG log from OtherComponent"); - LOG.info("This is an INFO log from OtherComponent"); - LOG.error("This is an ERROR log from OtherComponent"); + LOG.trace("This is a TRACE log from another package"); + LOG.debug("This is a DEBUG log from another package"); + LOG.info("This is an INFO log from another package"); + LOG.error("This is an ERROR log from another package"); } } From 7186d96b12c4906243828b5875a2bc4e10e7121f Mon Sep 17 00:00:00 2001 From: mprevisic Date: Wed, 10 Apr 2019 15:28:37 +0200 Subject: [PATCH 17/56] BAEL-1970 fixed formatting (use spaces instead of tabs) --- ...ltiProfileTestLogLevelIntegrationTest.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java index 5192a1f00e..7a1eb4adbe 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -22,49 +22,49 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("logback-test2") public class LogbackMultiProfileTestLogLevelIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - private String baseUrl = "/testLogLevel"; + private String baseUrl = "/testLogLevel"; - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintTraceLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("TRACE"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("TRACE"); + } - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenNoTraceLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("TRACE"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("TRACE"); + } - @Test - public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndTraceLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("ERROR"); - assertThatOutputContainsLogForOtherPackages("ERROR"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } From c3bd97f39a67cb38f3adf850b1f88d3642b3ff3b Mon Sep 17 00:00:00 2001 From: mprevisic Date: Wed, 10 Apr 2019 15:52:47 +0200 Subject: [PATCH 18/56] BAEL-1970 fixed formatting in xml files --- .../test/resources/logback-multiprofile.xml | 34 +++++++++---------- .../src/test/resources/logback-test.xml | 22 ++++++------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml index 3711f1ec71..09ca6e4cac 100644 --- a/spring-boot-testing/src/test/resources/logback-multiprofile.xml +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -1,18 +1,18 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - \ No newline at end of file + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + diff --git a/spring-boot-testing/src/test/resources/logback-test.xml b/spring-boot-testing/src/test/resources/logback-test.xml index 9c6df17024..312af7c2bf 100644 --- a/spring-boot-testing/src/test/resources/logback-test.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -1,13 +1,13 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + From d9540eff75f2a525ae6a73c97ba004e7a493d866 Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Thu, 11 Apr 2019 14:52:55 +0530 Subject: [PATCH 19/56] changes for review comments --- .../filechannel/FileChannelUnitTest.java | 239 ++++++++---------- 1 file changed, 105 insertions(+), 134 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index 37b203241b..d883972369 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -21,10 +21,8 @@ public class FileChannelUnitTest { @Test public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); FileChannel channel = reader.getChannel(); ByteArrayOutputStream out = new ByteArrayOutputStream();) { @@ -34,130 +32,108 @@ public class FileChannelUnitTest { } ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } - - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - } - - - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - String expected_value = "Hello world"; - String file = "src/test/resources/test_read.in"; - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream(file); - FileChannel channel = fin.getChannel();) { - - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); - - while (channel.read(buff) > 0) { - if (buff.hasArray()) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } - } - - assertEquals(expected_value, new String(out.toByteArray(), StandardCharsets.UTF_8)); - - } - } - - - @Test - public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { - String expected_value = "world"; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { - - MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - - if(buff.hasRemaining()) { - byte[] data = new byte[buff.remaining()]; - buff.get(data); - assertEquals(expected_value, new String(data, StandardCharsets.UTF_8)); - - } - - } - } - - - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() - throws IOException { - String expected = "Hello world"; - String file = "src/test/resources/test_write_using_filechannel.txt"; - - try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel();){ - ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); - - if (buff.hasRemaining()) { - channel.write(buff); - } - - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals(expected, reader.readLine()); - reader.close(); - } - } - - - @Test - public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "rw"); - FileChannel channel = reader.getChannel(); - FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE );){ - - - assertNotNull(fileLock); - - }catch(OverlappingFileLockException | IOException ex) { - - - } - - } - - - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - long expected_value = 11; - String file = "src/test/resources/test_read.in"; - - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel();) { - - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { out.write(buff.array(), 0, buff.position()); buff.clear(); } - assertEquals(expected_value, channel.position()); + assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + } + } + + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); + FileChannel channel = fin.getChannel();) { + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + + assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + + } + } + + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { + + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); + + if (buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals("world", new String(data, StandardCharsets.UTF_8)); + + } + + } + } + + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String file = "src/test/resources/test_write_using_filechannel.txt"; + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();) { + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + + if (buff.hasRemaining()) { + channel.write(buff); + } + + // verify + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals("Hello world", reader.readLine()); + reader.close(); + } + } + + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { + + assertNotNull(fileLock); + + } catch (OverlappingFileLockException | IOException ex) { + + } + + } + + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { + + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); + + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + + assertEquals(11, channel.position()); channel.position(4); assertEquals(4, channel.position()); @@ -165,28 +141,23 @@ public class FileChannelUnitTest { } } - @Test public void whenGetFileSize_thenCorrect() throws IOException { - long expectedSize = 11; - String file = "src/test/resources/test_read.in"; - - try (RandomAccessFile reader = new RandomAccessFile(file, "r"); - FileChannel channel = reader.getChannel();) { + + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { long imageFileSize = channel.size(); - assertEquals(expectedSize, imageFileSize); + assertEquals(11, imageFileSize); } } @Test public void whenTruncateFile_thenCorrect() throws IOException { - long expectedSize = 5; String input = "this is a test input"; - String file = "src/test/resources/test_truncate.txt"; - FileOutputStream fout = new FileOutputStream(file); + FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); FileChannel channel = fout.getChannel(); ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); @@ -194,7 +165,7 @@ public class FileChannelUnitTest { buff.flip(); channel = channel.truncate(5); - assertEquals(expectedSize, channel.size()); + assertEquals(5, channel.size()); fout.close(); channel.close(); From fece0dc4b8bcbb870c5a524719a30a93529deb7f Mon Sep 17 00:00:00 2001 From: Anurag Goyal Date: Thu, 11 Apr 2019 19:06:41 +0530 Subject: [PATCH 20/56] changes as per review comments --- .../filechannel/FileChannelUnitTest.java | 230 +++++++++--------- 1 file changed, 111 insertions(+), 119 deletions(-) diff --git a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java index d883972369..6964ba80e3 100644 --- a/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/filechannel/FileChannelUnitTest.java @@ -12,162 +12,154 @@ import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.nio.channels.OverlappingFileLockException; import java.nio.charset.StandardCharsets; import org.junit.Test; public class FileChannelUnitTest { - @Test - public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + @Test + public void givenFile_whenReadWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); - } - } + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); - @Test - public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { + assertEquals("Hello world", fileContent); + } + } - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); - FileChannel channel = fin.getChannel();) { + @Test + public void givenFile_whenReadWithFileChannelUsingFileInputStream_thenCorrect() throws IOException { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream("src/test/resources/test_read.in"); + FileChannel channel = fin.getChannel();) { - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - assertEquals("Hello world", new String(out.toByteArray(), StandardCharsets.UTF_8)); + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); - } - } + assertEquals("Hello world", fileContent); + } + } - @Test - public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { + @Test + public void givenFile_whenReadAFileSectionIntoMemoryWithFileChannel_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel(); - ByteArrayOutputStream out = new ByteArrayOutputStream();) { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel(); + ByteArrayOutputStream out = new ByteArrayOutputStream();) { - MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); + MappedByteBuffer buff = channel.map(FileChannel.MapMode.READ_ONLY, 6, 5); - if (buff.hasRemaining()) { - byte[] data = new byte[buff.remaining()]; - buff.get(data); - assertEquals("world", new String(data, StandardCharsets.UTF_8)); + if (buff.hasRemaining()) { + byte[] data = new byte[buff.remaining()]; + buff.get(data); + assertEquals("world", new String(data, StandardCharsets.UTF_8)); + } + } + } - } + @Test + public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { + String file = "src/test/resources/test_write_using_filechannel.txt"; + try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); + FileChannel channel = writer.getChannel();) { + ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); - } - } + channel.write(buff); - @Test - public void whenWriteWithFileChannelUsingRandomAccessFile_thenCorrect() throws IOException { - String file = "src/test/resources/test_write_using_filechannel.txt"; - try (RandomAccessFile writer = new RandomAccessFile(file, "rw"); - FileChannel channel = writer.getChannel();) { - ByteBuffer buff = ByteBuffer.wrap("Hello world".getBytes(StandardCharsets.UTF_8)); + // now we verify whether the file was written correctly + RandomAccessFile reader = new RandomAccessFile(file, "r"); + assertEquals("Hello world", reader.readLine()); + reader.close(); + } + } - if (buff.hasRemaining()) { - channel.write(buff); - } + @Test + public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); + FileChannel channel = reader.getChannel(); + FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { - // verify - RandomAccessFile reader = new RandomAccessFile(file, "r"); - assertEquals("Hello world", reader.readLine()); - reader.close(); - } - } + assertNotNull(fileLock); + } + } - @Test - public void givenFile_whenWriteAFileUsingLockAFileSectionWithFileChannel_thenCorrect() throws IOException { - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "rw"); - FileChannel channel = reader.getChannel(); - FileLock fileLock = channel.tryLock(6, 5, Boolean.FALSE);) { + @Test + public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { - assertNotNull(fileLock); + try (ByteArrayOutputStream out = new ByteArrayOutputStream(); + RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { - } catch (OverlappingFileLockException | IOException ex) { + int bufferSize = 1024; + if (bufferSize > channel.size()) { + bufferSize = (int) channel.size(); + } + ByteBuffer buff = ByteBuffer.allocate(bufferSize); - } + while (channel.read(buff) > 0) { + out.write(buff.array(), 0, buff.position()); + buff.clear(); + } - } + // the original file is 11 bytes long, so that's where the position pointer should be + assertEquals(11, channel.position()); - @Test - public void givenFile_whenReadWithFileChannelGetPosition_thenCorrect() throws IOException { + channel.position(4); + assertEquals(4, channel.position()); + } + } - try (ByteArrayOutputStream out = new ByteArrayOutputStream(); - RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel();) { + @Test + public void whenGetFileSize_thenCorrect() throws IOException { - int bufferSize = 1024; - if (bufferSize > channel.size()) { - bufferSize = (int) channel.size(); - } - ByteBuffer buff = ByteBuffer.allocate(bufferSize); + try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); + FileChannel channel = reader.getChannel();) { - while (channel.read(buff) > 0) { - out.write(buff.array(), 0, buff.position()); - buff.clear(); - } + // the original file is 11 bytes long, so that's where the position pointer should be + assertEquals(11, channel.size()); + } + } - assertEquals(11, channel.position()); + @Test + public void whenTruncateFile_thenCorrect() throws IOException { + String input = "this is a test input"; - channel.position(4); - assertEquals(4, channel.position()); + FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); + FileChannel channel = fout.getChannel(); - } - } + ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); + channel.write(buff); + buff.flip(); - @Test - public void whenGetFileSize_thenCorrect() throws IOException { + channel = channel.truncate(5); + assertEquals(5, channel.size()); - try (RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r"); - FileChannel channel = reader.getChannel();) { - - long imageFileSize = channel.size(); - assertEquals(11, imageFileSize); - } - - } - - @Test - public void whenTruncateFile_thenCorrect() throws IOException { - String input = "this is a test input"; - - FileOutputStream fout = new FileOutputStream("src/test/resources/test_truncate.txt"); - FileChannel channel = fout.getChannel(); - - ByteBuffer buff = ByteBuffer.wrap(input.getBytes()); - channel.write(buff); - buff.flip(); - - channel = channel.truncate(5); - assertEquals(5, channel.size()); - - fout.close(); - channel.close(); - } + fout.close(); + channel.close(); + } } From 7bb364a2f20c059ff53ec38e0b11e5d2174b0b76 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Thu, 11 Apr 2019 23:01:50 +0530 Subject: [PATCH 21/56] BAEL-2841 updated test cases and test data --- .../com/baeldung/config/JpaPopulators.java | 66 +++++++------- .../src/main/resources/fruit-data.xml | 14 +-- .../repository/FruitPopulatorTest.java | 91 ++++++++----------- 3 files changed, 78 insertions(+), 93 deletions(-) diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java index cb4b32aabc..0791df85f4 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -1,33 +1,33 @@ -package com.baeldung.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; -import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; - -import com.baeldung.entity.Fruit; - -@Configuration -public class JpaPopulators { - - @Bean - public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { - Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); - factory.setResources(new Resource[] { (Resource) new ClassPathResource("fruit-data.json") }); - return factory; - } - - @Bean - public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { - Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - marshaller.setClassesToBeBound(Fruit.class); - UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); - factory.setUnmarshaller(marshaller); - factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); - return factory; - } - -} +package com.baeldung.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.data.repository.init.Jackson2RepositoryPopulatorFactoryBean; +import org.springframework.data.repository.init.UnmarshallerRepositoryPopulatorFactoryBean; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +import com.baeldung.entity.Fruit; + +@Configuration +public class JpaPopulators { + + @Bean + public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws Exception { + Jackson2RepositoryPopulatorFactoryBean factory = new Jackson2RepositoryPopulatorFactoryBean(); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.json") }); + return factory; + } + + @Bean + public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); + factory.setUnmarshaller(marshaller); + factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + return factory; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml index fe6eb71faf..d0101e3f4d 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -1,7 +1,7 @@ - - - - 3 - mango - yellow - + + + + 1 + apple + red + diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java index 8760c69ce8..29ef52dcef 100644 --- a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/repository/FruitPopulatorTest.java @@ -1,53 +1,38 @@ -package com.baeldung.repository; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -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.test.context.junit4.SpringRunner; - -import com.baeldung.entity.Fruit; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class FruitPopulatorTest { - - @Autowired - private FruitRepository fruitRepository; - - @Test - public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { - - List fruits = fruitRepository.findAll(); - assertEquals("record count is not matching", 3, fruits.size()); - - fruits.forEach(fruit -> { - if (1 == fruit.getId()) { - assertEquals("This is not an apple", "apple", fruit.getName()); - assertEquals("It is not a red colored fruit", "red", fruit.getColor()); - } else if (2 == fruit.getId()) { - assertEquals("This is not a guava", "guava", fruit.getName()); - assertEquals("It is not a green colored fruit", "green", fruit.getColor()); - } - }); - } - - @Test - public void givenFruitXmlPopulatorThenShouldInsertRecordOnStart() { - - List fruits = fruitRepository.findAll(); - assertEquals("record count is not matching", 3, fruits.size()); - - fruits.forEach(fruit -> { - if (3 == fruit.getId()) { - assertEquals("This is not a mango", "mango", fruit.getName()); - assertEquals("It is not a yellow colored fruit", "yellow", fruit.getColor()); - } - }); - } - -} +package com.baeldung.repository; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +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.test.context.junit4.SpringRunner; + +import com.baeldung.entity.Fruit; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class FruitPopulatorTest { + + @Autowired + private FruitRepository fruitRepository; + + @Test + public void givenFruitJsonPopulatorThenShouldInsertRecordOnStart() { + + List fruits = fruitRepository.findAll(); + assertEquals("record count is not matching", 2, fruits.size()); + + fruits.forEach(fruit -> { + if (1 == fruit.getId()) { + assertEquals("apple", fruit.getName()); + assertEquals("red", fruit.getColor()); + } else if (2 == fruit.getId()) { + assertEquals("guava", fruit.getName()); + assertEquals("green", fruit.getColor()); + } + }); + } +} From 6ae1e85d1361b62f5762129c2664e2fbe822ea25 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Fri, 12 Apr 2019 09:13:59 +0200 Subject: [PATCH 22/56] BAEL-1970 fixed formatting --- .../LogbackTestLogLevelIntegrationTest.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index 5fb40a2f36..af3bafdc2e 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -22,49 +22,49 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("logback-test") public class LogbackTestLogLevelIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Rule - public OutputCapture outputCapture = new OutputCapture(); + @Rule + public OutputCapture outputCapture = new OutputCapture(); - private String baseUrl = "/testLogLevel"; + private String baseUrl = "/testLogLevel"; - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintDebugLogsForOurPackage() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("DEBUG"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("DEBUG"); + } - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenNoDebugLogsForOtherPackages() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputDoesntContainLogForOtherPackages("DEBUG"); + } - @Test - public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { - ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); + @Test + public void givenErrorRootLevelAndDebugLevelForOurPackage_whenCall_thenPrintErrorLogs() { + ResponseEntity response = restTemplate.getForEntity(baseUrl, String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThatOutputContainsLogForOurPackage("ERROR"); - assertThatOutputContainsLogForOtherPackages("ERROR"); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThatOutputContainsLogForOurPackage("ERROR"); + assertThatOutputContainsLogForOtherPackages("ERROR"); + } - private void assertThatOutputContainsLogForOurPackage(String level) { - assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); - } + private void assertThatOutputContainsLogForOurPackage(String level) { + assertThat(outputCapture.toString()).containsPattern("TestLogLevelController.*" + level + ".*"); + } - private void assertThatOutputDoesntContainLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); - } + private void assertThatOutputDoesntContainLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).doesNotContain(level); + } - private void assertThatOutputContainsLogForOtherPackages(String level) { - assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); - } + private void assertThatOutputContainsLogForOtherPackages(String level) { + assertThat(outputCapture.toString().replaceAll("(?m)^.*TestLogLevelController.*$", "")).contains(level); + } } From 00d6406ef9b343c3f64868b657e0350b77194f73 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 12 Apr 2019 16:31:22 +0200 Subject: [PATCH 23/56] add generic constructor examples --- .../java/com/baeldung/generics/Entry.java | 38 ++++++++++ .../com/baeldung/generics/GenericEntry.java | 53 +++++++++++++ .../java/com/baeldung/generics/MapEntry.java | 34 +++++++++ .../java/com/baeldung/generics/Product.java | 50 ++++++++++++ .../java/com/baeldung/generics/Rankable.java | 5 ++ .../generics/GenericConstructorUnitTest.java | 76 +++++++++++++++++++ 6 files changed, 256 insertions(+) create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java create mode 100644 core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java create mode 100644 core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java new file mode 100644 index 0000000000..07759ca9ba --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java @@ -0,0 +1,38 @@ +package com.baeldung.generics; + +import java.io.Serializable; + +public class Entry { + private String data; + private int rank; + + // non-generic constructor + public Entry(String data, int rank) { + this.data = data; + this.rank = rank; + } + + // generic constructor + public Entry(E element) { + this.data = element.toString(); + this.rank = element.getRank(); + } + + // getters and setters + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java new file mode 100644 index 0000000000..27d3a44069 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java @@ -0,0 +1,53 @@ +package com.baeldung.generics; + +import java.io.Serializable; +import java.util.Optional; + +public class GenericEntry { + private T data; + private int rank; + + // non-generic constructor + public GenericEntry(int rank) { + this.rank = rank; + } + + // generic constructor + public GenericEntry(T data, int rank) { + this.data = data; + this.rank = rank; + } + + // generic constructor with different type + public GenericEntry(E element) { + this.data = (T) element; + this.rank = element.getRank(); + } + + // generic constructor with different type and wild card + public GenericEntry(Optional optional) { + if (optional.isPresent()) { + this.data = (T) optional.get(); + this.rank = optional.get() + .getRank(); + } + } + + // getters and setters + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java new file mode 100644 index 0000000000..3d626b2fa5 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java @@ -0,0 +1,34 @@ +package com.baeldung.generics; + +public class MapEntry { + private K key; + private V value; + + public MapEntry() { + super(); + } + + // generic constructor with two parameters + public MapEntry(K key, V value) { + this.key = key; + this.value = value; + } + + // getters and setters + public K getKey() { + return key; + } + + public void setKey(K key) { + this.key = key; + } + + public V getValue() { + return value; + } + + public void setValue(V value) { + this.value = value; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java new file mode 100644 index 0000000000..bfc9f63071 --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java @@ -0,0 +1,50 @@ +package com.baeldung.generics; + +import java.io.Serializable; + +public class Product implements Rankable, Serializable { + private String name; + private double price; + private int sales; + + public Product(String name, double price) { + this.name = name; + this.price = price; + } + + @Override + public int getRank() { + return sales; + } + + @Override + public String toString() { + return "Product [name=" + name + ", price=" + price + ", sales=" + sales + "]"; + } + + // getters and setters + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public int getSales() { + return sales; + } + + public void setSales(int sales) { + this.sales = sales; + } + +} diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java new file mode 100644 index 0000000000..72bda67d9d --- /dev/null +++ b/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java @@ -0,0 +1,5 @@ +package com.baeldung.generics; + +public interface Rankable { + public int getRank(); +} diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java new file mode 100644 index 0000000000..60907bbfd3 --- /dev/null +++ b/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.generics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.Serializable; +import java.util.Optional; + +import org.junit.Test; + +public class GenericConstructorUnitTest { + + @Test + public void givenNonGenericConstructor_whenCreateNonGenericEntry_thenOK() { + Entry entry = new Entry("sample", 1); + + assertEquals("sample", entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateNonGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + Entry entry = new Entry(product); + + assertEquals(product.toString(), entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenNonGenericConstructor_whenCreateGenericEntry_thenOK() { + GenericEntry entry = new GenericEntry(1); + + assertNull(entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateGenericEntry_thenOK() { + GenericEntry entry = new GenericEntry("sample", 1); + + assertEquals("sample", entry.getData()); + assertEquals(1, entry.getRank()); + } + + @Test + public void givenGenericConstructorWithDifferentType_whenCreateGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + GenericEntry entry = new GenericEntry(product); + + assertEquals(product, entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenGenericConstructorWithWildCard_whenCreateGenericEntry_thenOK() { + Product product = new Product("milk", 2.5); + product.setSales(30); + Optional optional = Optional.of(product); + GenericEntry entry = new GenericEntry(optional); + + assertEquals(product, entry.getData()); + assertEquals(30, entry.getRank()); + } + + @Test + public void givenGenericConstructor_whenCreateGenericEntryWithTwoTypes_thenOK() { + MapEntry entry = new MapEntry("sample", 1); + + assertEquals("sample", entry.getKey()); + assertEquals(1, entry.getValue() + .intValue()); + } +} From 03a369d153874f5f89ef613691e500e8c83d4ad3 Mon Sep 17 00:00:00 2001 From: mprevisic Date: Sat, 13 Apr 2019 10:36:17 +0200 Subject: [PATCH 24/56] BAEL-1970 fixed logback base.xml path --- spring-boot-testing/src/test/resources/logback-multiprofile.xml | 2 +- spring-boot-testing/src/test/resources/logback-test.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-testing/src/test/resources/logback-multiprofile.xml index 09ca6e4cac..be790234f2 100644 --- a/spring-boot-testing/src/test/resources/logback-multiprofile.xml +++ b/spring-boot-testing/src/test/resources/logback-multiprofile.xml @@ -1,5 +1,5 @@ - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n diff --git a/spring-boot-testing/src/test/resources/logback-test.xml b/spring-boot-testing/src/test/resources/logback-test.xml index 312af7c2bf..0528aa88f3 100644 --- a/spring-boot-testing/src/test/resources/logback-test.xml +++ b/spring-boot-testing/src/test/resources/logback-test.xml @@ -1,5 +1,5 @@ - + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n From 431670601afc51c2ed84cc58def8dff95bf99651 Mon Sep 17 00:00:00 2001 From: Sushant Date: Sun, 14 Apr 2019 12:21:51 +0300 Subject: [PATCH 25/56] Created new module guava-collections-set --- guava-collections-set/.gitignore | 13 +++++++ guava-collections-set/pom.xml | 37 +++++++++++++++++++ .../baeldung/guava/GuavaMultiSetUnitTest.java | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 guava-collections-set/.gitignore create mode 100644 guava-collections-set/pom.xml rename {guava-collections => guava-collections-set}/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java (99%) diff --git a/guava-collections-set/.gitignore b/guava-collections-set/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/guava-collections-set/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/guava-collections-set/pom.xml b/guava-collections-set/pom.xml new file mode 100644 index 0000000000..46dcae492d --- /dev/null +++ b/guava-collections-set/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + com.baeldung + guava-collections-set + 0.1.0-SNAPSHOT + guava-collections-set + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + guava-collections-set + + + + + 27.1-jre + + 3.6.1 + + + diff --git a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java similarity index 99% rename from guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java rename to guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java index 47411031b9..e74db29881 100644 --- a/guava-collections/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java @@ -89,4 +89,4 @@ public class GuavaMultiSetUnitTest { bookStore.put("Potter", -1); assertThat(bookStore.containsKey("Potter")).isTrue(); } -} +} \ No newline at end of file From 15cb0aebfcec2893324b79b41d2c8d6ff667a652 Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Sun, 14 Apr 2019 17:42:51 +0530 Subject: [PATCH 26/56] fix spring boot project --- vaadin/pom.xml | 22 +- .../com/baeldung/introduction/VaadinUI.java | 281 ------------------ 2 files changed, 3 insertions(+), 300 deletions(-) delete mode 100644 vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java diff --git a/vaadin/pom.xml b/vaadin/pom.xml index d24b3dff1b..145a6af293 100644 --- a/vaadin/pom.xml +++ b/vaadin/pom.xml @@ -33,22 +33,6 @@ javax.servlet-api provided - - com.vaadin - vaadin-server - - - com.vaadin - vaadin-push - - - com.vaadin - vaadin-client-compiled - - - com.vaadin - vaadin-themes - org.springframework.boot @@ -183,9 +167,9 @@ 3.0.1 - 7.7.10 - 8.0.6 - 10.0.1 + 10.0.11 + 10.0.11 + 10.0.11 9.3.9.v20160517 UTF-8 1.8 diff --git a/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java b/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java deleted file mode 100644 index 1b3733ad74..0000000000 --- a/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.baeldung.introduction; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.servlet.annotation.WebServlet; - -import com.vaadin.annotations.Push; -import com.vaadin.annotations.Theme; -import com.vaadin.annotations.VaadinServletConfiguration; -import com.vaadin.data.Validator.InvalidValueException; -import com.vaadin.data.fieldgroup.BeanFieldGroup; -import com.vaadin.data.validator.StringLengthValidator; -import com.vaadin.server.ExternalResource; -import com.vaadin.server.FontAwesome; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinServlet; -import com.vaadin.ui.Button; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.Grid; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.InlineDateField; -import com.vaadin.ui.Label; -import com.vaadin.ui.Link; -import com.vaadin.ui.ListSelect; -import com.vaadin.ui.NativeButton; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Panel; -import com.vaadin.ui.PasswordField; -import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.TextArea; -import com.vaadin.ui.TextField; -import com.vaadin.ui.TwinColSelect; -import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; - -@SuppressWarnings("serial") -@Push -@Theme("mytheme") -public class VaadinUI extends UI { - - private Label currentTime; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - protected void init(VaadinRequest vaadinRequest) { - final VerticalLayout verticalLayout = new VerticalLayout(); - verticalLayout.setSpacing(true); - verticalLayout.setMargin(true); - final GridLayout gridLayout = new GridLayout(3, 2); - gridLayout.setSpacing(true); - gridLayout.setMargin(true); - final HorizontalLayout horizontalLayout = new HorizontalLayout(); - horizontalLayout.setSpacing(true); - horizontalLayout.setMargin(true); - final FormLayout formLayout = new FormLayout(); - formLayout.setSpacing(true); - formLayout.setMargin(true); - final GridLayout buttonLayout = new GridLayout(3, 5); - buttonLayout.setMargin(true); - buttonLayout.setSpacing(true); - - final Label label = new Label(); - label.setId("Label"); - label.setValue("Label Value"); - label.setCaption("Label"); - gridLayout.addComponent(label); - - final Link link = new Link("Baeldung", new ExternalResource("http://www.baeldung.com/")); - link.setId("Link"); - link.setTargetName("_blank"); - gridLayout.addComponent(link); - - final TextField textField = new TextField(); - textField.setId("TextField"); - textField.setCaption("TextField:"); - textField.setValue("TextField Value"); - textField.setIcon(FontAwesome.USER); - gridLayout.addComponent(textField); - - final TextArea textArea = new TextArea(); - textArea.setCaption("TextArea"); - textArea.setId("TextArea"); - textArea.setValue("TextArea Value"); - gridLayout.addComponent(textArea); - - final DateField dateField = new DateField("DateField", new Date(0)); - dateField.setId("DateField"); - gridLayout.addComponent(dateField); - - final PasswordField passwordField = new PasswordField(); - passwordField.setId("PasswordField"); - passwordField.setCaption("PasswordField:"); - passwordField.setValue("password"); - gridLayout.addComponent(passwordField); - - final RichTextArea richTextArea = new RichTextArea(); - richTextArea.setCaption("Rich Text Area"); - richTextArea.setValue("

RichTextArea

"); - richTextArea.setSizeFull(); - - Panel richTextPanel = new Panel(); - richTextPanel.setContent(richTextArea); - - final InlineDateField inlineDateField = new InlineDateField(); - inlineDateField.setValue(new Date(0)); - inlineDateField.setCaption("Inline Date Field"); - horizontalLayout.addComponent(inlineDateField); - - Button normalButton = new Button("Normal Button"); - normalButton.setId("NormalButton"); - normalButton.addClickListener(e -> { - label.setValue("CLICK"); - }); - buttonLayout.addComponent(normalButton); - - Button tinyButton = new Button("Tiny Button"); - tinyButton.addStyleName("tiny"); - buttonLayout.addComponent(tinyButton); - - Button smallButton = new Button("Small Button"); - smallButton.addStyleName("small"); - buttonLayout.addComponent(smallButton); - - Button largeButton = new Button("Large Button"); - largeButton.addStyleName("large"); - buttonLayout.addComponent(largeButton); - - Button hugeButton = new Button("Huge Button"); - hugeButton.addStyleName("huge"); - buttonLayout.addComponent(hugeButton); - - Button disabledButton = new Button("Disabled Button"); - disabledButton.setDescription("This button cannot be clicked"); - disabledButton.setEnabled(false); - buttonLayout.addComponent(disabledButton); - - Button dangerButton = new Button("Danger Button"); - dangerButton.addStyleName("danger"); - buttonLayout.addComponent(dangerButton); - - Button friendlyButton = new Button("Friendly Button"); - friendlyButton.addStyleName("friendly"); - buttonLayout.addComponent(friendlyButton); - - Button primaryButton = new Button("Primary Button"); - primaryButton.addStyleName("primary"); - buttonLayout.addComponent(primaryButton); - - NativeButton nativeButton = new NativeButton("Native Button"); - buttonLayout.addComponent(nativeButton); - - Button iconButton = new Button("Icon Button"); - iconButton.setIcon(FontAwesome.ALIGN_LEFT); - buttonLayout.addComponent(iconButton); - - Button borderlessButton = new Button("BorderLess Button"); - borderlessButton.addStyleName("borderless"); - buttonLayout.addComponent(borderlessButton); - - Button linkButton = new Button("Link Button"); - linkButton.addStyleName("link"); - buttonLayout.addComponent(linkButton); - - Button quietButton = new Button("Quiet Button"); - quietButton.addStyleName("quiet"); - buttonLayout.addComponent(quietButton); - - horizontalLayout.addComponent(buttonLayout); - - final CheckBox checkbox = new CheckBox("CheckBox"); - checkbox.setValue(true); - checkbox.addValueChangeListener(e -> checkbox.setValue(!checkbox.getValue())); - formLayout.addComponent(checkbox); - - List numbers = new ArrayList(); - numbers.add("One"); - numbers.add("Ten"); - numbers.add("Eleven"); - ComboBox comboBox = new ComboBox("ComboBox"); - comboBox.addItems(numbers); - formLayout.addComponent(comboBox); - - ListSelect listSelect = new ListSelect("ListSelect"); - listSelect.addItems(numbers); - listSelect.setRows(2); - formLayout.addComponent(listSelect); - - NativeSelect nativeSelect = new NativeSelect("NativeSelect"); - nativeSelect.addItems(numbers); - formLayout.addComponent(nativeSelect); - - TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect"); - twinColSelect.addItems(numbers); - - Grid grid = new Grid("Grid"); - grid.setColumns("Column1", "Column2", "Column3"); - grid.addRow("Item1", "Item2", "Item3"); - grid.addRow("Item4", "Item5", "Item6"); - - Panel panel = new Panel("Panel"); - panel.setContent(grid); - panel.setSizeUndefined(); - - Panel serverPushPanel = new Panel("Server Push"); - FormLayout timeLayout = new FormLayout(); - timeLayout.setSpacing(true); - timeLayout.setMargin(true); - currentTime = new Label("No TIME..."); - timeLayout.addComponent(currentTime); - serverPushPanel.setContent(timeLayout); - serverPushPanel.setSizeUndefined(); - ScheduledExecutorService scheduleExecutor = Executors.newScheduledThreadPool(1); - Runnable task = () -> { - currentTime.setValue("Current Time : " + Instant.now()); - }; - scheduleExecutor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.SECONDS); - - FormLayout dataBindingLayout = new FormLayout(); - dataBindingLayout.setSpacing(true); - dataBindingLayout.setMargin(true); - - BindData bindData = new BindData("BindData"); - BeanFieldGroup beanFieldGroup = new BeanFieldGroup(BindData.class); - beanFieldGroup.setItemDataSource(bindData); - TextField bindedTextField = (TextField) beanFieldGroup.buildAndBind("BindName", "bindName"); - bindedTextField.setWidth("250px"); - dataBindingLayout.addComponent(bindedTextField); - - FormLayout validatorLayout = new FormLayout(); - validatorLayout.setSpacing(true); - validatorLayout.setMargin(true); - - HorizontalLayout textValidatorLayout = new HorizontalLayout(); - textValidatorLayout.setSpacing(true); - textValidatorLayout.setMargin(true); - - TextField stringValidator = new TextField(); - stringValidator.setNullSettingAllowed(true); - stringValidator.setNullRepresentation(""); - stringValidator.addValidator(new StringLengthValidator("String must have 2-5 characters lenght", 2, 5, true)); - stringValidator.setValidationVisible(false); - textValidatorLayout.addComponent(stringValidator); - Button buttonStringValidator = new Button("Validate String"); - buttonStringValidator.addClickListener(e -> { - try { - stringValidator.setValidationVisible(false); - stringValidator.validate(); - } catch (InvalidValueException err) { - stringValidator.setValidationVisible(true); - } - }); - textValidatorLayout.addComponent(buttonStringValidator); - - validatorLayout.addComponent(textValidatorLayout); - verticalLayout.addComponent(gridLayout); - verticalLayout.addComponent(richTextPanel); - verticalLayout.addComponent(horizontalLayout); - verticalLayout.addComponent(formLayout); - verticalLayout.addComponent(twinColSelect); - verticalLayout.addComponent(panel); - verticalLayout.addComponent(serverPushPanel); - verticalLayout.addComponent(dataBindingLayout); - verticalLayout.addComponent(validatorLayout); - setContent(verticalLayout); - } - - @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) - @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) - public static class MyUIServlet extends VaadinServlet { - } -} From 93d6d243ac16562b3ff557d8dbeb88ab0ee64ec2 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Sun, 14 Apr 2019 20:56:40 +0530 Subject: [PATCH 27/56] formatting done : removing tabs --- persistence-modules/spring-data-jpa-2/pom.xml | 61 ++++++++++--------- .../src/main/resources/fruit-data.json | 26 ++++---- .../src/main/resources/fruit-data.xml | 6 +- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/persistence-modules/spring-data-jpa-2/pom.xml b/persistence-modules/spring-data-jpa-2/pom.xml index 5080ad9bd3..251007ba6d 100644 --- a/persistence-modules/spring-data-jpa-2/pom.xml +++ b/persistence-modules/spring-data-jpa-2/pom.xml @@ -1,40 +1,41 @@ - 4.0.0 - com.baeldung - spring-data-jpa-2 - spring-data-jpa + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + com.baeldung + spring-data-jpa-2 + spring-data-jpa - - - org.springframework.boot - spring-boot-starter-data-jpa - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - com.h2database - h2 - + + + org.springframework.boot + spring-boot-starter-data-jpa + - - com.fasterxml.jackson.core - jackson-databind - + + com.h2database + h2 + - - org.springframework - spring-oxm - + + com.fasterxml.jackson.core + jackson-databind + - + + org.springframework + spring-oxm + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json index 214ea18e4d..6dc44e2586 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.json @@ -1,14 +1,14 @@ -[ - { - "_class": "com.baeldung.entity.Fruit", - "name": "apple", - "color": "red", - "id": 1 - }, - { - "_class": "com.baeldung.entity.Fruit", - "name": "guava", - "color": "green", - "id": 2 - } +[ + { + "_class": "com.baeldung.entity.Fruit", + "name": "apple", + "color": "red", + "id": 1 + }, + { + "_class": "com.baeldung.entity.Fruit", + "name": "guava", + "color": "green", + "id": 2 + } ] \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml index d0101e3f4d..d87ae28f1e 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml @@ -1,7 +1,7 @@ - 1 - apple - red + 1 + apple + red From bcca8479d5d2d7b315a825d1150eae595cac609b Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 14 Apr 2019 22:37:03 +0530 Subject: [PATCH 28/56] [BAEL-14127] - Moved code to jackson-simple --- jackson-simple/.gitignore | 13 ++ jackson-simple/README.md | 14 ++ jackson-simple/pom.xml | 131 ++++++++++++++++++ jackson-simple/src/main/resources/logback.xml | 19 +++ .../jackson/annotation/AliasBean.java | 0 .../jackson/annotation/BeanWithCreator.java | 0 .../annotation/BeanWithCustomAnnotation.java | 0 .../jackson/annotation/BeanWithFilter.java | 0 .../jackson/annotation/BeanWithGetter.java | 0 .../jackson/annotation/BeanWithIgnore.java | 0 .../jackson/annotation/BeanWithInject.java | 0 .../jackson/annotation/ExtendableBean.java | 0 .../baeldung/jackson/annotation/MyBean.java | 0 .../jackson/annotation/PrivateBean.java | 0 .../baeldung/jackson/annotation/RawBean.java | 0 .../jackson/annotation/UnwrappedUser.java | 0 .../annotation/UserWithIgnoreType.java | 0 .../com/baeldung/jackson/annotation/Zoo.java | 0 .../jackson/bidirection/ItemWithIdentity.java | 21 +++ .../jackson/bidirection/ItemWithIgnore.java | 17 +++ .../jackson/bidirection/ItemWithRef.java | 21 +++ .../jackson/bidirection/UserWithIdentity.java | 28 ++++ .../jackson/bidirection/UserWithIgnore.java | 28 ++++ .../jackson/bidirection/UserWithRef.java | 28 ++++ .../jackson/date/CustomDateDeserializer.java | 36 +++++ .../jackson/date/CustomDateSerializer.java | 29 ++++ .../jackson/date/EventWithFormat.java | 29 ++++ .../jackson/date/EventWithSerializer.java | 31 +++++ .../ItemDeserializerOnClass.java | 41 ++++++ .../java/com/baeldung/jackson/dtos/Item.java | 32 +++++ .../jackson/dtos/ItemWithSerializer.java | 36 +++++ .../java/com/baeldung/jackson/dtos/MyDto.java | 54 ++++++++ .../jackson/dtos/MyDtoFieldNameChanged.java | 0 .../jackson/dtos/MyDtoIncludeNonDefault.java | 0 .../jackson/dtos/MyDtoNoAccessors.java | 0 .../MyDtoNoAccessorsAndFieldVisibility.java | 0 .../jackson/dtos/MyDtoWithFilter.java | 0 .../jackson/dtos/MyDtoWithSpecialField.java | 0 .../jackson/dtos/MyMixInForIgnoreType.java | 0 .../java/com/baeldung/jackson/dtos/User.java | 26 ++++ .../jackson/dtos/ignore/MyDtoIgnoreField.java | 0 .../dtos/ignore/MyDtoIgnoreFieldByName.java | 0 .../jackson/dtos/ignore/MyDtoIgnoreNull.java | 0 .../dtos/withEnum/DistanceEnumWithValue.java | 29 ++++ .../jackson/exception/UserWithRoot.java | 18 +++ .../exception/UserWithRootNamespace.java | 0 .../com/baeldung/jackson/jsonview/Item.java | 36 +++++ .../com/baeldung/jackson/jsonview/Views.java | 9 ++ .../objectmapper/CustomCarDeserializer.java | 0 .../objectmapper/CustomCarSerializer.java | 0 .../JavaReadWriteJsonExampleUnitTest.java | 0 ...izationDeserializationFeatureUnitTest.java | 0 .../jackson/objectmapper/dto/Car.java | 0 .../jackson/objectmapper/dto/Request.java | 0 .../jackson/serialization/ItemSerializer.java | 0 .../serialization/ItemSerializerOnClass.java | 32 +++++ .../serialization/MyDtoNullKeySerializer.java | 0 .../test/JacksonAnnotationUnitTest.java | 0 .../JacksonSerializationIgnoreUnitTest.java | 0 .../test/JacksonSerializationUnitTest.java | 0 jackson-simple/src/test/resources/.gitignore | 13 ++ jackson/README.md | 6 - .../baeldung/jackson/test/UnitTestSuite.java | 2 - pom.xml | 2 + 64 files changed, 773 insertions(+), 8 deletions(-) create mode 100644 jackson-simple/.gitignore create mode 100644 jackson-simple/README.md create mode 100644 jackson-simple/pom.xml create mode 100644 jackson-simple/src/main/resources/logback.xml rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/AliasBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/MyBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/RawBean.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/annotation/Zoo.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java (100%) create mode 100644 jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java (100%) rename {jackson => jackson-simple}/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java (100%) create mode 100644 jackson-simple/src/test/resources/.gitignore diff --git a/jackson-simple/.gitignore b/jackson-simple/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/jackson-simple/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/jackson-simple/README.md b/jackson-simple/README.md new file mode 100644 index 0000000000..5a43bebb29 --- /dev/null +++ b/jackson-simple/README.md @@ -0,0 +1,14 @@ +========= + +## Jackson Cookbooks and Examples + +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: +- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) +- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) +- [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) +- [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) +- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) +- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) \ No newline at end of file diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml new file mode 100644 index 0000000000..5023ad87b6 --- /dev/null +++ b/jackson-simple/pom.xml @@ -0,0 +1,131 @@ + + 4.0.0 + jackson-simple + 0.1-SNAPSHOT + jackson-simple + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + commons-io + commons-io + ${commons-io.version} + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson.version} + + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + ${jackson.version} + + + + joda-time + joda-time + ${joda-time.version} + + + + com.google.code.gson + gson + ${gson.version} + + + + + + io.rest-assured + json-schema-validator + ${rest-assured.version} + test + + + + io.rest-assured + json-path + ${rest-assured.version} + test + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + jackson-simple + + + src/main/resources + true + + + + + + + 3.8 + 2.10 + 2.8.5 + 4.2 + + + 3.1.1 + 3.11.0 + + + diff --git a/jackson-simple/src/main/resources/logback.xml b/jackson-simple/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/jackson-simple/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/AliasBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/AliasBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/AliasBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/AliasBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCreator.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithCustomAnnotation.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithFilter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithGetter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithIgnore.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/BeanWithInject.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/ExtendableBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/MyBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/MyBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/MyBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/MyBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/PrivateBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/RawBean.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/RawBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/RawBean.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/RawBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/UnwrappedUser.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/UserWithIgnoreType.java diff --git a/jackson/src/test/java/com/baeldung/jackson/annotation/Zoo.java b/jackson-simple/src/test/java/com/baeldung/jackson/annotation/Zoo.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/annotation/Zoo.java rename to jackson-simple/src/test/java/com/baeldung/jackson/annotation/Zoo.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java new file mode 100644 index 0000000000..25de4a8f7a --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java @@ -0,0 +1,21 @@ +package com.baeldung.jackson.bidirection; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") +public class ItemWithIdentity { + public int id; + public String itemName; + public UserWithIdentity owner; + + public ItemWithIdentity() { + super(); + } + + public ItemWithIdentity(final int id, final String itemName, final UserWithIdentity owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java new file mode 100644 index 0000000000..910ccec174 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java @@ -0,0 +1,17 @@ +package com.baeldung.jackson.bidirection; + +public class ItemWithIgnore { + public int id; + public String itemName; + public UserWithIgnore owner; + + public ItemWithIgnore() { + super(); + } + + public ItemWithIgnore(final int id, final String itemName, final UserWithIgnore owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java new file mode 100644 index 0000000000..0ca8d721e8 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/ItemWithRef.java @@ -0,0 +1,21 @@ +package com.baeldung.jackson.bidirection; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +public class ItemWithRef { + public int id; + public String itemName; + + @JsonManagedReference + public UserWithRef owner; + + public ItemWithRef() { + super(); + } + + public ItemWithRef(final int id, final String itemName, final UserWithRef owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java new file mode 100644 index 0000000000..db83a09389 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIdentity.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; + +@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") +public class UserWithIdentity { + public int id; + public String name; + public List userItems; + + public UserWithIdentity() { + super(); + } + + public UserWithIdentity(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithIdentity item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java new file mode 100644 index 0000000000..857a373cc5 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithIgnore.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public class UserWithIgnore { + public int id; + public String name; + + @JsonIgnore + public List userItems; + + public UserWithIgnore() { + super(); + } + + public UserWithIgnore(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithIgnore item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java new file mode 100644 index 0000000000..3de03fc651 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/bidirection/UserWithRef.java @@ -0,0 +1,28 @@ +package com.baeldung.jackson.bidirection; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonBackReference; + +public class UserWithRef { + public int id; + public String name; + + @JsonBackReference + public List userItems; + + public UserWithRef() { + super(); + } + + public UserWithRef(final int id, final String name) { + this.id = id; + this.name = name; + userItems = new ArrayList(); + } + + public void addItem(final ItemWithRef item) { + userItems.add(item); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java new file mode 100644 index 0000000000..90c7d9fbac --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateDeserializer.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.date; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +public class CustomDateDeserializer extends StdDeserializer { + + private static final long serialVersionUID = -5451717385630622729L; + private SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); + + public CustomDateDeserializer() { + this(null); + } + + public CustomDateDeserializer(final Class vc) { + super(vc); + } + + @Override + public Date deserialize(final JsonParser jsonparser, final DeserializationContext context) throws IOException, JsonProcessingException { + final String date = jsonparser.getText(); + try { + return formatter.parse(date); + } catch (final ParseException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java new file mode 100644 index 0000000000..d840e1940f --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/CustomDateSerializer.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.date; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class CustomDateSerializer extends StdSerializer { + + private static final long serialVersionUID = -2894356342227378312L; + private SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); + + public CustomDateSerializer() { + this(null); + } + + public CustomDateSerializer(final Class t) { + super(t); + } + + @Override + public void serialize(final Date value, final JsonGenerator gen, final SerializerProvider arg2) throws IOException, JsonProcessingException { + gen.writeString(formatter.format(value)); + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java new file mode 100644 index 0000000000..607e694cef --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithFormat.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.date; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class EventWithFormat { + public String name; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") + public Date eventDate; + + public EventWithFormat() { + super(); + } + + public EventWithFormat(final String name, final Date eventDate) { + this.name = name; + this.eventDate = eventDate; + } + + public Date getEventDate() { + return eventDate; + } + + public String getName() { + return name; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java new file mode 100644 index 0000000000..c359b5c846 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/date/EventWithSerializer.java @@ -0,0 +1,31 @@ +package com.baeldung.jackson.date; + +import java.util.Date; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +public class EventWithSerializer { + public String name; + + @JsonDeserialize(using = CustomDateDeserializer.class) + @JsonSerialize(using = CustomDateSerializer.class) + public Date eventDate; + + public EventWithSerializer() { + super(); + } + + public EventWithSerializer(final String name, final Date eventDate) { + this.name = name; + this.eventDate = eventDate; + } + + public Date getEventDate() { + return eventDate; + } + + public String getName() { + return name; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java b/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java new file mode 100644 index 0000000000..eaba9a7173 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/deserialization/ItemDeserializerOnClass.java @@ -0,0 +1,41 @@ +package com.baeldung.jackson.deserialization; + +import java.io.IOException; + +import com.baeldung.jackson.dtos.ItemWithSerializer; +import com.baeldung.jackson.dtos.User; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.node.IntNode; + +public class ItemDeserializerOnClass extends StdDeserializer { + + private static final long serialVersionUID = 5579141241817332594L; + + public ItemDeserializerOnClass() { + this(null); + } + + public ItemDeserializerOnClass(final Class vc) { + super(vc); + } + + /** + * {"id":1,"itemNr":"theItem","owner":2} + */ + @Override + public ItemWithSerializer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { + final JsonNode node = jp.getCodec() + .readTree(jp); + final int id = (Integer) ((IntNode) node.get("id")).numberValue(); + final String itemName = node.get("itemName") + .asText(); + final int userId = (Integer) ((IntNode) node.get("owner")).numberValue(); + + return new ItemWithSerializer(id, itemName, new User(userId, null)); + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java new file mode 100644 index 0000000000..6fce2bc88e --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/Item.java @@ -0,0 +1,32 @@ +package com.baeldung.jackson.dtos; + +public class Item { + public int id; + public String itemName; + public User owner; + + public Item() { + super(); + } + + public Item(final int id, final String itemName, final User owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } + + // API + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public User getOwner() { + return owner; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java new file mode 100644 index 0000000000..aea9aa770d --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ItemWithSerializer.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.dtos; + +import com.baeldung.jackson.deserialization.ItemDeserializerOnClass; +import com.baeldung.jackson.serialization.ItemSerializerOnClass; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(using = ItemSerializerOnClass.class) +@JsonDeserialize(using = ItemDeserializerOnClass.class) +public class ItemWithSerializer { + public final int id; + public final String itemName; + public final User owner; + + public ItemWithSerializer(final int id, final String itemName, final User owner) { + this.id = id; + this.itemName = itemName; + this.owner = owner; + } + + // API + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public User getOwner() { + return owner; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java new file mode 100644 index 0000000000..49cf07baea --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDto.java @@ -0,0 +1,54 @@ +package com.baeldung.jackson.dtos; + +public class MyDto { + + private String stringValue; + private int intValue; + private boolean booleanValue; + + public MyDto() { + super(); + } + + public MyDto(final String stringValue, final int intValue, final boolean booleanValue) { + super(); + + this.stringValue = stringValue; + this.intValue = intValue; + this.booleanValue = booleanValue; + } + + // API + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } + + public int getIntValue() { + return intValue; + } + + public void setIntValue(final int intValue) { + this.intValue = intValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public void setBooleanValue(final boolean booleanValue) { + this.booleanValue = booleanValue; + } + + // + + @Override + public String toString() { + return "MyDto [stringValue=" + stringValue + ", intValue=" + intValue + ", booleanValue=" + booleanValue + "]"; + } + +} diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoFieldNameChanged.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoIncludeNonDefault.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessors.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoNoAccessorsAndFieldVisibility.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithFilter.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyDtoWithSpecialField.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/MyMixInForIgnoreType.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java new file mode 100644 index 0000000000..2418e8070d --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/User.java @@ -0,0 +1,26 @@ +package com.baeldung.jackson.dtos; + +public class User { + public int id; + public String name; + + public User() { + super(); + } + + public User(final int id, final String name) { + this.id = id; + this.name = name; + } + + // API + + public int getId() { + return id; + } + + public String getName() { + return name; + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreField.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreFieldByName.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java rename to jackson-simple/src/test/java/com/baeldung/jackson/dtos/ignore/MyDtoIgnoreNull.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java new file mode 100644 index 0000000000..69c476d8a5 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java @@ -0,0 +1,29 @@ +package com.baeldung.jackson.dtos.withEnum; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum DistanceEnumWithValue { + KILOMETER("km", 1000), MILE("miles", 1609.34), METER("meters", 1), INCH("inches", 0.0254), CENTIMETER("cm", 0.01), MILLIMETER("mm", 0.001); + + private String unit; + private final double meters; + + private DistanceEnumWithValue(String unit, double meters) { + this.unit = unit; + this.meters = meters; + } + + @JsonValue + public double getMeters() { + return meters; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + +} \ No newline at end of file diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java new file mode 100644 index 0000000000..d879c16e6a --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRoot.java @@ -0,0 +1,18 @@ +package com.baeldung.jackson.exception; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "user") +public class UserWithRoot { + public int id; + public String name; + + public UserWithRoot() { + super(); + } + + public UserWithRoot(final int id, final String name) { + this.id = id; + this.name = name; + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java b/jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java rename to jackson-simple/src/test/java/com/baeldung/jackson/exception/UserWithRootNamespace.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java new file mode 100644 index 0000000000..26d20d4847 --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Item.java @@ -0,0 +1,36 @@ +package com.baeldung.jackson.jsonview; + +import com.fasterxml.jackson.annotation.JsonView; + +public class Item { + @JsonView(Views.Public.class) + public int id; + + @JsonView(Views.Public.class) + public String itemName; + + @JsonView(Views.Internal.class) + public String ownerName; + + public Item() { + super(); + } + + public Item(final int id, final String itemName, final String ownerName) { + this.id = id; + this.itemName = itemName; + this.ownerName = ownerName; + } + + public int getId() { + return id; + } + + public String getItemName() { + return itemName; + } + + public String getOwnerName() { + return ownerName; + } +} diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java new file mode 100644 index 0000000000..65950b7f9f --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/jsonview/Views.java @@ -0,0 +1,9 @@ +package com.baeldung.jackson.jsonview; + +public class Views { + public static class Public { + } + + public static class Internal extends Public { + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarDeserializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/CustomCarSerializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/JavaReadWriteJsonExampleUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/SerializationDeserializationFeatureUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Car.java diff --git a/jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java b/jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java rename to jackson-simple/src/test/java/com/baeldung/jackson/objectmapper/dto/Request.java diff --git a/jackson/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializer.java diff --git a/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java new file mode 100644 index 0000000000..1fdf44e17c --- /dev/null +++ b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/ItemSerializerOnClass.java @@ -0,0 +1,32 @@ +package com.baeldung.jackson.serialization; + +import java.io.IOException; + +import com.baeldung.jackson.dtos.ItemWithSerializer; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class ItemSerializerOnClass extends StdSerializer { + + private static final long serialVersionUID = -1760959597313610409L; + + public ItemSerializerOnClass() { + this(null); + } + + public ItemSerializerOnClass(final Class t) { + super(t); + } + + @Override + public final void serialize(final ItemWithSerializer value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeStartObject(); + jgen.writeNumberField("id", value.id); + jgen.writeStringField("itemName", value.itemName); + jgen.writeNumberField("owner", value.owner.id); + jgen.writeEndObject(); + } + +} \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java b/jackson-simple/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java rename to jackson-simple/src/test/java/com/baeldung/jackson/serialization/MyDtoNullKeySerializer.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonAnnotationUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationIgnoreUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java b/jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java rename to jackson-simple/src/test/java/com/baeldung/jackson/test/JacksonSerializationUnitTest.java diff --git a/jackson-simple/src/test/resources/.gitignore b/jackson-simple/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/jackson-simple/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/jackson/README.md b/jackson/README.md index eeb8f1b874..794ddc04d9 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -6,9 +6,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) - [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) - [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) - [Getting Started with Custom Deserialization in Jackson](http://www.baeldung.com/jackson-deserialization) - [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) @@ -17,10 +15,8 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) - [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) -- [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) - [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) - [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) -- [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) - [XML Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-xml-serialization-and-deserialization) - [More Jackson Annotations](http://www.baeldung.com/jackson-advanced-annotations) - [Inheritance with Jackson](http://www.baeldung.com/jackson-inheritance) @@ -31,9 +27,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson – JsonMappingException (No serializer found for class)](http://www.baeldung.com/jackson-jsonmappingexception) - [How To Serialize Enums as JSON Objects with Jackson](http://www.baeldung.com/jackson-serialize-enums) - [Jackson – Marshall String to JsonNode](http://www.baeldung.com/jackson-json-to-jsonnode) -- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) - [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) - [Serialize Only Fields that meet a Custom Criteria with Jackson](http://www.baeldung.com/jackson-serialize-field-custom-criteria) - [Mapping Nested Values with Jackson](http://www.baeldung.com/jackson-nested-values) - [Convert XML to JSON Using Jackson](https://www.baeldung.com/jackson-convert-xml-json) diff --git a/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java b/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java index 6be2f29baa..e783c67f5b 100644 --- a/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java +++ b/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java @@ -12,8 +12,6 @@ import org.junit.runners.Suite; ,JacksonDeserializationUnitTest.class ,JacksonDeserializationUnitTest.class ,JacksonPrettyPrintUnitTest.class - ,JacksonSerializationIgnoreUnitTest.class - ,JacksonSerializationUnitTest.class ,SandboxUnitTest.class ,JacksonFieldUnitTest.class }) // @formatter:on diff --git a/pom.xml b/pom.xml index d57fa1694e..0559985fca 100644 --- a/pom.xml +++ b/pom.xml @@ -443,6 +443,7 @@ jackson jackson-2 + jackson-simple java-collections-conversions java-collections-maps java-collections-maps-2 @@ -1101,6 +1102,7 @@ jackson jackson-2 + jackson-simple java-collections-conversions java-collections-maps java-collections-maps-2 From d0a6c5701a6cadc509d92ede72957a8e170b2994 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sun, 14 Apr 2019 22:02:14 +0300 Subject: [PATCH 29/56] BAEL-2661 - Groovy def keyword --- core-groovy-2/README.md | 5 + core-groovy-2/pom.xml | 123 ++++++++++++++++++ .../baeldung/defkeyword/DefUnitTest.groovy | 73 +++++++++++ pom.xml | 2 + 4 files changed, 203 insertions(+) create mode 100644 core-groovy-2/README.md create mode 100644 core-groovy-2/pom.xml create mode 100644 core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md new file mode 100644 index 0000000000..0aed5602ab --- /dev/null +++ b/core-groovy-2/README.md @@ -0,0 +1,5 @@ +# Groovy + +## Relevant articles: + +- [Groovy def Keyword] diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml new file mode 100644 index 0000000000..68382e613b --- /dev/null +++ b/core-groovy-2/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + core-groovy-2 + 1.0-SNAPSHOT + core-groovy-2 + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.codehaus.groovy + groovy + ${groovy.version} + + + org.codehaus.groovy + groovy-all + ${groovy-all.version} + pom + + + org.codehaus.groovy + groovy-dateutil + ${groovy.version} + + + org.codehaus.groovy + groovy-sql + ${groovy-sql.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + + + org.spockframework + spock-core + ${spock-core.version} + test + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + ${gmavenplus-plugin.version} + + + + addSources + addTestSources + compile + compileTests + + + + + + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + org.junit.platform + junit-platform-surefire-provider + ${junit.platform.version} + + + + + junit5 + + integration-test + verify + + + + **/*Test5.java + + + + + + + + + + + central + http://jcenter.bintray.com + + + + + 1.0.0 + + + + 2.5.6 + 2.5.6 + 2.5.6 + 2.4.0 + 1.1-groovy-2.4 + 1.6 + + + diff --git a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy new file mode 100644 index 0000000000..baab7455a5 --- /dev/null +++ b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy @@ -0,0 +1,73 @@ +package com.baeldung.defkeyword + +import org.codehaus.groovy.runtime.NullObject +import org.codehaus.groovy.runtime.typehandling.GroovyCastException + +import groovy.transform.TypeChecked +import groovy.transform.TypeCheckingMode + +@TypeChecked +class DefUnitTest extends GroovyTestCase { + + def id + def firstName = "Samwell" + def listOfCountries = ['USA', 'UK', 'FRANCE', 'INDIA'] + + @TypeChecked(TypeCheckingMode.SKIP) + def multiply(x, y) { + return x*y + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testDef() { + + def list + assert list.getClass() == org.codehaus.groovy.runtime.NullObject + assert list.is(null) + + list = [1,2,4] + assert list instanceof ArrayList + + int sum = 200 + try { + sum = [12] //GroovyCastException + sum = "nill" //GroovyCastException + } catch(GroovyCastException) { + println "Cannot assign anything other than integer" + } + + def rate + assert rate == null + assert rate.getClass() == org.codehaus.groovy.runtime.NullObject + + rate = 12 + assert rate instanceof Integer + + rate = "Not Available" + assert rate instanceof String + + rate = [1, 4] + assert rate instanceof List + + assert divide(12, 3) instanceof BigDecimal + assert divide(1, 0) instanceof String + + } + + def divide(int x, int y) { + if(y==0) { + return "Should not divide by 0" + } else { + return x/y + } + } + + def greetMsg() { + println "Hello! I am Groovy" + } + + void testDefVsType() { + def int count + assert count instanceof Integer + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bdd8403231..8746f8492b 100644 --- a/pom.xml +++ b/pom.xml @@ -376,6 +376,7 @@ cdi checker-plugin core-groovy + core-groovy-2 @@ -1034,6 +1035,7 @@ cdi checker-plugin core-groovy + core-groovy-2 core-java-8 From 532c5f28a3bdb3bc0a90fa59b1f8060fa293a5cd Mon Sep 17 00:00:00 2001 From: DOHA Date: Mon, 15 Apr 2019 00:39:36 +0200 Subject: [PATCH 30/56] move generic constructor code --- .../src/main/java/com/baeldung/generics/Entry.java | 0 .../src/main/java/com/baeldung/generics/GenericEntry.java | 0 .../src/main/java/com/baeldung/generics/MapEntry.java | 0 .../src/main/java/com/baeldung/generics/Product.java | 0 .../src/main/java/com/baeldung/generics/Rankable.java | 0 .../java/com/baeldung/generics/GenericConstructorUnitTest.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Entry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/GenericEntry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/MapEntry.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Product.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/main/java/com/baeldung/generics/Rankable.java (100%) rename {core-java-lang-syntax => core-java-lang-oop-2}/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java (100%) diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Entry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/GenericEntry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/MapEntry.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Product.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java diff --git a/core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java b/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java similarity index 100% rename from core-java-lang-syntax/src/main/java/com/baeldung/generics/Rankable.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java diff --git a/core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java similarity index 100% rename from core-java-lang-syntax/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java rename to core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java From 56d2e3c594dbe7c153a6df2c1c9a51c0bb1ef7a6 Mon Sep 17 00:00:00 2001 From: Dave Crane Date: Mon, 15 Apr 2019 21:03:51 +0100 Subject: [PATCH 31/56] corrected test to pull in profile-based config, fixe app cntext startup issues --- .../com/baeldung/boot/config/H2JpaConfig.java | 13 ++++++++----- .../SpringBootProfileIntegrationTest.java | 15 +++++++-------- .../baeldung/config/H2TestProfileJPAConfig.java | 12 +++++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java index 547a905d91..c5c77be56f 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java @@ -1,13 +1,9 @@ package com.baeldung.boot.config; -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -17,10 +13,17 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.Properties; + @Configuration @EnableJpaRepositories(basePackages = { "com.baeldung.boot.repository", "com.baeldung.repository" }) @PropertySource("classpath:persistence-generic-entity.properties") @EnableTransactionManagement +@Profile("default") //only required to allow H2JpaConfig and H2TestProfileJPAConfig to coexist in same project + //this demo project is showcasing several ways to achieve the same end, and class-level + //Profile annotations are only necessary because the different techniques are sharing a project public class H2JpaConfig { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java index 0227458987..d7bb44e133 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java @@ -1,8 +1,9 @@ package com.baeldung; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import com.baeldung.boot.Application; +import com.baeldung.boot.domain.GenericEntity; +import com.baeldung.boot.repository.GenericEntityRepository; +import com.baeldung.config.H2TestProfileJPAConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -10,13 +11,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; -import com.baeldung.boot.config.H2JpaConfig; -import com.baeldung.boot.domain.GenericEntity; -import com.baeldung.boot.repository.GenericEntityRepository; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) -@SpringBootTest(classes = { Application.class, H2JpaConfig.class }) +@SpringBootTest(classes = { Application.class, H2TestProfileJPAConfig.class }) @ActiveProfiles("test") public class SpringBootProfileIntegrationTest { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java index e0678bcf47..f73000a10e 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java @@ -1,10 +1,5 @@ package com.baeldung.config; -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -17,9 +12,16 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.Properties; + @Configuration @EnableJpaRepositories(basePackages = { "com.baeldung.repository", "com.baeldung.boot.repository" }) @EnableTransactionManagement +@Profile("test") //only required to allow H2JpaConfig and H2TestProfileJPAConfig to coexist in same project + //this demo project is showcasing several ways to achieve the same end, and class-level + //Profile annotations are only necessary because the different techniques are sharing a project public class H2TestProfileJPAConfig { @Autowired From c0eb679136b7475b8279a3241b4d77aa30fe00a9 Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Tue, 16 Apr 2019 02:10:13 +0300 Subject: [PATCH 32/56] Create Core Kotlin IO module --- core-kotlin-io/.gitignore | 11 +++ core-kotlin-io/README.md | 3 + core-kotlin-io/pom.xml | 78 +++++++++++++++++++ .../inputstream/InputStreamExtension.kt | 0 .../inputstream/InputStreamToStringTest.kt | 0 .../src/test/resources/inputstream2string.txt | 0 6 files changed, 92 insertions(+) create mode 100644 core-kotlin-io/.gitignore create mode 100644 core-kotlin-io/README.md create mode 100644 core-kotlin-io/pom.xml rename {core-kotlin-2 => core-kotlin-io}/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt (100%) rename {core-kotlin-2 => core-kotlin-io}/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt (100%) rename {core-kotlin-2 => core-kotlin-io}/src/test/resources/inputstream2string.txt (100%) diff --git a/core-kotlin-io/.gitignore b/core-kotlin-io/.gitignore new file mode 100644 index 0000000000..f521947850 --- /dev/null +++ b/core-kotlin-io/.gitignore @@ -0,0 +1,11 @@ +/bin/ + +#ignore gradle +.gradle/ + + +#ignore build and generated files +build/ +node/ +target/ +out/ diff --git a/core-kotlin-io/README.md b/core-kotlin-io/README.md new file mode 100644 index 0000000000..c085c0653f --- /dev/null +++ b/core-kotlin-io/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [InputStream to String in Kotlin](https://www.baeldung.com/kotlin-inputstream-to-string) diff --git a/core-kotlin-io/pom.xml b/core-kotlin-io/pom.xml new file mode 100644 index 0000000000..2e21079d7f --- /dev/null +++ b/core-kotlin-io/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + core-kotlin-io + core-kotlin-io + jar + + + com.baeldung + parent-kotlin + 1.0.0-SNAPSHOT + ../parent-kotlin + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + 1.8 + + + + + + + 1.2.71 + 1.1.1 + 5.2.0 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt b/core-kotlin-io/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt rename to core-kotlin-io/src/main/kotlin/com/baeldung/inputstream/InputStreamExtension.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt rename to core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt diff --git a/core-kotlin-2/src/test/resources/inputstream2string.txt b/core-kotlin-io/src/test/resources/inputstream2string.txt similarity index 100% rename from core-kotlin-2/src/test/resources/inputstream2string.txt rename to core-kotlin-io/src/test/resources/inputstream2string.txt From 5e6a5ae662180792c2b13ca015cb400b259e759a Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Tue, 16 Apr 2019 09:30:26 +0300 Subject: [PATCH 33/56] Add core-kotlin-io to the root pom --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d57fa1694e..80187ffc6f 100644 --- a/pom.xml +++ b/pom.xml @@ -953,6 +953,7 @@ core-java-concurrency-advanced core-kotlin core-kotlin-2 + core-kotlin-io jenkins/hello-world jws From 2e99f89775e545c9345ee09d7dcfa84f20f66310 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Tue, 16 Apr 2019 12:07:35 +0300 Subject: [PATCH 34/56] BAEL-2661 - Groovy def keyword - variable names --- .../com/baeldung/defkeyword/DefUnitTest.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy index baab7455a5..310d97d3fd 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/defkeyword/DefUnitTest.groovy @@ -19,7 +19,7 @@ class DefUnitTest extends GroovyTestCase { } @TypeChecked(TypeCheckingMode.SKIP) - void testDef() { + void testDefVariableDeclaration() { def list assert list.getClass() == org.codehaus.groovy.runtime.NullObject @@ -27,15 +27,21 @@ class DefUnitTest extends GroovyTestCase { list = [1,2,4] assert list instanceof ArrayList - - int sum = 200 + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testTypeVariables() { + int rate = 200 try { - sum = [12] //GroovyCastException - sum = "nill" //GroovyCastException + rate = [12] //GroovyCastException + rate = "nill" //GroovyCastException } catch(GroovyCastException) { println "Cannot assign anything other than integer" } - + } + + @TypeChecked(TypeCheckingMode.SKIP) + void testDefVariableMultipleAssignment() { def rate assert rate == null assert rate.getClass() == org.codehaus.groovy.runtime.NullObject From 6b00fadcb24e7916148d432c7bdc656c23978e88 Mon Sep 17 00:00:00 2001 From: Dave Crane Date: Tue, 16 Apr 2019 14:01:33 +0100 Subject: [PATCH 35/56] moved spring core to spring 5 parent, all tests still pass --- spring-core/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/pom.xml b/spring-core/pom.xml index d348d742e7..814addecdd 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-spring-4 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-4 + ../parent-spring-5 From 8ba93d8dc62f4ca04d570784dba9fc59114e6e98 Mon Sep 17 00:00:00 2001 From: Kevin Wittek Date: Tue, 16 Apr 2019 23:21:09 +0200 Subject: [PATCH 36/56] BAEL-2771 string matching - Move to new module (#6744) * BAEL-2771 Add String matching example to core-groovy * Move test to new core-groovy-2 module --- .gitignore | 4 + core-groovy-2/README.md | 5 ++ core-groovy-2/pom.xml | 80 +++++++++++++++++++ .../strings/StringMatchingSpec.groovy | 44 ++++++++++ pom.xml | 1 + 5 files changed, 134 insertions(+) create mode 100644 core-groovy-2/README.md create mode 100644 core-groovy-2/pom.xml create mode 100644 core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy diff --git a/.gitignore b/.gitignore index 21586748b7..b981a473f6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .idea/ *.iml *.iws +out/ # Mac .DS_Store @@ -27,6 +28,9 @@ log/ target/ +# Gradle +.gradle/ + spring-openid/src/main/resources/application.properties .recommenders/ /spring-hibernate4/nbproject/ diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md new file mode 100644 index 0000000000..9701976142 --- /dev/null +++ b/core-groovy-2/README.md @@ -0,0 +1,5 @@ +# Groovy + +## Relevant articles: + +- [String Matching in Groovy](http://www.baeldung.com/) \ No newline at end of file diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml new file mode 100644 index 0000000000..bbedbf2157 --- /dev/null +++ b/core-groovy-2/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + core-groovy + 1.0-SNAPSHOT + core-groovy-2 + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.codehaus.groovy + groovy-all + ${groovy-all.version} + pom + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + + + org.spockframework + spock-core + ${spock-core.version} + test + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + ${gmavenplus-plugin.version} + + + + compile + compileTests + + + + + + maven-surefire-plugin + 2.20.1 + + false + + **/*Test.java + **/*Spec.java + + + + + + + + + central + http://jcenter.bintray.com + + + + + 2.5.6 + 2.4.0 + 1.3-groovy-2.5 + 1.6.3 + + + diff --git a/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy b/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy new file mode 100644 index 0000000000..3865bc73fa --- /dev/null +++ b/core-groovy-2/src/test/groovy/com/baeldung/strings/StringMatchingSpec.groovy @@ -0,0 +1,44 @@ +package com.baeldung.strings + +import spock.lang.Specification + +import java.util.regex.Pattern + +class StringMatchingSpec extends Specification { + + def "pattern operator example"() { + given: "a pattern" + def p = ~'foo' + + expect: + p instanceof Pattern + + and: "you can use slash strings to avoid escaping of blackslash" + def digitPattern = ~/\d*/ + digitPattern.matcher('4711').matches() + } + + def "match operator example"() { + expect: + 'foobar' ==~ /.*oba.*/ + + and: "matching is strict" + !('foobar' ==~ /foo/) + } + + def "find operator example"() { + when: "using the find operator" + def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/ + + then: "will find groups" + matcher.size() == 2 + + and: "can access groups using array" + matcher[0][0] == 'foo and bar' + matcher[1][2] == 'buz' + + and: "you can use it as a predicate" + 'foobarbaz' =~ /bar/ + } + +} diff --git a/pom.xml b/pom.xml index 80187ffc6f..ff2fa55410 100644 --- a/pom.xml +++ b/pom.xml @@ -1039,6 +1039,7 @@ cdi checker-plugin core-groovy + core-groovy-2 core-java-8 From 2be225b6fc9d681fc7e3f62dc686a9fea40efeb8 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Tue, 16 Apr 2019 22:57:57 -0600 Subject: [PATCH 37/56] added jpa embeddable example (#6636) * [BAEL-12731] - Fixed tests in spring-boot-security module * [BAEL-12731] - Added BcryptPasswordEncoder support * first commit * [BAEL-13322] - Removed noexception module : Code already present in libraries module * added jpa embeddable example * Issue-6604: Upgrade spring cloud to Edgware.SR5 * BAEL-2569 EnvironmentPostProcessor in Spring Boot (#6608) * BAEL-2569 : EnvironmentPostProcessor in Spring Boot * BAEL-2569 add test * BAEL-2569 update test * BAEL-2569 refactoring the class PriceCalculationEnvironmentPostProcessor * BAEL-2569: changes to class PriceCalculationEnvironmentPostProcessor * BAEL-2477 * BAEL-2829: Moving to spring-data-jpa-2 * BAEL-379 A Guide to jBPM with Java (#6619) * BAEL-379 A Guide to jBPM with Java * BAEL-379 * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-1959 Classpath contains multiple bindings Updated pom.xml to exclude log4j binding * Fixed or added Context Integration Tests for modules named in ticket * extension function in java * BAEL-2803 (#6640) * added sample code for eval article * BAEL-2803 Sample Code * updated tests, repo method names * moved sources for BAEL-2803 here * removed dependencies introduced by BAEL-2803 * re-added sources * moved code to new module * removed eval article code * BAEL-2736: Update README (#6651) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL * BAEL-2844 (#6641) * Revering tree update (#6561) * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * corrections * BAEL-2481: Moved to spring-mvc-java * BAEL-2820 Transforming Optional of an Empty String into Empty Optional (#6634) * [BAEL-13311] - Checked modules that don't use our standard parents * BAEL2489:Avoid check for null statements in Java (#6647) * BAEL2489 - Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * Delete pom.xml Removing unused changes in core-java * BAEL2489 Avoid check for null statement in Java - Removing unused pom changes * BAEL2489 Avoid check for null statement in Java - adding ofnullable to Optional example * BAEL-2801 (#6665) * BAEL-2727 Example Code * BAEL-2801 Example code * Change to use parent-boot-2 * fix bean config * [BAEL-13378] - Added modules those were not built * Bael 2826 case insensitive spring data jpa (#6668) * BAEL-2826: Case Insensitive Comparison Spring data jpa * BAEL-2826: Fixing imports * BAEL-2826: Case Insensitive Comparison Spring data jpa * BAEL-2826: Fixing imports * BAEL-2826: Moving code to another repo * BAEL-2826: Moving code to another repo * BAEL-2826 : Refactor * BAEL-2826 : Refactor * BAEL-2826 : Override equals hashcode * [BAEL-13313] - Extract versions into properties * BAEL * BAEL-2859 : Updating to Spring Boot 2.0.6.RELEASE * BAEL-2859 : Updating to Spring Boot 2.0.6.RELEASE * BAEL-1959: Moved to logging-modules/logback * [BAEL-13313] - Fixed PMD violation for string-test-functions module unit test * [BAEL-13313] - Fixed PMD violation for math-test-functions module * [BAEL-13378] - Added submodules in integration profiles also * BAEL-2789: update README (#6676) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD * BAEL-2577: add link back to article * BAEL-2490: add link back to article * BAEL-2471: add link back to article * BAEL-2583: add link back to article * BAEL-2738: add link back to article * BAEL-2711: Add spring-boot-angular module to root pom * BAEL-2544 BAEL-2711 BAEL-2575 BAEL-2657 Add links back to articles * BAEL-2736: Add link back to article * BAEL-2789: Add link back to article * BAEL-2569 (#6679) * BAEL-2569 : EnvironmentPostProcessor in Spring Boot * BAEL-2569 add test * BAEL-2569 update test * BAEL-2569 refactoring the class PriceCalculationEnvironmentPostProcessor * BAEL-2569: changes to class PriceCalculationEnvironmentPostProcessor * BAEL-2569 move code to spring-boot-ops module * [BAEL-13314] - Fix formatting of POMs * BAEL-379 A Guide to jBPM with Java (#6687) * BAEL-379 A Guide to jBPM with Java * BAEL-379 A Guide to jBPM with Java * BAEL-2811: Added sample code for jpa joins (#6691) * added jpa embeddable example * moved embeddable example to spring-data-jpa-2 * moved embeddable example to spring-data-jpa-2 --- .../baeldung/embeddable/model/Company.java | 71 ++++++++++ .../embeddable/model/ContactPerson.java | 38 ++++++ .../repositories/CompanyRepository.java | 18 +++ .../embeddable/EmbeddableIntegrationTest.java | 125 ++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java create mode 100644 persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java create mode 100644 persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java new file mode 100644 index 0000000000..203cff1e35 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/Company.java @@ -0,0 +1,71 @@ +package com.baeldung.embeddable.model; + +import javax.persistence.AttributeOverride; +import javax.persistence.AttributeOverrides; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Company { + + @Id + @GeneratedValue + private Integer id; + + private String name; + + private String address; + + private String phone; + + @Embedded + @AttributeOverrides(value = { + @AttributeOverride( name = "firstName", column = @Column(name = "contact_first_name")), + @AttributeOverride( name = "lastName", column = @Column(name = "contact_last_name")), + @AttributeOverride( name = "phone", column = @Column(name = "contact_phone")) + }) + private ContactPerson contactPerson; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public ContactPerson getContactPerson() { + return contactPerson; + } + + public void setContactPerson(ContactPerson contactPerson) { + this.contactPerson = contactPerson; + } +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java new file mode 100644 index 0000000000..561da80878 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/model/ContactPerson.java @@ -0,0 +1,38 @@ +package com.baeldung.embeddable.model; + +import javax.persistence.Embeddable; + +@Embeddable +public class ContactPerson { + + private String firstName; + + private String lastName; + + private String phone; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + +} diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java new file mode 100644 index 0000000000..f456b15652 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java @@ -0,0 +1,18 @@ +package com.baeldung.embeddable.repositories; + +import com.baeldung.embeddable.model.Company; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface CompanyRepository extends JpaRepository { + + List findByContactPersonFirstName(String firstName); + + @Query("SELECT C FROM Company C WHERE C.contactPerson.firstName = ?1") + List findByContactPersonFirstNameWithJPQL(String firstName); + + @Query(value = "SELECT * FROM company WHERE contact_first_name = ?1", nativeQuery = true) + List findByContactPersonFirstNameWithNativeQuery(String firstName); +} diff --git a/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java new file mode 100644 index 0000000000..b4c365a2d9 --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/test/java/com/baeldung/embeddable/EmbeddableIntegrationTest.java @@ -0,0 +1,125 @@ +package com.baeldung.embeddable; + +import com.baeldung.Application; +import com.baeldung.embeddable.model.Company; +import com.baeldung.embeddable.model.ContactPerson; +import com.baeldung.embeddable.repositories.CompanyRepository; +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.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {Application.class}) +public class EmbeddableIntegrationTest { + + @Autowired + private CompanyRepository companyRepository; + + @Test + @Transactional + public void whenInsertingCompany_thenEmbeddedContactPersonDetailsAreMapped() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("First"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + Company result = companyRepository.getOne(company.getId()); + + assertEquals("Company", result.getName()); + assertEquals("1st street", result.getAddress()); + assertEquals("987-654-321", result.getPhone()); + assertEquals("First", result.getContactPerson().getFirstName()); + assertEquals("Last", result.getContactPerson().getLastName()); + assertEquals("123-456-789", result.getContactPerson().getPhone()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttribute_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("Name"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstName("Name"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstName("FirstName"); + + assertEquals(0, result.size()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttributeWithJPQL_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("@QueryName"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstNameWithJPQL("@QueryName"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstNameWithJPQL("FirstName"); + + assertEquals(0, result.size()); + } + + @Test + @Transactional + public void whenFindingCompanyByContactPersonAttributeWithNativeQuery_thenCompanyIsReturnedProperly() { + ContactPerson contactPerson = new ContactPerson(); + contactPerson.setFirstName("NativeQueryName"); + contactPerson.setLastName("Last"); + contactPerson.setPhone("123-456-789"); + + Company company = new Company(); + company.setName("Company"); + company.setAddress("1st street"); + company.setPhone("987-654-321"); + company.setContactPerson(contactPerson); + + companyRepository.save(company); + + List result = companyRepository.findByContactPersonFirstNameWithNativeQuery("NativeQueryName"); + + assertEquals(1, result.size()); + + result = companyRepository.findByContactPersonFirstNameWithNativeQuery("FirstName"); + + assertEquals(0, result.size()); + } +} From 274cd5b4b142407a3e95cb19419b1ac631927a22 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 17 Apr 2019 11:01:36 +0300 Subject: [PATCH 38/56] BAEL-2661 - Groovy def keyword - conflicts resolved --- core-groovy-2/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index 69a390a3a0..9819bc4c16 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -96,6 +96,8 @@
+ + maven-surefire-plugin 2.20.1 From 029ab027edb2d30eb620be5d78dc7388c94c2302 Mon Sep 17 00:00:00 2001 From: "sumit.sg34" Date: Wed, 17 Apr 2019 18:52:51 +0530 Subject: [PATCH 39/56] BAEL-2841 updated code to use multiple xml files --- .../main/java/com/baeldung/config/JpaPopulators.java | 10 ++++++---- .../resources/{fruit-data.xml => apple-fruit-data.xml} | 0 .../src/main/resources/guava-fruit-data.xml | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) rename persistence-modules/spring-data-jpa-2/src/main/resources/{fruit-data.xml => apple-fruit-data.xml} (100%) create mode 100644 persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml diff --git a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java index 0791df85f4..24348d31c5 100644 --- a/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java +++ b/persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java @@ -22,11 +22,13 @@ public class JpaPopulators { @Bean public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() { - Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - marshaller.setClassesToBeBound(Fruit.class); + + Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller(); + unmarshaller.setClassesToBeBound(Fruit.class); + UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean(); - factory.setUnmarshaller(marshaller); - factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") }); + factory.setUnmarshaller(unmarshaller); + factory.setResources(new Resource[] { new ClassPathResource("apple-fruit-data.xml"), new ClassPathResource("guava-fruit-data.xml") }); return factory; } diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/apple-fruit-data.xml similarity index 100% rename from persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml rename to persistence-modules/spring-data-jpa-2/src/main/resources/apple-fruit-data.xml diff --git a/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml b/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml new file mode 100644 index 0000000000..ffd75bb4bb --- /dev/null +++ b/persistence-modules/spring-data-jpa-2/src/main/resources/guava-fruit-data.xml @@ -0,0 +1,7 @@ + + + + 2 + guava + green + From e8d15ceadcffe4f2f92b831eacb5083132c51bbe Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Apr 2019 21:51:12 +0300 Subject: [PATCH 40/56] Update README.md --- jackson-simple/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jackson-simple/README.md b/jackson-simple/README.md index 5a43bebb29..be647e22d5 100644 --- a/jackson-simple/README.md +++ b/jackson-simple/README.md @@ -1,6 +1,5 @@ ========= - -## Jackson Cookbooks and Examples +### Jackson Articles that are also part of the e-book ###The Course The "REST With Spring" Classes: http://bit.ly/restwithspring @@ -11,4 +10,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) - [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) - [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) -- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) \ No newline at end of file +- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) From 2b0d0665ba7b6fb770da96d9ae71263e4ed191f6 Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Thu, 18 Apr 2019 03:29:57 +0100 Subject: [PATCH 41/56] updated the example code with data.sql (#6749) * added example code for BAEL-2083 * updated example code for BAEL-2083 * added example code for BAEL-2849 * updated the example code with data.sql --- .../src/main/resources/data.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql new file mode 100644 index 0000000000..2d7b446005 --- /dev/null +++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/src/main/resources/data.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS billionaires; + +CREATE TABLE billionaires ( + id INT AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(250) NOT NULL, + last_name VARCHAR(250) NOT NULL, + career VARCHAR(250) DEFAULT NULL +); + +INSERT INTO billionaires (first_name, last_name, career) VALUES +('Aliko', 'Dangote', 'Billionaire Industrialist'), +('Bill', 'Gates', 'Billionaire Tech Entrepreneur'), +('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); \ No newline at end of file From 275a4acaeaba3037913aaaaa9126dda12aa3100d Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Thu, 18 Apr 2019 11:13:09 +0530 Subject: [PATCH 42/56] Adding source files for article BAEL-1932 (#6746) --- pom.xml | 5 +- spring-security-kerberos/README.md | 10 +++ spring-security-kerberos/pom.xml | 61 +++++++++++++ .../main/java/org/baeldung/Application.java | 13 +++ .../baeldung/config/WebSecurityConfig.java | 87 +++++++++++++++++++ .../security/DummyUserDetailsService.java | 16 ++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 spring-security-kerberos/README.md create mode 100644 spring-security-kerberos/pom.xml create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/Application.java create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java create mode 100644 spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java diff --git a/pom.xml b/pom.xml index 79dab80c74..b102b5cd30 100644 --- a/pom.xml +++ b/pom.xml @@ -381,7 +381,7 @@ core-java-8 core-java-8-2 - core-java-lambdas + core-java-lambdas core-java-arrays @@ -542,6 +542,7 @@ tensorflow-java spring-boot-flowable + spring-security-kerberos @@ -769,6 +770,7 @@ tensorflow-java spring-boot-flowable + spring-security-kerberos @@ -913,6 +915,7 @@ persistence-modules/spring-hibernate-5 spring-boot-flowable + spring-security-kerberos diff --git a/spring-security-kerberos/README.md b/spring-security-kerberos/README.md new file mode 100644 index 0000000000..0338c2058c --- /dev/null +++ b/spring-security-kerberos/README.md @@ -0,0 +1,10 @@ +## @PreFilter and @PostFilter annotations + +### Build the Project ### + +``` +mvn clean install +``` + +### Relevant Articles: +- [Spring Security – Kerberos](http://www.baeldung.com/xxxxxx) diff --git a/spring-security-kerberos/pom.xml b/spring-security-kerberos/pom.xml new file mode 100644 index 0000000000..35c4ba4926 --- /dev/null +++ b/spring-security-kerberos/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + com.baeldung + spring-security-kerberos + 0.1-SNAPSHOT + spring-security-kerberos + war + + parent-boot-1 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-1 + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.security.kerberos + spring-security-kerberos-core + 1.0.1.RELEASE + + + org.springframework.security.kerberos + spring-security-kerberos-web + 1.0.1.RELEASE + + + org.springframework.security.kerberos + spring-security-kerberos-client + 1.0.1.RELEASE + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + diff --git a/spring-security-kerberos/src/main/java/org/baeldung/Application.java b/spring-security-kerberos/src/main/java/org/baeldung/Application.java new file mode 100644 index 0000000000..39c2b51356 --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/Application.java @@ -0,0 +1,13 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java b/spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java new file mode 100644 index 0000000000..49a1cf0a8e --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/config/WebSecurityConfig.java @@ -0,0 +1,87 @@ +package org.baeldung.config; + +import org.baeldung.security.DummyUserDetailsService; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.FileSystemResource; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider; +import org.springframework.security.kerberos.authentication.KerberosServiceAuthenticationProvider; +import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosClient; +import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator; +import org.springframework.security.kerberos.web.authentication.SpnegoAuthenticationProcessingFilter; +import org.springframework.security.kerberos.web.authentication.SpnegoEntryPoint; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .anyRequest() + .authenticated() + .and() + .addFilterBefore(spnegoAuthenticationProcessingFilter(authenticationManagerBean()), BasicAuthenticationFilter.class); + } + + @Override + @Bean + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.authenticationProvider(kerberosAuthenticationProvider()) + .authenticationProvider(kerberosServiceAuthenticationProvider()); + } + + @Bean + public KerberosAuthenticationProvider kerberosAuthenticationProvider() { + KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider(); + SunJaasKerberosClient client = new SunJaasKerberosClient(); + client.setDebug(true); + provider.setKerberosClient(client); + provider.setUserDetailsService(dummyUserDetailsService()); + return provider; + } + + @Bean + public SpnegoEntryPoint spnegoEntryPoint() { + return new SpnegoEntryPoint("/login"); + } + + @Bean + public SpnegoAuthenticationProcessingFilter spnegoAuthenticationProcessingFilter(AuthenticationManager authenticationManager) { + SpnegoAuthenticationProcessingFilter filter = new SpnegoAuthenticationProcessingFilter(); + filter.setAuthenticationManager(authenticationManager); + return filter; + } + + @Bean + public KerberosServiceAuthenticationProvider kerberosServiceAuthenticationProvider() { + KerberosServiceAuthenticationProvider provider = new KerberosServiceAuthenticationProvider(); + provider.setTicketValidator(sunJaasKerberosTicketValidator()); + provider.setUserDetailsService(dummyUserDetailsService()); + return provider; + } + + @Bean + public SunJaasKerberosTicketValidator sunJaasKerberosTicketValidator() { + SunJaasKerberosTicketValidator ticketValidator = new SunJaasKerberosTicketValidator(); + ticketValidator.setServicePrincipal("HTTP/demo.kerberos.bealdung.com@baeldung.com"); + ticketValidator.setKeyTabLocation(new FileSystemResource("baeldung.keytab")); + ticketValidator.setDebug(true); + return ticketValidator; + } + + @Bean + public DummyUserDetailsService dummyUserDetailsService() { + return new DummyUserDetailsService(); + } + +} \ No newline at end of file diff --git a/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java b/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java new file mode 100644 index 0000000000..10d71fca8f --- /dev/null +++ b/spring-security-kerberos/src/main/java/org/baeldung/security/DummyUserDetailsService.java @@ -0,0 +1,16 @@ +package org.baeldung.security; + +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +public class DummyUserDetailsService implements UserDetailsService { + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + return new User(username, "notUsed", true, true, true, true, AuthorityUtils.createAuthorityList("ROLE_USER")); + } + +} \ No newline at end of file From a249fbaf6299999ce8a0442a24a4cf73b5da50cd Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Thu, 18 Apr 2019 10:03:19 +0200 Subject: [PATCH 43/56] BAEL-2493 --- pom.xml | 239 +++++++++--------- spring-boot-configuration/.gitignore | 29 +++ spring-boot-configuration/README.MD | 0 spring-boot-configuration/pom.xml | 41 +++ .../SpringBootConfigurationApplication.java | 13 + .../resources/application-tomcat.properties | 23 ++ .../src/main/resources/application.properties | 1 + .../SpringContextIntegrationTest.java | 16 ++ 8 files changed, 244 insertions(+), 118 deletions(-) create mode 100644 spring-boot-configuration/.gitignore create mode 100644 spring-boot-configuration/README.MD create mode 100644 spring-boot-configuration/pom.xml create mode 100644 spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java create mode 100644 spring-boot-configuration/src/main/resources/application-tomcat.properties create mode 100644 spring-boot-configuration/src/main/resources/application.properties create mode 100644 spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java diff --git a/pom.xml b/pom.xml index b102b5cd30..3bfa182d72 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.0.0-SNAPSHOT parent-modules pom - + lombok-custom @@ -233,7 +233,7 @@ ${maven-war-plugin.version} - + com.vackosar.gitflowincrementalbuilder @@ -377,7 +377,7 @@ checker-plugin core-groovy - + core-java-8 core-java-8-2 @@ -404,7 +404,7 @@ core-scala couchbase custom-pmd - + dagger data-structures ddd @@ -412,13 +412,13 @@ disruptor dozer drools - dubbo - + dubbo + ethereum - + feign flyway-cdi-extension - + geotools google-cloud google-web-toolkit @@ -432,12 +432,12 @@ guava-modules guice - + hazelcast helidon httpclient hystrix - + image-processing immutables @@ -485,7 +485,7 @@ kotlin-libraries - + libraries libraries-2 @@ -512,8 +512,8 @@ mustache mybatis - - + + optaplanner orika osgi @@ -523,9 +523,9 @@ performance-tests protobuffer - + persistence-modules - + rabbitmq ratpack @@ -537,17 +537,17 @@ rule-engines rsocket rxjava - rxjava-2 + rxjava-2 software-security/sql-injection-samples - + tensorflow-java spring-boot-flowable spring-security-kerberos - + - + default-second @@ -581,12 +581,12 @@ parent-spring-5 parent-java parent-kotlin - + saas spark-java - + spring-4 - + spring-5 spring-5-webflux spring-5-data-reactive @@ -597,7 +597,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth - + spring-activiti spring-akka spring-all @@ -607,7 +607,7 @@ spring-apache-camel spring-batch spring-bom - + spring-boot spring-boot-admin spring-boot-angular @@ -617,6 +617,7 @@ spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-crud spring-boot-ctx-fluent spring-boot-custom-starter @@ -635,41 +636,41 @@ spring-boot-testing spring-boot-vue spring-boot-libraries - + spring-cloud spring-cloud-bus spring-cloud-data-flow - + spring-core spring-cucumber - + spring-data-rest spring-data-rest-querydsl spring-dispatcher-servlet spring-drools - + spring-ehcache spring-ejb spring-exceptions - + spring-freemarker - + spring-groovy - + spring-integration - + spring-jenkins-pipeline spring-jersey spring-jinq spring-jms spring-jooq - + spring-kafka spring-katharsis - + spring-ldap - + spring-mobile spring-mockito spring-mvc-forms-jsp @@ -681,12 +682,12 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - + spring-protobuf - + spring-quartz - + spring-reactive-kotlin spring-reactor spring-remoting @@ -702,9 +703,9 @@ spring-security-acl spring-security-angular/server spring-security-cache-control - + spring-security-client - + spring-security-core spring-security-mvc-boot spring-security-mvc-custom @@ -732,50 +733,50 @@ spring-state-machine spring-static-resources spring-swagger-codegen - + spring-thymeleaf - + spring-userservice - + spring-vault spring-vertx - + spring-webflux-amqp - + spring-zuul - + static-analysis stripe structurizr struts-2 - + testing-modules - + twilio Twitter4J - + undertow - + vavr vertx vertx-and-rxjava video-tutorials vraptor - + wicket - + xml xmlunit-2 xstream - + tensorflow-java spring-boot-flowable spring-security-kerberos - + - + spring-context @@ -817,6 +818,7 @@ spring-boot-bootstrap spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-custom-starter greeter-spring-boot-autoconfigure greeter-spring-boot-sample-app @@ -913,7 +915,7 @@ persistence-modules/spring-data-eclipselink persistence-modules/spring-data-solr persistence-modules/spring-hibernate-5 - + spring-boot-flowable spring-security-kerberos @@ -953,7 +955,7 @@ parent-spring-5 parent-java parent-kotlin - + core-java-concurrency-advanced core-kotlin core-kotlin-2 @@ -967,12 +969,12 @@ persistence-modules/hibernate5 persistence-modules/java-jpa persistence-modules/java-mongodb - persistence-modules/jnosql + persistence-modules/jnosql - vaadin + vaadin - + integration-lite-first @@ -1045,7 +1047,7 @@ core-groovy core-groovy-2 - + core-java-8 core-java-8-2 @@ -1068,7 +1070,7 @@ core-scala couchbase custom-pmd - + dagger data-structures ddd @@ -1076,13 +1078,13 @@ disruptor dozer drools - dubbo - + dubbo + ethereum - + feign flyway-cdi-extension - + geotools google-cloud google-web-toolkit @@ -1096,12 +1098,12 @@ guava-modules guice - + hazelcast helidon httpclient hystrix - + image-processing immutables @@ -1148,7 +1150,7 @@ kotlin-libraries - + libraries libraries-data @@ -1174,8 +1176,8 @@ mustache mybatis - - + + optaplanner orika osgi @@ -1185,9 +1187,9 @@ performance-tests protobuffer - + persistence-modules - + rabbitmq ratpack @@ -1199,8 +1201,8 @@ rule-engines rsocket rxjava - rxjava-2 - + rxjava-2 + @@ -1234,12 +1236,12 @@ parent-spring-5 parent-java parent-kotlin - + saas spark-java - + spring-4 - + spring-5 spring-5-data-reactive spring-5-mvc @@ -1249,7 +1251,7 @@ spring-5-reactive-security spring-5-security spring-5-security-oauth - + spring-activiti spring-akka spring-all @@ -1259,7 +1261,7 @@ spring-apache-camel spring-batch spring-bom - + spring-boot spring-boot-admin spring-boot-angular @@ -1269,6 +1271,7 @@ spring-boot-camel spring-boot-client + spring-boot-configuration spring-boot-crud spring-boot-ctx-fluent spring-boot-custom-starter @@ -1285,41 +1288,41 @@ spring-boot-property-exp spring-boot-security spring-boot-vue - + spring-cloud spring-cloud-bus spring-cloud-data-flow - + spring-core spring-cucumber - + spring-data-rest spring-data-rest-querydsl spring-dispatcher-servlet spring-drools - - spring-ehcache + + spring-ehcache spring-ejb spring-exceptions - + spring-freemarker - + spring-groovy - + spring-integration - + spring-jenkins-pipeline spring-jersey spring-jinq spring-jms spring-jooq - + spring-kafka spring-katharsis - + spring-ldap - + spring-mobile spring-mockito spring-mvc-forms-jsp @@ -1331,12 +1334,12 @@ spring-mvc-velocity spring-mvc-webflow spring-mvc-xml - + spring-protobuf - + spring-quartz - + spring-reactive-kotlin spring-reactor spring-remoting @@ -1349,13 +1352,13 @@ spring-rest-simple spring-resttemplate spring-roo - + spring-security-acl spring-security-angular/server spring-security-cache-control - + spring-security-client - + spring-security-core spring-security-mvc-boot spring-security-mvc-custom @@ -1382,42 +1385,42 @@ spring-state-machine spring-static-resources spring-swagger-codegen - + spring-thymeleaf - + spring-userservice - + spring-vault spring-vertx - + spring-webflux-amqp - + spring-zuul - + static-analysis stripe structurizr struts-2 - + testing-modules - + twilio Twitter4J - + undertow - + vavr vertx vertx-and-rxjava video-tutorials vraptor - + wicket - + xml xmlunit-2 xstream - + @@ -1451,8 +1454,8 @@ parent-spring-5 parent-java parent-kotlin - - core-java + + core-java core-java-concurrency-advanced core-kotlin core-kotlin-2 @@ -1465,9 +1468,9 @@ persistence-modules/hibernate5 persistence-modules/java-jpa persistence-modules/java-mongodb - persistence-modules/jnosql + persistence-modules/jnosql - vaadin + vaadin @@ -1493,15 +1496,15 @@ false false false - + 4.12 1.3 2.21.0 - + 1.7.21 1.1.7 - + 2.21.0 3.7.0 diff --git a/spring-boot-configuration/.gitignore b/spring-boot-configuration/.gitignore new file mode 100644 index 0000000000..153c9335eb --- /dev/null +++ b/spring-boot-configuration/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-boot-configuration/README.MD b/spring-boot-configuration/README.MD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-boot-configuration/pom.xml b/spring-boot-configuration/pom.xml new file mode 100644 index 0000000000..2ecef7bb02 --- /dev/null +++ b/spring-boot-configuration/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + com.baeldung + spring-boot-configuration + 0.0.1-SNAPSHOT + spring-boot-configuration + Demo project for Spring Boot configuration + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java b/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java new file mode 100644 index 0000000000..b4f5681475 --- /dev/null +++ b/spring-boot-configuration/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.springbootconfiguration; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootConfigurationApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootConfigurationApplication.class, args); + } + +} diff --git a/spring-boot-configuration/src/main/resources/application-tomcat.properties b/spring-boot-configuration/src/main/resources/application-tomcat.properties new file mode 100644 index 0000000000..d7c1ba9ac3 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/application-tomcat.properties @@ -0,0 +1,23 @@ +# server configuration +server.port=80 +server.address=127.0.0.1 + +## Error handling configuration +server.error.whitelabel.enabled=true +server.error.path=/user-error +server.error.include-exception=true +server.error.include-stacktrace=always + +## Server connections configuration +server.tomcat.max-threads=200 +server.connection-timeout=5s +server.max-http-header-size=8KB +server.tomcat.max-swallow-size=2MB +server.tomcat.max-http-post-size=2MB + +## Access logs configuration +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.directory=logs +server.tomcat.accesslog.file-date-format=yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log diff --git a/spring-boot-configuration/src/main/resources/application.properties b/spring-boot-configuration/src/main/resources/application.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/spring-boot-configuration/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java b/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java new file mode 100644 index 0000000000..d6b2b50a2f --- /dev/null +++ b/spring-boot-configuration/src/test/java/com/baeldung/springbootconfiguration/SpringContextIntegrationTest.java @@ -0,0 +1,16 @@ +package com.baeldung.springbootconfiguration; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringContextIntegrationTest { + + @Test + public void contextLoads() { + } + +} From 15b053c6a84a6ec00ab8424d8a5401a464bb38a3 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Thu, 18 Apr 2019 12:34:40 -0300 Subject: [PATCH 44/56] [BAEL-2735] REST-Assured Authentication article (#6753) * Added restassured test using basic auth, form auth and digest. * Added Rest Assured Authentication - OAuth Live Test * Add Authentication with Rest Assured for autoconfigured Form Login * Add OAuth 1 Rest Assured scenario --- testing-modules/rest-assured/pom.xml | 13 ++++ .../BasicAuthenticationLiveTest.java | 38 ++++++++++++ .../BasicPreemtiveAuthenticationLiveTest.java | 56 +++++++++++++++++ .../DigestAuthenticationLiveTest.java | 40 ++++++++++++ .../FormAuthenticationLiveTest.java | 57 +++++++++++++++++ .../FormAutoconfAuthenticationLiveTest.java | 42 +++++++++++++ .../OAuth2AuthenticationLiveTest.java | 61 +++++++++++++++++++ .../OAuthAuthenticationLiveTest.java | 53 ++++++++++++++++ 8 files changed, 360 insertions(+) create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/DigestAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAutoconfAuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuth2AuthenticationLiveTest.java create mode 100644 testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java diff --git a/testing-modules/rest-assured/pom.xml b/testing-modules/rest-assured/pom.xml index cd342ccd11..c528a34e21 100644 --- a/testing-modules/rest-assured/pom.xml +++ b/testing-modules/rest-assured/pom.xml @@ -162,6 +162,11 @@ commons-collections ${commons-collections.version} + + + org.springframework.boot + spring-boot-starter-security + @@ -179,6 +184,12 @@ json-schema-validator test + + com.github.scribejava + scribejava-apis + ${scribejava.version} + test + @@ -211,6 +222,8 @@ 3.0.1 3.0.1 + + 2.5.3 diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java new file mode 100644 index 0000000000..aff765dfa3 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicAuthenticationLiveTest.java @@ -0,0 +1,38 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-security-rest-basic-auth module. + * @see spring-security-rest-basic-auth module + * + */ +public class BasicAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenBasicAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + given().auth() + .basic(USER, PASSWORD) + .when() + .get(SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java new file mode 100644 index 0000000000..02138f22e3 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/BasicPreemtiveAuthenticationLiveTest.java @@ -0,0 +1,56 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-boot-admin/spring-boot-admin-server module. + * @see spring-boot-admin/spring-boot-admin-server module + * + */ +public class BasicPreemtiveAuthenticationLiveTest { + + private static final String USER = "admin"; + private static final String PASSWORD = "admin"; + private static final String SVC_URL = "http://localhost:8080/api/applications/"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-security-mvc-digest-auth module + * + */ +public class DigestAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-mvc-digest-auth/homepage.html"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenFormAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + given().auth() + .digest(USER, PASSWORD) + .when() + .get(SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("This is the body of the sample view")); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java new file mode 100644 index 0000000000..66ae9fb162 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/FormAuthenticationLiveTest.java @@ -0,0 +1,57 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.isEmptyString; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +import io.restassured.authentication.FormAuthConfig; + +/** + * For this Live Test we need: + * * a running instance of the service located in the spring-security-mvc-login module. + * @see spring-security-mvc-login module + * + */ +public class FormAuthenticationLiveTest { + + private static final String USER = "user1"; + private static final String PASSWORD = "user1Pass"; + private static final String SVC_URL = "http://localhost:8080/spring-security-mvc-login/secured"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenLoginFormResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-boot-admin/spring-boot-admin-server module + * + */ +public class FormAutoconfAuthenticationLiveTest { + + private static final String USER = "admin"; + private static final String PASSWORD = "admin"; + private static final String SVC_URL = "http://localhost:8080/ger1/api/applications/"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .content(containsString("spring-security-oauth/oauth-authorization-server module + * + * * a running instance of the service located in the spring-security-oauth repo - oauth-resource-server-1 module. + * @see spring-security-oauth/oauth-resource-server-1 module + * + */ +public class OAuth2AuthenticationLiveTest { + + private static final String USER = "john"; + private static final String PASSWORD = "123"; + private static final String CLIENT_ID = "fooClientIdPassword"; + private static final String SECRET = "secret"; + private static final String AUTH_SVC_TOKEN_URL = "http://localhost:8081/spring-security-oauth-server/oauth/token"; + private static final String RESOURCE_SVC_URL = "http://localhost:8082/spring-security-oauth-resource/foos/1"; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(RESOURCE_SVC_URL).then() + .assertThat() + .statusCode(HttpStatus.UNAUTHORIZED.value()); + } + + @Test + public void givenAccessTokenAuthentication_whenRequestSecuredResource_thenResourceRetrieved() { + String accessToken = given().auth() + .basic(CLIENT_ID, SECRET) + .formParam("grant_type", "password") + .formParam("username", USER) + .formParam("password", PASSWORD) + .formParam("scope", "read foo") + .when() + .post(AUTH_SVC_TOKEN_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .extract() + .path("access_token"); + + given().auth() + .oauth2(accessToken) + .when() + .get(RESOURCE_SVC_URL) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .body("$", hasKey("id")) + .body("$", hasKey("name")); + } +} diff --git a/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java new file mode 100644 index 0000000000..c720bc04e4 --- /dev/null +++ b/testing-modules/rest-assured/src/test/java/com/baeldung/restassured/authentication/OAuthAuthenticationLiveTest.java @@ -0,0 +1,53 @@ +package com.baeldung.restassured.authentication; + +import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.hasKey; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; + +import io.restassured.http.ContentType; + +/** + * For this Live Test we need to obtain a valid Access Token and Token Secret: + * * start spring-mvc-simple application in debug mode + * @see spring-mvc-simple module + * * calling localhost:8080/spring-mvc-simple/twitter/authorization/ using the browser + * * debug the callback function where we can obtain the fields + */ +public class OAuthAuthenticationLiveTest { + + // We can obtain these two from the spring-mvc-simple / TwitterController class + private static final String OAUTH_API_KEY = "PSRszoHhRDVhyo2RIkThEbWko"; + private static final String OAUTH_API_SECRET = "prpJbz03DcGRN46sb4ucdSYtVxG8unUKhcnu3an5ItXbEOuenL"; + private static final String TWITTER_ENDPOINT = "https://api.twitter.com/1.1/account/settings.json"; + /* We can obtain the following by: + * - starting the spring-mvc-simple application + * - calling localhost:8080/spring-mvc-simple/twitter/authorization/ + * - debugging the callback function */ + private static final String ACCESS_TOKEN = "..."; + private static final String TOKEN_SECRET = "..."; + + @Test + public void givenNoAuthentication_whenRequestSecuredResource_thenUnauthorizedResponse() { + get(TWITTER_ENDPOINT).then() + .assertThat() + .statusCode(HttpStatus.BAD_REQUEST.value()); + } + + @Test + public void givenAccessTokenAuthentication_whenRequestSecuredResource_thenResourceIsRequested() { + given().accept(ContentType.JSON) + .auth() + .oauth(OAUTH_API_KEY, OAUTH_API_SECRET, ACCESS_TOKEN, TOKEN_SECRET) + .when() + .get(TWITTER_ENDPOINT) + .then() + .assertThat() + .statusCode(HttpStatus.OK.value()) + .body("$", hasKey("geo_enabled")) + .body("$", hasKey("language")); + } + +} From 062ea56d7ab5ba21a940695cedd18e75d981f35d Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Fri, 19 Apr 2019 03:54:24 +0200 Subject: [PATCH 45/56] Move code for BAEL-2833 from core-java-8-2 to core-java-lang-oop-2 (#6755) --- .../src/test/java/com/baeldung/UnitTest.java | 18 ------------------ .../main/java/com/baeldung/anonymous/Book.java | 0 .../main/java/com/baeldung/anonymous/Main.java | 0 3 files changed, 18 deletions(-) delete mode 100644 core-java-8-2/src/test/java/com/baeldung/UnitTest.java rename {core-java-8-2 => core-java-lang-oop-2}/src/main/java/com/baeldung/anonymous/Book.java (100%) rename {core-java-8-2 => core-java-lang-oop-2}/src/main/java/com/baeldung/anonymous/Main.java (100%) diff --git a/core-java-8-2/src/test/java/com/baeldung/UnitTest.java b/core-java-8-2/src/test/java/com/baeldung/UnitTest.java deleted file mode 100644 index 9757901f52..0000000000 --- a/core-java-8-2/src/test/java/com/baeldung/UnitTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class UnitTest { - /** - * Stub test - */ - @Test - public void givenPreconditions_whenCondition_shouldResult() { - assertTrue(true); - } -} diff --git a/core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java b/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java similarity index 100% rename from core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java diff --git a/core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java b/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java similarity index 100% rename from core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java rename to core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java From d5ee7de5a55cb3269436e01485155f1d005e2bab Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Thu, 18 Apr 2019 21:37:00 -0500 Subject: [PATCH 46/56] Update pom.xml Fixed start-class in pom --- spring-boot-mvc-birt/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-mvc-birt/pom.xml b/spring-boot-mvc-birt/pom.xml index 05d3f3865a..8f41e8410a 100644 --- a/spring-boot-mvc-birt/pom.xml +++ b/spring-boot-mvc-birt/pom.xml @@ -75,7 +75,7 @@ 2.1.1.RELEASE - com.baeldung.springbootmvc.SpringBootMvcApplication + com.baeldung.birt.engine.ReportEngineApplication 1.8 1.8 From f6b1967cbee9604330ff4a2717f6c2b39a048c58 Mon Sep 17 00:00:00 2001 From: Juan Moreno Date: Thu, 18 Apr 2019 23:40:33 -0300 Subject: [PATCH 47/56] BAEL-2655 Sample code (#6731) * Upgraded dependencies * Fixed test in Linux Environment * Added I/O samples * FIX End of line reference, previous version was OS dependent * CHORE Added junit5 dependency * UPGRADE gradle version, UPDATE versions * Deleted emtpy lines --- core-kotlin-2/build.gradle | 22 +++-- .../gradle/wrapper/gradle-wrapper.jar | Bin 54329 -> 55616 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- core-kotlin-2/gradlew | 18 +++- core-kotlin-2/gradlew.bat | 18 +++- core-kotlin-2/pom.xml | 33 ++++++-- .../com/baeldung/console/ConsoleIOUnitTest.kt | 79 ++++++++++++++++++ .../org.mockito.plugins.MockMaker | 1 + .../inputstream/InputStreamToStringTest.kt | 5 +- parent-kotlin/pom.xml | 6 +- 10 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt create mode 100644 core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/core-kotlin-2/build.gradle b/core-kotlin-2/build.gradle index b058e0ecad..1c52172404 100644 --- a/core-kotlin-2/build.gradle +++ b/core-kotlin-2/build.gradle @@ -5,7 +5,7 @@ version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.2.41' + ext.kotlin_version = '1.3.30' repositories { mavenCentral() @@ -26,8 +26,6 @@ sourceCompatibility = 1.8 compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } -kotlin { experimental { coroutines "enable" } } - repositories { mavenCentral() jcenter() @@ -39,10 +37,22 @@ sourceSets { srcDirs 'com/baeldung/ktor' } } +} +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } } dependencies { - compile "ch.qos.logback:logback-classic:1.2.1" - testCompile group: 'junit', name: 'junit', version: '4.12' -} \ No newline at end of file + implementation "ch.qos.logback:logback-classic:1.2.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" + testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' + testImplementation 'junit:junit:4.12' + testImplementation 'org.assertj:assertj-core:3.12.2' + testImplementation 'org.mockito:mockito-core:2.27.0' + testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:${kotlin_version}" +} diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar b/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar index 01b8bf6b1f99cad9213fc495b33ad5bbab8efd20..5c2d1cf016b3885f6930543d57b744ea8c220a1a 100644 GIT binary patch literal 55616 zcmafaW0WS*vSoFbZJS-TZP!<}ZQEV8ZQHihW!tvx>6!c9%-lQoy;&DmfdT@8fB*sl68LLCKtKQ283+jS?^Q-bNq|NIAW8=eB==8_)^)r*{C^$z z{u;{v?IMYnO`JhmPq7|LA_@Iz75S9h~8`iX>QrjrmMeu{>hn4U;+$dor zz+`T8Q0f}p^Ao)LsYq74!W*)&dTnv}E8;7H*Zetclpo2zf_f>9>HT8;`O^F8;M%l@ z57Z8dk34kG-~Wg7n48qF2xwPp;SOUpd1}9Moir5$VSyf4gF)Mp-?`wO3;2x9gYj59oFwG>?Leva43@e(z{mjm0b*@OAYLC`O9q|s+FQLOE z!+*Y;%_0(6Sr<(cxE0c=lS&-FGBFGWd_R<5$vwHRJG=tB&Mi8@hq_U7@IMyVyKkOo6wgR(<% zQw1O!nnQl3T9QJ)Vh=(`cZM{nsEKChjbJhx@UQH+G>6p z;beBQ1L!3Zl>^&*?cSZjy$B3(1=Zyn~>@`!j%5v7IBRt6X`O)yDpVLS^9EqmHxBcisVG$TRwiip#ViN|4( zYn!Av841_Z@Ys=T7w#>RT&iXvNgDq3*d?$N(SznG^wR`x{%w<6^qj&|g})La;iD?`M=p>99p><39r9+e z`dNhQ&tol5)P#;x8{tT47i*blMHaDKqJs8!Pi*F{#)9%USFxTVMfMOy{mp2ZrLR40 z2a9?TJgFyqgx~|j0eA6SegKVk@|Pd|_6P$HvwTrLTK)Re`~%kg8o9`EAE1oAiY5Jgo=H}0*D?tSCn^=SIN~fvv453Ia(<1|s07aTVVtsRxY6+tT3589iQdi^ zC92D$ewm9O6FA*u*{Fe_=b`%q`pmFv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b2Qk2^-fHr0VWM=p)9vIcH@vQ6}bS*6Yn+<0` zHS-Vv-qdTr#{}n3wF3e|XZ$C;U)Qd{m8L}r&_O_ewZqTP@pJJM`6Zf!wef%L?Uz~3 zpTS_ne+l+mInQ6()XNOo&n#$?|C{C4&G0hQ=rg7e;4A)%PJcP|_)Ff=moW%6^ug z8A_gu6#(#0?fWxw=jFpM^OZb5obmUE|C2J}zt06c~G6javMT=uh?kFRJn{;a>`(Kf~)={S*9)sq#zMmpb6ju-(@G1p8+%!%NJUqO#AJ zLyrH1`9}=EfBQ1Nly7}TZE*Sx)c-E#`m*{jB`KeY#NB?E=#S?4w?O4ff|v4t&jdW4 zzd`U1Vt_B1UW$Z0Gx_`c2GegzhP~u`sr&TIN$CF@od2W(^^)qPP{uQrcGz!F{ex`A zOQx5i1kX&Gk-x$8hdJ>6Qlj7`)yr7$XDZp4-=+e5Uu^!Y>-Li5WoYd)iE;dIll<|% z{z+`)CCkeg&Sw^b#NTH5b42G$f|v1g&jg|=|DOc^tHoYMG(A({rT+%i|7@$5p)Jq& zu9?4q|IdLgFWc>9B)~ISBVax9V!-~>SoO!R`1K^~<^J${kotlin.version} - org.junit.platform - junit-platform-runner - ${junit.platform.version} + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + net.bytebuddy + byte-buddy + ${byte-buddy.version} test @@ -37,6 +49,12 @@ ${kotlin.version} test + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin.version} + test + @@ -69,10 +87,11 @@ - 1.2.71 - 1.1.1 - 5.2.0 + 1.3.30 + 5.4.2 + 2.27.0 + 1.9.12 3.10.0 - \ No newline at end of file + diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt new file mode 100644 index 0000000000..c73096fce6 --- /dev/null +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt @@ -0,0 +1,79 @@ +package com.baeldung.console + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.Test +import org.mockito.Mockito.`when` +import org.mockito.Mockito.mock +import java.io.BufferedReader +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.Console +import java.io.InputStreamReader +import java.io.PrintStream +import java.util.* + + +class ConsoleIOUnitTest { + + @Test + fun givenText_whenPrint_thenPrintText() { + val expectedTest = "Hello from Kotlin" + val out = ByteArrayOutputStream() + System.setOut(PrintStream(out)) + + print(expectedTest) + out.flush() + val printedText = String(out.toByteArray()) + + assertThat(printedText).isEqualTo(expectedTest) + } + + @Test + fun givenInput_whenRead_thenReadText() { + val expectedTest = "Hello from Kotlin" + val input = ByteArrayInputStream(expectedTest.toByteArray()) + System.setIn(input) + + val readText = readLine() + + assertThat(readText).isEqualTo(expectedTest) + } + + @Test + fun givenInput_whenReadWithScanner_thenReadText() { + val expectedTest = "Hello from Kotlin" + val scanner = Scanner(ByteArrayInputStream(expectedTest.toByteArray())) + + val readText = scanner.nextLine() + + assertThat(readText).isEqualTo(expectedTest) + } + + @Test + fun givenInput_whenReadWithBufferedReader_thenReadText() { + val expectedTest = "Hello from Kotlin" + val reader = BufferedReader(InputStreamReader(ByteArrayInputStream(expectedTest.toByteArray()))) + + val readText = reader.readLine() + + assertThat(readText).isEqualTo(expectedTest) + } + + @Test + fun givenInput_whenReadWithConsole_thenReadText() { + val expectedTest = "Hello from Kotlin" + val console = mock(Console::class.java) + `when`(console.readLine()).thenReturn(expectedTest) + + val readText = console.readLine() + + assertThat(readText).isEqualTo(expectedTest) + } + + @AfterEach + fun resetIO() { + System.setOut(System.out) + System.setIn(System.`in`) + } +} \ No newline at end of file diff --git a/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 0000000000..ca6ee9cea8 --- /dev/null +++ b/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline \ No newline at end of file diff --git a/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt index 3437ddb68a..d10d23bef0 100644 --- a/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt +++ b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt @@ -8,7 +8,8 @@ import kotlin.test.assertEquals class InputStreamToStringTest { private val fileName = "src/test/resources/inputstream2string.txt" - private val fileFullContent = "Computer programming can be a hassle\r\n" + + private val endOfLine = System.lineSeparator() + private val fileFullContent = "Computer programming can be a hassle$endOfLine" + "It's like trying to take a defended castle" @Test @@ -46,7 +47,7 @@ class InputStreamToStringTest { } finally { reader.close() } - assertEquals(fileFullContent.replace("\r\n", ""), content.toString()) + assertEquals(fileFullContent.replace(endOfLine, ""), content.toString()) } diff --git a/parent-kotlin/pom.xml b/parent-kotlin/pom.xml index 7a3a8b10ca..86ab45ecb1 100644 --- a/parent-kotlin/pom.xml +++ b/parent-kotlin/pom.xml @@ -202,10 +202,10 @@ - 1.3.10 + 1.3.30 1.0.0 0.9.5 - 3.11.0 - 1.2.0 + 3.12.0 + 1.3.2 From 9da56d97b677051cf0ab4a756491047fe433be19 Mon Sep 17 00:00:00 2001 From: Raghav Jha Date: Sat, 20 Apr 2019 10:04:34 +0530 Subject: [PATCH 48/56] BAEL-2822 Persisting Maps with Hibernate (#6692) * BAEL-2822 Persisting Maps with Hibernate * BAEL-2822 Move PersistMaps Tutorial to new module * BAEL-2822 Move PersistMaps Tutorial to new module * BAEL-2822 Move PersistMaps Tutorial to new module --- persistence-modules/hibernate-mapping/pom.xml | 52 ++++++++ .../com/baeldung/hibernate/HibernateUtil.java | 64 ++++++++++ .../java/com/baeldung/hibernate/Strategy.java | 31 +++++ .../hibernate/persistmaps/ItemType.java | 6 + .../hibernate/persistmaps/mapkey/Item.java | 95 +++++++++++++++ .../hibernate/persistmaps/mapkey/Order.java | 44 +++++++ .../persistmaps/mapkeycolumn/Order.java | 43 +++++++ .../persistmaps/mapkeyenumerated/Order.java | 48 ++++++++ .../persistmaps/mapkeyjoincolumn/Item.java | 112 ++++++++++++++++++ .../persistmaps/mapkeyjoincolumn/Order.java | 44 +++++++ .../persistmaps/mapkeyjoincolumn/Seller.java | 51 ++++++++ .../persistmaps/mapkeytemporal/Order.java | 48 ++++++++ .../src/main/resources/logback.xml | 13 ++ .../MapKeyColumnIntegrationTest.java | 79 ++++++++++++ .../MapKeyEnumeratedIntegrationTest.java | 95 +++++++++++++++ .../persistmaps/MapKeyIntegrationTest.java | 95 +++++++++++++++ .../MapKeyJoinColumnIntegrationTest.java | 105 ++++++++++++++++ .../MapKeyTemporalIntegrationTest.java | 96 +++++++++++++++ .../src/test/resources/hibernate.properties | 10 ++ persistence-modules/pom.xml | 1 + pom.xml | 1 + 21 files changed, 1133 insertions(+) create mode 100644 persistence-modules/hibernate-mapping/pom.xml create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/Strategy.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/ItemType.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java create mode 100644 persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java create mode 100644 persistence-modules/hibernate-mapping/src/main/resources/logback.xml create mode 100644 persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyColumnIntegrationTest.java create mode 100644 persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyEnumeratedIntegrationTest.java create mode 100644 persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyIntegrationTest.java create mode 100644 persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyJoinColumnIntegrationTest.java create mode 100644 persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyTemporalIntegrationTest.java create mode 100644 persistence-modules/hibernate-mapping/src/test/resources/hibernate.properties diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml new file mode 100644 index 0000000000..11caf67bf1 --- /dev/null +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -0,0 +1,52 @@ + + + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + hibernate-mapping + 1.0.0-SNAPSHOT + 4.0.0 + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + com.h2database + h2 + ${h2database.version} + + + + + hibernate-mapping + + + src/test/resources + true + + + + + + 5.3.7.Final + 1.4.196 + 3.8.0 + + + \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java new file mode 100644 index 0000000000..7411edd225 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java @@ -0,0 +1,64 @@ +package com.baeldung.hibernate; + +import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.service.ServiceRegistry; + +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Properties; + +public class HibernateUtil { + private static SessionFactory sessionFactory; + + private HibernateUtil() { + } + + public static SessionFactory getSessionFactory(Strategy strategy) { + if (sessionFactory == null) { + sessionFactory = buildSessionFactory(strategy); + } + return sessionFactory; + } + + private static SessionFactory buildSessionFactory(Strategy strategy) { + try { + ServiceRegistry serviceRegistry = configureServiceRegistry(); + + MetadataSources metadataSources = new MetadataSources(serviceRegistry); + + for (Class entityClass : strategy.getEntityClasses()) { + metadataSources.addAnnotatedClass(entityClass); + } + + Metadata metadata = metadataSources.getMetadataBuilder() + .build(); + + return metadata.getSessionFactoryBuilder() + .build(); + } catch (IOException ex) { + throw new ExceptionInInitializerError(ex); + } + } + + + private static ServiceRegistry configureServiceRegistry() throws IOException { + Properties properties = getProperties(); + return new StandardServiceRegistryBuilder().applySettings(properties) + .build(); + } + + private static Properties getProperties() throws IOException { + Properties properties = new Properties(); + URL propertiesURL = Thread.currentThread() + .getContextClassLoader() + .getResource("hibernate.properties"); + try (FileInputStream inputStream = new FileInputStream(propertiesURL.getFile())) { + properties.load(inputStream); + } + return properties; + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/Strategy.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/Strategy.java new file mode 100644 index 0000000000..75f10ed583 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/Strategy.java @@ -0,0 +1,31 @@ +package com.baeldung.hibernate; + + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public enum Strategy { + //See that the classes belongs to different packages + MAP_KEY_COLUMN_BASED(Collections.singletonList(com.baeldung.hibernate.persistmaps.mapkeycolumn.Order.class)), + MAP_KEY_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkey.Item.class, + com.baeldung.hibernate.persistmaps.mapkey.Order.class)), + MAP_KEY_JOIN_COLUMN_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Seller.class, + com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Item.class, + com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Order.class)), + MAP_KEY_ENUMERATED_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkeyenumerated.Order.class, + com.baeldung.hibernate.persistmaps.mapkey.Item.class)), + MAP_KEY_TEMPORAL_BASED(Arrays.asList(com.baeldung.hibernate.persistmaps.mapkeytemporal.Order.class, + com.baeldung.hibernate.persistmaps.mapkey.Item.class)); + + + private List> entityClasses; + + Strategy(List> entityClasses) { + this.entityClasses = entityClasses; + } + + public List> getEntityClasses() { + return entityClasses; + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/ItemType.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/ItemType.java new file mode 100644 index 0000000000..b7f3cef9a2 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/ItemType.java @@ -0,0 +1,6 @@ +package com.baeldung.hibernate.persistmaps; + +public enum ItemType { + JEANS, + TSHIRTS +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java new file mode 100644 index 0000000000..385ffe93ea --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java @@ -0,0 +1,95 @@ +package com.baeldung.hibernate.persistmaps.mapkey; + +import com.baeldung.hibernate.persistmaps.ItemType; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; +import java.util.Objects; + +@Entity +@Table(name = "item") +public class Item { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @Column(name = "name") + private String itemName; + + @Column(name = "price") + private double itemPrice; + + @Enumerated(EnumType.STRING) + @Column(name = "item_type") + private ItemType itemType; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on") + private Date createdOn; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public double getItemPrice() { + return itemPrice; + } + + public void setItemPrice(double itemPrice) { + this.itemPrice = itemPrice; + } + + public ItemType getItemType() { + return itemType; + } + + public void setItemType(ItemType itemType) { + this.itemType = itemType; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Item item = (Item) o; + return id == item.id && + Double.compare(item.itemPrice, itemPrice) == 0 && + Objects.equals(itemName, item.itemName) && + itemType == item.itemType && + Objects.equals(createdOn, item.createdOn); + } + + @Override + public int hashCode() { + return Objects.hash(id, itemName, itemPrice, itemType, createdOn); + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java new file mode 100644 index 0000000000..8409cacd6b --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java @@ -0,0 +1,44 @@ +package com.baeldung.hibernate.persistmaps.mapkey; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKey; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.util.Map; + +@Entity +@Table(name = "orders") +public class Order { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "order_item_mapping", joinColumns = {@JoinColumn(name = "order_id", referencedColumnName = "id")}, + inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "id")}) + @MapKey(name = "itemName") + private Map itemMap; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getItemMap() { + return itemMap; + } + + public void setItemMap(Map itemMap) { + this.itemMap = itemMap; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java new file mode 100644 index 0000000000..fa092060da --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java @@ -0,0 +1,43 @@ +package com.baeldung.hibernate.persistmaps.mapkeycolumn; + +import javax.persistence.CollectionTable; +import javax.persistence.Column; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.MapKeyColumn; +import javax.persistence.Table; +import java.util.Map; + +@Entity +@Table(name = "orders") +public class Order { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @ElementCollection + @CollectionTable(name = "order_item_mapping", joinColumns = {@JoinColumn(name = "order_id", referencedColumnName = "id")}) + @MapKeyColumn(name = "item_name") + @Column(name = "price") + private Map itemPriceMap; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getItemPriceMap() { + return itemPriceMap; + } + + public void setItemPriceMap(Map itemPriceMap) { + this.itemPriceMap = itemPriceMap; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java new file mode 100644 index 0000000000..e1f62599b8 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java @@ -0,0 +1,48 @@ +package com.baeldung.hibernate.persistmaps.mapkeyenumerated; + +import com.baeldung.hibernate.persistmaps.ItemType; +import com.baeldung.hibernate.persistmaps.mapkey.Item; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKeyEnumerated; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.util.Map; + +@Entity +@Table(name = "orders") +public class Order { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "order_item_mapping", joinColumns = {@JoinColumn(name = "order_id", referencedColumnName = "id")}, + inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "id")}) + @MapKeyEnumerated(EnumType.STRING) + private Map itemMap; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getItemMap() { + return itemMap; + } + + public void setItemMap(Map itemMap) { + this.itemMap = itemMap; + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java new file mode 100644 index 0000000000..97bbd5b539 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java @@ -0,0 +1,112 @@ +package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn; + +import com.baeldung.hibernate.persistmaps.ItemType; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; +import java.util.Objects; + +@Entity +@Table(name = "item") +public class Item { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @Column(name = "name") + private String itemName; + + @Column(name = "price") + private double itemPrice; + + @Column(name = "item_type") + @Enumerated(EnumType.STRING) + private ItemType itemType; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on") + private Date createdOn; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "seller_id") + private Seller seller; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public double getItemPrice() { + return itemPrice; + } + + public void setItemPrice(double itemPrice) { + this.itemPrice = itemPrice; + } + + public ItemType getItemType() { + return itemType; + } + + public void setItemType(ItemType itemType) { + this.itemType = itemType; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + public Seller getSeller() { + return seller; + } + + public void setSeller(Seller seller) { + this.seller = seller; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Item item = (Item) o; + return id == item.id && + Double.compare(item.itemPrice, itemPrice) == 0 && + Objects.equals(itemName, item.itemName) && + itemType == item.itemType && + Objects.equals(createdOn, item.createdOn) && + Objects.equals(seller, item.seller); + } + + @Override + public int hashCode() { + + return Objects.hash(id, itemName, itemPrice, itemType, createdOn, seller); + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java new file mode 100644 index 0000000000..d680d84501 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java @@ -0,0 +1,44 @@ +package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKeyJoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.util.Map; + +@Entity +@Table(name = "orders") +public class Order { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "order_item_mapping", joinColumns = {@JoinColumn(name = "order_id", referencedColumnName = "id")}, + inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "id")}) + @MapKeyJoinColumn(name = "seller_id") + private Map sellerItemMap; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getSellerItemMap() { + return sellerItemMap; + } + + public void setSellerItemMap(Map sellerItemMap) { + this.sellerItemMap = sellerItemMap; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java new file mode 100644 index 0000000000..15b08e9fe6 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java @@ -0,0 +1,51 @@ +package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Objects; + +@Entity +@Table(name = "seller") +public class Seller { + + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @Column(name = "name") + private String sellerName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSellerName() { + return sellerName; + } + + public void setSellerName(String sellerName) { + this.sellerName = sellerName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Seller seller = (Seller) o; + return Objects.equals(sellerName, seller.sellerName); + } + + @Override + public int hashCode() { + + return Objects.hash(sellerName); + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java new file mode 100644 index 0000000000..be602c1e9f --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java @@ -0,0 +1,48 @@ +package com.baeldung.hibernate.persistmaps.mapkeytemporal; + +import com.baeldung.hibernate.persistmaps.mapkey.Item; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.MapKeyTemporal; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.TemporalType; +import java.util.Date; +import java.util.Map; + +@Entity +@Table(name = "orders") +public class Order { + @Id + @GeneratedValue + @Column(name = "id") + private int id; + + @OneToMany(cascade = CascadeType.ALL) + @JoinTable(name = "order_item_mapping", joinColumns = {@JoinColumn(name = "order_id", referencedColumnName = "id")}, + inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "id")}) + @MapKeyTemporal(TemporalType.TIMESTAMP) + private Map itemMap; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Map getItemMap() { + return itemMap; + } + + public void setItemMap(Map itemMap) { + this.itemMap = itemMap; + } +} diff --git a/persistence-modules/hibernate-mapping/src/main/resources/logback.xml b/persistence-modules/hibernate-mapping/src/main/resources/logback.xml new file mode 100644 index 0000000000..26beb6d5b4 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyColumnIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyColumnIntegrationTest.java new file mode 100644 index 0000000000..acd77ee382 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyColumnIntegrationTest.java @@ -0,0 +1,79 @@ +package com.baeldung.hibernate.persistmaps; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.Strategy; +import com.baeldung.hibernate.persistmaps.mapkeycolumn.Order; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MapKeyColumnIntegrationTest { + private static SessionFactory sessionFactory; + + private Session session; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_COLUMN_BASED); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + @Test + public void givenData_whenInsertUsingMapKeyColumn_thenPersistMap() { + Map itemPriceMap = new HashMap<>(); + itemPriceMap.put("Wrangler Jeans", 150.0); + itemPriceMap.put("Lee Jeans", 180.0); + + + Order order = new Order(); + order.setItemPriceMap(itemPriceMap); + + session.persist(order); + session.getTransaction().commit(); + + assertInsertedData(); + } + + private void assertInsertedData() { + @SuppressWarnings("unchecked") + List orderList = session.createQuery("FROM Order").list(); + + assertNotNull(orderList); + assertEquals(1, orderList.size()); + + Order order = orderList.get(0); + + Map itemPriceMap = order.getItemPriceMap(); + assertNotNull(itemPriceMap); + assertEquals(itemPriceMap.size(), 2); + assertEquals((Double) 150.0, itemPriceMap.get("Wrangler Jeans")); + assertEquals((Double) 180.0, itemPriceMap.get("Lee Jeans")); + + } + + @After + public void tearDown() { + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } +} diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyEnumeratedIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyEnumeratedIntegrationTest.java new file mode 100644 index 0000000000..221aa7b1d7 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyEnumeratedIntegrationTest.java @@ -0,0 +1,95 @@ +package com.baeldung.hibernate.persistmaps; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.Strategy; +import com.baeldung.hibernate.persistmaps.mapkey.Item; +import com.baeldung.hibernate.persistmaps.mapkeyenumerated.Order; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.time.Instant; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MapKeyEnumeratedIntegrationTest { + private static SessionFactory sessionFactory; + + private Session session; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_ENUMERATED_BASED); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + @Test + public void givenData_whenInsertUsingMapKeyEnumerated_thenPersistMap() { + Item item1 = new Item(); + item1.setItemName("Wrangler Jeans"); + item1.setItemPrice(150.0); + item1.setItemType(ItemType.JEANS); + item1.setCreatedOn(Date.from(Instant.ofEpochSecond(1554926573))); + + + Item item2 = new Item(); + item2.setItemName("Armani Tshirts"); + item2.setItemPrice(180.0); + item2.setItemType(ItemType.TSHIRTS); + item2.setCreatedOn(Date.from(Instant.ofEpochSecond(1554890573))); + + Map itemMap = new HashMap<>(); + itemMap.put(item1.getItemType(), item1); + itemMap.put(item2.getItemType(), item2); + + Order order = new Order(); + order.setItemMap(itemMap); + + session.persist(order); + session.getTransaction().commit(); + + assertInsertedData(item1, item2); + } + + private void assertInsertedData(Item expectedItem1, Item expectedItem2) { + @SuppressWarnings("unchecked") + List orderList = session.createQuery("FROM Order").list(); + + assertNotNull(orderList); + assertEquals(1, orderList.size()); + + Order order = orderList.get(0); + + Map itemMap = order.getItemMap(); + assertNotNull(itemMap); + assertEquals(2, itemMap.size()); + assertEquals(expectedItem1, itemMap.get(ItemType.JEANS)); + assertEquals(expectedItem2, itemMap.get(ItemType.TSHIRTS)); + + } + + @After + public void tearDown() { + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } +} + diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyIntegrationTest.java new file mode 100644 index 0000000000..b500deb78e --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyIntegrationTest.java @@ -0,0 +1,95 @@ +package com.baeldung.hibernate.persistmaps; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.Strategy; +import com.baeldung.hibernate.persistmaps.mapkey.Item; +import com.baeldung.hibernate.persistmaps.mapkey.Order; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.time.Instant; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MapKeyIntegrationTest { + private static SessionFactory sessionFactory; + + private Session session; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_BASED); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + @Test + public void givenData_whenInsertUsingMapKey_thenPersistMap() { + Item item1 = new Item(); + item1.setItemName("Wrangler Jeans"); + item1.setItemPrice(150.0); + item1.setItemType(ItemType.JEANS); + item1.setCreatedOn(Date.from(Instant.ofEpochSecond(1554926573))); + + + Item item2 = new Item(); + item2.setItemName("Armani Tshirts"); + item2.setItemPrice(180.0); + item2.setItemType(ItemType.TSHIRTS); + item2.setCreatedOn(Date.from(Instant.ofEpochSecond(1554890573))); + + Map itemMap = new HashMap<>(); + itemMap.put(item1.getItemName(), item1); + itemMap.put(item2.getItemName(), item2); + + Order order = new Order(); + order.setItemMap(itemMap); + + session.persist(order); + session.getTransaction().commit(); + + assertInsertedData(item1, item2); + } + + private void assertInsertedData(Item expectedItem1, Item expectedItem2) { + @SuppressWarnings("unchecked") + List orderList = session.createQuery("FROM Order").list(); + + assertNotNull(orderList); + assertEquals(1, orderList.size()); + + Order order = orderList.get(0); + + Map itemMap = order.getItemMap(); + assertNotNull(itemMap); + assertEquals(2, itemMap.size()); + assertEquals(expectedItem1, itemMap.get("Wrangler Jeans")); + assertEquals(expectedItem2, itemMap.get("Armani Tshirts")); + + } + + @After + public void tearDown() { + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } +} + diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyJoinColumnIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyJoinColumnIntegrationTest.java new file mode 100644 index 0000000000..88b22f5c99 --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyJoinColumnIntegrationTest.java @@ -0,0 +1,105 @@ +package com.baeldung.hibernate.persistmaps; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.Strategy; +import com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Item; +import com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Order; +import com.baeldung.hibernate.persistmaps.mapkeyjoincolumn.Seller; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.time.Instant; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MapKeyJoinColumnIntegrationTest { + private static SessionFactory sessionFactory; + + private Session session; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_JOIN_COLUMN_BASED); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + @Test + public void givenData_whenInsertUsingMapKeyJoinColumn_thenPersistMap() { + Seller seller1 = new Seller(); + seller1.setSellerName("Walmart"); + + Item item1 = new Item(); + item1.setItemName("Wrangler Jeans"); + item1.setItemPrice(150.0); + item1.setItemType(ItemType.JEANS); + item1.setCreatedOn(Date.from(Instant.ofEpochSecond(1554926573))); + item1.setSeller(seller1); + + + Seller seller2 = new Seller(); + seller2.setSellerName("Amazon"); + + Item item2 = new Item(); + item2.setItemName("Armani Tshirts"); + item2.setItemPrice(180.0); + item2.setItemType(ItemType.TSHIRTS); + item2.setCreatedOn(Date.from(Instant.ofEpochSecond(1554890573))); + item2.setSeller(seller2); + + Map itemSellerMap = new HashMap<>(); + itemSellerMap.put(seller1, item1); + itemSellerMap.put(seller2, item2); + + Order order = new Order(); + order.setSellerItemMap(itemSellerMap); + + + session.persist(order); + session.getTransaction().commit(); + + assertInsertedData(seller1, item1, seller2, item2); + } + + private void assertInsertedData(Seller seller1, Item expectedItem1, Seller seller2, Item expectedItem2) { + @SuppressWarnings("unchecked") + List orderList = session.createQuery("FROM Order").list(); + + assertNotNull(orderList); + assertEquals(1, orderList.size()); + + Order order = orderList.get(0); + + Map sellerItemMap = order.getSellerItemMap(); + assertNotNull(sellerItemMap); + assertEquals(2, sellerItemMap.size()); + assertEquals(expectedItem1, sellerItemMap.get(seller1)); + assertEquals(expectedItem2, sellerItemMap.get(seller2)); + + } + + @After + public void tearDown() { + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } +} + diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyTemporalIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyTemporalIntegrationTest.java new file mode 100644 index 0000000000..7117cad22f --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/persistmaps/MapKeyTemporalIntegrationTest.java @@ -0,0 +1,96 @@ +package com.baeldung.hibernate.persistmaps; + +import com.baeldung.hibernate.HibernateUtil; +import com.baeldung.hibernate.Strategy; +import com.baeldung.hibernate.persistmaps.mapkey.Item; +import com.baeldung.hibernate.persistmaps.mapkeytemporal.Order; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.time.Instant; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MapKeyTemporalIntegrationTest { + private static SessionFactory sessionFactory; + + private Session session; + + @BeforeClass + public static void beforeTests() { + sessionFactory = HibernateUtil.getSessionFactory(Strategy.MAP_KEY_TEMPORAL_BASED); + } + + @Before + public void setUp() { + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + @Test + public void givenData_whenInsertUsingMapKeyEnumerated_thenPersistMap() { + Date item1CreatedOn = Date.from(Instant.ofEpochSecond(1554926573)); + Item item1 = new Item(); + item1.setItemName("Wrangler Jeans"); + item1.setItemPrice(150.0); + item1.setItemType(ItemType.JEANS); + item1.setCreatedOn(item1CreatedOn); + + + Date item2CreatedOn = Date.from(Instant.ofEpochSecond(1554890573)); + Item item2 = new Item(); + item2.setItemName("Armani Tshirts"); + item2.setItemPrice(180.0); + item2.setItemType(ItemType.TSHIRTS); + item2.setCreatedOn(item2CreatedOn); + + Map itemMap = new HashMap<>(); + itemMap.put(item1CreatedOn, item1); + itemMap.put(item2CreatedOn, item2); + + Order order = new Order(); + order.setItemMap(itemMap); + + session.persist(order); + session.getTransaction().commit(); + + assertInsertedData(item1CreatedOn, item1, item2CreatedOn, item2); + } + + private void assertInsertedData(Date item1CreatedOn, Item expectedItem1, Date item2CreatedOn, Item expectedItem2) { + @SuppressWarnings("unchecked") + List orderList = session.createQuery("FROM Order").list(); + + assertNotNull(orderList); + assertEquals(1, orderList.size()); + + Order order = orderList.get(0); + + Map itemMap = order.getItemMap(); + assertNotNull(itemMap); + assertEquals(2, itemMap.size()); + assertEquals(expectedItem1, itemMap.get(item1CreatedOn)); + assertEquals(expectedItem2, itemMap.get(item2CreatedOn)); + + } + + @After + public void tearDown() { + session.close(); + } + + @AfterClass + public static void afterTests() { + sessionFactory.close(); + } +} diff --git a/persistence-modules/hibernate-mapping/src/test/resources/hibernate.properties b/persistence-modules/hibernate-mapping/src/test/resources/hibernate.properties new file mode 100644 index 0000000000..c22da2496b --- /dev/null +++ b/persistence-modules/hibernate-mapping/src/test/resources/hibernate.properties @@ -0,0 +1,10 @@ +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1 +hibernate.connection.username=sa +hibernate.connection.autocommit=true +jdbc.password= + +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=create-drop + diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 47c733d8a7..ee55325b20 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -22,6 +22,7 @@ hbase hibernate5 hibernate-ogm + hibernate-mapping influxdb java-cassandra java-cockroachdb diff --git a/pom.xml b/pom.xml index 3bfa182d72..53ca4291bf 100644 --- a/pom.xml +++ b/pom.xml @@ -967,6 +967,7 @@ libraries persistence-modules/hibernate5 + persistence-modules/hibernate-mapping persistence-modules/java-jpa persistence-modules/java-mongodb persistence-modules/jnosql From e41d8320385d34e4dc7fbc36e53483024c0a3597 Mon Sep 17 00:00:00 2001 From: dcalap Date: Sat, 20 Apr 2019 06:38:03 +0200 Subject: [PATCH 49/56] #BAEL-2828 - first and top example methods added (#6742) * #BAEL-2828 - first and top example methods added * #BAEL-2828 - fix import and method same erasure error * #BAEL-2828 - get rid of Optional in order to pass tests --- .../main/java/com/baeldung/passenger/PassengerRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java index b2d145899e..6c6c145942 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/PassengerRepository.java @@ -9,6 +9,8 @@ interface PassengerRepository extends JpaRepository, CustomPass Passenger findFirstByOrderBySeatNumberAsc(); + Passenger findTopByOrderBySeatNumberAsc(); + List findByOrderBySeatNumberAsc(); List findByLastNameOrderBySeatNumberAsc(String lastName); From dda58cddc2fa7deadcc0baa50e20f13cb6b06a65 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 20 Apr 2019 18:59:18 +0530 Subject: [PATCH 50/56] [BAEL-13597] - Added new module : httpclient-simple, updated httpclient with new version and code --- httpclient-simple/.gitignore | 13 ++ httpclient-simple/README.md | 10 ++ httpclient-simple/pom.xml | 133 ++++++++++++++++++ .../src/main/resources/logback.xml | 19 +++ .../org/baeldung/httpclient/ResponseUtil.java | 26 ++++ .../base/HttpClientBasicLiveTest.java | 0 .../src/test/resources/.gitignore | 13 ++ httpclient/README.md | 1 - httpclient/pom.xml | 5 +- .../httpclient/HttpAsyncClientLiveTest.java | 7 +- .../httpclient/HttpsClientSslLiveTest.java | 68 ++++----- ...ttpClientConnectionManagementLiveTest.java | 3 +- pom.xml | 2 + 13 files changed, 259 insertions(+), 41 deletions(-) create mode 100644 httpclient-simple/.gitignore create mode 100644 httpclient-simple/README.md create mode 100644 httpclient-simple/pom.xml create mode 100644 httpclient-simple/src/main/resources/logback.xml create mode 100644 httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java rename {httpclient => httpclient-simple}/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java (100%) create mode 100644 httpclient-simple/src/test/resources/.gitignore diff --git a/httpclient-simple/.gitignore b/httpclient-simple/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/httpclient-simple/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md new file mode 100644 index 0000000000..aa66c11b1e --- /dev/null +++ b/httpclient-simple/README.md @@ -0,0 +1,10 @@ +========= +## HttpClient 4.x Cookbooks and Examples + +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + + +### Relevant Articles: + +- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) \ No newline at end of file diff --git a/httpclient-simple/pom.xml b/httpclient-simple/pom.xml new file mode 100644 index 0000000000..1ad68d2804 --- /dev/null +++ b/httpclient-simple/pom.xml @@ -0,0 +1,133 @@ + + 4.0.0 + com.baeldung + httpclient-simple + 0.1-SNAPSHOT + httpclient-simple + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + commons-logging + commons-logging + + + + + org.apache.httpcomponents + fluent-hc + ${httpclient.version} + + + commons-logging + commons-logging + + + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.apache.httpcomponents + httpasyncclient + ${httpasyncclient.version} + + + commons-logging + commons-logging + + + + + com.github.tomakehurst + wiremock + ${wiremock.version} + test + + + + + httpclient + + + src/main/resources + true + + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*ManualTest.java + + + **/*LiveTest.java + + + + + + + json + + + + + + + + + + + 19.0 + 3.5 + 1.10 + 4.1.4 + + 2.5.1 + 4.5.8 + + 1.6.1 + + + \ No newline at end of file diff --git a/httpclient-simple/src/main/resources/logback.xml b/httpclient-simple/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/httpclient-simple/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java b/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java new file mode 100644 index 0000000000..fd38b95cbe --- /dev/null +++ b/httpclient-simple/src/test/java/org/baeldung/httpclient/ResponseUtil.java @@ -0,0 +1,26 @@ +package org.baeldung.httpclient; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; + +import java.io.IOException; + +public final class ResponseUtil { + private ResponseUtil() { + } + + public static void closeResponse(CloseableHttpResponse response) throws IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + entity.getContent().close(); + } + } finally { + response.close(); + } + } +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java b/httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java similarity index 100% rename from httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java rename to httpclient-simple/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java diff --git a/httpclient-simple/src/test/resources/.gitignore b/httpclient-simple/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/httpclient-simple/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/httpclient/README.md b/httpclient/README.md index c5956068c6..ce98d7e72e 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -8,7 +8,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) -- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) - [HttpClient 4 – Cancel Request](http://www.baeldung.com/httpclient-cancel-request) - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) - [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index c9f9808ede..def3a05816 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -122,11 +122,10 @@ 19.0 3.5 1.10 - 4.1.2 + 4.1.4 2.5.1 - 4.4.5 - 4.5.3 + 4.5.8 1.6.1 diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java index d39697c0a9..47a587885e 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java @@ -4,7 +4,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import java.io.IOException; -import java.security.cert.X509Certificate; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -18,8 +17,7 @@ import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.SSLContexts; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.BasicCookieStore; import org.apache.http.impl.client.BasicCredentialsProvider; @@ -31,6 +29,7 @@ import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor; import org.apache.http.nio.reactor.ConnectingIOReactor; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; +import org.apache.http.ssl.SSLContexts; import org.junit.Test; public class HttpAsyncClientLiveTest { @@ -104,7 +103,7 @@ public class HttpAsyncClientLiveTest { final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); - final CloseableHttpAsyncClient client = HttpAsyncClients.custom().setSSLHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER).setSSLContext(sslContext).build(); + final CloseableHttpAsyncClient client = HttpAsyncClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setSSLContext(sslContext).build(); client.start(); final HttpGet request = new HttpGet(HOST_WITH_SSL); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java index 4eadfe24d5..9e95905c70 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,32 +1,31 @@ package org.baeldung.httpclient; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.ssl.SSLContexts; -import org.junit.Test; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLHandshakeException; -import java.io.IOException; -import java.security.GeneralSecurityException; - import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; +import java.io.IOException; +import java.security.GeneralSecurityException; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLHandshakeException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.SSLContexts; +import org.junit.Test; + /** * This test requires a localhost server over HTTPS
    * It should only be manually run, not part of the automated build @@ -50,16 +49,22 @@ public class HttpsClientSslLiveTest { .getStatusCode(), equalTo(200)); } - @SuppressWarnings("deprecation") @Test public final void givenHttpClientPre4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; - final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - final SchemeRegistry registry = new SchemeRegistry(); - registry.register(new Scheme("https", 443, sf)); - final ClientConnectionManager ccm = new PoolingClientConnectionManager(registry); + + final SSLContext sslContext = SSLContexts.custom() + .loadTrustMaterial(null, acceptingTrustStrategy) + .build(); - final CloseableHttpClient httpClient = new DefaultHttpClient(ccm); + final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); + Registry socketFactoryRegistry = RegistryBuilder. create().register("https", sslsf).build(); + PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); + + final CloseableHttpClient httpClient = HttpClients.custom() + .setSSLSocketFactory(sslsf) + .setConnectionManager(clientConnectionManager) + .build(); final HttpGet getMethod = new HttpGet(HOST_WITH_SSL); final HttpResponse response = httpClient.execute(getMethod); @@ -76,10 +81,9 @@ public class HttpsClientSslLiveTest { .loadTrustMaterial(null, acceptingTrustStrategy) .build(); - final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); final CloseableHttpClient httpClient = HttpClients.custom() - .setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) .setSSLSocketFactory(sslsf) .build(); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java index 0f8ebefe6c..cf945098db 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java @@ -327,7 +327,8 @@ public class HttpClientConnectionManagementLiveTest { // 8.1 public final void whenHttpClientChecksStaleConns_thenNoExceptions() { poolingConnManager = new PoolingHttpClientConnectionManager(); - client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().setStaleConnectionCheckEnabled(true).build()).setConnectionManager(poolingConnManager).build(); + poolingConnManager.setValidateAfterInactivity(1000); + client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().build()).setConnectionManager(poolingConnManager).build(); } @Test diff --git a/pom.xml b/pom.xml index 53ca4291bf..d588dfaba2 100644 --- a/pom.xml +++ b/pom.xml @@ -436,6 +436,7 @@ hazelcast helidon httpclient + httpclient-simple hystrix image-processing @@ -1103,6 +1104,7 @@ hazelcast helidon httpclient + httpclient-simple hystrix image-processing From 1f853d5d515174dd901bba6d42d5620ffb53f4f8 Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Sat, 20 Apr 2019 11:48:39 -0400 Subject: [PATCH 51/56] BAEL 2879 (#6767) * BAEL-2727 Example Code * Example code for BAEL-2879 Jackson YAML --- jackson-2/pom.xml | 14 ++++ .../com/baeldung/jackson/entities/Order.java | 68 +++++++++++++++++++ .../baeldung/jackson/entities/OrderLine.java | 49 +++++++++++++ jackson-2/src/main/resources/orderInput.yaml | 11 +++ .../baeldung/jackson/yaml/YamlUnitTest.java | 63 +++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 jackson-2/src/main/java/com/baeldung/jackson/entities/Order.java create mode 100644 jackson-2/src/main/java/com/baeldung/jackson/entities/OrderLine.java create mode 100644 jackson-2/src/main/resources/orderInput.yaml create mode 100644 jackson-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java diff --git a/jackson-2/pom.xml b/jackson-2/pom.xml index ddbcb81dcc..6b973dd6f5 100644 --- a/jackson-2/pom.xml +++ b/jackson-2/pom.xml @@ -22,6 +22,20 @@ ${jackson.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + 2.9.8 + + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.9.8 + + diff --git a/jackson-2/src/main/java/com/baeldung/jackson/entities/Order.java b/jackson-2/src/main/java/com/baeldung/jackson/entities/Order.java new file mode 100644 index 0000000000..2075b7879b --- /dev/null +++ b/jackson-2/src/main/java/com/baeldung/jackson/entities/Order.java @@ -0,0 +1,68 @@ +package com.baeldung.jackson.entities; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +public class Order { + private String orderNo; + private LocalDate date; + private String customerName; + private List orderLines; + + public Order() { + + } + + public Order(String orderNo, LocalDate date, String customerName, List orderLines) { + super(); + this.orderNo = orderNo; + this.date = date; + this.customerName = customerName; + this.orderLines = orderLines; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public List getOrderLines() { + if (orderLines == null) { + orderLines = new ArrayList<>(); + } + return orderLines; + } + + public void setOrderLines(List orderLines) { + if (orderLines == null) { + orderLines = new ArrayList<>(); + } + this.orderLines = orderLines; + } + + @Override + public String toString() { + return "Order [orderNo=" + orderNo + ", date=" + date + ", customerName=" + customerName + ", orderLines=" + orderLines + "]"; + } + +} diff --git a/jackson-2/src/main/java/com/baeldung/jackson/entities/OrderLine.java b/jackson-2/src/main/java/com/baeldung/jackson/entities/OrderLine.java new file mode 100644 index 0000000000..858d094dd1 --- /dev/null +++ b/jackson-2/src/main/java/com/baeldung/jackson/entities/OrderLine.java @@ -0,0 +1,49 @@ +package com.baeldung.jackson.entities; + +import java.math.BigDecimal; + +public class OrderLine { + private String item; + private int quantity; + private BigDecimal unitPrice; + + public OrderLine() { + + } + + public OrderLine(String item, int quantity, BigDecimal unitPrice) { + super(); + this.item = item; + this.quantity = quantity; + this.unitPrice = unitPrice; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = item; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public BigDecimal getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(BigDecimal unitPrice) { + this.unitPrice = unitPrice; + } + + @Override + public String toString() { + return "OrderLine [item=" + item + ", quantity=" + quantity + ", unitPrice=" + unitPrice + "]"; + } +} diff --git a/jackson-2/src/main/resources/orderInput.yaml b/jackson-2/src/main/resources/orderInput.yaml new file mode 100644 index 0000000000..0aaa6186a2 --- /dev/null +++ b/jackson-2/src/main/resources/orderInput.yaml @@ -0,0 +1,11 @@ +orderNo: A001 +date: 2019-04-17 +customerName: Customer, Joe +orderLines: + - item: No. 9 Sprockets + quantity: 12 + unitPrice: 1.23 + - item: Widget (10mm) + quantity: 4 + unitPrice: 3.45 + \ No newline at end of file diff --git a/jackson-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java b/jackson-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java new file mode 100644 index 0000000000..3ed84db60e --- /dev/null +++ b/jackson-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.jackson.yaml; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.jackson.entities.Order; +import com.baeldung.jackson.entities.OrderLine; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; + +public class YamlUnitTest { + private ObjectMapper mapper; + + @Before + public void setup() { + mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER)); + mapper.findAndRegisterModules(); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + } + + @Test + public void givenYamlInput_ObjectCreated() throws JsonParseException, JsonMappingException, IOException { + Order order = mapper.readValue(new File("src/main/resources/orderInput.yaml"), Order.class); + assertEquals("A001", order.getOrderNo()); + assertEquals(LocalDate.parse("2019-04-17", DateTimeFormatter.ISO_DATE), order.getDate()); + assertEquals("Customer, Joe", order.getCustomerName()); + assertEquals(2, order.getOrderLines() + .size()); + } + + @Test + public void givenYamlObject_FileWritten() throws JsonGenerationException, JsonMappingException, IOException { + List lines = new ArrayList<>(); + lines.add(new OrderLine("Copper Wire (200ft)", 1, new BigDecimal(50.67).setScale(2, RoundingMode.HALF_UP))); + lines.add(new OrderLine("Washers (1/4\")", 24, new BigDecimal(.15).setScale(2, RoundingMode.HALF_UP))); + Order order = new Order( + "B-9910", + LocalDate.parse("2019-04-18", DateTimeFormatter.ISO_DATE), + "Customer, Jane", + lines); + mapper.writeValue(new File("src/main/resources/orderOutput.yaml"), order); + + File outputYaml = new File("src/main/resources/orderOutput.yaml"); + assertTrue(outputYaml.exists()); + } +} From e164ab8af010d5aff19401a560d3d4b281fc5e71 Mon Sep 17 00:00:00 2001 From: maibin Date: Sat, 20 Apr 2019 10:44:01 -0700 Subject: [PATCH 52/56] Fix the Groovy 2 build (#6772) * Fix the name of the artifact * Add Groovy 2 to build --- core-groovy-2/pom.xml | 2 +- pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index bbedbf2157..eb82f5d2e3 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - core-groovy + core-groovy-2 1.0-SNAPSHOT core-groovy-2 jar diff --git a/pom.xml b/pom.xml index d588dfaba2..2e31200652 100644 --- a/pom.xml +++ b/pom.xml @@ -376,6 +376,7 @@ cdi checker-plugin core-groovy + core-groovy-2 From fab2df5166fc6c974b0deeea3e282e0786586aa0 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 21 Apr 2019 00:19:55 +0530 Subject: [PATCH 53/56] [BAEL-13600] - Updated HttpClient with SSL Header article --- httpclient-simple/README.md | 3 +- httpclient-simple/pom.xml | 200 +++++++++++++++++- .../MyBasicAuthenticationEntryPoint.java | 30 +++ ...entsClientHttpRequestFactoryBasicAuth.java | 39 ++++ .../baeldung/client/RestTemplateFactory.java | 44 ++++ .../baeldung/client/spring/ClientConfig.java | 16 ++ .../org/baeldung/filter/CustomFilter.java | 18 ++ .../CustomWebSecurityConfigurerAdapter.java | 49 +++++ ...uestAwareAuthenticationSuccessHandler.java | 48 +++++ .../RestAuthenticationEntryPoint.java | 23 ++ .../baeldung/spring/SecSecurityConfig.java | 16 ++ .../java/org/baeldung/spring/WebConfig.java | 30 +++ .../web/controller/BarController.java | 31 +++ .../web/controller/FooController.java | 33 +++ .../main/java/org/baeldung/web/dto/Bar.java | 14 ++ .../main/java/org/baeldung/web/dto/Foo.java | 14 ++ .../src/main/resources/webSecurityConfig.xml | 28 +++ .../src/main/webapp/WEB-INF/api-servlet.xml | 6 + .../src/main/webapp/WEB-INF/web.xml | 43 ++++ .../org/baeldung/client/ClientLiveTest.java | 4 +- .../client/RestClientLiveManualTest.java | 38 +++- .../httpclient/HttpsClientSslLiveTest.java | 0 .../java/org/baeldung/test/LiveTestSuite.java | 0 spring-security-rest-basic-auth/README.md | 1 - spring-security-rest-basic-auth/pom.xml | 4 +- 25 files changed, 712 insertions(+), 20 deletions(-) create mode 100644 httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java create mode 100644 httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java create mode 100644 httpclient-simple/src/main/resources/webSecurityConfig.xml create mode 100644 httpclient-simple/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 httpclient-simple/src/main/webapp/WEB-INF/web.xml rename {spring-security-rest-basic-auth => httpclient-simple}/src/test/java/org/baeldung/client/ClientLiveTest.java (88%) rename {spring-security-rest-basic-auth => httpclient-simple}/src/test/java/org/baeldung/client/RestClientLiveManualTest.java (63%) rename {httpclient => httpclient-simple}/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java (100%) rename {spring-security-rest-basic-auth => httpclient-simple}/src/test/java/org/baeldung/test/LiveTestSuite.java (100%) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index aa66c11b1e..d1224359e0 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -7,4 +7,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) \ No newline at end of file +- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) +- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) \ No newline at end of file diff --git a/httpclient-simple/pom.xml b/httpclient-simple/pom.xml index 1ad68d2804..f3d00251d7 100644 --- a/httpclient-simple/pom.xml +++ b/httpclient-simple/pom.xml @@ -5,15 +5,111 @@ httpclient-simple 0.1-SNAPSHOT httpclient-simple + war com.baeldung - parent-java + parent-spring-5 0.0.1-SNAPSHOT - ../parent-java + ../parent-spring-5 + + + + + org.springframework.security + spring-security-web + ${spring.version} + + + org.springframework.security + spring-security-config + ${spring.version} + + + + + + org.springframework + spring-core + ${spring.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-aop + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + org.springframework + spring-expression + ${spring.version} + + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-webmvc + ${spring.version} + + + + org.springframework + spring-oxm + ${spring.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + org.apache.httpcomponents + httpcore + ${httpcore.version} + + + commons-logging + commons-logging + + + + org.apache.commons @@ -70,16 +166,77 @@ ${wiremock.version} test + + + + + javax.servlet + javax.servlet-api + ${javax.servlet.version} + provided + + + + javax.servlet + jstl + ${jstl.version} + runtime + + + + + + com.google.guava + guava + ${guava.version} + + + + + + org.springframework + spring-test + ${spring.version} + test + - httpclient + httpclient-simple src/main/resources true + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + @@ -87,6 +244,27 @@ live + + org.codehaus.cargo + cargo-maven2-plugin + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -98,26 +276,28 @@ - **/*ManualTest.java + none **/*LiveTest.java + + cargo + - - - json - - + + + 1.2 + 3.1.0 19.0 3.5 @@ -125,8 +305,10 @@ 4.1.4 2.5.1 + 4.4.11 4.5.8 + 2.6 1.6.1 diff --git a/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java new file mode 100644 index 0000000000..6e580e7a22 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java @@ -0,0 +1,30 @@ +package org.baeldung.basic; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +@Component +public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + final PrintWriter writer = response.getWriter(); + writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage()); + } + + @Override + public void afterPropertiesSet() throws Exception { + setRealmName("Baeldung"); + super.afterPropertiesSet(); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java b/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java new file mode 100644 index 0000000000..a2f51d343b --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java @@ -0,0 +1,39 @@ +package org.baeldung.client; + +import java.net.URI; + +import org.apache.http.HttpHost; +import org.apache.http.client.AuthCache; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; +import org.springframework.http.HttpMethod; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; + +public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { + + HttpHost host; + + public HttpComponentsClientHttpRequestFactoryBasicAuth(HttpHost host) { + super(); + this.host = host; + } + + protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) { + return createHttpContext(); + } + + private HttpContext createHttpContext() { + + AuthCache authCache = new BasicAuthCache(); + + BasicScheme basicAuth = new BasicScheme(); + authCache.put(host, basicAuth); + + BasicHttpContext localcontext = new BasicHttpContext(); + localcontext.setAttribute(HttpClientContext.AUTH_CACHE, authCache); + return localcontext; + } +} \ No newline at end of file diff --git a/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java b/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java new file mode 100644 index 0000000000..3ed0bc82b7 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -0,0 +1,44 @@ +package org.baeldung.client; + +import org.apache.http.HttpHost; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.support.BasicAuthenticationInterceptor; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +@Component +public class RestTemplateFactory implements FactoryBean, InitializingBean { + private RestTemplate restTemplate; + + public RestTemplateFactory() { + super(); + } + + // API + + @Override + public RestTemplate getObject() { + return restTemplate; + } + + @Override + public Class getObjectType() { + return RestTemplate.class; + } + + @Override + public boolean isSingleton() { + return true; + } + + @Override + public void afterPropertiesSet() { + HttpHost host = new HttpHost("localhost", 8082, "http"); + final ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); + restTemplate = new RestTemplate(requestFactory); + restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor("user1", "user1Pass")); + } + +} \ No newline at end of file diff --git a/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java b/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java new file mode 100644 index 0000000000..73e602855c --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/client/spring/ClientConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.client.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("org.baeldung.client") +public class ClientConfig { + + public ClientConfig() { + super(); + } + + // beans + +} \ No newline at end of file diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java b/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java new file mode 100644 index 0000000000..01e5b0b59d --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/filter/CustomFilter.java @@ -0,0 +1,18 @@ +package org.baeldung.filter; + +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import java.io.IOException; + +public class CustomFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + chain.doFilter(request, response); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java b/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java new file mode 100644 index 0000000000..7ca2a80c52 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/filter/CustomWebSecurityConfigurerAdapter.java @@ -0,0 +1,49 @@ +package org.baeldung.filter; + +import org.baeldung.security.RestAuthenticationEntryPoint; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + +@Configuration +@EnableWebSecurity +public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { + + @Autowired private RestAuthenticationEntryPoint authenticationEntryPoint; + + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + auth + .inMemoryAuthentication() + .withUser("user1") + .password(passwordEncoder().encode("user1Pass")) + .authorities("ROLE_USER"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/securityNone") + .permitAll() + .anyRequest() + .authenticated() + .and() + .httpBasic() + .authenticationEntryPoint(authenticationEntryPoint); + + http.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class); + } + + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java b/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java new file mode 100644 index 0000000000..698052fa2b --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/security/MySavedRequestAwareAuthenticationSuccessHandler.java @@ -0,0 +1,48 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; + +public class MySavedRequestAwareAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + private RequestCache requestCache = new HttpSessionRequestCache(); + + @Override + public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws ServletException, IOException { + final SavedRequest savedRequest = requestCache.getRequest(request, response); + + if (savedRequest == null) { + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + final String targetUrlParameter = getTargetUrlParameter(); + if (isAlwaysUseDefaultTargetUrl() || (targetUrlParameter != null && StringUtils.hasText(request.getParameter(targetUrlParameter)))) { + requestCache.removeRequest(request, response); + super.onAuthenticationSuccess(request, response, authentication); + + return; + } + + clearAuthenticationAttributes(request); + + // Use the DefaultSavedRequest URL + // final String targetUrl = savedRequest.getRedirectUrl(); + // logger.debug("Redirecting to DefaultSavedRequest Url: " + targetUrl); + // getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + public void setRequestCache(final RequestCache requestCache) { + this.requestCache = requestCache; + } +} diff --git a/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java new file mode 100644 index 0000000000..77aa32ff97 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/security/RestAuthenticationEntryPoint.java @@ -0,0 +1,23 @@ +package org.baeldung.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +/** + * The Entry Point will not redirect to any sort of Login - it will return the 401 + */ +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } + +} \ No newline at end of file diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java new file mode 100644 index 0000000000..4ce80dab9f --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -0,0 +1,16 @@ +package org.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +@Configuration +@ImportResource({ "classpath:webSecurityConfig.xml" }) +@ComponentScan("org.baeldung.security") +public class SecSecurityConfig { + + public SecSecurityConfig() { + super(); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java b/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java new file mode 100644 index 0000000000..5876e1307b --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/spring/WebConfig.java @@ -0,0 +1,30 @@ +package org.baeldung.spring; + +import java.util.List; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@EnableWebMvc +@ComponentScan("org.baeldung.web") +public class WebConfig implements WebMvcConfigurer { + + public WebConfig() { + super(); + } + + // beans + + @Override + public void configureMessageConverters(final List> converters) { + converters.add(new MappingJackson2HttpMessageConverter()); + } + + // + +} \ No newline at end of file diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java b/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java new file mode 100644 index 0000000000..2bc314baa2 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/web/controller/BarController.java @@ -0,0 +1,31 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Bar; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/bars") +public class BarController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public BarController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Bar findOne(@PathVariable("id") final Long id) { + return new Bar(); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java b/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 0000000000..b50edb2dcf --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,33 @@ +package org.baeldung.web.controller; + +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping(value = "/foos") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + @PreAuthorize("hasRole('ROLE_USER')") + public Foo findOne(@PathVariable("id") final Long id) { + return new Foo(); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java b/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java new file mode 100644 index 0000000000..d33e39a823 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/web/dto/Bar.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Bar implements Serializable { + + public Bar() { + super(); + } + +} diff --git a/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java b/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 0000000000..09c1dac933 --- /dev/null +++ b/httpclient-simple/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,14 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Foo implements Serializable { + + public Foo() { + super(); + } + +} diff --git a/httpclient-simple/src/main/resources/webSecurityConfig.xml b/httpclient-simple/src/main/resources/webSecurityConfig.xml new file mode 100644 index 0000000000..a93dc841b6 --- /dev/null +++ b/httpclient-simple/src/main/resources/webSecurityConfig.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/httpclient-simple/src/main/webapp/WEB-INF/api-servlet.xml b/httpclient-simple/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 0000000000..1dbff70b83 --- /dev/null +++ b/httpclient-simple/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/httpclient-simple/src/main/webapp/WEB-INF/web.xml b/httpclient-simple/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..83b4aeb0a7 --- /dev/null +++ b/httpclient-simple/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,43 @@ + + + + Spring Security Custom Application + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + contextConfigLocation + org.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java b/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java similarity index 88% rename from spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java rename to httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java index 2a668f827a..286ee3c900 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/ClientLiveTest.java +++ b/httpclient-simple/src/test/java/org/baeldung/client/ClientLiveTest.java @@ -33,13 +33,13 @@ public class ClientLiveTest { @Test public final void whenSecuredRestApiIsConsumed_then200OK() { - final ResponseEntity responseEntity = secureRestTemplate.exchange("http://localhost:8082/spring-security-rest-basic-auth/api/foos/1", HttpMethod.GET, null, Foo.class); + final ResponseEntity responseEntity = secureRestTemplate.exchange("http://localhost:8082/httpclient-simple/api/foos/1", HttpMethod.GET, null, Foo.class); assertThat(responseEntity.getStatusCode().value(), is(200)); } @Test(expected = ResourceAccessException.class) public final void whenHttpsUrlIsConsumed_thenException() { - final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1"; + final String urlOverHttps = "https://localhost:8443/httpclient-simple/api/bars/1"; final ResponseEntity response = new RestTemplate().exchange(urlOverHttps, HttpMethod.GET, null, String.class); assertThat(response.getStatusCode().value(), equalTo(200)); } diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RestClientLiveManualTest.java b/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java similarity index 63% rename from spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RestClientLiveManualTest.java rename to httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java index 104129b663..53f259c21d 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/client/RestClientLiveManualTest.java +++ b/httpclient-simple/src/test/java/org/baeldung/client/RestClientLiveManualTest.java @@ -8,19 +8,24 @@ import java.io.IOException; import java.security.GeneralSecurityException; import java.security.cert.X509Certificate; -import javax.net.ssl.SSLException; -import javax.net.ssl.SSLPeerUnverifiedException; +import javax.net.ssl.SSLContext; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.apache.http.ssl.SSLContexts; import org.junit.Ignore; import org.junit.Test; import org.springframework.http.HttpMethod; @@ -34,14 +39,14 @@ import org.springframework.web.client.RestTemplate; * */ public class RestClientLiveManualTest { - final String urlOverHttps = "http://localhost:8082/spring-security-rest-basic-auth/api/bars/1"; + final String urlOverHttps = "http://localhost:8082/httpclient-simple/api/bars/1"; // tests // old httpClient will throw UnsupportedOperationException @Ignore @Test - public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException() throws GeneralSecurityException { + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException_1() throws GeneralSecurityException { final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient(); @@ -57,6 +62,29 @@ public class RestClientLiveManualTest { final ResponseEntity response = new RestTemplate(requestFactory).exchange(urlOverHttps, HttpMethod.GET, null, String.class); assertThat(response.getStatusCode().value(), equalTo(200)); } + + // new httpClient : 4.4 and above + @Test + public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException_2() throws GeneralSecurityException { + + final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true; + final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); + final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); + final Registry socketFactoryRegistry = RegistryBuilder. create() + .register("https", sslsf) + .register("http", new PlainConnectionSocketFactory()) + .build(); + + final BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(socketFactoryRegistry); + final CloseableHttpClient httpClient = HttpClients.custom() + .setSSLSocketFactory(sslsf) + .setConnectionManager(connectionManager) + .build(); + + final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); + final ResponseEntity response = new RestTemplate(requestFactory).exchange(urlOverHttps, HttpMethod.GET, null, String.class); + assertThat(response.getStatusCode().value(), equalTo(200)); + } @Test public final void givenAcceptingAllCertificatesUsing4_4_whenHttpsUrlIsConsumed_thenCorrect() throws ClientProtocolException, IOException { diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java similarity index 100% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java rename to httpclient-simple/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/test/LiveTestSuite.java b/httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java similarity index 100% rename from spring-security-rest-basic-auth/src/test/java/org/baeldung/test/LiveTestSuite.java rename to httpclient-simple/src/test/java/org/baeldung/test/LiveTestSuite.java diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md index 30da3afbcf..0a48a747c2 100644 --- a/spring-security-rest-basic-auth/README.md +++ b/spring-security-rest-basic-auth/README.md @@ -8,6 +8,5 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: - [Basic Authentication with the RestTemplate](http://www.baeldung.com/how-to-use-resttemplate-with-basic-authentication-in-spring) - [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) -- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) - [A Custom Filter in the Spring Security Filter Chain](http://www.baeldung.com/spring-security-custom-filter) - [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-rest-basic-auth/pom.xml b/spring-security-rest-basic-auth/pom.xml index ca5c4c38e6..3c7f8eaa2b 100644 --- a/spring-security-rest-basic-auth/pom.xml +++ b/spring-security-rest-basic-auth/pom.xml @@ -272,8 +272,8 @@ - 4.4.5 - 4.5.3 + 4.4.11 + 4.5.8 1.2 From 28f80013cb9561d840efbb757a718c26f51282ad Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 20 Apr 2019 22:14:27 +0300 Subject: [PATCH 54/56] BAEL-2661 - Groovy def keyword - pr comments resolved --- core-groovy-2/pom.xml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index 9819bc4c16..e783533ccc 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -95,8 +95,8 @@ - - + + maven-surefire-plugin 2.20.1 @@ -120,9 +120,6 @@ 1.0.0 - - - 2.5.6 2.5.6 2.5.6 From 743e1b04e12eefca54691f4e4478f8d3230d0d00 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 20 Apr 2019 22:16:30 +0300 Subject: [PATCH 55/56] BAEL-2661 - Groovy def keyword - pr comments resolved --- core-groovy-2/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index e783533ccc..77de9c8fc8 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -95,9 +95,9 @@ - + - + maven-surefire-plugin 2.20.1 From 0ee62413a5075f9b34c0c2b12af8fe8f7039d67d Mon Sep 17 00:00:00 2001 From: Eugen Date: Sun, 21 Apr 2019 08:32:46 +0300 Subject: [PATCH 56/56] Update README.md --- spring-boot-rest/README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 5b7bbdac60..5abac75452 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -7,12 +7,10 @@ Module for the articles that are part of the Spring REST E-book: 5. [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application) 6. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) 7. [REST API Discoverability and HATEOAS](http://www.baeldung.com/restful-web-service-discoverability) -8. -9. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) -10. [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) - -- [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) -- [Versioning a REST API](http://www.baeldung.com/rest-versioning) -- [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) -- [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) -- [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) +8. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) +9. [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) +10. [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) +11. [Versioning a REST API](http://www.baeldung.com/rest-versioning) +12. [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) +13. [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) +14. [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections)