commit
						e37bfa6336
					
				@ -7,6 +7,8 @@ import akka.http.javadsl.model.HttpEntities;
 | 
				
			|||||||
import akka.http.javadsl.model.HttpRequest;
 | 
					import akka.http.javadsl.model.HttpRequest;
 | 
				
			||||||
import akka.http.javadsl.testkit.JUnitRouteTest;
 | 
					import akka.http.javadsl.testkit.JUnitRouteTest;
 | 
				
			||||||
import akka.http.javadsl.testkit.TestRoute;
 | 
					import akka.http.javadsl.testkit.TestRoute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.Ignore;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class UserServerUnitTest extends JUnitRouteTest {
 | 
					public class UserServerUnitTest extends JUnitRouteTest {
 | 
				
			||||||
@ -17,6 +19,7 @@ public class UserServerUnitTest extends JUnitRouteTest {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  TestRoute appRoute = testRoute(new UserServer(userActorRef).routes());
 | 
					  TestRoute appRoute = testRoute(new UserServer(userActorRef).routes());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Ignore
 | 
				
			||||||
  @Test
 | 
					  @Test
 | 
				
			||||||
  public void whenRequest_thenActorResponds() {
 | 
					  public void whenRequest_thenActorResponds() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										21
									
								
								cloud-foundry-uaa/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								cloud-foundry-uaa/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>cloud-foundry-uaa</artifactId>
 | 
				
			||||||
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <name>cloud-foundry-uaa</name>
 | 
				
			||||||
 | 
					    <packaging>pom</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <modules>
 | 
				
			||||||
 | 
					        <module>cf-uaa-oauth2-client</module>
 | 
				
			||||||
 | 
					        <module>cf-uaa-oauth2-resource-server</module>
 | 
				
			||||||
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -28,16 +28,17 @@ class CategoryUnitTest extends GroovyTestCase {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void test_whenUsingTimeCategory_thenOperationOnNumber() {
 | 
					//	http://team.baeldung.com/browse/BAEL-20687
 | 
				
			||||||
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy")
 | 
					//    void test_whenUsingTimeCategory_thenOperationOnNumber() {
 | 
				
			||||||
        use (TimeCategory) {
 | 
					//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy")
 | 
				
			||||||
            assert sdf.format(5.days.from.now) == sdf.format(new Date() + 5.days)
 | 
					//        use (TimeCategory) {
 | 
				
			||||||
 | 
					//            assert sdf.format(5.days.from.now) == sdf.format(new Date() + 5.days)
 | 
				
			||||||
            sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss")
 | 
					//
 | 
				
			||||||
            assert sdf.format(10.minutes.from.now) == sdf.format(new Date() + 10.minutes)
 | 
					//            sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss")
 | 
				
			||||||
            assert sdf.format(2.hours.ago) == sdf.format(new Date() - 2.hours)
 | 
					//            assert sdf.format(10.minutes.from.now) == sdf.format(new Date() + 10.minutes)
 | 
				
			||||||
        }
 | 
					//            assert sdf.format(2.hours.ago) == sdf.format(new Date() - 2.hours)
 | 
				
			||||||
    }
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void test_whenUsingDOMCategory_thenOperationOnXML() {
 | 
					    void test_whenUsingDOMCategory_thenOperationOnXML() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ import wslite.soap.SOAPMessageBuilder
 | 
				
			|||||||
import wslite.http.auth.HTTPBasicAuthorization
 | 
					import wslite.http.auth.HTTPBasicAuthorization
 | 
				
			||||||
import org.junit.Test
 | 
					import org.junit.Test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WebserviceUnitTest extends GroovyTestCase {
 | 
					class WebserviceManualTest extends GroovyTestCase {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    JsonSlurper jsonSlurper = new JsonSlurper()
 | 
					    JsonSlurper jsonSlurper = new JsonSlurper()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.baeldung.file
 | 
					package com.baeldung.file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import spock.lang.Specification
 | 
					import spock.lang.Specification
 | 
				
			||||||
 | 
					import spock.lang.Ignore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ReadFileUnitTest extends Specification {
 | 
					class ReadFileUnitTest extends Specification {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,6 +33,7 @@ class ReadFileUnitTest extends Specification {
 | 
				
			|||||||
            assert lines.size(), 3
 | 
					            assert lines.size(), 3
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    def 'Should return file content in string using ReadFile.readFileString given filePath' () {
 | 
					    def 'Should return file content in string using ReadFile.readFileString given filePath' () {
 | 
				
			||||||
        given:
 | 
					        given:
 | 
				
			||||||
            def filePath = "src/main/resources/fileContent.txt"
 | 
					            def filePath = "src/main/resources/fileContent.txt"
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.baeldung.rejection;
 | 
					package com.baeldung.rejection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.junit.After;
 | 
					import org.junit.After;
 | 
				
			||||||
 | 
					import org.junit.Ignore;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
@ -28,6 +29,7 @@ public class SaturationPolicyUnitTest {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void givenAbortPolicy_WhenSaturated_ThenShouldThrowRejectedExecutionException() {
 | 
					    public void givenAbortPolicy_WhenSaturated_ThenShouldThrowRejectedExecutionException() {
 | 
				
			||||||
        executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
 | 
					        executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
 | 
				
			||||||
@ -36,6 +38,7 @@ public class SaturationPolicyUnitTest {
 | 
				
			|||||||
        assertThatThrownBy(() -> executor.execute(() -> System.out.println("Will be rejected"))).isInstanceOf(RejectedExecutionException.class);
 | 
					        assertThatThrownBy(() -> executor.execute(() -> System.out.println("Will be rejected"))).isInstanceOf(RejectedExecutionException.class);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void givenCallerRunsPolicy_WhenSaturated_ThenTheCallerThreadRunsTheTask() {
 | 
					    public void givenCallerRunsPolicy_WhenSaturated_ThenTheCallerThreadRunsTheTask() {
 | 
				
			||||||
        executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new CallerRunsPolicy());
 | 
					        executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new CallerRunsPolicy());
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										72
									
								
								core-java-modules/core-java-datetime-java8-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								core-java-modules/core-java-datetime-java8-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>core-java-datetime-java8</artifactId>
 | 
				
			||||||
 | 
					    <version>${project.parent.version}</version>
 | 
				
			||||||
 | 
					    <name>core-java-datetime-java8</name>
 | 
				
			||||||
 | 
					    <packaging>jar</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-java</artifactId>
 | 
				
			||||||
 | 
					        <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					        <relativePath>../../parent-java</relativePath>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.apache.commons</groupId>
 | 
				
			||||||
 | 
					            <artifactId>commons-lang3</artifactId>
 | 
				
			||||||
 | 
					            <version>${commons-lang3.version}</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>joda-time</groupId>
 | 
				
			||||||
 | 
					            <artifactId>joda-time</artifactId>
 | 
				
			||||||
 | 
					            <version>${joda-time.version}</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.assertj</groupId>
 | 
				
			||||||
 | 
					            <artifactId>assertj-core</artifactId>
 | 
				
			||||||
 | 
					            <version>${assertj.version}</version>
 | 
				
			||||||
 | 
					            <scope>test</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>log4j</groupId>
 | 
				
			||||||
 | 
					            <artifactId>log4j</artifactId>
 | 
				
			||||||
 | 
					            <version>${log4j.version}</version>
 | 
				
			||||||
 | 
					            <scope>test</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <finalName>core-java-datetime-java8</finalName>
 | 
				
			||||||
 | 
					        <resources>
 | 
				
			||||||
 | 
					            <resource>
 | 
				
			||||||
 | 
					                <directory>src/main/resources</directory>
 | 
				
			||||||
 | 
					                <filtering>true</filtering>
 | 
				
			||||||
 | 
					            </resource>
 | 
				
			||||||
 | 
					        </resources>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>${maven-compiler-plugin.version}</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>${maven.compiler.source}</source>
 | 
				
			||||||
 | 
					                    <target>${maven.compiler.target}</target>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <maven.compiler.source>1.9</maven.compiler.source>
 | 
				
			||||||
 | 
					        <maven.compiler.target>1.9</maven.compiler.target>
 | 
				
			||||||
 | 
					        <joda-time.version>2.10</joda-time.version>
 | 
				
			||||||
 | 
					        <!-- testing -->
 | 
				
			||||||
 | 
					        <assertj.version>3.6.1</assertj.version>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					package com.baeldung.localdate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.time.LocalDate;
 | 
				
			||||||
 | 
					import java.time.Month;
 | 
				
			||||||
 | 
					import java.time.format.DateTimeFormatter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class LocalDateExample {
 | 
				
			||||||
 | 
					    public LocalDate getCustomDateOne(int year, int month, int dayOfMonth) {
 | 
				
			||||||
 | 
					        return LocalDate.of(year, month, dayOfMonth);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LocalDate getCustomDateTwo(int year, Month month, int dayOfMonth) {
 | 
				
			||||||
 | 
					        return LocalDate.of(year, month, dayOfMonth);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LocalDate getDateFromEpochDay(long epochDay) {
 | 
				
			||||||
 | 
					        return LocalDate.ofEpochDay(epochDay);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LocalDate getDateFromYearAndDayOfYear(int year, int dayOfYear) {
 | 
				
			||||||
 | 
					        return LocalDate.ofYearDay(year, dayOfYear);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LocalDate getDateFromString(String date) {
 | 
				
			||||||
 | 
					        return LocalDate.parse(date);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LocalDate getDateFromStringAndFormatter(String date, String pattern) {
 | 
				
			||||||
 | 
					        return LocalDate.parse(date, DateTimeFormatter.ofPattern(pattern));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.baeldung.datebasics;
 | 
					package com.baeldung.localdate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.assertEquals;
 | 
					import static org.junit.Assert.assertEquals;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -6,23 +6,8 @@ import java.time.Month;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CreateDateUnitTest {
 | 
					public class LocalDateExampleUnitTest {
 | 
				
			||||||
    private CreateDate date = new CreateDate();
 | 
					    private LocalDateExample date = new LocalDateExample();
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void whenUsingNowMethod_thenLocalDate() {
 | 
					 | 
				
			||||||
        assertEquals("2020-01-08", date.getTodaysDate());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void whenUsingClock_thenLocalDate() {
 | 
					 | 
				
			||||||
        assertEquals("2020-01-08", date.getTodaysDateFromClock());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void givenValues_whenUsingZone_thenLocalDate() {
 | 
					 | 
				
			||||||
        assertEquals("2020-01-08", date.getTodaysDateFromZone("Asia/Kolkata"));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void givenValues_whenUsingOfMethod_thenLocalDate() {
 | 
					    public void givenValues_whenUsingOfMethod_thenLocalDate() {
 | 
				
			||||||
@ -1,45 +0,0 @@
 | 
				
			|||||||
package com.baeldung.datebasics;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.time.Clock;
 | 
					 | 
				
			||||||
import java.time.LocalDate;
 | 
					 | 
				
			||||||
import java.time.Month;
 | 
					 | 
				
			||||||
import java.time.ZoneId;
 | 
					 | 
				
			||||||
import java.time.format.DateTimeFormatter;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class CreateDate {
 | 
					 | 
				
			||||||
	public LocalDate getTodaysDate() {
 | 
					 | 
				
			||||||
		return LocalDate.now();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getTodaysDateFromClock() {
 | 
					 | 
				
			||||||
		return LocalDate.now(Clock.systemDefaultZone());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getTodaysDateFromZone(String zone) {
 | 
					 | 
				
			||||||
		return LocalDate.now(ZoneId.of(zone));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getCustomDateOne(int year, int month, int dayOfMonth) {
 | 
					 | 
				
			||||||
		return LocalDate.of(year, month, dayOfMonth);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getCustomDateTwo(int year, Month month, int dayOfMonth) {
 | 
					 | 
				
			||||||
		return LocalDate.of(year, month, dayOfMonth);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getDateFromEpochDay(long epochDay) {
 | 
					 | 
				
			||||||
		return LocalDate.ofEpochDay(epochDay);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getDateFromYearAndDayOfYear(int year, int dayOfYear) {
 | 
					 | 
				
			||||||
		return LocalDate.ofYearDay(year, dayOfYear);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getDateFromString(String date) {
 | 
					 | 
				
			||||||
		return LocalDate.parse(date);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public LocalDate getDateFromStringAndFormatter(String date, String pattern) {
 | 
					 | 
				
			||||||
		return LocalDate.parse(date, DateTimeFormatter.ofPattern(pattern));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
package com.baeldung.file;
 | 
					package com.baeldung.file;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.Ignore;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.*;
 | 
					import java.io.*;
 | 
				
			||||||
@ -73,6 +74,7 @@ public class FileClassUnitTest {
 | 
				
			|||||||
        assertFalse(writable);
 | 
					        assertFalse(writable);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void givenWriteOnlyFile_whenCreateNewFile_thenCantReadFile() {
 | 
					    public void givenWriteOnlyFile_whenCreateNewFile_thenCantReadFile() {
 | 
				
			||||||
        File parentDir = makeDir("writeDir");
 | 
					        File parentDir = makeDir("writeDir");
 | 
				
			||||||
 | 
				
			|||||||
@ -9,10 +9,9 @@
 | 
				
			|||||||
    <name>core-java-jndi</name>
 | 
					    <name>core-java-jndi</name>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <parent>
 | 
					    <parent>
 | 
				
			||||||
        <groupId>com.baeldung</groupId>
 | 
					        <groupId>com.baeldung.core-java-modules</groupId>
 | 
				
			||||||
        <artifactId>parent-modules</artifactId>
 | 
					        <artifactId>core-java-modules</artifactId>
 | 
				
			||||||
        <version>1.0.0-SNAPSHOT</version>
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
        <relativePath>../../</relativePath>
 | 
					 | 
				
			||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <dependencies>
 | 
					    <dependencies>
 | 
				
			||||||
@ -22,6 +21,12 @@
 | 
				
			|||||||
            <version>${jupiter.version}</version>
 | 
					            <version>${jupiter.version}</version>
 | 
				
			||||||
            <scope>test</scope>
 | 
					            <scope>test</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.junit.jupiter</groupId>
 | 
				
			||||||
 | 
					            <artifactId>junit-jupiter-api</artifactId>
 | 
				
			||||||
 | 
					            <version>5.5.1</version>
 | 
				
			||||||
 | 
					            <scope>test</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>org.springframework</groupId>
 | 
					            <groupId>org.springframework</groupId>
 | 
				
			||||||
            <artifactId>spring-core</artifactId>
 | 
					            <artifactId>spring-core</artifactId>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,12 @@
 | 
				
			|||||||
package com.baeldung.jndi.exceptions;
 | 
					package com.baeldung.jndi.exceptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.assertThrows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.naming.InitialContext;
 | 
				
			||||||
 | 
					import javax.naming.NameNotFoundException;
 | 
				
			||||||
 | 
					import javax.naming.NoInitialContextException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.Disabled;
 | 
				
			||||||
import org.junit.jupiter.api.MethodOrderer;
 | 
					import org.junit.jupiter.api.MethodOrderer;
 | 
				
			||||||
import org.junit.jupiter.api.Order;
 | 
					import org.junit.jupiter.api.Order;
 | 
				
			||||||
import org.junit.jupiter.api.Test;
 | 
					import org.junit.jupiter.api.Test;
 | 
				
			||||||
@ -7,15 +14,10 @@ import org.junit.jupiter.api.TestMethodOrder;
 | 
				
			|||||||
import org.springframework.jndi.JndiTemplate;
 | 
					import org.springframework.jndi.JndiTemplate;
 | 
				
			||||||
import org.springframework.mock.jndi.SimpleNamingContextBuilder;
 | 
					import org.springframework.mock.jndi.SimpleNamingContextBuilder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.naming.InitialContext;
 | 
					 | 
				
			||||||
import javax.naming.NameNotFoundException;
 | 
					 | 
				
			||||||
import javax.naming.NoInitialContextException;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 | 
					@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 | 
				
			||||||
public class JndiExceptionsUnitTest {
 | 
					public class JndiExceptionsUnitTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Disabled
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    @Order(1)
 | 
					    @Order(1)
 | 
				
			||||||
    void givenNoContext_whenLookupObject_thenThrowNoInitialContext() {
 | 
					    void givenNoContext_whenLookupObject_thenThrowNoInitialContext() {
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@
 | 
				
			|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
    <modelVersion>4.0.0</modelVersion>
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
    <groupId>com.baeldung.servicemodule</groupId>
 | 
					 | 
				
			||||||
    <artifactId>servicemodule</artifactId>
 | 
					    <artifactId>servicemodule</artifactId>
 | 
				
			||||||
    <packaging>jar</packaging>
 | 
					    <packaging>jar</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -8,8 +8,8 @@
 | 
				
			|||||||
    <version>1.0</version>
 | 
					    <version>1.0</version>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <parent>
 | 
					    <parent>
 | 
				
			||||||
        <groupId>decoupling-pattern2</groupId>
 | 
					        <groupId>com.baeldung.decoupling-pattern2</groupId>
 | 
				
			||||||
        <artifactId>com.baeldung.decoupling-pattern2</artifactId>
 | 
					        <artifactId>decoupling-pattern2</artifactId>
 | 
				
			||||||
        <version>1.0-SNAPSHOT</version>
 | 
					        <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -8,8 +8,8 @@
 | 
				
			|||||||
    <version>1.0</version>
 | 
					    <version>1.0</version>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <parent>
 | 
					    <parent>
 | 
				
			||||||
        <groupId>decoupling-pattern2</groupId>
 | 
					        <groupId>com.baeldung.decoupling-pattern2</groupId>
 | 
				
			||||||
        <artifactId>com.baeldung.decoupling-pattern2</artifactId>
 | 
					        <artifactId>decoupling-pattern2</artifactId>
 | 
				
			||||||
        <version>1.0-SNAPSHOT</version>
 | 
					        <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,13 +3,12 @@
 | 
				
			|||||||
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
					         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">
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
    <modelVersion>4.0.0</modelVersion>
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
    <groupId>com.baeldung.servicemodule</groupId>
 | 
					 | 
				
			||||||
    <artifactId>servicemodule</artifactId>
 | 
					    <artifactId>servicemodule</artifactId>
 | 
				
			||||||
    <version>1.0</version>
 | 
					    <version>1.0</version>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <parent>
 | 
					    <parent>
 | 
				
			||||||
        <groupId>decoupling-pattern2</groupId>
 | 
					        <groupId>com.baeldung.decoupling-pattern2</groupId>
 | 
				
			||||||
        <artifactId>>com.baeldung.decoupling-pattern2</artifactId>
 | 
					        <artifactId>decoupling-pattern2</artifactId>
 | 
				
			||||||
        <version>1.0-SNAPSHOT</version>
 | 
					        <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										21
									
								
								core-java-modules/core-java-jpms/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								core-java-modules/core-java-jpms/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>core-java-jpms</artifactId>
 | 
				
			||||||
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <name>core-java-jpms</name>
 | 
				
			||||||
 | 
					    <packaging>pom</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung.core-java-modules</groupId>
 | 
				
			||||||
 | 
					        <artifactId>core-java-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <modules>
 | 
				
			||||||
 | 
					        <module>decoupling-pattern1</module>
 | 
				
			||||||
 | 
					        <module>decoupling-pattern2</module>
 | 
				
			||||||
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -2,7 +2,7 @@ package com.baeldung.exitvshalt;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class JvmExitDemoUnitTest {
 | 
					public class JvmExitDemoManualTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
 | 
					    JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2,7 +2,7 @@ package com.baeldung.exitvshalt;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class JvmHaltDemoUnitTest {
 | 
					public class JvmHaltDemoManualTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
 | 
					    JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package com.baeldung.optional;
 | 
					package com.baeldung.optional;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Optional;
 | 
					import java.util.Optional;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Person {
 | 
					public class Person {
 | 
				
			||||||
    private String name;
 | 
					    private String name;
 | 
				
			||||||
@ -21,7 +23,7 @@ public class Person {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Optional<Integer> getAge() {
 | 
					    public Optional<Integer> getAge() {
 | 
				
			||||||
        return Optional.ofNullable(age);
 | 
					        return Optional.of(age);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setAge(int age) {
 | 
					    public void setAge(int age) {
 | 
				
			||||||
@ -36,4 +38,37 @@ public class Person {
 | 
				
			|||||||
        return Optional.ofNullable(password);
 | 
					        return Optional.ofNullable(password);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static List<Person> search(List<Person> people, String name, Optional<Integer> age) {
 | 
				
			||||||
 | 
					        // Null checks for people and name
 | 
				
			||||||
 | 
					        return people.stream()
 | 
				
			||||||
 | 
					                .filter(p -> p.getName().equals(name))
 | 
				
			||||||
 | 
					                .filter(p -> p.getAge().get() >= age.orElse(0))
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static List<Person> search(List<Person> people, String name, Integer age) {
 | 
				
			||||||
 | 
					        // Null checks for people and name
 | 
				
			||||||
 | 
					        final Integer ageFilter = age != null ? age : 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return people.stream()
 | 
				
			||||||
 | 
					                .filter(p -> p.getName().equals(name))
 | 
				
			||||||
 | 
					                .filter(p -> p.getAge().get() >= ageFilter)
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static List<Person> search(List<Person> people, String name) {
 | 
				
			||||||
 | 
					        return doSearch(people, name, 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static List<Person> search(List<Person> people, String name, int age) {
 | 
				
			||||||
 | 
					        return doSearch(people, name, age);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static List<Person> doSearch(List<Person> people, String name, int age) {
 | 
				
			||||||
 | 
					        // Null checks for people and name
 | 
				
			||||||
 | 
					        return people.stream()
 | 
				
			||||||
 | 
					                .filter(p -> p.getName().equals(name))
 | 
				
			||||||
 | 
					                .filter(p -> p.getAge().get().intValue() >= age)
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -14,11 +14,110 @@
 | 
				
			|||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <modules>
 | 
					    <modules>
 | 
				
			||||||
        <module>pre-jpms</module>
 | 
					        <module>core-java</module>
 | 
				
			||||||
        <module>core-java-optional</module>
 | 
					        <!-- <module>core-java-10</module> --> <!-- We haven't upgraded to java 10. Fixing in BAEL-10841 -->
 | 
				
			||||||
        <module>core-java-lang-operators</module>
 | 
					        <!-- <module>core-java-11</module> --> <!-- We haven't upgraded to java 11. Fixing in BAEL-10841 -->
 | 
				
			||||||
        <module>core-java-networking-2</module>
 | 
					        <!-- <module>core-java-12</module> --> <!-- We haven't upgraded to java 12. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <!-- <module>core-java-13</module> --> <!-- We haven't upgraded to java 12. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <module>core-java-8</module>
 | 
				
			||||||
 | 
					        <module>core-java-8-2</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- <module>core-java-9</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <!-- <module>core-java-9-improvements</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <!-- <module>core-java-9-jigsaw</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <!-- <module>core-java-9-new-features</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <!-- <module>core-java-9-streams</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-annotations</module>
 | 
				
			||||||
 | 
					        <module>core-java-arrays</module>
 | 
				
			||||||
 | 
					        <module>core-java-arrays-2</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-collections</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-array-list</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-list</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-list-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-list-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-collections-set</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-advanced</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-advanced-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-advanced-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-basic</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-basic-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-concurrency-collections</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- <module>core-java-date-operations-1</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
        <module>core-java-date-operations-2</module>
 | 
					        <module>core-java-date-operations-2</module>
 | 
				
			||||||
 | 
					        <!-- We haven't upgraded to java 9.-->
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					        <module>core-java-datetime-computations</module>
 | 
				
			||||||
 | 
					        <module>core-java-datetime-conversion</module>
 | 
				
			||||||
 | 
					        <module>core-java-datetime-java8</module>
 | 
				
			||||||
 | 
					        <module>core-java-datetime-string</module>
 | 
				
			||||||
 | 
					        -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-exceptions</module>
 | 
				
			||||||
 | 
					        <module>core-java-exceptions-2</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-function</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-io</module>
 | 
				
			||||||
 | 
					        <module>core-java-io-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-io-apis</module>
 | 
				
			||||||
 | 
					        <module>core-java-io-conversions</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-jar</module>
 | 
				
			||||||
 | 
					        <module>core-java-jndi</module>
 | 
				
			||||||
 | 
					        <!-- <module>core-java-jpms</module> --> <!-- We haven't upgraded to java 10. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <module>core-java-jvm</module>		
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-lambdas</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-math</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-oop</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-oop-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-oop-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-oop-4</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-operators</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-syntax</module>
 | 
				
			||||||
 | 
					        <module>core-java-lang-syntax-2</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-networking</module>
 | 
				
			||||||
 | 
					        <module>core-java-networking-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-nio</module>
 | 
				
			||||||
 | 
					        <module>core-java-nio-2</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-optional</module>
 | 
				
			||||||
 | 
					        <!--<module>core-java-os</module> --> <!-- We haven't upgraded to java 9.-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-perf</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-reflection</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-security</module>
 | 
				
			||||||
 | 
					        <module>core-java-streams</module>
 | 
				
			||||||
 | 
					        <module>core-java-streams-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-streams-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-algorithms</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-algorithms-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-algorithms-3</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-apis</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-conversions</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-conversions-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-operations</module>
 | 
				
			||||||
 | 
					        <module>core-java-string-operations-2</module>
 | 
				
			||||||
 | 
					        <module>core-java-strings</module>
 | 
				
			||||||
 | 
					        <module>core-java-sun</module>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>core-java-text</module>
 | 
				
			||||||
 | 
					        <!-- <module>core-java-time-measurements</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <!-- <module>multimodulemavenproject</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
 | 
				
			||||||
 | 
					        <module>pre-jpms</module>
 | 
				
			||||||
    </modules>
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</project>
 | 
					</project>
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template;
 | 
				
			|||||||
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
 | 
					import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
 | 
				
			||||||
import com.github.jknack.handlebars.io.TemplateLoader;
 | 
					import com.github.jknack.handlebars.io.TemplateLoader;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.Ignore;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -18,6 +20,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
 | 
					    private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedWith_ThenContextChanges() throws IOException {
 | 
					    public void whenUsedWith_ThenContextChanges() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -30,6 +33,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
        assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
 | 
					        assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException {
 | 
					    public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -42,6 +46,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
        assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
 | 
					        assertThat(templateString).isEqualTo("\n<h4>I live in World</h4>\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedEach_ThenIterates() throws IOException {
 | 
					    public void whenUsedEach_ThenIterates() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -58,6 +63,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
                                               + "\n<span>Spring is my friend.</span>\n");
 | 
					                                               + "\n<span>Spring is my friend.</span>\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedEachMustacheStyle_ThenIterates() throws IOException {
 | 
					    public void whenUsedEachMustacheStyle_ThenIterates() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -74,6 +80,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
                                               + "\n<span>Spring is my friend.</span>\n");
 | 
					                                               + "\n<span>Spring is my friend.</span>\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedIf_ThenPutsCondition() throws IOException {
 | 
					    public void whenUsedIf_ThenPutsCondition() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -86,6 +93,7 @@ public class BuiltinHelperUnitTest {
 | 
				
			|||||||
        assertThat(templateString).isEqualTo("\n<h4>Baeldung is busy.</h4>\n");
 | 
					        assertThat(templateString).isEqualTo("\n<h4>Baeldung is busy.</h4>\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenUsedIfMustacheStyle_ThenPutsCondition() throws IOException {
 | 
					    public void whenUsedIfMustacheStyle_ThenPutsCondition() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template;
 | 
				
			|||||||
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
 | 
					import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
 | 
				
			||||||
import com.github.jknack.handlebars.io.TemplateLoader;
 | 
					import com.github.jknack.handlebars.io.TemplateLoader;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.Ignore;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -18,6 +20,7 @@ public class ReusingTemplatesUnitTest {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
 | 
					    private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException {
 | 
					    public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
@ -30,6 +33,7 @@ public class ReusingTemplatesUnitTest {
 | 
				
			|||||||
        assertThat(templateString).isEqualTo("<h4>Hi Baeldung!</h4>\n<p>This is the page Baeldung</p>");
 | 
					        assertThat(templateString).isEqualTo("<h4>Hi Baeldung!</h4>\n<p>This is the page Baeldung</p>");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Ignore
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException {
 | 
					    public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException {
 | 
				
			||||||
        Handlebars handlebars = new Handlebars(templateLoader);
 | 
					        Handlebars handlebars = new Handlebars(templateLoader);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										25
									
								
								maven-all/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								maven-all/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>maven-all</artifactId>
 | 
				
			||||||
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <name>maven-all</name>
 | 
				
			||||||
 | 
					    <packaging>pom</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <modules>
 | 
				
			||||||
 | 
					        <!-- <module>compiler-plugin-java-9</module> --> <!-- We haven't upgraded to java 9. -->
 | 
				
			||||||
 | 
					        <module>maven</module>
 | 
				
			||||||
 | 
					        <module>maven-custom-plugin/counter-maven-plugin</module>
 | 
				
			||||||
 | 
					        <module>maven-war-plugin</module>
 | 
				
			||||||
 | 
					        <module>profiles</module>
 | 
				
			||||||
 | 
					        <module>versions-maven-plugin</module>
 | 
				
			||||||
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
							
								
								
									
										22
									
								
								maven-polyglot/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								maven-polyglot/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>maven-polyglot</artifactId>
 | 
				
			||||||
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <name>maven-polyglot</name>
 | 
				
			||||||
 | 
					    <packaging>pom</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <modules>
 | 
				
			||||||
 | 
					        <!-- <module>maven-polyglot-json-app</module> --> <!-- Not a maven project -->
 | 
				
			||||||
 | 
					        <module>maven-polyglot-json-extension</module>
 | 
				
			||||||
 | 
					        <!-- <module>maven-polyglot-yml-app</module> --> <!-- Not a maven project -->
 | 
				
			||||||
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -2,4 +2,4 @@ micronaut:
 | 
				
			|||||||
    application:
 | 
					    application:
 | 
				
			||||||
        name: hello-world-server
 | 
					        name: hello-world-server
 | 
				
			||||||
    server:
 | 
					    server:
 | 
				
			||||||
        port: 9080
 | 
					        port: ${random.port}
 | 
				
			||||||
@ -5,9 +5,9 @@ import java.util.List;
 | 
				
			|||||||
import org.springframework.data.domain.Pageable;
 | 
					import org.springframework.data.domain.Pageable;
 | 
				
			||||||
import org.springframework.data.repository.PagingAndSortingRepository;
 | 
					import org.springframework.data.repository.PagingAndSortingRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baeldung.multipledb.model.product.ProductMultipleDB;
 | 
					import com.baeldung.multipledb.model.product.Product;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface ProductRepository extends PagingAndSortingRepository<ProductMultipleDB, Integer> {
 | 
					public interface ProductRepository extends PagingAndSortingRepository<Product, Integer> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    List<ProductMultipleDB> findAllByPrice(double price, Pageable pageable);
 | 
					    List<Product> findAllByPrice(double price, Pageable pageable);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import javax.persistence.Table;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
@Table(schema = "products")
 | 
					@Table(schema = "products")
 | 
				
			||||||
public class ProductMultipleDB {
 | 
					public class Product {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Id
 | 
					    @Id
 | 
				
			||||||
    private int id;
 | 
					    private int id;
 | 
				
			||||||
@ -15,19 +15,19 @@ public class ProductMultipleDB {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private double price;
 | 
					    private double price;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ProductMultipleDB() {
 | 
					    public Product() {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ProductMultipleDB(int id, String name, double price) {
 | 
					    private Product(int id, String name, double price) {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
        this.id = id;
 | 
					        this.id = id;
 | 
				
			||||||
        this.name = name;
 | 
					        this.name = name;
 | 
				
			||||||
        this.price = price;
 | 
					        this.price = price;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static ProductMultipleDB from(int id, String name, double price) {
 | 
					    public static Product from(int id, String name, double price) {
 | 
				
			||||||
        return new ProductMultipleDB(id, name, price);
 | 
					        return new Product(id, name, price);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public int getId() {
 | 
					    public int getId() {
 | 
				
			||||||
@ -23,7 +23,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 | 
				
			|||||||
import org.springframework.transaction.annotation.Transactional;
 | 
					import org.springframework.transaction.annotation.Transactional;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baeldung.multipledb.dao.product.ProductRepository;
 | 
					import com.baeldung.multipledb.dao.product.ProductRepository;
 | 
				
			||||||
import com.baeldung.multipledb.model.product.ProductMultipleDB;
 | 
					import com.baeldung.multipledb.model.product.Product;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@RunWith(SpringRunner.class)
 | 
					@RunWith(SpringRunner.class)
 | 
				
			||||||
@SpringBootTest(classes=MultipleDbApplication.class)
 | 
					@SpringBootTest(classes=MultipleDbApplication.class)
 | 
				
			||||||
@ -36,22 +36,22 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
    @Before
 | 
					    @Before
 | 
				
			||||||
    @Transactional("productTransactionManager")
 | 
					    @Transactional("productTransactionManager")
 | 
				
			||||||
    public void setUp() {
 | 
					    public void setUp() {
 | 
				
			||||||
        productRepository.save(ProductMultipleDB.from(1001, "Book", 21));
 | 
					        productRepository.save(Product.from(1001, "Book", 21));
 | 
				
			||||||
        productRepository.save(ProductMultipleDB.from(1002, "Coffee", 10));
 | 
					        productRepository.save(Product.from(1002, "Coffee", 10));
 | 
				
			||||||
        productRepository.save(ProductMultipleDB.from(1003, "Jeans", 30));
 | 
					        productRepository.save(Product.from(1003, "Jeans", 30));
 | 
				
			||||||
        productRepository.save(ProductMultipleDB.from(1004, "Shirt", 32));
 | 
					        productRepository.save(Product.from(1004, "Shirt", 32));
 | 
				
			||||||
        productRepository.save(ProductMultipleDB.from(1005, "Bacon", 10));
 | 
					        productRepository.save(Product.from(1005, "Bacon", 10));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() {
 | 
					    public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() {
 | 
				
			||||||
        Pageable pageRequest = PageRequest.of(0, 2);
 | 
					        Pageable pageRequest = PageRequest.of(0, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(2));
 | 
					        assertThat(result.getContent(), hasSize(2));
 | 
				
			||||||
        assertTrue(result.stream()
 | 
					        assertTrue(result.stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .allMatch(id -> Arrays.asList(1001, 1002)
 | 
					            .allMatch(id -> Arrays.asList(1001, 1002)
 | 
				
			||||||
                .contains(id)));
 | 
					                .contains(id)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -60,11 +60,11 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
    public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() {
 | 
					    public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() {
 | 
				
			||||||
        Pageable pageRequest = PageRequest.of(1, 2);
 | 
					        Pageable pageRequest = PageRequest.of(1, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(2));
 | 
					        assertThat(result.getContent(), hasSize(2));
 | 
				
			||||||
        assertTrue(result.stream()
 | 
					        assertTrue(result.stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .allMatch(id -> Arrays.asList(1003, 1004)
 | 
					            .allMatch(id -> Arrays.asList(1003, 1004)
 | 
				
			||||||
                .contains(id)));
 | 
					                .contains(id)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -73,11 +73,11 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
    public void whenRequestingLastPage_ThenReturnLastPageWithRemData() {
 | 
					    public void whenRequestingLastPage_ThenReturnLastPageWithRemData() {
 | 
				
			||||||
        Pageable pageRequest = PageRequest.of(2, 2);
 | 
					        Pageable pageRequest = PageRequest.of(2, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(1));
 | 
					        assertThat(result.getContent(), hasSize(1));
 | 
				
			||||||
        assertTrue(result.stream()
 | 
					        assertTrue(result.stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .allMatch(id -> Arrays.asList(1005)
 | 
					            .allMatch(id -> Arrays.asList(1005)
 | 
				
			||||||
                .contains(id)));
 | 
					                .contains(id)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -86,12 +86,12 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
    public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() {
 | 
					    public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() {
 | 
				
			||||||
        Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name"));
 | 
					        Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(3));
 | 
					        assertThat(result.getContent(), hasSize(3));
 | 
				
			||||||
        assertThat(result.getContent()
 | 
					        assertThat(result.getContent()
 | 
				
			||||||
            .stream()
 | 
					            .stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002)));
 | 
					            .collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -101,12 +101,12 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
        Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price")
 | 
					        Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price")
 | 
				
			||||||
            .descending());
 | 
					            .descending());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(3));
 | 
					        assertThat(result.getContent(), hasSize(3));
 | 
				
			||||||
        assertThat(result.getContent()
 | 
					        assertThat(result.getContent()
 | 
				
			||||||
            .stream()
 | 
					            .stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001)));
 | 
					            .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -117,12 +117,12 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
            .descending()
 | 
					            .descending()
 | 
				
			||||||
            .and(Sort.by("name")));
 | 
					            .and(Sort.by("name")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Page<ProductMultipleDB> result = productRepository.findAll(pageRequest);
 | 
					        Page<Product> result = productRepository.findAll(pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result.getContent(), hasSize(5));
 | 
					        assertThat(result.getContent(), hasSize(5));
 | 
				
			||||||
        assertThat(result.getContent()
 | 
					        assertThat(result.getContent()
 | 
				
			||||||
            .stream()
 | 
					            .stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002)));
 | 
					            .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -131,11 +131,11 @@ public class ProductRepositoryIntegrationTest {
 | 
				
			|||||||
    public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() {
 | 
					    public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() {
 | 
				
			||||||
        Pageable pageRequest = PageRequest.of(0, 2);
 | 
					        Pageable pageRequest = PageRequest.of(0, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<ProductMultipleDB> result = productRepository.findAllByPrice(10, pageRequest);
 | 
					        List<Product> result = productRepository.findAllByPrice(10, pageRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assertThat(result, hasSize(2));
 | 
					        assertThat(result, hasSize(2));
 | 
				
			||||||
        assertTrue(result.stream()
 | 
					        assertTrue(result.stream()
 | 
				
			||||||
            .map(ProductMultipleDB::getId)
 | 
					            .map(Product::getId)
 | 
				
			||||||
            .allMatch(id -> Arrays.asList(1002, 1005)
 | 
					            .allMatch(id -> Arrays.asList(1002, 1005)
 | 
				
			||||||
                .contains(id)));
 | 
					                .contains(id)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										61
									
								
								slack/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								slack/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>com.baeldung.examples</groupId>
 | 
				
			||||||
 | 
					    <artifactId>slack</artifactId>
 | 
				
			||||||
 | 
					    <version>1.0</version>
 | 
				
			||||||
 | 
					    <name>slack</name>
 | 
				
			||||||
 | 
					    <packaging>jar</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.hubspot.slack</groupId>
 | 
				
			||||||
 | 
					            <artifactId>slack-base</artifactId>
 | 
				
			||||||
 | 
					            <version>${slack.version}</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.hubspot.slack</groupId>
 | 
				
			||||||
 | 
					            <artifactId>slack-java-client</artifactId>
 | 
				
			||||||
 | 
					            <version>${slack.version}</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-jar-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>${maven-jar-plugin.version}</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <archive>
 | 
				
			||||||
 | 
					                        <manifest>
 | 
				
			||||||
 | 
					                            <addClasspath>true</addClasspath>
 | 
				
			||||||
 | 
					                            <mainClass>com.baeldung.examples.slack.MainClass</mainClass>
 | 
				
			||||||
 | 
					                        </manifest>
 | 
				
			||||||
 | 
					                    </archive>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.codehaus.mojo</groupId>
 | 
				
			||||||
 | 
					                <artifactId>exec-maven-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>1.6.0</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <mainClass>com.baeldung.examples.slack.MainClass</mainClass>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <slack.version>1.4</slack.version>
 | 
				
			||||||
 | 
					        <maven-jar-plugin.version>2.4</maven-jar-plugin.version>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.nio.file.FileSystems;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class DiskSpaceErrorChecker implements ErrorChecker {
 | 
				
			||||||
 | 
					    private static final Logger LOG = LoggerFactory.getLogger(DiskSpaceErrorChecker.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final ErrorReporter errorReporter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final double limit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public DiskSpaceErrorChecker(ErrorReporter errorReporter, double limit) {
 | 
				
			||||||
 | 
					        this.errorReporter = errorReporter;
 | 
				
			||||||
 | 
					        this.limit = limit;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void check() {
 | 
				
			||||||
 | 
					        LOG.info("Checking disk space");
 | 
				
			||||||
 | 
					        FileSystems.getDefault().getFileStores().forEach(fileStore -> {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                long totalSpace = fileStore.getTotalSpace();
 | 
				
			||||||
 | 
					                long usableSpace = fileStore.getUsableSpace();
 | 
				
			||||||
 | 
					                double usablePercentage = ((double) usableSpace) / totalSpace;
 | 
				
			||||||
 | 
					                LOG.debug("File store {} has {} of {} ({}) usable space",
 | 
				
			||||||
 | 
					                    fileStore, usableSpace, totalSpace, usablePercentage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (totalSpace > 0 && usablePercentage < limit) {
 | 
				
			||||||
 | 
					                    String error = String.format("File store %s only has %d%% usable disk space",
 | 
				
			||||||
 | 
					                        fileStore.name(), (int)(usablePercentage * 100));
 | 
				
			||||||
 | 
					                    errorReporter.reportProblem(error);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (IOException e) {
 | 
				
			||||||
 | 
					                LOG.error("Error getting disk space for file store {}", fileStore, e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface ErrorChecker {
 | 
				
			||||||
 | 
					    void check();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface ErrorReporter {
 | 
				
			||||||
 | 
					    void reportProblem(String problem);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.util.Timer;
 | 
				
			||||||
 | 
					import java.util.TimerTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.SlackClient;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.SlackClientFactory;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.SlackClientRuntimeConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MainClass {
 | 
				
			||||||
 | 
					    public static final long MINUTES = 1000 * 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void main(String[] args) throws IOException {
 | 
				
			||||||
 | 
					        SlackClientRuntimeConfig runtimeConfig = SlackClientRuntimeConfig.builder()
 | 
				
			||||||
 | 
					            .setTokenSupplier(() -> "<Your API Token>")
 | 
				
			||||||
 | 
					            .build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SlackClient slackClient = SlackClientFactory.defaultFactory().build(runtimeConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ErrorReporter slackChannelErrorReporter = new SlackChannelErrorReporter(slackClient, "general");
 | 
				
			||||||
 | 
					        ErrorReporter slackUserErrorReporter = new SlackUserErrorReporter(slackClient, "testuser@baeldung.com");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ErrorChecker diskSpaceErrorChecker10pct = new DiskSpaceErrorChecker(slackChannelErrorReporter, 0.1);
 | 
				
			||||||
 | 
					        ErrorChecker diskSpaceErrorChecker2pct = new DiskSpaceErrorChecker(slackUserErrorReporter, 0.02);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Timer timer = new Timer();
 | 
				
			||||||
 | 
					        timer.scheduleAtFixedRate(new TimerTask() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void run() {
 | 
				
			||||||
 | 
					                diskSpaceErrorChecker10pct.check();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }, 0, 5 * MINUTES);
 | 
				
			||||||
 | 
					        timer.scheduleAtFixedRate(new TimerTask() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void run() {
 | 
				
			||||||
 | 
					                diskSpaceErrorChecker2pct.check();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }, 0, 5 * MINUTES);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.SlackClient;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams;
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SlackChannelErrorReporter implements ErrorReporter {
 | 
				
			||||||
 | 
					    private static final Logger LOG = LoggerFactory.getLogger(SlackChannelErrorReporter.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final SlackClient slackClient;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final String channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public SlackChannelErrorReporter(SlackClient slackClient, String channel) {
 | 
				
			||||||
 | 
					        this.slackClient = slackClient;
 | 
				
			||||||
 | 
					        this.channel = channel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void reportProblem(String problem) {
 | 
				
			||||||
 | 
					        LOG.debug("Sending message to channel {}: {}", channel, problem);
 | 
				
			||||||
 | 
					        slackClient.postMessage(
 | 
				
			||||||
 | 
					            ChatPostMessageParams.builder()
 | 
				
			||||||
 | 
					                .setText(problem)
 | 
				
			||||||
 | 
					                .setChannelId(channel)
 | 
				
			||||||
 | 
					                .build()
 | 
				
			||||||
 | 
					        ).join().unwrapOrElseThrow();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					package com.baeldung.examples.slack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.SlackClient;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.conversations.ConversationCreateParams;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.im.ImOpenParams;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.users.UserEmailParams;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.methods.params.users.UsersInfoParams;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.models.response.im.ImOpenResponse;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.models.response.users.UsersInfoResponse;
 | 
				
			||||||
 | 
					import com.hubspot.slack.client.models.users.SlackUser;
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SlackUserErrorReporter implements ErrorReporter {
 | 
				
			||||||
 | 
					    private static final Logger LOG = LoggerFactory.getLogger(SlackUserErrorReporter.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final SlackClient slackClient;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final String user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public SlackUserErrorReporter(SlackClient slackClient, String user) {
 | 
				
			||||||
 | 
					        this.slackClient = slackClient;
 | 
				
			||||||
 | 
					        this.user = user;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void reportProblem(String problem) {
 | 
				
			||||||
 | 
					        LOG.debug("Sending message to user {}: {}", user, problem);
 | 
				
			||||||
 | 
					        UsersInfoResponse usersInfoResponse = slackClient
 | 
				
			||||||
 | 
					            .lookupUserByEmail(UserEmailParams.builder()
 | 
				
			||||||
 | 
					                .setEmail(user)
 | 
				
			||||||
 | 
					                .build()
 | 
				
			||||||
 | 
					            ).join().unwrapOrElseThrow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ImOpenResponse imOpenResponse = slackClient.openIm(ImOpenParams.builder()
 | 
				
			||||||
 | 
					            .setUserId(usersInfoResponse.getUser().getId())
 | 
				
			||||||
 | 
					            .build()
 | 
				
			||||||
 | 
					        ).join().unwrapOrElseThrow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        imOpenResponse.getChannel().ifPresent(channel -> {
 | 
				
			||||||
 | 
					            slackClient.postMessage(
 | 
				
			||||||
 | 
					                ChatPostMessageParams.builder()
 | 
				
			||||||
 | 
					                    .setText(problem)
 | 
				
			||||||
 | 
					                    .setChannelId(channel.getId())
 | 
				
			||||||
 | 
					                    .build()
 | 
				
			||||||
 | 
					            ).join().unwrapOrElseThrow();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										13
									
								
								slack/src/main/resources/logback.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								slack/src/main/resources/logback.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<configuration>
 | 
				
			||||||
 | 
					    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
 | 
				
			||||||
 | 
					        <encoder>
 | 
				
			||||||
 | 
					            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
 | 
				
			||||||
 | 
					            </pattern>
 | 
				
			||||||
 | 
					        </encoder>
 | 
				
			||||||
 | 
					    </appender>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <root level="DEBUG">
 | 
				
			||||||
 | 
					        <appender-ref ref="STDOUT" />
 | 
				
			||||||
 | 
					    </root>
 | 
				
			||||||
 | 
					</configuration>
 | 
				
			||||||
@ -68,6 +68,10 @@
 | 
				
			|||||||
            <artifactId>spring-boot-starter-test</artifactId>
 | 
					            <artifactId>spring-boot-starter-test</artifactId>
 | 
				
			||||||
            <scope>test</scope>
 | 
					            <scope>test</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					        	<groupId>org.springframework.boot</groupId>
 | 
				
			||||||
 | 
					        	<artifactId>spring-boot-devtools</artifactId>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
    </dependencies>
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <build>
 | 
					    <build>
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					package com.baeldung.springcloudgateway.custompredicates;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
				
			||||||
 | 
					import org.springframework.boot.builder.SpringApplicationBuilder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@SpringBootApplication
 | 
				
			||||||
 | 
					public class CustomPredicatesApplication {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void main(String[] args) {
 | 
				
			||||||
 | 
					        new SpringApplicationBuilder(CustomPredicatesApplication.class)
 | 
				
			||||||
 | 
					          .profiles("customroutes")
 | 
				
			||||||
 | 
					          .run(args);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					package com.baeldung.springcloudgateway.custompredicates.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.cloud.gateway.filter.GatewayFilter;
 | 
				
			||||||
 | 
					import org.springframework.cloud.gateway.route.RouteLocator;
 | 
				
			||||||
 | 
					import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Bean;
 | 
				
			||||||
 | 
					import org.springframework.context.annotation.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baeldung.springcloudgateway.custompredicates.factories.GoldenCustomerRoutePredicateFactory;
 | 
				
			||||||
 | 
					import com.baeldung.springcloudgateway.custompredicates.factories.GoldenCustomerRoutePredicateFactory.Config;
 | 
				
			||||||
 | 
					import com.baeldung.springcloudgateway.custompredicates.service.GoldenCustomerService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Configuration
 | 
				
			||||||
 | 
					public class CustomPredicatesConfig {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Bean
 | 
				
			||||||
 | 
					    public GoldenCustomerRoutePredicateFactory goldenCustomer(GoldenCustomerService goldenCustomerService) {
 | 
				
			||||||
 | 
					        return new GoldenCustomerRoutePredicateFactory(goldenCustomerService);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //@Bean
 | 
				
			||||||
 | 
					    public RouteLocator routes(RouteLocatorBuilder builder, GoldenCustomerRoutePredicateFactory gf ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return builder.routes()
 | 
				
			||||||
 | 
					          .route("dsl_golden_route", r -> r.path("/dsl_api/**")
 | 
				
			||||||
 | 
					            .filters(f -> f.stripPrefix(1))
 | 
				
			||||||
 | 
					            .uri("https://httpbin.org")
 | 
				
			||||||
 | 
					            .predicate(gf.apply(new Config(true, "customerId"))))
 | 
				
			||||||
 | 
					          .route("dsl_common_route", r -> r.path("/dsl_api/**")
 | 
				
			||||||
 | 
					            .filters(f -> f.stripPrefix(1))
 | 
				
			||||||
 | 
					            .uri("https://httpbin.org")
 | 
				
			||||||
 | 
					            .predicate(gf.apply(new Config(false, "customerId"))))             
 | 
				
			||||||
 | 
					          .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package com.baeldung.springcloudgateway.custompredicates.factories;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.function.Predicate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.validation.constraints.NotEmpty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.cloud.gateway.handler.predicate.AbstractRoutePredicateFactory;
 | 
				
			||||||
 | 
					import org.springframework.http.HttpCookie;
 | 
				
			||||||
 | 
					import org.springframework.validation.annotation.Validated;
 | 
				
			||||||
 | 
					import org.springframework.web.server.ServerWebExchange;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baeldung.springcloudgateway.custompredicates.service.GoldenCustomerService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @author Philippe
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class GoldenCustomerRoutePredicateFactory extends AbstractRoutePredicateFactory<GoldenCustomerRoutePredicateFactory.Config> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final GoldenCustomerService goldenCustomerService;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public GoldenCustomerRoutePredicateFactory(GoldenCustomerService goldenCustomerService ) {
 | 
				
			||||||
 | 
					        super(Config.class);
 | 
				
			||||||
 | 
					        this.goldenCustomerService = goldenCustomerService;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<String> shortcutFieldOrder() {
 | 
				
			||||||
 | 
					        return Arrays.asList("isGolden","customerIdCookie");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Predicate<ServerWebExchange> apply(Config config) {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return (ServerWebExchange t) -> {
 | 
				
			||||||
 | 
					            List<HttpCookie> cookies = t.getRequest()
 | 
				
			||||||
 | 
					              .getCookies()
 | 
				
			||||||
 | 
					              .get(config.getCustomerIdCookie());
 | 
				
			||||||
 | 
					              
 | 
				
			||||||
 | 
					            boolean isGolden; 
 | 
				
			||||||
 | 
					            if ( cookies == null || cookies.isEmpty()) {
 | 
				
			||||||
 | 
					                isGolden = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {                
 | 
				
			||||||
 | 
					                String customerId = cookies.get(0).getValue();                
 | 
				
			||||||
 | 
					                isGolden = goldenCustomerService.isGoldenCustomer(customerId);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					              
 | 
				
			||||||
 | 
					            return config.isGolden()?isGolden:!isGolden;           
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Validated
 | 
				
			||||||
 | 
					    public static class Config {        
 | 
				
			||||||
 | 
					        boolean isGolden = true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        @NotEmpty
 | 
				
			||||||
 | 
					        String customerIdCookie = "customerId";
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public Config() {}
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public Config( boolean isGolden, String customerIdCookie) {
 | 
				
			||||||
 | 
					            this.isGolden = isGolden;
 | 
				
			||||||
 | 
					            this.customerIdCookie = customerIdCookie;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public boolean isGolden() {
 | 
				
			||||||
 | 
					            return isGolden;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public void setGolden(boolean value) {
 | 
				
			||||||
 | 
					            this.isGolden = value;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * @return the customerIdCookie
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public String getCustomerIdCookie() {
 | 
				
			||||||
 | 
					            return customerIdCookie;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * @param customerIdCookie the customerIdCookie to set
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public void setCustomerIdCookie(String customerIdCookie) {
 | 
				
			||||||
 | 
					            this.customerIdCookie = customerIdCookie;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package com.baeldung.springcloudgateway.custompredicates.service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Component;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @author Philippe
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Component
 | 
				
			||||||
 | 
					public class GoldenCustomerService {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean isGoldenCustomer(String customerId) {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // TODO: Add some AI logic to check is this customer deserves a "golden" status ;^)
 | 
				
			||||||
 | 
					        if ( "baeldung".equalsIgnoreCase(customerId)) {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					spring:
 | 
				
			||||||
 | 
					  cloud:
 | 
				
			||||||
 | 
					    gateway:
 | 
				
			||||||
 | 
					      routes:
 | 
				
			||||||
 | 
					      - id: golden_route
 | 
				
			||||||
 | 
					        uri: https://httpbin.org
 | 
				
			||||||
 | 
					        predicates:
 | 
				
			||||||
 | 
					        - Path=/api/**
 | 
				
			||||||
 | 
					        - GoldenCustomer=true
 | 
				
			||||||
 | 
					        filters:
 | 
				
			||||||
 | 
					        - StripPrefix=1
 | 
				
			||||||
 | 
					        - AddRequestHeader=GoldenCustomer,true
 | 
				
			||||||
 | 
					      - id: common_route
 | 
				
			||||||
 | 
					        uri: https://httpbin.org
 | 
				
			||||||
 | 
					        predicates:
 | 
				
			||||||
 | 
					        - Path=/api/**
 | 
				
			||||||
 | 
					        - name: GoldenCustomer
 | 
				
			||||||
 | 
					          args:
 | 
				
			||||||
 | 
					            golden: false
 | 
				
			||||||
 | 
					            customerIdCookie: customerId
 | 
				
			||||||
 | 
					        filters:
 | 
				
			||||||
 | 
					        - StripPrefix=1
 | 
				
			||||||
 | 
					        - AddRequestHeader=GoldenCustomer,false
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					              
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 | 
				
			|||||||
import org.assertj.core.api.Condition;
 | 
					import org.assertj.core.api.Condition;
 | 
				
			||||||
import org.junit.jupiter.api.BeforeEach;
 | 
					import org.junit.jupiter.api.BeforeEach;
 | 
				
			||||||
import org.junit.jupiter.api.Test;
 | 
					import org.junit.jupiter.api.Test;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
					import org.springframework.boot.test.context.SpringBootTest;
 | 
				
			||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 | 
					import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 | 
				
			||||||
import org.springframework.boot.web.server.LocalServerPort;
 | 
					import org.springframework.boot.web.server.LocalServerPort;
 | 
				
			||||||
@ -27,6 +28,7 @@ public class CustomFiltersLiveTest {
 | 
				
			|||||||
    @LocalServerPort
 | 
					    @LocalServerPort
 | 
				
			||||||
    String port;
 | 
					    String port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
    private WebTestClient client;
 | 
					    private WebTestClient client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @BeforeEach
 | 
					    @BeforeEach
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					package com.baeldung.springcloudgateway.custompredicates;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.assertj.core.api.Assertions.assertThat;
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.net.URI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.json.JSONException;
 | 
				
			||||||
 | 
					import org.json.JSONObject;
 | 
				
			||||||
 | 
					import org.json.JSONTokener;
 | 
				
			||||||
 | 
					import org.junit.Before;
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.Test;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.boot.test.context.SpringBootTest;
 | 
				
			||||||
 | 
					import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 | 
				
			||||||
 | 
					import org.springframework.boot.test.web.client.TestRestTemplate;
 | 
				
			||||||
 | 
					import org.springframework.boot.web.server.LocalServerPort;
 | 
				
			||||||
 | 
					import org.springframework.http.HttpStatus;
 | 
				
			||||||
 | 
					import org.springframework.http.RequestEntity;
 | 
				
			||||||
 | 
					import org.springframework.http.ResponseEntity;
 | 
				
			||||||
 | 
					import org.springframework.test.context.ActiveProfiles;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * This test requires
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 | 
				
			||||||
 | 
					@ActiveProfiles("customroutes")
 | 
				
			||||||
 | 
					public class CustomPredicatesApplicationLiveTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @LocalServerPort
 | 
				
			||||||
 | 
					    String serverPort;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private TestRestTemplate restTemplate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    void givenNormalCustomer_whenCallHeadersApi_thenResponseForNormalCustomer() throws JSONException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String url = "http://localhost:" + serverPort + "/api/headers";        
 | 
				
			||||||
 | 
					        ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
 | 
				
			||||||
 | 
					        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        JSONObject json = new JSONObject(response.getBody());
 | 
				
			||||||
 | 
					        JSONObject headers = json.getJSONObject("headers");
 | 
				
			||||||
 | 
					        assertThat(headers.getString("Goldencustomer")).isEqualTo("false");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    void givenGoldenCustomer_whenCallHeadersApi_thenResponseForGoldenCustomer() throws JSONException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String url = "http://localhost:" + serverPort + "/api/headers";   
 | 
				
			||||||
 | 
					        RequestEntity<Void> request = RequestEntity
 | 
				
			||||||
 | 
					            .get(URI.create(url))
 | 
				
			||||||
 | 
					            .header("Cookie", "customerId=baeldung")
 | 
				
			||||||
 | 
					            .build();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        ResponseEntity<String> response = restTemplate.exchange(request, String.class);
 | 
				
			||||||
 | 
					        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        JSONObject json = new JSONObject(response.getBody());
 | 
				
			||||||
 | 
					        JSONObject headers = json.getJSONObject("headers");
 | 
				
			||||||
 | 
					        assertThat(headers.getString("Goldencustomer")).isEqualTo("true");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										44
									
								
								spring-security-modules/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								spring-security-modules/pom.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project xmlns="http://maven.apache.org/POM/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">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <artifactId>spring-security-modules</artifactId>
 | 
				
			||||||
 | 
					    <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <name>spring-security-modules</name>
 | 
				
			||||||
 | 
					    <packaging>pom</packaging>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <parent>
 | 
				
			||||||
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
 | 
					        <artifactId>parent-modules</artifactId>
 | 
				
			||||||
 | 
					        <version>1.0.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <modules>
 | 
				
			||||||
 | 
					        <module>spring-security-acl</module>
 | 
				
			||||||
 | 
					        <module>spring-security-angular/server</module>
 | 
				
			||||||
 | 
					        <module>spring-security-cache-control</module>
 | 
				
			||||||
 | 
					        <module>spring-security-core</module>
 | 
				
			||||||
 | 
					        <module>spring-security-cors</module>
 | 
				
			||||||
 | 
					        <module>spring-security-kerberos</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-boot</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-custom</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-digest-auth</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-jsonview</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-ldap</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-login</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-persisted-remember-me</module>
 | 
				
			||||||
 | 
					        <module>spring-security-mvc-socket</module>
 | 
				
			||||||
 | 
					        <module>spring-security-oidc</module>
 | 
				
			||||||
 | 
					        <!--<module>spring-security-react</module> --> <!-- Module broken, fixing in BAEL-20772 -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <module>spring-security-rest</module>
 | 
				
			||||||
 | 
					        <module>spring-security-rest-basic-auth</module>
 | 
				
			||||||
 | 
					        <module>spring-security-rest-custom</module>
 | 
				
			||||||
 | 
					        <module>spring-security-sso</module>
 | 
				
			||||||
 | 
					        <module>spring-security-stormpath</module>
 | 
				
			||||||
 | 
					        <module>spring-security-thymeleaf</module>
 | 
				
			||||||
 | 
					        <module>spring-security-x509</module>
 | 
				
			||||||
 | 
					    </modules>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@ -3,15 +3,14 @@
 | 
				
			|||||||
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
    <modelVersion>4.0.0</modelVersion>
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
    <artifactId>spring-security-cors</artifactId>
 | 
					    <artifactId>spring-security-cors</artifactId>
 | 
				
			||||||
    <version>0.0.1-SNAPSHOT</version>
 | 
					 | 
				
			||||||
    <name>spring-security-cors</name>
 | 
					    <name>spring-security-cors</name>
 | 
				
			||||||
    <packaging>jar</packaging>
 | 
					    <packaging>jar</packaging>
 | 
				
			||||||
    <description>Spring Security CORS</description>
 | 
					    <description>Spring Security CORS</description>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <parent>
 | 
					    <parent>
 | 
				
			||||||
        <groupId>com.baeldung</groupId>
 | 
					        <groupId>com.baeldung</groupId>
 | 
				
			||||||
        <artifactId>parent-modules</artifactId>
 | 
					        <artifactId>spring-security-modules</artifactId>
 | 
				
			||||||
        <version>1.0.0-SNAPSHOT</version>
 | 
					        <version>0.0.1-SNAPSHOT</version>
 | 
				
			||||||
    </parent>
 | 
					    </parent>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <dependencyManagement>
 | 
					    <dependencyManagement>
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ import com.baeldung.springbootsecuritycors.basicauth.SpringBootSecurityApplicati
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@RunWith(SpringRunner.class)
 | 
					@RunWith(SpringRunner.class)
 | 
				
			||||||
@SpringBootTest(classes = { SpringBootSecurityApplication.class })
 | 
					@SpringBootTest(classes = { SpringBootSecurityApplication.class })
 | 
				
			||||||
public class ResourceControllerTest {
 | 
					public class ResourceControllerUnitTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MockMvc mockMvc;
 | 
					    private MockMvc mockMvc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1,3 +0,0 @@
 | 
				
			|||||||
### Relevant Articles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2)
 | 
					 | 
				
			||||||
@ -1,3 +0,0 @@
 | 
				
			|||||||
### Relevant Articles:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2)
 | 
					 | 
				
			||||||
@ -1,3 +0,0 @@
 | 
				
			|||||||
### Relevant Articles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2)
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user