diff --git a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationTest.java b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationIntegrationTest.java
similarity index 92%
rename from flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationTest.java
rename to flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationIntegrationTest.java
index b3f2cb29e1..59ef5820d7 100644
--- a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationTest.java
+++ b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInitialMigrationIntegrationTest.java
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertNotNull;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CustomerRepositoryInitialMigrationTest {
+public class CustomerRepositoryInitialMigrationIntegrationTest {
@Autowired CustomerRepository customerRepository;
diff --git a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataMigrationTest.java b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataIntegrationTest.java
similarity index 94%
rename from flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataMigrationTest.java
rename to flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataIntegrationTest.java
index 369e61d98f..3feedf2fd9 100644
--- a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataMigrationTest.java
+++ b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryInsertDataIntegrationTest.java
@@ -15,7 +15,7 @@ import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CustomerRepositoryInsertDataMigrationTest {
+public class CustomerRepositoryInsertDataIntegrationTest {
@Autowired CustomerRepository customerRepository;
diff --git a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationTest.java b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationIntegrationTest.java
similarity index 91%
rename from flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationTest.java
rename to flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationIntegrationTest.java
index 90517c9225..9ec5d4d77e 100644
--- a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationTest.java
+++ b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryNotNullConstraintMigrationIntegrationTest.java
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CustomerRepositoryNotNullConstraintMigrationTest {
+public class CustomerRepositoryNotNullConstraintMigrationIntegrationTest {
@Autowired CustomerRepository customerRepository;
diff --git a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationTest.java b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationIntegrationTest.java
similarity index 92%
rename from flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationTest.java
rename to flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationIntegrationTest.java
index e5ba782fda..f615f477bc 100644
--- a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationTest.java
+++ b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintJavaMigrationIntegrationTest.java
@@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(properties = {
"flyway.locations[0]=db/migration", "flyway.locations[1]=com/baeldung/springflyway/migration"
})
-public class CustomerRepositoryUniqueConstraintJavaMigrationTest {
+public class CustomerRepositoryUniqueConstraintJavaMigrationIntegrationTest {
@Autowired CustomerRepository customerRepository;
diff --git a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationTest.java b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationIntegrationTest.java
similarity index 92%
rename from flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationTest.java
rename to flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationIntegrationTest.java
index 9fa2dee42d..e9ac34b384 100644
--- a/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationTest.java
+++ b/flyway/spring-flyway/src/test/java/com/baeldung/springflyway/CustomerRepositoryUniqueConstraintMigrationIntegrationTest.java
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
-public class CustomerRepositoryUniqueConstraintMigrationTest {
+public class CustomerRepositoryUniqueConstraintMigrationIntegrationTest {
@Autowired CustomerRepository customerRepository;
diff --git a/libraries/pom.xml b/libraries/pom.xml
index eaa2d9d38f..3627e74472 100644
--- a/libraries/pom.xml
+++ b/libraries/pom.xml
@@ -633,9 +633,26 @@
${googleclient.version}
- com.google.http-client
- google-http-client-gson
- ${googleclient.version}
+ com.google.http-client
+ google-http-client-gson
+ ${googleclient.version}
+
+
+
+
+ com.google.api-client
+ google-api-client
+ ${google-api.version}
+
+
+ com.google.oauth-client
+ google-oauth-client-jetty
+ ${google-api.version}
+
+
+ com.google.apis
+ google-api-services-sheets
+ ${google-sheets.version}
@@ -710,5 +727,7 @@
1.0.0
3.8.4
2.5.5
+ 1.23.0
+ v4-rev493-1.21.0
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/google/sheets/GoogleAuthorizeUtil.java b/libraries/src/main/java/com/baeldung/google/sheets/GoogleAuthorizeUtil.java
new file mode 100644
index 0000000000..650a1d084c
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/google/sheets/GoogleAuthorizeUtil.java
@@ -0,0 +1,42 @@
+package com.baeldung.google.sheets;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.GeneralSecurityException;
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.api.client.auth.oauth2.Credential;
+import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
+import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
+import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
+import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
+import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.client.util.store.MemoryDataStoreFactory;
+import com.google.api.services.sheets.v4.SheetsScopes;
+
+public class GoogleAuthorizeUtil {
+ public static Credential authorize() throws IOException, GeneralSecurityException {
+ InputStream in = GoogleAuthorizeUtil.class.getResourceAsStream("/google-sheets-client-secret.json");
+ GoogleClientSecrets clientSecrets = GoogleClientSecrets
+ .load(JacksonFactory.getDefaultInstance(), new InputStreamReader(in));
+
+ List scopes = Arrays.asList(SheetsScopes.SPREADSHEETS);
+
+ GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow
+ .Builder(GoogleNetHttpTransport.newTrustedTransport(),
+ JacksonFactory.getDefaultInstance(),
+ clientSecrets,
+ scopes)
+ .setDataStoreFactory(new MemoryDataStoreFactory())
+ .setAccessType("offline")
+ .build();
+ Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver())
+ .authorize("user");
+
+ return credential;
+ }
+
+}
diff --git a/libraries/src/main/java/com/baeldung/google/sheets/SheetsServiceUtil.java b/libraries/src/main/java/com/baeldung/google/sheets/SheetsServiceUtil.java
new file mode 100644
index 0000000000..bbce96f389
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/google/sheets/SheetsServiceUtil.java
@@ -0,0 +1,23 @@
+package com.baeldung.google.sheets;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import com.google.api.client.auth.oauth2.Credential;
+import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
+import com.google.api.client.json.jackson2.JacksonFactory;
+import com.google.api.services.sheets.v4.Sheets;
+
+public class SheetsServiceUtil {
+
+ private static final String APPLICATION_NAME = "Google Sheets Example";
+
+ public static Sheets getSheetsService() throws IOException, GeneralSecurityException {
+ Credential credential = GoogleAuthorizeUtil.authorize();
+ return new Sheets.Builder(GoogleNetHttpTransport.newTrustedTransport(),
+ JacksonFactory.getDefaultInstance(), credential)
+ .setApplicationName(APPLICATION_NAME)
+ .build();
+ }
+
+}
diff --git a/libraries/src/main/resources/google-sheets-client-secret.json b/libraries/src/main/resources/google-sheets-client-secret.json
new file mode 100644
index 0000000000..c92ccd6b9b
--- /dev/null
+++ b/libraries/src/main/resources/google-sheets-client-secret.json
@@ -0,0 +1 @@
+{"installed":{"client_id":"394827218507-2ev02b2ha8plt7g2lh5nqse02ee737cf.apps.googleusercontent.com","project_id":"decisive-octane-187810","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"2MnN1DfenoCGWMay3v8Bf7eI","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
\ No newline at end of file
diff --git a/libraries/src/test/java/com/baeldung/google/sheets/GoogleSheetsIntegrationTest.java b/libraries/src/test/java/com/baeldung/google/sheets/GoogleSheetsIntegrationTest.java
new file mode 100644
index 0000000000..5280073be2
--- /dev/null
+++ b/libraries/src/test/java/com/baeldung/google/sheets/GoogleSheetsIntegrationTest.java
@@ -0,0 +1,140 @@
+package com.baeldung.google.sheets;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.api.services.sheets.v4.Sheets;
+import com.google.api.services.sheets.v4.model.AppendValuesResponse;
+import com.google.api.services.sheets.v4.model.BatchGetValuesResponse;
+import com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest;
+import com.google.api.services.sheets.v4.model.BatchUpdateValuesRequest;
+import com.google.api.services.sheets.v4.model.BatchUpdateValuesResponse;
+import com.google.api.services.sheets.v4.model.CopyPasteRequest;
+import com.google.api.services.sheets.v4.model.GridRange;
+import com.google.api.services.sheets.v4.model.Request;
+import com.google.api.services.sheets.v4.model.Spreadsheet;
+import com.google.api.services.sheets.v4.model.SpreadsheetProperties;
+import com.google.api.services.sheets.v4.model.UpdateSpreadsheetPropertiesRequest;
+import com.google.api.services.sheets.v4.model.UpdateValuesResponse;
+import com.google.api.services.sheets.v4.model.ValueRange;
+
+import static org.assertj.core.api.Assertions.*;
+
+public class GoogleSheetsIntegrationTest {
+
+ private static Sheets sheetsService;
+
+ // this id can be replaced with your spreadsheet id
+ // otherwise be advised that multiple people may run this test and update the public spreadsheet
+ private static final String SPREADSHEET_ID = "1sILuxZUnyl_7-MlNThjt765oWshN3Xs-PPLfqYe4DhI";
+
+ @BeforeClass
+ public static void setup() throws GeneralSecurityException, IOException {
+ sheetsService = SheetsServiceUtil.getSheetsService();
+ }
+
+ @Test
+ public void whenWriteSheet_thenReadSheetOk() throws IOException {
+ ValueRange body = new ValueRange()
+ .setValues(Arrays.asList(
+ Arrays.asList("Expenses January"),
+ Arrays.asList("books", "30"),
+ Arrays.asList("pens", "10"),
+ Arrays.asList("Expenses February"),
+ Arrays.asList("clothes", "20"),
+ Arrays.asList("shoes", "5")));
+ UpdateValuesResponse result = sheetsService.spreadsheets().values()
+ .update(SPREADSHEET_ID, "A1", body)
+ .setValueInputOption("RAW")
+ .execute();
+
+ List data = new ArrayList<>();
+ data.add(new ValueRange()
+ .setRange("D1")
+ .setValues(Arrays.asList(
+ Arrays.asList("January Total", "=B2+B3"))));
+ data.add(new ValueRange()
+ .setRange("D4")
+ .setValues(Arrays.asList(
+ Arrays.asList("February Total", "=B5+B6"))));
+
+ BatchUpdateValuesRequest batchBody = new BatchUpdateValuesRequest()
+ .setValueInputOption("USER_ENTERED")
+ .setData(data);
+ BatchUpdateValuesResponse batchResult =
+ sheetsService.spreadsheets().values()
+ .batchUpdate(SPREADSHEET_ID, batchBody)
+ .execute();
+
+ List ranges = Arrays.asList("E1","E4");
+ BatchGetValuesResponse readResult =
+ sheetsService.spreadsheets().values()
+ .batchGet(SPREADSHEET_ID)
+ .setRanges(ranges)
+ .execute();
+
+ ValueRange januaryTotal = readResult.getValueRanges().get(0);
+ assertThat(januaryTotal.getValues().get(0).get(0)).isEqualTo("40");
+
+ ValueRange febTotal = readResult.getValueRanges().get(1);
+ assertThat(febTotal.getValues().get(0).get(0)).isEqualTo("25");
+
+ ValueRange appendBody = new ValueRange()
+ .setValues(Arrays.asList(
+ Arrays.asList("Total", "=E1+E4")));
+ AppendValuesResponse appendResult =
+ sheetsService.spreadsheets().values()
+ .append(SPREADSHEET_ID, "A1", appendBody)
+ .setValueInputOption("USER_ENTERED")
+ .setInsertDataOption("INSERT_ROWS")
+ .setIncludeValuesInResponse(true)
+ .execute();
+
+ ValueRange total = appendResult.getUpdates().getUpdatedData();
+ assertThat(total.getValues().get(0).get(1)).isEqualTo("65");
+ }
+
+
+ @Test
+ public void whenUpdateSpreadSheetTitle_thenOk() throws IOException {
+
+ UpdateSpreadsheetPropertiesRequest updateRequest = new UpdateSpreadsheetPropertiesRequest()
+ .setFields("*")
+ .setProperties(new SpreadsheetProperties().setTitle("Expenses"));
+
+ CopyPasteRequest copyRequest = new CopyPasteRequest()
+ .setSource(new GridRange().setSheetId(0)
+ .setStartColumnIndex(0).setEndColumnIndex(2)
+ .setStartRowIndex(0).setEndRowIndex(1))
+ .setDestination(new GridRange().setSheetId(1)
+ .setStartColumnIndex(0).setEndColumnIndex(2)
+ .setStartRowIndex(0).setEndRowIndex(1))
+ .setPasteType("PASTE_VALUES");
+
+ List requests = new ArrayList<>();
+
+ requests.add(new Request().setCopyPaste(copyRequest));
+ requests.add(new Request().setUpdateSpreadsheetProperties(updateRequest));
+
+ BatchUpdateSpreadsheetRequest body =
+ new BatchUpdateSpreadsheetRequest().setRequests(requests);
+
+ sheetsService.spreadsheets().batchUpdate(SPREADSHEET_ID, body).execute();
+ }
+
+ @Test
+ public void whenCreateSpreadSheet_thenIdOk() throws IOException {
+ Spreadsheet spreadSheet = new Spreadsheet()
+ .setProperties(new SpreadsheetProperties().setTitle("My Spreadsheet"));
+ Spreadsheet result = sheetsService.spreadsheets().create(spreadSheet).execute();
+
+ assertThat(result.getSpreadsheetId()).isNotNull();
+ }
+
+}
diff --git a/libraries/src/test/java/com/baeldung/neuroph/XORTest.java b/libraries/src/test/java/com/baeldung/neuroph/XORIntegrationTest.java
similarity index 97%
rename from libraries/src/test/java/com/baeldung/neuroph/XORTest.java
rename to libraries/src/test/java/com/baeldung/neuroph/XORIntegrationTest.java
index 4a6ecf8e46..5da1d166f6 100644
--- a/libraries/src/test/java/com/baeldung/neuroph/XORTest.java
+++ b/libraries/src/test/java/com/baeldung/neuroph/XORIntegrationTest.java
@@ -7,7 +7,7 @@ import org.neuroph.core.NeuralNetwork;
import static org.junit.Assert.*;
-public class XORTest {
+public class XORIntegrationTest {
private NeuralNetwork ann = null;
private void print(String input, double output, double actual) {
diff --git a/pom.xml b/pom.xml
index 9d8f687c0e..6698735c5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,8 +49,6 @@
core-java-8
core-java-concurrency
couchbase
- cas/cas-server
- cas/cas-secured-app
deltaspike
dozer
@@ -141,8 +139,8 @@
persistence-modules/solr
spark-java
+ spring-5-reactive
spring-5-mvc
- spring-acl
spring-activiti
spring-akka
spring-amqp
@@ -152,7 +150,7 @@
spring-batch
spring-bom
spring-boot
- spring-boot-keycloak
+ spring-boot-keycloak
spring-boot-bootstrap
spring-cloud-data-flow
spring-cloud
diff --git a/spring-5-reactive-client/.gitignore b/spring-5-reactive-client/.gitignore
new file mode 100644
index 0000000000..dec013dfa4
--- /dev/null
+++ b/spring-5-reactive-client/.gitignore
@@ -0,0 +1,12 @@
+#folders#
+.idea
+/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/spring-5-reactive-client/README.md b/spring-5-reactive-client/README.md
new file mode 100644
index 0000000000..400e343263
--- /dev/null
+++ b/spring-5-reactive-client/README.md
@@ -0,0 +1,15 @@
+## Spring REST Example Project
+
+### The Course
+The "REST With Spring" Classes: http://bit.ly/restwithspring
+
+### Relevant Articles
+
+- [Concurrent Test Execution in Spring 5](http://www.baeldung.com/spring-5-concurrent-tests)
+- [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web)
+- [Exploring the Spring 5 MVC URL Matching Improvements](http://www.baeldung.com/spring-5-mvc-url-matching)
+- [Spring 5 WebClient](http://www.baeldung.com/spring-5-webclient)
+- [Spring 5 Functional Bean Registration](http://www.baeldung.com/spring-5-functional-beans)
+- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](http://www.baeldung.com/spring-5-junit-config)
+- [Spring Security 5 for Reactive Applications](http://www.baeldung.com/spring-security-5-reactive)
+- [Spring 5 Testing with @EnabledIf Annotation](https://github.com/eugenp/tutorials/tree/master/spring-5)
diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml
new file mode 100644
index 0000000000..8aa579b724
--- /dev/null
+++ b/spring-5-reactive-client/pom.xml
@@ -0,0 +1,201 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ spring-5-reactive-client
+ 0.0.1-SNAPSHOT
+ jar
+
+ spring-5
+ spring 5 sample project about new features
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.M7
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+ org.projectreactor
+ reactor-spring
+ ${reactor-spring.version}
+
+
+ javax.json.bind
+ javax.json.bind-api
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.geronimo.specs
+ geronimo-json_1.1_spec
+ ${geronimo-json_1.1_spec.version}
+
+
+ org.apache.johnzon
+ johnzon-jsonb
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework
+ spring-test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.apache.commons
+ commons-collections4
+ 4.1
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-runner
+ ${junit.platform.version}
+ test
+
+
+
+ org.projectlombok
+ lombok
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ com.baeldung.Spring5Application
+ JAR
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ 3
+ true
+ methods
+ true
+
+ **/*IntegrationTest.java
+ **/*LiveTest.java
+
+
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.0.0
+ 5.0.0
+ 2.20
+ 5.0.1.RELEASE
+ 1.0.1.RELEASE
+ 1.1.3
+ 1.0
+ 1.0
+
+
+
diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java
new file mode 100644
index 0000000000..2c49e6146a
--- /dev/null
+++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java
@@ -0,0 +1,13 @@
+package com.baeldung.reactive.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@AllArgsConstructor
+@Data
+public class Foo {
+
+ private long id;
+ private String name;
+
+}
diff --git a/spring-5-reactive-client/src/main/resources/application.properties b/spring-5-reactive-client/src/main/resources/application.properties
new file mode 100644
index 0000000000..2d93456aeb
--- /dev/null
+++ b/spring-5-reactive-client/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+logging.level.root=INFO
+
+server.port=8081
\ No newline at end of file
diff --git a/spring-5-reactive-client/src/main/resources/logback.xml b/spring-5-reactive-client/src/main/resources/logback.xml
new file mode 100644
index 0000000000..8bbe8c1d67
--- /dev/null
+++ b/spring-5-reactive-client/src/main/resources/logback.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ # Pattern of log message for console appender
+ %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-5-reactive-client/src/main/webapp/WEB-INF/web.xml b/spring-5-reactive-client/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..bfcf43dad2
--- /dev/null
+++ b/spring-5-reactive-client/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,21 @@
+
+
+
+ Spring Functional Application
+
+
+ functional
+ com.baeldung.functional.RootServlet
+ 1
+ true
+
+
+ functional
+ /
+
+
+
+
\ No newline at end of file
diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java
new file mode 100644
index 0000000000..394ff42e5f
--- /dev/null
+++ b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java
@@ -0,0 +1,42 @@
+package com.baeldung.reactive;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.WebClient;
+
+import com.baeldung.reactive.model.Foo;
+
+import reactor.core.publisher.Mono;
+
+@SpringBootTest
+public class ReactiveIntegrationTest {
+
+ private WebClient client;
+
+ @BeforeEach
+ public void before() {
+ client = WebClient.create("http://localhost:8080");
+ }
+
+ //
+
+ @Test
+ public void whenMonoReactiveEndpointIsConsumed_thenCorrectOutput() {
+ final Mono fooMono = client.get().uri("/foos/123").exchange().log();
+
+ System.out.println(fooMono.subscribe());
+ }
+
+ @Test
+ public void whenFluxReactiveEndpointIsConsumed_thenCorrectOutput() throws InterruptedException {
+ client.get().uri("/foos")
+ .retrieve()
+ .bodyToFlux(Foo.class).log()
+ .subscribe(System.out::println);
+
+ System.out.println();
+ }
+
+}
diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java
new file mode 100644
index 0000000000..c884ace323
--- /dev/null
+++ b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java
@@ -0,0 +1,35 @@
+package com.baeldung.reactive;
+
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.reactive.function.client.WebClient;
+
+import com.baeldung.reactive.model.Foo;
+
+@SpringBootApplication
+public class Spring5ReactiveTestApplication {
+
+ @Bean
+ public WebClient client() {
+ return WebClient.create("http://localhost:8080");
+ }
+
+ @Bean
+ CommandLineRunner cmd(WebClient client) {
+ return args -> {
+ client.get().uri("/foos2")
+ .retrieve()
+ .bodyToFlux(Foo.class).log()
+ .subscribe(System.out::println);
+ };
+ }
+
+ //
+
+ public static void main(String[] args) {
+ SpringApplication.run(Spring5ReactiveTestApplication.class, args);
+ }
+
+}
diff --git a/spring-5-reactive-client/src/test/resources/logback-test.xml b/spring-5-reactive-client/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..8bbe8c1d67
--- /dev/null
+++ b/spring-5-reactive-client/src/test/resources/logback-test.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ # Pattern of log message for console appender
+ %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-5-reactive/.gitignore b/spring-5-reactive/.gitignore
new file mode 100644
index 0000000000..dec013dfa4
--- /dev/null
+++ b/spring-5-reactive/.gitignore
@@ -0,0 +1,12 @@
+#folders#
+.idea
+/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/spring-5-reactive/README.md b/spring-5-reactive/README.md
new file mode 100644
index 0000000000..400e343263
--- /dev/null
+++ b/spring-5-reactive/README.md
@@ -0,0 +1,15 @@
+## Spring REST Example Project
+
+### The Course
+The "REST With Spring" Classes: http://bit.ly/restwithspring
+
+### Relevant Articles
+
+- [Concurrent Test Execution in Spring 5](http://www.baeldung.com/spring-5-concurrent-tests)
+- [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web)
+- [Exploring the Spring 5 MVC URL Matching Improvements](http://www.baeldung.com/spring-5-mvc-url-matching)
+- [Spring 5 WebClient](http://www.baeldung.com/spring-5-webclient)
+- [Spring 5 Functional Bean Registration](http://www.baeldung.com/spring-5-functional-beans)
+- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](http://www.baeldung.com/spring-5-junit-config)
+- [Spring Security 5 for Reactive Applications](http://www.baeldung.com/spring-security-5-reactive)
+- [Spring 5 Testing with @EnabledIf Annotation](https://github.com/eugenp/tutorials/tree/master/spring-5)
diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml
new file mode 100644
index 0000000000..c1c18fbc82
--- /dev/null
+++ b/spring-5-reactive/pom.xml
@@ -0,0 +1,201 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ spring-5-reactive
+ 0.0.1-SNAPSHOT
+ jar
+
+ spring-5
+ spring 5 sample project about new features
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.M7
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+ org.projectreactor
+ reactor-spring
+ ${reactor-spring.version}
+
+
+ javax.json.bind
+ javax.json.bind-api
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.geronimo.specs
+ geronimo-json_1.1_spec
+ ${geronimo-json_1.1_spec.version}
+
+
+ org.apache.johnzon
+ johnzon-jsonb
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework
+ spring-test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.apache.commons
+ commons-collections4
+ 4.1
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-runner
+ ${junit.platform.version}
+ test
+
+
+
+ org.projectlombok
+ lombok
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ com.baeldung.Spring5Application
+ JAR
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ 3
+ true
+ methods
+ true
+
+ **/*IntegrationTest.java
+ **/*LiveTest.java
+
+
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.0.0
+ 5.0.0
+ 2.20
+ 5.0.1.RELEASE
+ 1.0.1.RELEASE
+ 1.1.3
+ 1.0
+ 1.0
+
+
+
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java
new file mode 100644
index 0000000000..a9308124fa
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java
@@ -0,0 +1,13 @@
+package com.baeldung.reactive;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Spring5ReactiveApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Spring5ReactiveApplication.class, args);
+ }
+
+}
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java
new file mode 100644
index 0000000000..933d469f65
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java
@@ -0,0 +1,46 @@
+package com.baeldung.reactive.controller;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+
+import java.time.Duration;
+import java.util.Random;
+import java.util.stream.Stream;
+
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baeldung.reactive.model.Foo;
+
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+import reactor.util.function.Tuple2;
+
+@RestController
+public class FooReactiveController {
+
+ @GetMapping("/foos/{id}")
+ public Mono getFoo(@PathVariable("id") long id) {
+ return Mono.just(new Foo(id, randomAlphabetic(6)));
+ }
+
+ @GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE, value = "/foos")
+ public Flux getAllFoos2() {
+ final Flux foosFlux = Flux.fromStream(Stream.generate(() -> new Foo(new Random().nextLong(), randomAlphabetic(6))));
+ final Flux emmitFlux = Flux.interval(Duration.ofSeconds(1));
+ return Flux.zip(foosFlux, emmitFlux).map(Tuple2::getT1);
+ }
+
+ @GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE, value = "/foos2")
+ public Flux getAllFoos() {
+ final Flux flux = Flux. create(fluxSink -> {
+ while (true) {
+ fluxSink.next(new Foo(new Random().nextLong(), randomAlphabetic(6)));
+ }
+ }).sample(Duration.ofSeconds(1)).log();
+
+ return flux;
+ }
+
+}
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Foo.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Foo.java
new file mode 100644
index 0000000000..2c49e6146a
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Foo.java
@@ -0,0 +1,13 @@
+package com.baeldung.reactive.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@AllArgsConstructor
+@Data
+public class Foo {
+
+ private long id;
+ private String name;
+
+}
diff --git a/spring-5-reactive/src/main/resources/application.properties b/spring-5-reactive/src/main/resources/application.properties
new file mode 100644
index 0000000000..4b49e8e8a2
--- /dev/null
+++ b/spring-5-reactive/src/main/resources/application.properties
@@ -0,0 +1 @@
+logging.level.root=INFO
\ No newline at end of file
diff --git a/spring-5-reactive/src/main/webapp/WEB-INF/web.xml b/spring-5-reactive/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..bfcf43dad2
--- /dev/null
+++ b/spring-5-reactive/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,21 @@
+
+
+
+ Spring Functional Application
+
+
+ functional
+ com.baeldung.functional.RootServlet
+ 1
+ true
+
+
+ functional
+ /
+
+
+
+
\ No newline at end of file
diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java
new file mode 100644
index 0000000000..bad5fc5f22
--- /dev/null
+++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java
@@ -0,0 +1,30 @@
+package com.baeldung.reactive;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.junit.Assert.assertNotNull;
+
+import java.time.Duration;
+import java.util.Random;
+
+import org.junit.jupiter.api.Test;
+
+import com.baeldung.reactive.model.Foo;
+
+import reactor.core.publisher.Flux;
+
+public class FluxUnitTest {
+
+ @Test
+ public void whenFluxIsConstructed_thenCorrect() {
+ final Flux flux = Flux. create(fluxSink -> {
+ while (true) {
+ fluxSink.next(new Foo(new Random().nextLong(), randomAlphabetic(6)));
+ }
+ }).sample(Duration.ofSeconds(1)).log();
+
+ flux.subscribe();
+
+ assertNotNull(flux);
+ }
+
+}
diff --git a/spring-5/src/main/java/com/baeldung/web/PathPatternController.java b/spring-5/src/main/java/com/baeldung/web/PathPatternController.java
index 15b689257a..6fd972f2a4 100644
--- a/spring-5/src/main/java/com/baeldung/web/PathPatternController.java
+++ b/spring-5/src/main/java/com/baeldung/web/PathPatternController.java
@@ -2,7 +2,6 @@ package com.baeldung.web;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
diff --git a/spring-acl/pom.xml b/spring-acl/pom.xml
deleted file mode 100644
index 3bcc0cf596..0000000000
--- a/spring-acl/pom.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
- 4.0.0
-
- com.baeldung
- spring-acl
- 0.0.1-SNAPSHOT
- war
-
- spring-acl
- Spring ACL
-
-
- parent-boot-5
- com.baeldung
- 0.0.1-SNAPSHOT
- ../parent-boot-5
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
-
- com.h2database
- h2
-
-
-
- org.springframework
- spring-test
- test
-
-
-
- org.springframework.security
- spring-security-test
- test
-
-
-
- org.springframework.security
- spring-security-acl
-
-
- org.springframework.security
- spring-security-config
-
-
- org.springframework
- spring-context-support
-
-
- net.sf.ehcache
- ehcache-core
- 2.6.11
- jar
-
-
-
-
-
diff --git a/spring-acl/src/main/java/org/baeldung/acl/config/ACLContext.java b/spring-acl/src/main/java/org/baeldung/acl/config/ACLContext.java
deleted file mode 100644
index 63a4ea58ef..0000000000
--- a/spring-acl/src/main/java/org/baeldung/acl/config/ACLContext.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.baeldung.acl.config;
-
-import javax.sql.DataSource;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.cache.ehcache.EhCacheFactoryBean;
-import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
-import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
-import org.springframework.security.acls.AclPermissionCacheOptimizer;
-import org.springframework.security.acls.AclPermissionEvaluator;
-import org.springframework.security.acls.domain.AclAuthorizationStrategy;
-import org.springframework.security.acls.domain.AclAuthorizationStrategyImpl;
-import org.springframework.security.acls.domain.ConsoleAuditLogger;
-import org.springframework.security.acls.domain.DefaultPermissionGrantingStrategy;
-import org.springframework.security.acls.domain.EhCacheBasedAclCache;
-import org.springframework.security.acls.jdbc.BasicLookupStrategy;
-import org.springframework.security.acls.jdbc.JdbcMutableAclService;
-import org.springframework.security.acls.jdbc.LookupStrategy;
-import org.springframework.security.acls.model.PermissionGrantingStrategy;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-
-@Configuration
-@EnableAutoConfiguration
-public class ACLContext {
-
- @Autowired
- DataSource dataSource;
-
- @Bean
- public EhCacheBasedAclCache aclCache() {
- return new EhCacheBasedAclCache(aclEhCacheFactoryBean().getObject(), permissionGrantingStrategy(), aclAuthorizationStrategy());
- }
-
- @Bean
- public EhCacheFactoryBean aclEhCacheFactoryBean() {
- EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
- ehCacheFactoryBean.setCacheManager(aclCacheManager().getObject());
- ehCacheFactoryBean.setCacheName("aclCache");
- return ehCacheFactoryBean;
- }
-
- @Bean
- public EhCacheManagerFactoryBean aclCacheManager() {
- return new EhCacheManagerFactoryBean();
- }
-
- @Bean
- public PermissionGrantingStrategy permissionGrantingStrategy() {
- return new DefaultPermissionGrantingStrategy(new ConsoleAuditLogger());
- }
-
- @Bean
- public AclAuthorizationStrategy aclAuthorizationStrategy() {
- return new AclAuthorizationStrategyImpl(new SimpleGrantedAuthority("ROLE_ADMIN"));
- }
-
- @Bean
- public MethodSecurityExpressionHandler defaultMethodSecurityExpressionHandler() {
- DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
- AclPermissionEvaluator permissionEvaluator = new AclPermissionEvaluator(aclService());
- expressionHandler.setPermissionEvaluator(permissionEvaluator);
- expressionHandler.setPermissionCacheOptimizer(new AclPermissionCacheOptimizer(aclService()));
- return expressionHandler;
- }
-
- @Bean
- public LookupStrategy lookupStrategy() {
- return new BasicLookupStrategy(dataSource, aclCache(), aclAuthorizationStrategy(), new ConsoleAuditLogger());
- }
-
- @Bean
- public JdbcMutableAclService aclService() {
- return new JdbcMutableAclService(dataSource, lookupStrategy(), aclCache());
- }
-
-}
\ No newline at end of file
diff --git a/spring-acl/src/main/java/org/baeldung/acl/config/AclMethodSecurityConfiguration.java b/spring-acl/src/main/java/org/baeldung/acl/config/AclMethodSecurityConfiguration.java
deleted file mode 100644
index 110c4a6d24..0000000000
--- a/spring-acl/src/main/java/org/baeldung/acl/config/AclMethodSecurityConfiguration.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.baeldung.acl.config;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
-
-@Configuration
-@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
-public class AclMethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {
-
- @Autowired
- MethodSecurityExpressionHandler defaultMethodSecurityExpressionHandler;
-
- @Override
- protected MethodSecurityExpressionHandler createExpressionHandler() {
- return defaultMethodSecurityExpressionHandler;
- }
-
-}
diff --git a/spring-acl/src/main/java/org/baeldung/acl/config/JPAPersistenceConfig.java b/spring-acl/src/main/java/org/baeldung/acl/config/JPAPersistenceConfig.java
deleted file mode 100644
index 9b87efa92c..0000000000
--- a/spring-acl/src/main/java/org/baeldung/acl/config/JPAPersistenceConfig.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.baeldung.acl.config;
-
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@Configuration
-@EnableTransactionManagement
-@EnableJpaRepositories(basePackages = "org.baeldung.acl.persistence.dao")
-@PropertySource("classpath:org.baeldung.acl.datasource.properties")
-@EntityScan(basePackages={ "org.baeldung.acl.persistence.entity" })
-public class JPAPersistenceConfig {
-
-}
diff --git a/spring-acl/src/main/java/org/baeldung/acl/persistence/dao/NoticeMessageRepository.java b/spring-acl/src/main/java/org/baeldung/acl/persistence/dao/NoticeMessageRepository.java
deleted file mode 100644
index 8662c88d6c..0000000000
--- a/spring-acl/src/main/java/org/baeldung/acl/persistence/dao/NoticeMessageRepository.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.baeldung.acl.persistence.dao;
-
-import java.util.List;
-
-import org.baeldung.acl.persistence.entity.NoticeMessage;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.security.access.prepost.PostAuthorize;
-import org.springframework.security.access.prepost.PostFilter;
-import org.springframework.security.access.prepost.PreAuthorize;
-
-public interface NoticeMessageRepository extends JpaRepository{
-
- @PostFilter("hasPermission(filterObject, 'READ')")
- List findAll();
-
- @PostAuthorize("hasPermission(returnObject, 'READ')")
- NoticeMessage findById(Integer id);
-
- @SuppressWarnings("unchecked")
- @PreAuthorize("hasPermission(#noticeMessage, 'WRITE')")
- NoticeMessage save(@Param("noticeMessage")NoticeMessage noticeMessage);
-
-}
diff --git a/spring-acl/src/main/java/org/baeldung/acl/persistence/entity/NoticeMessage.java b/spring-acl/src/main/java/org/baeldung/acl/persistence/entity/NoticeMessage.java
deleted file mode 100644
index 23f01a8edb..0000000000
--- a/spring-acl/src/main/java/org/baeldung/acl/persistence/entity/NoticeMessage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.baeldung.acl.persistence.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="system_message")
-public class NoticeMessage {
-
- @Id
- @Column
- private Integer id;
- @Column
- private String content;
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public String getContent() {
- return content;
- }
- public void setContent(String content) {
- this.content = content;
- }
-}
\ No newline at end of file
diff --git a/spring-acl/src/main/resources/acl-data.sql b/spring-acl/src/main/resources/acl-data.sql
deleted file mode 100644
index 6c01eaacc2..0000000000
--- a/spring-acl/src/main/resources/acl-data.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-INSERT INTO system_message(id,content) VALUES (1,'First Level Message');
-INSERT INTO system_message(id,content) VALUES (2,'Second Level Message');
-INSERT INTO system_message(id,content) VALUES (3,'Third Level Message');
-
-INSERT INTO acl_class (id, class) VALUES
-(1, 'org.baeldung.acl.persistence.entity.NoticeMessage');
-
-INSERT INTO acl_sid (id, principal, sid) VALUES
-(1, 1, 'manager'),
-(2, 1, 'hr'),
-(3, 1, 'admin'),
-(4, 0, 'ROLE_EDITOR');
-
-INSERT INTO acl_object_identity (id, object_id_class, object_id_identity, parent_object, owner_sid, entries_inheriting) VALUES
-(1, 1, 1, NULL, 3, 0),
-(2, 1, 2, NULL, 3, 0),
-(3, 1, 3, NULL, 3, 0)
-;
-
-INSERT INTO acl_entry (id, acl_object_identity, ace_order, sid, mask, granting, audit_success, audit_failure) VALUES
-(1, 1, 1, 1, 1, 1, 1, 1),
-(2, 1, 2, 1, 2, 1, 1, 1),
-(3, 1, 3, 4, 1, 1, 1, 1),
-(4, 2, 1, 2, 1, 1, 1, 1),
-(5, 2, 2, 4, 1, 1, 1, 1),
-(6, 3, 1, 4, 1, 1, 1, 1),
-(7, 3, 2, 4, 2, 1, 1, 1)
-;
\ No newline at end of file
diff --git a/spring-acl/src/main/resources/acl-schema.sql b/spring-acl/src/main/resources/acl-schema.sql
deleted file mode 100644
index 58e9394b2b..0000000000
--- a/spring-acl/src/main/resources/acl-schema.sql
+++ /dev/null
@@ -1,58 +0,0 @@
-create table system_message (id integer not null, content varchar(255), primary key (id));
-
-CREATE TABLE IF NOT EXISTS acl_sid (
- id bigint(20) NOT NULL AUTO_INCREMENT,
- principal tinyint(1) NOT NULL,
- sid varchar(100) NOT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY unique_uk_1 (sid,principal)
-);
-
-CREATE TABLE IF NOT EXISTS acl_class (
- id bigint(20) NOT NULL AUTO_INCREMENT,
- class varchar(255) NOT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY unique_uk_2 (class)
-);
-
-CREATE TABLE IF NOT EXISTS acl_entry (
- id bigint(20) NOT NULL AUTO_INCREMENT,
- acl_object_identity bigint(20) NOT NULL,
- ace_order int(11) NOT NULL,
- sid bigint(20) NOT NULL,
- mask int(11) NOT NULL,
- granting tinyint(1) NOT NULL,
- audit_success tinyint(1) NOT NULL,
- audit_failure tinyint(1) NOT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY unique_uk_4 (acl_object_identity,ace_order)
-);
-
-CREATE TABLE IF NOT EXISTS acl_object_identity (
- id bigint(20) NOT NULL AUTO_INCREMENT,
- object_id_class bigint(20) NOT NULL,
- object_id_identity bigint(20) NOT NULL,
- parent_object bigint(20) DEFAULT NULL,
- owner_sid bigint(20) DEFAULT NULL,
- entries_inheriting tinyint(1) NOT NULL,
- PRIMARY KEY (id),
- UNIQUE KEY unique_uk_3 (object_id_class,object_id_identity)
-);
-
-ALTER TABLE acl_entry
-ADD FOREIGN KEY (acl_object_identity) REFERENCES acl_object_identity(id);
-
-ALTER TABLE acl_entry
-ADD FOREIGN KEY (sid) REFERENCES acl_sid(id);
-
---
--- Constraints for table acl_object_identity
---
-ALTER TABLE acl_object_identity
-ADD FOREIGN KEY (parent_object) REFERENCES acl_object_identity (id);
-
-ALTER TABLE acl_object_identity
-ADD FOREIGN KEY (object_id_class) REFERENCES acl_class (id);
-
-ALTER TABLE acl_object_identity
-ADD FOREIGN KEY (owner_sid) REFERENCES acl_sid (id);
\ No newline at end of file
diff --git a/spring-acl/src/main/resources/org.baeldung.acl.datasource.properties b/spring-acl/src/main/resources/org.baeldung.acl.datasource.properties
deleted file mode 100644
index 739dd3f07c..0000000000
--- a/spring-acl/src/main/resources/org.baeldung.acl.datasource.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
-spring.datasource.username=sa
-spring.datasource.password=
-spring.datasource.driverClassName=org.h2.Driver
-spring.jpa.hibernate.ddl-auto=update
-spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
-
-spring.h2.console.path=/myconsole
-spring.h2.console.enabled=true
-spring.datasource.initialize=true
-spring.datasource.schema=classpath:acl-schema.sql
-spring.datasource.data=classpath:acl-data.sql
\ No newline at end of file
diff --git a/spring-acl/src/test/java/org/baeldung/acl/SpringAclTest.java b/spring-acl/src/test/java/org/baeldung/acl/SpringAclTest.java
deleted file mode 100644
index fd9069d9bc..0000000000
--- a/spring-acl/src/test/java/org/baeldung/acl/SpringAclTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.baeldung.acl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.baeldung.acl.persistence.dao.NoticeMessageRepository;
-import org.baeldung.acl.persistence.entity.NoticeMessage;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.access.AccessDeniedException;
-import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestExecutionListeners;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
-import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
-import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
-import org.springframework.test.context.web.ServletTestExecutionListener;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration
-@TestExecutionListeners(listeners={ServletTestExecutionListener.class,
- DependencyInjectionTestExecutionListener.class,
- DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class,
- WithSecurityContextTestExecutionListener.class})
-public class SpringAclTest extends AbstractJUnit4SpringContextTests{
-
- private static Integer FIRST_MESSAGE_ID = 1;
- private static Integer SECOND_MESSAGE_ID = 2;
- private static Integer THIRD_MESSAGE_ID = 3;
- private static String EDITTED_CONTENT = "EDITED";
-
- @Configuration
- @ComponentScan("org.baeldung.acl.*")
- public static class SpringConfig {
-
- }
-
- @Autowired
- NoticeMessageRepository repo;
-
- @Test
- @WithMockUser(username="manager")
- public void givenUsernameManager_whenFindAllMessage_thenReturnFirstMessage(){
- List details = repo.findAll();
- assertNotNull(details);
- assertEquals(1,details.size());
- assertEquals(FIRST_MESSAGE_ID,details.get(0).getId());
- }
-
- @Test
- @WithMockUser(username="manager")
- public void givenUsernameManager_whenFindFirstMessageByIdAndUpdateFirstMessageContent_thenOK(){
- NoticeMessage firstMessage = repo.findById(FIRST_MESSAGE_ID);
- assertNotNull(firstMessage);
- assertEquals(FIRST_MESSAGE_ID,firstMessage.getId());
-
- firstMessage.setContent(EDITTED_CONTENT);
- repo.save(firstMessage);
-
- NoticeMessage editedFirstMessage = repo.findById(FIRST_MESSAGE_ID);
- assertNotNull(editedFirstMessage);
- assertEquals(FIRST_MESSAGE_ID,editedFirstMessage.getId());
- assertEquals(EDITTED_CONTENT,editedFirstMessage.getContent());
- }
-
- @Test
- @WithMockUser(username="hr")
- public void givenUsernameHr_whenFindMessageById2_thenOK(){
- NoticeMessage secondMessage = repo.findById(SECOND_MESSAGE_ID);
- assertNotNull(secondMessage);
- assertEquals(SECOND_MESSAGE_ID,secondMessage.getId());
- }
-
- @Test(expected=AccessDeniedException.class)
- @WithMockUser(username="hr")
- public void givenUsernameHr_whenUpdateMessageWithId2_thenFail(){
- NoticeMessage secondMessage = new NoticeMessage();
- secondMessage.setId(SECOND_MESSAGE_ID);
- secondMessage.setContent(EDITTED_CONTENT);
- repo.save(secondMessage);
- }
-
- @Test
- @WithMockUser(roles={"EDITOR"})
- public void givenRoleEditor_whenFindAllMessage_thenReturnThreeMessage(){
- List details = repo.findAll();
- assertNotNull(details);
- assertEquals(3,details.size());
- }
-
- @Test
- @WithMockUser(roles={"EDITOR"})
- public void givenRoleEditor_whenUpdateThirdMessage_thenOK(){
- NoticeMessage thirdMessage = new NoticeMessage();
- thirdMessage.setId(THIRD_MESSAGE_ID);
- thirdMessage.setContent(EDITTED_CONTENT);
- repo.save(thirdMessage);
- }
-
- @Test(expected=AccessDeniedException.class)
- @WithMockUser(roles={"EDITOR"})
- public void givenRoleEditor_whenFindFirstMessageByIdAndUpdateFirstMessageContent_thenFail(){
- NoticeMessage firstMessage = repo.findById(FIRST_MESSAGE_ID);
- assertNotNull(firstMessage);
- assertEquals(FIRST_MESSAGE_ID,firstMessage.getId());
- firstMessage.setContent(EDITTED_CONTENT);
- repo.save(firstMessage);
- }
-}
-
\ No newline at end of file
diff --git a/spring-security-acl/pom.xml b/spring-security-acl/pom.xml
index 67197bc2f8..a19a54dd88 100644
--- a/spring-security-acl/pom.xml
+++ b/spring-security-acl/pom.xml
@@ -3,7 +3,6 @@
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-security-acl
0.0.1-SNAPSHOT
war
diff --git a/spring-security-acl/src/main/java/org/baeldung/acl/Application.java b/spring-security-acl/src/main/java/org/baeldung/acl/Application.java
new file mode 100644
index 0000000000..665ca64076
--- /dev/null
+++ b/spring-security-acl/src/main/java/org/baeldung/acl/Application.java
@@ -0,0 +1,11 @@
+package org.baeldung.acl;
+
+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-acl/src/test/java/org/baeldung/acl/SpringAclTest.java b/spring-security-acl/src/test/java/org/baeldung/acl/SpringACLIntegrationTest.java
similarity index 98%
rename from spring-security-acl/src/test/java/org/baeldung/acl/SpringAclTest.java
rename to spring-security-acl/src/test/java/org/baeldung/acl/SpringACLIntegrationTest.java
index b864639d74..1460d4f47b 100644
--- a/spring-security-acl/src/test/java/org/baeldung/acl/SpringAclTest.java
+++ b/spring-security-acl/src/test/java/org/baeldung/acl/SpringACLIntegrationTest.java
@@ -31,7 +31,7 @@ import org.springframework.test.context.web.ServletTestExecutionListener;
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class,
WithSecurityContextTestExecutionListener.class})
-public class SpringAclTest extends AbstractJUnit4SpringContextTests{
+public class SpringACLIntegrationTest extends AbstractJUnit4SpringContextTests{
private static Integer FIRST_MESSAGE_ID = 1;
private static Integer SECOND_MESSAGE_ID = 2;