diff --git a/core-java-9/.gitignore b/core-java-9/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-9/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java-9/README.md b/core-java-9/README.md
new file mode 100644
index 0000000000..b5d4dbef95
--- /dev/null
+++ b/core-java-9/README.md
@@ -0,0 +1,5 @@
+=========
+
+## Core Java 9 Examples
+
+http://inprogress.baeldung.com/java-9-new-features/
\ No newline at end of file
diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml
new file mode 100644
index 0000000000..b29838d283
--- /dev/null
+++ b/core-java-9/pom.xml
@@ -0,0 +1,102 @@
+
+ 4.0.0
+ com.baeldung
+ core-java9
+ 0.2-SNAPSHOT
+
+ core-java9
+
+
+
+ apache.snapshots
+ http://repository.apache.org/snapshots/
+
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+
+
+
+ core-java-9
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.9
+ 1.9
+
+ true
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+
+
+
+
+
+
+ 1.7.13
+ 1.0.13
+
+
+
+
+ 3.6-jigsaw-SNAPSHOT
+
+
+ 2.19.1
+
+
+ 1.3
+ 4.12
+ 1.10.19
+
+
+
diff --git a/core-java-9/src/main/java/.gitignore b/core-java-9/src/main/java/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-9/src/main/java/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java b/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java
new file mode 100644
index 0000000000..fd6a496b18
--- /dev/null
+++ b/core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java
@@ -0,0 +1,23 @@
+package com.baeldung.java9.language;
+
+public interface PrivateInterface {
+
+ private static String staticPrivate() {
+ return "static private";
+ }
+
+ private String instancePrivate() {
+ return "instance private";
+ }
+
+ public default void check(){
+ String result = staticPrivate();
+ if (!result.equals("static private"))
+ throw new AssertionError("Incorrect result for static private interface method");
+ PrivateInterface pvt = new PrivateInterface() {
+ };
+ result = pvt.instancePrivate();
+ if (!result.equals("instance private"))
+ throw new AssertionError("Incorrect result for instance private interface method");
+ }
+}
diff --git a/core-java-9/src/main/java/com/baeldung/java9/process/ProcessUtils.java b/core-java-9/src/main/java/com/baeldung/java9/process/ProcessUtils.java
new file mode 100644
index 0000000000..d6682bd0c8
--- /dev/null
+++ b/core-java-9/src/main/java/com/baeldung/java9/process/ProcessUtils.java
@@ -0,0 +1,44 @@
+package com.baeldung.java9.process;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.stream.Stream;
+
+
+public class ProcessUtils {
+
+ public static String getClassPath(){
+ String cp = System.getProperty("java.class.path");
+ System.out.println("ClassPath is "+cp);
+ return cp;
+ }
+
+ public static File getJavaCmd() throws IOException{
+ String javaHome = System.getProperty("java.home");
+ File javaCmd;
+ if(System.getProperty("os.name").startsWith("Win")){
+ javaCmd = new File(javaHome, "bin/java.exe");
+ }else{
+ javaCmd = new File(javaHome, "bin/java");
+ }
+ if(javaCmd.canExecute()){
+ return javaCmd;
+ }else{
+ throw new UnsupportedOperationException(javaCmd.getCanonicalPath() + " is not executable");
+ }
+ }
+
+ public static String getMainClass(){
+ return System.getProperty("sun.java.command");
+ }
+
+ public static String getSystemProperties(){
+ StringBuilder sb = new StringBuilder();
+ System.getProperties().forEach((s1, s2) -> sb.append(s1 +" - "+ s2) );
+ return sb.toString();
+ }
+}
diff --git a/core-java-9/src/main/java/com/baeldung/java9/process/ServiceMain.java b/core-java-9/src/main/java/com/baeldung/java9/process/ServiceMain.java
new file mode 100644
index 0000000000..458f746496
--- /dev/null
+++ b/core-java-9/src/main/java/com/baeldung/java9/process/ServiceMain.java
@@ -0,0 +1,22 @@
+package com.baeldung.java9.process;
+
+import java.util.Optional;
+
+public class ServiceMain {
+
+ public static void main(String[] args) throws InterruptedException {
+ ProcessHandle thisProcess = ProcessHandle.current();
+ long pid = thisProcess.getPid();
+
+
+ Optional opArgs = Optional.ofNullable(args);
+ String procName = opArgs.map(str -> str.length > 0 ? str[0] : null).orElse(System.getProperty("sun.java.command"));
+
+ for (int i = 0; i < 10000; i++) {
+ System.out.println("Process " + procName + " with ID " + pid + " is running!");
+ Thread.sleep(10000);
+ }
+
+ }
+
+}
diff --git a/core-java-9/src/main/resources/logback.xml b/core-java-9/src/main/resources/logback.xml
new file mode 100644
index 0000000000..eefdc7a337
--- /dev/null
+++ b/core-java-9/src/main/resources/logback.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ web - %date [%thread] %-5level %logger{36} - %message%n
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java
new file mode 100644
index 0000000000..102ceda18f
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java
@@ -0,0 +1,58 @@
+package com.baeldung.java8;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class Java9OptionalsStreamTest {
+
+ private static List> listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar"));
+
+ @Test
+ public void filterOutPresentOptionalsWithFilter() {
+ assertEquals(4, listOfOptionals.size());
+
+ List filteredList = listOfOptionals.stream()
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(Collectors.toList());
+
+ assertEquals(2, filteredList.size());
+ assertEquals("foo", filteredList.get(0));
+ assertEquals("bar", filteredList.get(1));
+ }
+
+ @Test
+ public void filterOutPresentOptionalsWithFlatMap() {
+ assertEquals(4, listOfOptionals.size());
+
+ List filteredList = listOfOptionals.stream()
+ .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty())
+ .collect(Collectors.toList());
+ assertEquals(2, filteredList.size());
+
+ assertEquals("foo", filteredList.get(0));
+ assertEquals("bar", filteredList.get(1));
+ }
+
+ @Test
+ public void filterOutPresentOptionalsWithJava9() {
+ assertEquals(4, listOfOptionals.size());
+
+ List filteredList = listOfOptionals.stream()
+ .flatMap(Optional::stream)
+ .collect(Collectors.toList());
+
+ assertEquals(2, filteredList.size());
+ assertEquals("foo", filteredList.get(0));
+ assertEquals("bar", filteredList.get(1));
+ }
+
+}
diff --git a/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java b/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java
new file mode 100644
index 0000000000..d6c16b91bc
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java
@@ -0,0 +1,48 @@
+package com.baeldung.java9;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.awt.Image;
+import java.awt.image.BaseMultiResolutionImage;
+import java.awt.image.BufferedImage;
+import java.awt.image.MultiResolutionImage;
+import java.util.List;
+
+import org.junit.Test;
+
+public class MultiResultionImageTest {
+
+
+ @Test
+ public void baseMultiResImageTest() {
+ int baseIndex = 1;
+ int length = 4;
+ BufferedImage[] resolutionVariants = new BufferedImage[length];
+ for (int i = 0; i < length; i++) {
+ resolutionVariants[i] = createImage(i);
+ }
+ MultiResolutionImage bmrImage = new BaseMultiResolutionImage(baseIndex, resolutionVariants);
+ List rvImageList = bmrImage.getResolutionVariants();
+ assertEquals("MultiResoltion Image shoudl contain the same number of resolution variants!", rvImageList.size(), length);
+
+ for (int i = 0; i < length; i++) {
+ int imageSize = getSize(i);
+ Image testRVImage = bmrImage.getResolutionVariant(imageSize, imageSize);
+ assertSame("Images should be the same", testRVImage, resolutionVariants[i]);
+ }
+
+ }
+
+ private static int getSize(int i) {
+ return 8 * (i + 1);
+ }
+
+
+ private static BufferedImage createImage(int i) {
+ return new BufferedImage(getSize(i), getSize(i),
+ BufferedImage.TYPE_INT_RGB);
+ }
+
+}
diff --git a/core-java-9/src/test/java/com/baeldung/java9/httpclient/SimpleHttpRequestsTest.java b/core-java-9/src/test/java/com/baeldung/java9/httpclient/SimpleHttpRequestsTest.java
new file mode 100644
index 0000000000..ab28b0a805
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/httpclient/SimpleHttpRequestsTest.java
@@ -0,0 +1,126 @@
+package com.baeldung.java9.httpclient;
+
+
+
+import static java.net.HttpURLConnection.HTTP_OK;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.CookieManager;
+import java.net.CookiePolicy;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SimpleHttpRequestsTest {
+
+ private URI httpURI;
+
+ @Before
+ public void init() throws URISyntaxException {
+ httpURI = new URI("http://www.baeldung.com/");
+ }
+
+ @Test
+ public void quickGet() throws IOException, InterruptedException, URISyntaxException {
+ HttpRequest request = HttpRequest.create( httpURI ).GET();
+ HttpResponse response = request.response();
+ int responseStatusCode = response.statusCode();
+ String responseBody = response.body(HttpResponse.asString());
+ assertTrue("Get response status code is bigger then 400", responseStatusCode < 400);
+ }
+
+ @Test
+ public void asynchronousGet() throws URISyntaxException, IOException, InterruptedException, ExecutionException{
+ HttpRequest request = HttpRequest.create(httpURI).GET();
+ long before = System.currentTimeMillis();
+ CompletableFuture futureResponse = request.responseAsync();
+ futureResponse.thenAccept( response -> {
+ String responseBody = response.body(HttpResponse.asString());
+ });
+ HttpResponse resp = futureResponse.get();
+ HttpHeaders hs = resp.headers();
+ assertTrue("There should be more then 1 header.", hs.map().size() >1);
+ }
+
+ @Test
+ public void postMehtod() throws URISyntaxException, IOException, InterruptedException {
+ HttpRequest.Builder requestBuilder = HttpRequest.create(httpURI);
+ requestBuilder.body(HttpRequest.fromString("param1=foo,param2=bar")).followRedirects(HttpClient.Redirect.SECURE);
+ HttpRequest request = requestBuilder.POST();
+ HttpResponse response = request.response();
+ int statusCode = response.statusCode();
+ assertTrue("HTTP return code", statusCode == HTTP_OK);
+ }
+
+ @Test
+ public void configureHttpClient() throws NoSuchAlgorithmException, URISyntaxException, IOException, InterruptedException{
+ CookieManager cManager = new CookieManager();
+ cManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
+
+ SSLParameters sslParam = new SSLParameters (new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" }, new String[] { "TLSv1.2" });
+
+ HttpClient.Builder hcBuilder = HttpClient.create();
+ hcBuilder.cookieManager(cManager).sslContext(SSLContext.getDefault()).sslParameters(sslParam);
+ HttpClient httpClient = hcBuilder.build();
+ HttpRequest.Builder reqBuilder = httpClient.request(new URI("https://www.facebook.com"));
+
+ HttpRequest request = reqBuilder.followRedirects(HttpClient.Redirect.ALWAYS).GET();
+ HttpResponse response = request.response();
+ int statusCode = response.statusCode();
+ assertTrue("HTTP return code", statusCode == HTTP_OK);
+ }
+
+ SSLParameters getDefaultSSLParameters() throws NoSuchAlgorithmException{
+ SSLParameters sslP1 = SSLContext.getDefault().getSupportedSSLParameters();
+ String [] proto = sslP1.getApplicationProtocols();
+ String [] cifers = sslP1.getCipherSuites();
+ System.out.println(printStringArr(proto));
+ System.out.println(printStringArr(cifers));
+ return sslP1;
+ }
+
+ String printStringArr(String ... args ){
+ if(args == null){
+ return null;
+ }
+ StringBuilder sb = new StringBuilder();
+ for (String s : args){
+ sb.append(s);
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ String printHeaders(HttpHeaders h){
+ if(h == null){
+ return null;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ Map> hMap = h.map();
+ for(String k : hMap.keySet()){
+ sb.append(k).append(":");
+ List l = hMap.get(k);
+ if( l != null ){
+ l.forEach( s -> { sb.append(s).append(","); } );
+ }
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+}
diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/DiamondTest.java b/core-java-9/src/test/java/com/baeldung/java9/language/DiamondTest.java
new file mode 100644
index 0000000000..33da6486f4
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/language/DiamondTest.java
@@ -0,0 +1,36 @@
+package com.baeldung.java9.language;
+
+import org.junit.Test;
+
+public class DiamondTest {
+
+ static class FooClass {
+ FooClass(X x) {
+ }
+
+ FooClass(X x, Z z) {
+ }
+ }
+
+ @Test
+ public void diamondTest() {
+ FooClass fc = new FooClass<>(1) {
+ };
+ FooClass extends Integer> fc0 = new FooClass<>(1) {
+ };
+ FooClass> fc1 = new FooClass<>(1) {
+ };
+ FooClass super Integer> fc2 = new FooClass<>(1) {
+ };
+
+ FooClass fc3 = new FooClass<>(1, "") {
+ };
+ FooClass extends Integer> fc4 = new FooClass<>(1, "") {
+ };
+ FooClass> fc5 = new FooClass<>(1, "") {
+ };
+ FooClass super Integer> fc6 = new FooClass<>(1, "") {
+ };
+
+ }
+}
diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceTest.java b/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceTest.java
new file mode 100644
index 0000000000..29ef3930f8
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/language/PrivateInterfaceTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.java9.language;
+
+import com.baeldung.java9.language.PrivateInterface;
+import org.junit.Test;
+
+public class PrivateInterfaceTest {
+
+ @Test
+ public void test() {
+ PrivateInterface piClass = new PrivateInterface() {
+ };
+ piClass.check();
+ }
+
+}
diff --git a/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesTest.java b/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesTest.java
new file mode 100644
index 0000000000..687dfbc390
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesTest.java
@@ -0,0 +1,70 @@
+package com.baeldung.java9.language;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class TryWithResourcesTest {
+
+ static int closeCount = 0;
+
+ static class MyAutoCloseable implements AutoCloseable{
+ final FinalWrapper finalWrapper = new FinalWrapper();
+
+ public void close() {
+ closeCount++;
+ }
+
+ static class FinalWrapper {
+ public final AutoCloseable finalCloseable = new AutoCloseable() {
+ @Override
+ public void close() throws Exception {
+ closeCount++;
+ }
+ };
+ }
+ }
+
+ @Test
+ public void tryWithResourcesTest() {
+ MyAutoCloseable mac = new MyAutoCloseable();
+
+ try (mac) {
+ assertEquals("Expected and Actual does not match", 0, closeCount);
+ }
+
+ try (mac.finalWrapper.finalCloseable) {
+ assertEquals("Expected and Actual does not match", 1, closeCount);
+ } catch (Exception ex) {
+ }
+
+ try (new MyAutoCloseable() { }.finalWrapper.finalCloseable) {
+ assertEquals("Expected and Actual does not match", 2, closeCount);
+ } catch (Exception ex) {
+ }
+
+ try ((closeCount > 0 ? mac : new MyAutoCloseable()).finalWrapper.finalCloseable) {
+ assertEquals("Expected and Actual does not match", 3, closeCount);
+ } catch (Exception ex) {
+ }
+
+ try {
+ throw new CloseableException();
+ } catch (CloseableException ex) {
+ try (ex) {
+ assertEquals("Expected and Actual does not match", 4, closeCount);
+ }
+ }
+ assertEquals("Expected and Actual does not match", 5, closeCount);
+ }
+
+
+ static class CloseableException extends Exception implements AutoCloseable {
+ @Override
+ public void close() {
+ closeCount++;
+ }
+ }
+
+}
+
+
diff --git a/core-java-9/src/test/java/com/baeldung/java9/process/ProcessApi.java b/core-java-9/src/test/java/com/baeldung/java9/process/ProcessApi.java
new file mode 100644
index 0000000000..419516cb64
--- /dev/null
+++ b/core-java-9/src/test/java/com/baeldung/java9/process/ProcessApi.java
@@ -0,0 +1,112 @@
+package com.baeldung.java9.process;
+
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Stream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ProcessApi {
+
+
+ @Before
+ public void init() {
+
+ }
+
+ @Test
+ public void processInfoExample()throws NoSuchAlgorithmException{
+ ProcessHandle self = ProcessHandle.current();
+ long PID = self.getPid();
+ ProcessHandle.Info procInfo = self.info();
+ Optional args = procInfo.arguments();
+ Optional cmd = procInfo.commandLine();
+ Optional startTime = procInfo.startInstant();
+ Optional cpuUsage = procInfo.totalCpuDuration();
+
+ waistCPU();
+ System.out.println("Args "+ args);
+ System.out.println("Command " +cmd.orElse("EmptyCmd"));
+ System.out.println("Start time: "+ startTime.get().toString());
+ System.out.println(cpuUsage.get().toMillis());
+
+ Stream allProc = ProcessHandle.current().children();
+ allProc.forEach(p -> {
+ System.out.println("Proc "+ p.getPid());
+ });
+
+ }
+
+ @Test
+ public void createAndDestroyProcess() throws IOException, InterruptedException{
+ int numberOfChildProcesses = 5;
+ for(int i=0; i < numberOfChildProcesses; i++){
+ createNewJVM(ServiceMain.class, i).getPid();
+ }
+
+ Stream childProc = ProcessHandle.current().children();
+ assertEquals( childProc.count(), numberOfChildProcesses);
+
+ childProc = ProcessHandle.current().children();
+ childProc.forEach(processHandle -> {
+ assertTrue("Process "+ processHandle.getPid() +" should be alive!", processHandle.isAlive());
+ CompletableFuture onProcExit = processHandle.onExit();
+ onProcExit.thenAccept(procHandle -> {
+ System.out.println("Process with PID "+ procHandle.getPid() + " has stopped");
+ });
+ });
+
+ Thread.sleep(10000);
+
+ childProc = ProcessHandle.current().children();
+ childProc.forEach(procHandle -> {
+ assertTrue("Could not kill process "+procHandle.getPid(), procHandle.destroy());
+ });
+
+ Thread.sleep(5000);
+
+ childProc = ProcessHandle.current().children();
+ childProc.forEach(procHandle -> {
+ assertFalse("Process "+ procHandle.getPid() +" should not be alive!", procHandle.isAlive());
+ });
+
+ }
+
+ private Process createNewJVM(Class mainClass, int number) throws IOException{
+ ArrayList cmdParams = new ArrayList(5);
+ cmdParams.add(ProcessUtils.getJavaCmd().getAbsolutePath());
+ cmdParams.add("-cp");
+ cmdParams.add(ProcessUtils.getClassPath());
+ cmdParams.add(mainClass.getName());
+ cmdParams.add("Service "+ number);
+ ProcessBuilder myService = new ProcessBuilder(cmdParams);
+ myService.inheritIO();
+ return myService.start();
+ }
+
+ private void waistCPU() throws NoSuchAlgorithmException{
+ ArrayList randArr = new ArrayList(4096);
+ SecureRandom sr = SecureRandom.getInstanceStrong();
+ Duration somecpu = Duration.ofMillis(4200L);
+ Instant end = Instant.now().plus(somecpu);
+ while (Instant.now().isBefore(end)) {
+ //System.out.println(sr.nextInt());
+ randArr.add( sr.nextInt() );
+ }
+ }
+
+}
diff --git a/core-java-9/src/test/resources/.gitignore b/core-java-9/src/test/resources/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-9/src/test/resources/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Animal.java b/core-java/src/main/java/com/baeldung/java/reflection/Animal.java
new file mode 100644
index 0000000000..3f36243c29
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Animal.java
@@ -0,0 +1,23 @@
+package com.baeldung.java.reflection;
+
+public abstract class Animal implements Eating {
+
+ public static final String CATEGORY = "domestic";
+
+ private String name;
+
+ public Animal(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ protected abstract String getSound();
+
+}
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Bird.java b/core-java/src/main/java/com/baeldung/java/reflection/Bird.java
new file mode 100644
index 0000000000..bd6f13094c
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Bird.java
@@ -0,0 +1,36 @@
+package com.baeldung.java.reflection;
+
+public class Bird extends Animal {
+ private boolean walks;
+
+ public Bird() {
+ super("bird");
+ }
+
+ public Bird(String name, boolean walks) {
+ super(name);
+ setWalks(walks);
+ }
+
+ public Bird(String name) {
+ super(name);
+ }
+
+ @Override
+ public String eats() {
+ return "grains";
+ }
+
+ @Override
+ protected String getSound() {
+ return "chaps";
+ }
+
+ public boolean walks() {
+ return walks;
+ }
+
+ public void setWalks(boolean walks) {
+ this.walks = walks;
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Eating.java b/core-java/src/main/java/com/baeldung/java/reflection/Eating.java
new file mode 100644
index 0000000000..479425cad4
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Eating.java
@@ -0,0 +1,5 @@
+package com.baeldung.java.reflection;
+
+public interface Eating {
+ String eats();
+}
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Goat.java b/core-java/src/main/java/com/baeldung/java/reflection/Goat.java
new file mode 100644
index 0000000000..503717ae5e
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Goat.java
@@ -0,0 +1,24 @@
+package com.baeldung.java.reflection;
+
+public class Goat extends Animal implements Locomotion {
+
+ public Goat(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String getSound() {
+ return "bleat";
+ }
+
+ @Override
+ public String getLocomotion() {
+ return "walks";
+ }
+
+ @Override
+ public String eats() {
+ return "grass";
+ }
+
+}
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Locomotion.java b/core-java/src/main/java/com/baeldung/java/reflection/Locomotion.java
new file mode 100644
index 0000000000..047c00cb13
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Locomotion.java
@@ -0,0 +1,5 @@
+package com.baeldung.java.reflection;
+
+public interface Locomotion {
+ String getLocomotion();
+}
diff --git a/core-java/src/main/java/com/baeldung/java/reflection/Person.java b/core-java/src/main/java/com/baeldung/java/reflection/Person.java
new file mode 100644
index 0000000000..f3d7f9f001
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java/reflection/Person.java
@@ -0,0 +1,6 @@
+package com.baeldung.java.reflection;
+
+public class Person {
+ private String name;
+ private int age;
+}
diff --git a/core-java/src/test/java/com/baeldung/java/reflection/ReflectionTest.java b/core-java/src/test/java/com/baeldung/java/reflection/ReflectionTest.java
new file mode 100644
index 0000000000..a12a2f205f
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/java/reflection/ReflectionTest.java
@@ -0,0 +1,326 @@
+package com.baeldung.java.reflection;
+
+import org.junit.Test;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import static org.junit.Assert.*;
+
+public class ReflectionTest {
+
+ @Test
+ public void givenObject_whenGetsFieldNamesAtRuntime_thenCorrect() {
+ Object person = new Person();
+ Field[] fields = person.getClass().getDeclaredFields();
+
+ List actualFieldNames = getFieldNames(fields);
+
+ assertTrue(Arrays.asList("name", "age")
+ .containsAll(actualFieldNames));
+ }
+
+ @Test
+ public void givenObject_whenGetsClassName_thenCorrect() {
+ Object goat = new Goat("goat");
+ Class> clazz = goat.getClass();
+
+ assertEquals("Goat", clazz.getSimpleName());
+ assertEquals("com.baeldung.java.reflection.Goat", clazz.getName());
+ assertEquals("com.baeldung.java.reflection.Goat", clazz.getCanonicalName());
+ }
+
+ @Test
+ public void givenClassName_whenCreatesObject_thenCorrect()
+ throws ClassNotFoundException {
+ Class> clazz = Class.forName("com.baeldung.java.reflection.Goat");
+
+ assertEquals("Goat", clazz.getSimpleName());
+ assertEquals("com.baeldung.java.reflection.Goat", clazz.getName());
+ assertEquals("com.baeldung.java.reflection.Goat", clazz.getCanonicalName());
+ }
+
+ @Test
+ public void givenClass_whenRecognisesModifiers_thenCorrect()
+ throws ClassNotFoundException {
+ Class> goatClass = Class.forName("com.baeldung.java.reflection.Goat");
+ Class> animalClass = Class.forName("com.baeldung.java.reflection.Animal");
+ int goatMods = goatClass.getModifiers();
+ int animalMods = animalClass.getModifiers();
+
+ assertTrue(Modifier.isPublic(goatMods));
+ assertTrue(Modifier.isAbstract(animalMods));
+ assertTrue(Modifier.isPublic(animalMods));
+ }
+
+ @Test
+ public void givenClass_whenGetsPackageInfo_thenCorrect() {
+ Goat goat = new Goat("goat");
+ Class> goatClass = goat.getClass();
+ Package pkg = goatClass.getPackage();
+
+ assertEquals("com.baeldung.java.reflection", pkg.getName());
+ }
+
+ @Test
+ public void givenClass_whenGetsSuperClass_thenCorrect() {
+ Goat goat = new Goat("goat");
+ String str = "any string";
+
+ Class> goatClass = goat.getClass();
+ Class> goatSuperClass = goatClass.getSuperclass();
+
+ assertEquals("Animal", goatSuperClass.getSimpleName());
+ assertEquals("Object", str.getClass().getSuperclass().getSimpleName());
+
+ }
+
+ @Test
+ public void givenClass_whenGetsImplementedInterfaces_thenCorrect()
+ throws ClassNotFoundException {
+ Class> goatClass = Class.forName("com.baeldung.java.reflection.Goat");
+ Class> animalClass = Class.forName("com.baeldung.java.reflection.Animal");
+ Class>[] goatInterfaces = goatClass.getInterfaces();
+ Class>[] animalInterfaces = animalClass.getInterfaces();
+
+ assertEquals(1, goatInterfaces.length);
+ assertEquals(1, animalInterfaces.length);
+ assertEquals("Locomotion", goatInterfaces[0].getSimpleName());
+ assertEquals("Eating", animalInterfaces[0].getSimpleName());
+ }
+
+ @Test
+ public void givenClass_whenGetsConstructor_thenCorrect()
+ throws ClassNotFoundException {
+ Class> goatClass = Class.forName("com.baeldung.java.reflection.Goat");
+ Constructor>[] constructors = goatClass.getConstructors();
+
+ assertEquals(1, constructors.length);
+ assertEquals("com.baeldung.java.reflection.Goat", constructors[0].getName());
+ }
+
+ @Test
+ public void givenClass_whenGetsFields_thenCorrect()
+ throws ClassNotFoundException {
+ Class> animalClass = Class.forName("com.baeldung.java.reflection.Animal");
+ Field[] fields = animalClass.getDeclaredFields();
+
+ List actualFields = getFieldNames(fields);
+
+ assertEquals(2, actualFields.size());
+ assertTrue(actualFields.containsAll(Arrays.asList("name", "CATEGORY")));
+ }
+
+ @Test
+ public void givenClass_whenGetsMethods_thenCorrect()
+ throws ClassNotFoundException {
+ Class> animalClass = Class.forName("com.baeldung.java.reflection.Animal");
+ Method[] methods = animalClass.getDeclaredMethods();
+ List actualMethods = getMethodNames(methods);
+
+ assertEquals(4, actualMethods.size());
+ assertTrue(actualMethods.containsAll(Arrays.asList("getName",
+ "setName", "getSound")));
+ }
+
+ @Test
+ public void givenClass_whenGetsAllConstructors_thenCorrect()
+ throws ClassNotFoundException {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Constructor>[] constructors = birdClass.getConstructors();
+
+ assertEquals(3, constructors.length);
+ }
+
+ @Test
+ public void givenClass_whenGetsEachConstructorByParamTypes_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Constructor> cons1 = birdClass.getConstructor();
+ Constructor> cons2 = birdClass.getConstructor(String.class);
+ Constructor> cons3 = birdClass.getConstructor(String.class,
+ boolean.class);
+ }
+
+ @Test
+ public void givenClass_whenInstantiatesObjectsAtRuntime_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+
+ Constructor> cons1 = birdClass.getConstructor();
+ Constructor> cons2 = birdClass.getConstructor(String.class);
+ Constructor> cons3 = birdClass.getConstructor(String.class,
+ boolean.class);
+
+ Bird bird1 = (Bird) cons1.newInstance();
+ Bird bird2 = (Bird) cons2.newInstance("Weaver bird");
+ Bird bird3 = (Bird) cons3.newInstance("dove", true);
+
+ assertEquals("bird", bird1.getName());
+ assertEquals("Weaver bird", bird2.getName());
+ assertEquals("dove", bird3.getName());
+ assertFalse(bird1.walks());
+ assertTrue(bird3.walks());
+ }
+
+ @Test
+ public void givenClass_whenGetsPublicFields_thenCorrect()
+ throws ClassNotFoundException {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Field[] fields = birdClass.getFields();
+ assertEquals(1, fields.length);
+ assertEquals("CATEGORY", fields[0].getName());
+
+ }
+
+ @Test
+ public void givenClass_whenGetsPublicFieldByName_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Field field = birdClass.getField("CATEGORY");
+ assertEquals("CATEGORY", field.getName());
+
+ }
+
+ @Test
+ public void givenClass_whenGetsDeclaredFields_thenCorrect()
+ throws ClassNotFoundException {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Field[] fields = birdClass.getDeclaredFields();
+ assertEquals(1, fields.length);
+ assertEquals("walks", fields[0].getName());
+ }
+
+ @Test
+ public void givenClass_whenGetsFieldsByName_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Field field = birdClass.getDeclaredField("walks");
+ assertEquals("walks", field.getName());
+
+ }
+
+ @Test
+ public void givenClassField_whenGetsType_thenCorrect()
+ throws Exception {
+ Field field = Class.forName("com.baeldung.java.reflection.Bird")
+ .getDeclaredField("walks");
+ Class> fieldClass = field.getType();
+ assertEquals("boolean", fieldClass.getSimpleName());
+ }
+
+ @Test
+ public void givenClassField_whenSetsAndGetsValue_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Bird bird = (Bird) birdClass.newInstance();
+ Field field = birdClass.getDeclaredField("walks");
+ field.setAccessible(true);
+
+ assertFalse(field.getBoolean(bird));
+ assertFalse(bird.walks());
+
+ field.set(bird, true);
+
+ assertTrue(field.getBoolean(bird));
+ assertTrue(bird.walks());
+
+ }
+
+ @Test
+ public void givenClassField_whenGetsAndSetsWithNull_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Field field = birdClass.getField("CATEGORY");
+ field.setAccessible(true);
+
+ assertEquals("domestic", field.get(null));
+ }
+
+ @Test
+ public void givenClass_whenGetsAllPublicMethods_thenCorrect()
+ throws ClassNotFoundException {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Method[] methods = birdClass.getMethods();
+ List methodNames = getMethodNames(methods);
+
+ assertTrue(methodNames.containsAll(Arrays
+ .asList("equals", "notifyAll", "hashCode",
+ "walks", "eats", "toString")));
+
+ }
+
+ @Test
+ public void givenClass_whenGetsOnlyDeclaredMethods_thenCorrect()
+ throws ClassNotFoundException {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ List actualMethodNames = getMethodNames(birdClass.getDeclaredMethods());
+
+ List expectedMethodNames = Arrays.asList("setWalks", "walks", "getSound", "eats");
+
+ assertEquals(expectedMethodNames.size(), actualMethodNames.size());
+ assertTrue(expectedMethodNames.containsAll(actualMethodNames));
+ assertTrue(actualMethodNames.containsAll(expectedMethodNames));
+
+ }
+
+ @Test
+ public void givenMethodName_whenGetsMethod_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Method walksMethod = birdClass.getDeclaredMethod("walks");
+ Method setWalksMethod = birdClass.getDeclaredMethod("setWalks",
+ boolean.class);
+
+ assertFalse(walksMethod.isAccessible());
+ assertFalse(setWalksMethod.isAccessible());
+
+ walksMethod.setAccessible(true);
+ setWalksMethod.setAccessible(true);
+
+ assertTrue(walksMethod.isAccessible());
+ assertTrue(setWalksMethod.isAccessible());
+
+ }
+
+ @Test
+ public void givenMethod_whenInvokes_thenCorrect()
+ throws Exception {
+ Class> birdClass = Class.forName("com.baeldung.java.reflection.Bird");
+ Bird bird = (Bird) birdClass.newInstance();
+ Method setWalksMethod = birdClass.getDeclaredMethod("setWalks",
+ boolean.class);
+ Method walksMethod = birdClass.getDeclaredMethod("walks");
+ boolean walks = (boolean) walksMethod.invoke(bird);
+
+ assertFalse(walks);
+ assertFalse(bird.walks());
+
+ setWalksMethod.invoke(bird, true);
+ boolean walks2 = (boolean) walksMethod.invoke(bird);
+
+ assertTrue(walks2);
+ assertTrue(bird.walks());
+
+ }
+
+ private static List getFieldNames(Field[] fields) {
+ List fieldNames = new ArrayList<>();
+ for (Field field : fields)
+ fieldNames.add(field.getName());
+ return fieldNames;
+
+ }
+
+ private static List getMethodNames(Method[] methods) {
+ List methodNames = new ArrayList<>();
+ for (Method method : methods)
+ methodNames.add(method.getName());
+ return methodNames;
+ }
+
+}
diff --git a/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java b/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java
index 4996a1f0a2..30b0111555 100644
--- a/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java
+++ b/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java
@@ -1,63 +1,65 @@
package org.baeldung.java.collections;
+import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import java.util.stream.*;
+import static java.util.stream.Collectors.*;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.*;
public class ArrayListTest {
- List stringsToSearch;
+ private List stringsToSearch;
@Before
public void setUp() {
- List xs = LongStream.range(0, 16)
- .boxed()
- .map(Long::toHexString)
- .collect(Collectors.toList());
- stringsToSearch = new ArrayList<>(xs);
- stringsToSearch.addAll(xs);
+ List list = LongStream.range(0, 16)
+ .boxed()
+ .map(Long::toHexString)
+ .collect(toCollection(ArrayList::new));
+ stringsToSearch = new ArrayList<>(list);
+ stringsToSearch.addAll(list);
}
@Test
public void givenNewArrayList_whenCheckCapacity_thenDefaultValue() {
- List xs = new ArrayList<>();
- assertTrue(xs.isEmpty());
+ List list = new ArrayList<>();
+ assertTrue(list.isEmpty());
}
@Test
public void givenCollection_whenProvideItToArrayListCtor_thenArrayListIsPopulatedWithItsElements() {
Collection numbers =
- IntStream.range(0, 10).boxed().collect(Collectors.toSet());
+ IntStream.range(0, 10).boxed().collect(toSet());
- List xs = new ArrayList<>(numbers);
- assertEquals(10, xs.size());
- assertTrue(numbers.containsAll(xs));
+ List list = new ArrayList<>(numbers);
+ assertEquals(10, list.size());
+ assertTrue(numbers.containsAll(list));
}
@Test
public void givenElement_whenAddToArrayList_thenIsAdded() {
- List xs = new ArrayList<>();
+ List list = new ArrayList<>();
- xs.add(1L);
- xs.add(2L);
- xs.add(1, 3L);
+ list.add(1L);
+ list.add(2L);
+ list.add(1, 3L);
- assertThat(Arrays.asList(1L, 3L, 2L), equalTo(xs));
+ assertThat(Arrays.asList(1L, 3L, 2L), equalTo(list));
}
@Test
public void givenCollection_whenAddToArrayList_thenIsAdded() {
- List xs = new ArrayList<>(Arrays.asList(1L, 2L, 3L));
- Collection ys = LongStream.range(4, 10).boxed().collect(Collectors.toList());
- xs.addAll(0, ys);
+ List list = new ArrayList<>(Arrays.asList(1L, 2L, 3L));
+ LongStream.range(4, 10).boxed()
+ .collect(collectingAndThen(toCollection(ArrayList::new), ys -> list.addAll(0, ys)));
- assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(xs));
+ assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(list));
}
@Test
@@ -87,9 +89,9 @@ public class ArrayListTest {
Set matchingStrings = new HashSet<>(Arrays.asList("a", "c", "9"));
List result = stringsToSearch
- .stream()
- .filter(matchingStrings::contains)
- .collect(Collectors.toList());
+ .stream()
+ .filter(matchingStrings::contains)
+ .collect(toCollection(ArrayList::new));
assertEquals(6, result.size());
}
@@ -104,37 +106,33 @@ public class ArrayListTest {
@Test
public void givenIndex_whenRemove_thenCorrectElementRemoved() {
- List xs = new ArrayList<>(
- IntStream.range(0, 10).boxed().collect(Collectors.toList())
- );
- Collections.reverse(xs);
+ List list = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new));
+ Collections.reverse(list);
- xs.remove(0);
- assertThat(xs.get(0), equalTo(8));
+ list.remove(0);
+ assertThat(list.get(0), equalTo(8));
- xs.remove(Integer.valueOf(0));
- assertFalse(xs.contains(0));
+ list.remove(Integer.valueOf(0));
+ assertFalse(list.contains(0));
}
@Test
public void givenListIterator_whenReverseTraversal_thenRetrieveElementsInOppositeOrder() {
- List xs = new ArrayList<>(
- IntStream.range(0, 10).boxed().collect(Collectors.toList())
- );
- ListIterator it = xs.listIterator(xs.size());
- List result = new ArrayList<>(xs.size());
+ List list = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new));
+ ListIterator it = list.listIterator(list.size());
+ List result = new ArrayList<>(list.size());
while (it.hasPrevious()) {
result.add(it.previous());
}
- Collections.reverse(xs);
- assertThat(result, equalTo(xs));
+ Collections.reverse(list);
+ assertThat(result, equalTo(list));
}
@Test
public void givenCondition_whenIterateArrayList_thenRemoveAllElementsSatisfyingCondition() {
Set matchingStrings
- = new HashSet<>(Arrays.asList("a", "b", "c", "d", "e", "f"));
+ = Sets.newHashSet("a", "b", "c", "d", "e", "f");
Iterator it = stringsToSearch.iterator();
while (it.hasNext()) {
diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
index f8c85ab8b5..3f7723facd 100644
--- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
+++ b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
@@ -5,63 +5,59 @@ import java.util.HashSet;
public class ComplexClass {
- private ArrayList> genericArrayList;
- private HashSet integerHashSet;
+ private ArrayList> genericArrayList;
+ private HashSet integerHashSet;
- public ComplexClass(ArrayList> genericArrayList,
- HashSet integerHashSet) {
- super();
- this.genericArrayList = genericArrayList;
- this.integerHashSet = integerHashSet;
- }
+ public ComplexClass(ArrayList> genericArrayList, HashSet integerHashSet) {
+ super();
+ this.genericArrayList = genericArrayList;
+ this.integerHashSet = integerHashSet;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime
- * result
- + ((genericArrayList == null) ? 0 : genericArrayList.hashCode());
- result = prime * result
- + ((integerHashSet == null) ? 0 : integerHashSet.hashCode());
- return result;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((genericArrayList == null) ? 0 : genericArrayList.hashCode());
+ result = prime * result + ((integerHashSet == null) ? 0 : integerHashSet.hashCode());
+ return result;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof ComplexClass))
- return false;
- ComplexClass other = (ComplexClass) obj;
- if (genericArrayList == null) {
- if (other.genericArrayList != null)
- return false;
- } else if (!genericArrayList.equals(other.genericArrayList))
- return false;
- if (integerHashSet == null) {
- if (other.integerHashSet != null)
- return false;
- } else if (!integerHashSet.equals(other.integerHashSet))
- return false;
- return true;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof ComplexClass))
+ return false;
+ ComplexClass other = (ComplexClass) obj;
+ if (genericArrayList == null) {
+ if (other.genericArrayList != null)
+ return false;
+ } else if (!genericArrayList.equals(other.genericArrayList))
+ return false;
+ if (integerHashSet == null) {
+ if (other.integerHashSet != null)
+ return false;
+ } else if (!integerHashSet.equals(other.integerHashSet))
+ return false;
+ return true;
+ }
- protected ArrayList> getGenericArrayList() {
- return genericArrayList;
- }
+ protected ArrayList> getGenericArrayList() {
+ return genericArrayList;
+ }
- protected void setGenericArrayList(ArrayList> genericArrayList) {
- this.genericArrayList = genericArrayList;
- }
+ protected void setGenericArrayList(ArrayList> genericArrayList) {
+ this.genericArrayList = genericArrayList;
+ }
- protected HashSet getIntegerHashSet() {
- return integerHashSet;
- }
+ protected HashSet getIntegerHashSet() {
+ return integerHashSet;
+ }
- protected void setIntegerHashSet(HashSet integerHashSet) {
- this.integerHashSet = integerHashSet;
- }
+ protected void setIntegerHashSet(HashSet integerHashSet) {
+ this.integerHashSet = integerHashSet;
+ }
}
diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
index 6cd4af5fdb..ebe005688c 100644
--- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
+++ b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
@@ -2,53 +2,53 @@ package org.baeldung.equalshashcode.entities;
public class PrimitiveClass {
- private boolean primitiveBoolean;
- private int primitiveInt;
+ private boolean primitiveBoolean;
+ private int primitiveInt;
- public PrimitiveClass(boolean primitiveBoolean, int primitiveInt) {
- super();
- this.primitiveBoolean = primitiveBoolean;
- this.primitiveInt = primitiveInt;
- }
+ public PrimitiveClass(boolean primitiveBoolean, int primitiveInt) {
+ super();
+ this.primitiveBoolean = primitiveBoolean;
+ this.primitiveInt = primitiveInt;
+ }
- protected boolean isPrimitiveBoolean() {
- return primitiveBoolean;
- }
+ protected boolean isPrimitiveBoolean() {
+ return primitiveBoolean;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (primitiveBoolean ? 1231 : 1237);
- result = prime * result + primitiveInt;
- return result;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (primitiveBoolean ? 1231 : 1237);
+ result = prime * result + primitiveInt;
+ return result;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- PrimitiveClass other = (PrimitiveClass) obj;
- if (primitiveBoolean != other.primitiveBoolean)
- return false;
- if (primitiveInt != other.primitiveInt)
- return false;
- return true;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PrimitiveClass other = (PrimitiveClass) obj;
+ if (primitiveBoolean != other.primitiveBoolean)
+ return false;
+ if (primitiveInt != other.primitiveInt)
+ return false;
+ return true;
+ }
- protected void setPrimitiveBoolean(boolean primitiveBoolean) {
- this.primitiveBoolean = primitiveBoolean;
- }
+ protected void setPrimitiveBoolean(boolean primitiveBoolean) {
+ this.primitiveBoolean = primitiveBoolean;
+ }
- protected int getPrimitiveInt() {
- return primitiveInt;
- }
+ protected int getPrimitiveInt() {
+ return primitiveInt;
+ }
- protected void setPrimitiveInt(int primitiveInt) {
- this.primitiveInt = primitiveInt;
- }
+ protected void setPrimitiveInt(int primitiveInt) {
+ this.primitiveInt = primitiveInt;
+ }
}
diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
index 61d20cbb05..315ef41a12 100644
--- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
+++ b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
@@ -1,62 +1,60 @@
package org.baeldung.equalshashcode.entities;
public class Rectangle extends Shape {
- private double width;
- private double length;
+ private double width;
+ private double length;
- public Rectangle(double width, double length) {
- this.width = width;
- this.length = length;
- }
+ public Rectangle(double width, double length) {
+ this.width = width;
+ this.length = length;
+ }
- @Override
- public double area() {
- // A = w * l
- return width * length;
- }
+ @Override
+ public double area() {
+ // A = w * l
+ return width * length;
+ }
- @Override
- public double perimeter() {
- // P = 2(w + l)
- return 2 * (width + length);
- }
+ @Override
+ public double perimeter() {
+ // P = 2(w + l)
+ return 2 * (width + length);
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- long temp;
- temp = Double.doubleToLongBits(length);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- temp = Double.doubleToLongBits(width);
- result = prime * result + (int) (temp ^ (temp >>> 32));
- return result;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ long temp;
+ temp = Double.doubleToLongBits(length);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(width);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Rectangle other = (Rectangle) obj;
- if (Double.doubleToLongBits(length) != Double
- .doubleToLongBits(other.length))
- return false;
- if (Double.doubleToLongBits(width) != Double
- .doubleToLongBits(other.width))
- return false;
- return true;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Rectangle other = (Rectangle) obj;
+ if (Double.doubleToLongBits(length) != Double.doubleToLongBits(other.length))
+ return false;
+ if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width))
+ return false;
+ return true;
+ }
- protected double getWidth() {
- return width;
- }
+ protected double getWidth() {
+ return width;
+ }
- protected double getLength() {
- return length;
- }
+ protected double getLength() {
+ return length;
+ }
}
\ No newline at end of file
diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
index 7f779e6ef2..3bfc81da8f 100644
--- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
+++ b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
@@ -1,7 +1,7 @@
package org.baeldung.equalshashcode.entities;
public abstract class Shape {
- public abstract double area();
+ public abstract double area();
- public abstract double perimeter();
+ public abstract double perimeter();
}
diff --git a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java
index 0bebc1e380..f11e34f0ba 100644
--- a/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java
+++ b/eclipse/src/main/java/org/baeldung/equalshashcode/entities/Square.java
@@ -4,44 +4,55 @@ import java.awt.Color;
public class Square extends Rectangle {
- Color color;
+ Color color;
- public Square(double width, Color color) {
- super(width, width);
- this.color = color;
- }
+ public Square(double width, Color color) {
+ super(width, width);
+ this.color = color;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((color == null) ? 0 : color.hashCode());
- return result;
- }
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((color == null) ? 0 : color.hashCode());
+ return result;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- Square other = (Square) obj;
- if (color == null) {
- if (other.color != null)
- return false;
- } else if (!color.equals(other.color))
- return false;
- return true;
- }
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (!(obj instanceof Square)) {
+ return false;
+ }
+ Square other = (Square) obj;
+ if (color == null) {
+ if (other.color != null) {
+ return false;
+ }
+ } else if (!color.equals(other.color)) {
+ return false;
+ }
+ return true;
+ }
- protected Color getColor() {
- return color;
- }
+ protected Color getColor() {
+ return color;
+ }
- protected void setColor(Color color) {
- this.color = color;
- }
+ protected void setColor(Color color) {
+ this.color = color;
+ }
}
diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java
index 2cca44bb9e..09123e988b 100644
--- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java
+++ b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/ComplexClassTest.java
@@ -8,32 +8,27 @@ import org.junit.Test;
public class ComplexClassTest {
- @Test
- public void testEqualsAndHashcodes() {
-
- ArrayList strArrayList = new ArrayList();
- strArrayList.add("abc");
- strArrayList.add("def");
- ComplexClass aObject = new ComplexClass(strArrayList, new HashSet(45,67));
- ComplexClass bObject = new ComplexClass(strArrayList, new HashSet(45,67));
- ComplexClass cObject = new ComplexClass(strArrayList, new HashSet(45,67));
-
- ArrayList strArrayListD = new ArrayList();
- strArrayListD.add("lmn");
- strArrayListD.add("pqr");
- ComplexClass dObject = new ComplexClass(strArrayListD, new HashSet(45,67));
-
- // equals()
- Assert.assertTrue(aObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject));
- Assert.assertTrue(bObject.equals(cObject));
- Assert.assertTrue(aObject.equals(cObject));
- // hashCode()
- Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
- // non-equal objects are not equals() and have different hashCode()
- Assert.assertFalse(aObject.equals(dObject));
- Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
- }
+ @Test
+ public void testEqualsAndHashcodes() {
+
+ ArrayList strArrayList = new ArrayList();
+ strArrayList.add("abc");
+ strArrayList.add("def");
+ ComplexClass aObject = new ComplexClass(strArrayList, new HashSet(45, 67));
+ ComplexClass bObject = new ComplexClass(strArrayList, new HashSet(45, 67));
+
+ ArrayList strArrayListD = new ArrayList();
+ strArrayListD.add("lmn");
+ strArrayListD.add("pqr");
+ ComplexClass dObject = new ComplexClass(strArrayListD, new HashSet(45, 67));
+
+ // equals()
+ Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
+ // hashCode()
+ Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
+ // non-equal objects are not equals() and have different hashCode()
+ Assert.assertFalse(aObject.equals(dObject));
+ Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
+ }
}
diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java
index 009753d1ae..feb04d65ff 100644
--- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java
+++ b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/PrimitiveClassTest.java
@@ -5,25 +5,20 @@ import org.junit.Test;
public class PrimitiveClassTest {
- @Test
- public void testTwoEqualsObjects() {
+ @Test
+ public void testTwoEqualsObjects() {
- PrimitiveClass aObject = new PrimitiveClass(false, 2);
- PrimitiveClass bObject = new PrimitiveClass(false, 2);
- PrimitiveClass cObject = new PrimitiveClass(false, 2);
- PrimitiveClass dObject = new PrimitiveClass(true, 2);
+ PrimitiveClass aObject = new PrimitiveClass(false, 2);
+ PrimitiveClass bObject = new PrimitiveClass(false, 2);
+ PrimitiveClass dObject = new PrimitiveClass(true, 2);
- // equals()
- Assert.assertTrue(aObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject));
- Assert.assertTrue(bObject.equals(cObject));
- Assert.assertTrue(aObject.equals(cObject));
- // hashCode()
- Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
- // non-equal objects are not equals() and have different hashCode()
- Assert.assertFalse(aObject.equals(dObject));
- Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
- }
+ // equals()
+ Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
+ // hashCode()
+ Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
+ // non-equal objects are not equals() and have different hashCode()
+ Assert.assertFalse(aObject.equals(dObject));
+ Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
+ }
}
diff --git a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java
index 1290f57c6d..53ca199405 100644
--- a/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java
+++ b/eclipse/src/test/java/org/baeldung/equalshashcode/entities/SquareClassTest.java
@@ -7,26 +7,21 @@ import org.junit.Test;
public class SquareClassTest {
- @Test
- public void testEqualsAndHashcodes() {
-
- Square aObject = new Square(10, Color.BLUE);
- Square bObject = new Square(10, Color.BLUE);
- Square cObject = new Square(10, Color.BLUE);
-
- Square dObject = new Square(20, Color.BLUE);
-
- // equals()
- Assert.assertTrue(aObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
- Assert.assertTrue(aObject.equals(bObject));
- Assert.assertTrue(bObject.equals(cObject));
- Assert.assertTrue(aObject.equals(cObject));
- // hashCode()
- Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
- // non-equal objects are not equals() and have different hashCode()
- Assert.assertFalse(aObject.equals(dObject));
- Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
- }
+ @Test
+ public void testEqualsAndHashcodes() {
+
+ Square aObject = new Square(10, Color.BLUE);
+ Square bObject = new Square(10, Color.BLUE);
+
+ Square dObject = new Square(20, Color.BLUE);
+
+ // equals()
+ Assert.assertTrue(aObject.equals(bObject) && bObject.equals(aObject));
+ // hashCode()
+ Assert.assertTrue(aObject.hashCode() == bObject.hashCode());
+ // non-equal objects are not equals() and have different hashCode()
+ Assert.assertFalse(aObject.equals(dObject));
+ Assert.assertFalse(aObject.hashCode() == dObject.hashCode());
+ }
}
diff --git a/enterprise-patterns/front-controller-pattern/pom.xml b/enterprise-patterns/front-controller-pattern/pom.xml
index 5fbe5730cb..d1868b81af 100644
--- a/enterprise-patterns/front-controller-pattern/pom.xml
+++ b/enterprise-patterns/front-controller-pattern/pom.xml
@@ -31,7 +31,11 @@
org.eclipse.jetty
jetty-maven-plugin
+<<<<<<< HEAD
9.3.11.v20160721
+=======
+ 9.4.0.M1
+>>>>>>> upstream/master
/front-controller
diff --git a/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.png b/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.png
new file mode 100644
index 0000000000..bd475bf3f3
Binary files /dev/null and b/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.png differ
diff --git a/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.puml b/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.puml
new file mode 100644
index 0000000000..fbd4f416ef
--- /dev/null
+++ b/enterprise-patterns/front-controller-pattern/src/main/resources/front controller.puml
@@ -0,0 +1,22 @@
+@startuml
+
+class Handler {
+doGet
+doPost
+}
+
+abstract class AbstractCommand {
+process
+}
+class ConcreteCommand1 {
+process
+}
+class ConcreteCommand2 {
+process
+}
+
+Handler .right.> AbstractCommand
+AbstractCommand <|-- ConcreteCommand1
+AbstractCommand <|-- ConcreteCommand2
+
+@enduml
\ No newline at end of file
diff --git a/feign-client/README.md b/feign-client/README.md
new file mode 100644
index 0000000000..e6ade4d161
--- /dev/null
+++ b/feign-client/README.md
@@ -0,0 +1,5 @@
+## Feign Hypermedia Client ##
+
+This is the implementation of a [spring-hypermedia-api][1] client using Feign.
+
+[1]: https://github.com/eugenp/spring-hypermedia-api
diff --git a/feign-client/pom.xml b/feign-client/pom.xml
new file mode 100644
index 0000000000..af61883f1b
--- /dev/null
+++ b/feign-client/pom.xml
@@ -0,0 +1,99 @@
+
+
+ 4.0.0
+
+ com.baeldung.feign
+ feign-client
+ 1.0.0-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ..
+
+
+
+ UTF-8
+
+
+
+
+ io.github.openfeign
+ feign-core
+ 9.3.1
+
+
+ io.github.openfeign
+ feign-okhttp
+ 9.3.1
+
+
+ io.github.openfeign
+ feign-gson
+ 9.3.1
+
+
+ io.github.openfeign
+ feign-slf4j
+ 9.3.1
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.6.2
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ 2.6.2
+
+
+ org.projectlombok
+ lombok
+ 1.16.10
+ provided
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.19.1
+
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.4.0.RELEASE
+
+
+
+
+
diff --git a/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java
new file mode 100644
index 0000000000..9c0c359d88
--- /dev/null
+++ b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java
@@ -0,0 +1,26 @@
+package com.baeldung.feign;
+
+import com.baeldung.feign.clients.BookClient;
+import feign.Feign;
+import feign.Logger;
+import feign.gson.GsonDecoder;
+import feign.gson.GsonEncoder;
+import feign.okhttp.OkHttpClient;
+import feign.slf4j.Slf4jLogger;
+import lombok.Getter;
+
+@Getter
+public class BookControllerFeignClientBuilder {
+ private BookClient bookClient = createClient(BookClient.class,
+ "http://localhost:8081/api/books");
+
+ private static T createClient(Class type, String uri) {
+ return Feign.builder()
+ .client(new OkHttpClient())
+ .encoder(new GsonEncoder())
+ .decoder(new GsonDecoder())
+ .logger(new Slf4jLogger(type))
+ .logLevel(Logger.Level.FULL)
+ .target(type, uri);
+ }
+}
diff --git a/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java b/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java
new file mode 100644
index 0000000000..df20ef8f93
--- /dev/null
+++ b/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java
@@ -0,0 +1,21 @@
+package com.baeldung.feign.clients;
+
+import com.baeldung.feign.models.Book;
+import com.baeldung.feign.models.BookResource;
+import feign.Headers;
+import feign.Param;
+import feign.RequestLine;
+
+import java.util.List;
+
+public interface BookClient {
+ @RequestLine("GET /{isbn}")
+ BookResource findByIsbn(@Param("isbn") String isbn);
+
+ @RequestLine("GET")
+ List findAll();
+
+ @RequestLine("POST")
+ @Headers("Content-Type: application/json")
+ void create(Book book);
+}
diff --git a/feign-client/src/main/java/com/baeldung/feign/models/Book.java b/feign-client/src/main/java/com/baeldung/feign/models/Book.java
new file mode 100644
index 0000000000..cda4412e27
--- /dev/null
+++ b/feign-client/src/main/java/com/baeldung/feign/models/Book.java
@@ -0,0 +1,18 @@
+package com.baeldung.feign.models;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class Book {
+ private String isbn;
+ private String author;
+ private String title;
+ private String synopsis;
+ private String language;
+}
diff --git a/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java b/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java
new file mode 100644
index 0000000000..7902db9fe8
--- /dev/null
+++ b/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java
@@ -0,0 +1,14 @@
+package com.baeldung.feign.models;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+@Data
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class BookResource {
+ private Book book;
+}
diff --git a/feign-client/src/main/resources/log4j2.xml b/feign-client/src/main/resources/log4j2.xml
new file mode 100644
index 0000000000..659c5fda0e
--- /dev/null
+++ b/feign-client/src/main/resources/log4j2.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java
new file mode 100644
index 0000000000..e7e058a336
--- /dev/null
+++ b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java
@@ -0,0 +1,58 @@
+package com.baeldung.feign.clients;
+
+import com.baeldung.feign.BookControllerFeignClientBuilder;
+import com.baeldung.feign.models.Book;
+import com.baeldung.feign.models.BookResource;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+@Slf4j
+@RunWith(JUnit4.class)
+public class BookClientTest {
+ private BookClient bookClient;
+
+ @Before
+ public void setup() {
+ BookControllerFeignClientBuilder feignClientBuilder = new BookControllerFeignClientBuilder();
+ bookClient = feignClientBuilder.getBookClient();
+ }
+
+ @Test
+ public void givenBookClient_shouldRunSuccessfully() throws Exception {
+ List books = bookClient.findAll().stream()
+ .map(BookResource::getBook)
+ .collect(Collectors.toList());
+ assertTrue(books.size() > 2);
+ log.info("{}", books);
+ }
+
+ @Test
+ public void givenBookClient_shouldFindOneBook() throws Exception {
+ Book book = bookClient.findByIsbn("0151072558").getBook();
+ assertThat(book.getAuthor(), containsString("Orwell"));
+ log.info("{}", book);
+ }
+
+ @Test
+ public void givenBookClient_shouldPostBook() throws Exception {
+ String isbn = UUID.randomUUID().toString();
+ Book book = new Book(isbn, "Me", "It's me!", null, null);
+ bookClient.create(book);
+
+ book = bookClient.findByIsbn(isbn).getBook();
+ assertThat(book.getAuthor(), is("Me"));
+ log.info("{}", book);
+ }
+}
diff --git a/flyway-migration/.gitignore b/flyway-migration/.gitignore
new file mode 100644
index 0000000000..abffe04ed2
--- /dev/null
+++ b/flyway-migration/.gitignore
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target/
\ No newline at end of file
diff --git a/flyway-migration/db/migration/V1_0__create_employee_schema.sql b/flyway-migration/db/migration/V1_0__create_employee_schema.sql
new file mode 100644
index 0000000000..09408faecb
--- /dev/null
+++ b/flyway-migration/db/migration/V1_0__create_employee_schema.sql
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS `employee` (
+
+`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
+`name` varchar(20),
+`email` varchar(50),
+`date_of_birth` timestamp
+
+)ENGINE=InnoDB DEFAULT CHARSET=UTF8;
\ No newline at end of file
diff --git a/flyway-migration/db/migration/V2_0__create_department_schema.sql b/flyway-migration/db/migration/V2_0__create_department_schema.sql
new file mode 100644
index 0000000000..2b9d3364a5
--- /dev/null
+++ b/flyway-migration/db/migration/V2_0__create_department_schema.sql
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS `department` (
+
+`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
+`name` varchar(20)
+
+)ENGINE=InnoDB DEFAULT CHARSET=UTF8;
+
+ALTER TABLE `employee` ADD `dept_id` int AFTER `email`;
\ No newline at end of file
diff --git a/flyway-migration/myFlywayConfig.properties b/flyway-migration/myFlywayConfig.properties
new file mode 100644
index 0000000000..22f3afefd3
--- /dev/null
+++ b/flyway-migration/myFlywayConfig.properties
@@ -0,0 +1,5 @@
+flyway.user=root
+flyway.password=mysql
+flyway.schemas=app-db
+flyway.url=jdbc:mysql://localhost:3306/
+flyway.locations=filesystem:db/migration
\ No newline at end of file
diff --git a/flyway-migration/pom.xml b/flyway-migration/pom.xml
new file mode 100644
index 0000000000..6e9d683a0e
--- /dev/null
+++ b/flyway-migration/pom.xml
@@ -0,0 +1,34 @@
+
+ 4.0.0
+ com.baeldung
+ flyway-migration
+ 1.0
+ flyway-migration
+ A sample project to demonstrate Flyway migrations
+
+
+ mysql
+ mysql-connector-java
+ 6.0.3
+
+
+
+
+
+ org.flywaydb
+ flyway-maven-plugin
+ 4.0.3
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+ 1.8
+
+
+
+
+
\ No newline at end of file
diff --git a/java-cassandra/pom.xml b/java-cassandra/pom.xml
new file mode 100644
index 0000000000..265a230eb4
--- /dev/null
+++ b/java-cassandra/pom.xml
@@ -0,0 +1,102 @@
+
+ 4.0.0
+ com.baeldung
+ cassandra-java-client
+ 1.0.0-SNAPSHOT
+
+ cassandra-java-client
+
+
+ UTF-8
+
+
+ 1.7.21
+ 1.1.7
+
+
+ 1.3
+ 4.12
+ 1.10.19
+ 6.8
+ 3.5.1
+
+
+ 3.5.1
+
+
+ 3.1.0
+
+
+
+
+
+ com.datastax.cassandra
+ cassandra-driver-core
+ ${cassandra-driver-core.version}
+ true
+
+
+
+
+ org.cassandraunit
+ cassandra-unit
+ 3.0.0.1
+
+
+
+
+ com.google.guava
+ guava
+ 19.0
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${org.slf4j.version}
+
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+ java-cassandra
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.8
+ 1.8
+
+
+
+
+
+
diff --git a/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraClient.java b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraClient.java
new file mode 100644
index 0000000000..c67a2c2ddb
--- /dev/null
+++ b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraClient.java
@@ -0,0 +1,44 @@
+package com.baeldung.cassandra.java.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.baeldung.cassandra.java.client.domain.Book;
+import com.baeldung.cassandra.java.client.repository.BookRepository;
+import com.baeldung.cassandra.java.client.repository.KeyspaceRepository;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.utils.UUIDs;
+
+public class CassandraClient {
+ private static final Logger LOG = LoggerFactory.getLogger(CassandraClient.class);
+
+ public static void main(String args[]) {
+ CassandraConnector connector = new CassandraConnector();
+ connector.connect("127.0.0.1", null);
+ Session session = connector.getSession();
+
+ KeyspaceRepository sr = new KeyspaceRepository(session);
+ sr.createKeyspace("library", "SimpleStrategy", 1);
+ sr.useKeyspace("library");
+
+ BookRepository br = new BookRepository(session);
+ br.createTable();
+ br.alterTablebooks("publisher", "text");
+
+ br.createTableBooksByTitle();
+
+ Book book = new Book(UUIDs.timeBased(), "Effective Java", "Joshua Bloch", "Programming");
+ br.insertBookBatch(book);
+
+ br.selectAll().forEach(o -> LOG.info("Title in books: " + o.getTitle()));
+ br.selectAllBookByTitle().forEach(o -> LOG.info("Title in booksByTitle: " + o.getTitle()));
+
+ br.deletebookByTitle("Effective Java");
+ br.deleteTable("books");
+ br.deleteTable("booksByTitle");
+
+ sr.deleteKeyspace("library");
+
+ connector.close();
+ }
+}
diff --git a/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraConnector.java b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraConnector.java
new file mode 100644
index 0000000000..e035335ca0
--- /dev/null
+++ b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/CassandraConnector.java
@@ -0,0 +1,51 @@
+package com.baeldung.cassandra.java.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Cluster.Builder;
+import com.datastax.driver.core.Host;
+import com.datastax.driver.core.Metadata;
+import com.datastax.driver.core.Session;
+
+/**
+ *
+ * This is an implementation of a simple Java client.
+ *
+ */
+public class CassandraConnector {
+ private static final Logger LOG = LoggerFactory.getLogger(CassandraConnector.class);
+
+ private Cluster cluster;
+
+ private Session session;
+
+ public void connect(final String node, final Integer port) {
+
+ Builder b = Cluster.builder().addContactPoint(node);
+
+ if (port != null) {
+ b.withPort(port);
+ }
+ cluster = b.build();
+
+ Metadata metadata = cluster.getMetadata();
+ LOG.info("Cluster name: " + metadata.getClusterName());
+
+ for (Host host : metadata.getAllHosts()) {
+ LOG.info("Datacenter: " + host.getDatacenter() + " Host: " + host.getAddress() + " Rack: " + host.getRack());
+ }
+
+ session = cluster.connect();
+ }
+
+ public Session getSession() {
+ return this.session;
+ }
+
+ public void close() {
+ session.close();
+ cluster.close();
+ }
+}
diff --git a/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/domain/Book.java b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/domain/Book.java
new file mode 100644
index 0000000000..e6c7753eb3
--- /dev/null
+++ b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/domain/Book.java
@@ -0,0 +1,66 @@
+package com.baeldung.cassandra.java.client.domain;
+
+import java.util.UUID;
+
+public class Book {
+
+ private UUID id;
+
+ private String title;
+
+ private String author;
+
+ private String subject;
+
+ private String publisher;
+
+ Book() {
+ }
+
+ public Book(UUID id, String title, String author, String subject) {
+ this.id = id;
+ this.title = title;
+ this.author = author;
+ this.subject = subject;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(String publisher) {
+ this.publisher = publisher;
+ }
+}
diff --git a/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/BookRepository.java b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/BookRepository.java
new file mode 100644
index 0000000000..31e2969e01
--- /dev/null
+++ b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/BookRepository.java
@@ -0,0 +1,177 @@
+package com.baeldung.cassandra.java.client.repository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.baeldung.cassandra.java.client.domain.Book;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+
+public class BookRepository {
+
+ private static final String TABLE_NAME = "books";
+
+ private static final String TABLE_NAME_BY_TITLE = TABLE_NAME + "ByTitle";
+
+ private Session session;
+
+ public BookRepository(Session session) {
+ this.session = session;
+ }
+
+ /**
+ * Creates the books table.
+ */
+ public void createTable() {
+ StringBuilder sb = new StringBuilder("CREATE TABLE IF NOT EXISTS ").append(TABLE_NAME).append("(").append("id uuid PRIMARY KEY, ").append("title text,").append("author text,").append("subject text);");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Creates the books table.
+ */
+ public void createTableBooksByTitle() {
+ StringBuilder sb = new StringBuilder("CREATE TABLE IF NOT EXISTS ").append(TABLE_NAME_BY_TITLE).append("(").append("id uuid, ").append("title text,").append("PRIMARY KEY (title, id));");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Alters the table books and adds an extra column.
+ */
+ public void alterTablebooks(String columnName, String columnType) {
+ StringBuilder sb = new StringBuilder("ALTER TABLE ").append(TABLE_NAME).append(" ADD ").append(columnName).append(" ").append(columnType).append(";");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Insert a row in the table books.
+ *
+ * @param book
+ */
+ public void insertbook(Book book) {
+ StringBuilder sb = new StringBuilder("INSERT INTO ").append(TABLE_NAME).append("(id, title, author, subject) ").append("VALUES (").append(book.getId()).append(", '").append(book.getTitle()).append("', '").append(book.getAuthor()).append("', '")
+ .append(book.getSubject()).append("');");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Insert a row in the table booksByTitle.
+ * @param book
+ */
+ public void insertbookByTitle(Book book) {
+ StringBuilder sb = new StringBuilder("INSERT INTO ").append(TABLE_NAME_BY_TITLE).append("(id, title) ").append("VALUES (").append(book.getId()).append(", '").append(book.getTitle()).append("');");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Insert a book into two identical tables using a batch query.
+ *
+ * @param book
+ */
+ public void insertBookBatch(Book book) {
+ StringBuilder sb = new StringBuilder("BEGIN BATCH ")
+ .append("INSERT INTO ").append(TABLE_NAME).append("(id, title, author, subject) ")
+ .append("VALUES (").append(book.getId()).append(", '").append(book.getTitle()).append("', '").append(book.getAuthor()).append("', '")
+ .append(book.getSubject()).append("');")
+ .append("INSERT INTO ").append(TABLE_NAME_BY_TITLE).append("(id, title) ")
+ .append("VALUES (").append(book.getId()).append(", '").append(book.getTitle()).append("');")
+ .append("APPLY BATCH;");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Select book by id.
+ *
+ * @return
+ */
+ public Book selectByTitle(String title) {
+ StringBuilder sb = new StringBuilder("SELECT * FROM ").append(TABLE_NAME_BY_TITLE).append(" WHERE title = '").append(title).append("';");
+
+ final String query = sb.toString();
+
+ ResultSet rs = session.execute(query);
+
+ List books = new ArrayList();
+
+ for (Row r : rs) {
+ Book s = new Book(r.getUUID("id"), r.getString("title"), null, null);
+ books.add(s);
+ }
+
+ return books.get(0);
+ }
+
+ /**
+ * Select all books from books
+ *
+ * @return
+ */
+ public List selectAll() {
+ StringBuilder sb = new StringBuilder("SELECT * FROM ").append(TABLE_NAME);
+
+ final String query = sb.toString();
+ ResultSet rs = session.execute(query);
+
+ List books = new ArrayList();
+
+ for (Row r : rs) {
+ Book book = new Book(r.getUUID("id"), r.getString("title"), r.getString("author"), r.getString("subject"));
+ books.add(book);
+ }
+ return books;
+ }
+
+ /**
+ * Select all books from booksByTitle
+ * @return
+ */
+ public List selectAllBookByTitle() {
+ StringBuilder sb = new StringBuilder("SELECT * FROM ").append(TABLE_NAME_BY_TITLE);
+
+ final String query = sb.toString();
+ ResultSet rs = session.execute(query);
+
+ List books = new ArrayList();
+
+ for (Row r : rs) {
+ Book book = new Book(r.getUUID("id"), r.getString("title"), null, null);
+ books.add(book);
+ }
+ return books;
+ }
+
+ /**
+ * Delete a book by title.
+ */
+ public void deletebookByTitle(String title) {
+ StringBuilder sb = new StringBuilder("DELETE FROM ").append(TABLE_NAME_BY_TITLE).append(" WHERE title = '").append(title).append("';");
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+
+ /**
+ * Delete table.
+ *
+ * @param tableName the name of the table to delete.
+ */
+ public void deleteTable(String tableName) {
+ StringBuilder sb = new StringBuilder("DROP TABLE IF EXISTS ").append(tableName);
+
+ final String query = sb.toString();
+ session.execute(query);
+ }
+}
diff --git a/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepository.java b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepository.java
new file mode 100644
index 0000000000..f15558f040
--- /dev/null
+++ b/java-cassandra/src/main/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepository.java
@@ -0,0 +1,49 @@
+package com.baeldung.cassandra.java.client.repository;
+
+import com.datastax.driver.core.Session;
+
+/**
+ * Repository to handle the Cassandra schema.
+ *
+ */
+public class KeyspaceRepository {
+ private Session session;
+
+ public KeyspaceRepository(Session session) {
+ this.session = session;
+ }
+
+ /**
+ * Method used to create any keyspace - schema.
+ *
+ * @param schemaName the name of the schema.
+ * @param replicatioonStrategy the replication strategy.
+ * @param numberOfReplicas the number of replicas.
+ *
+ */
+ public void createKeyspace(String keyspaceName, String replicatioonStrategy, int numberOfReplicas) {
+ StringBuilder sb = new StringBuilder("CREATE KEYSPACE IF NOT EXISTS ").append(keyspaceName).append(" WITH replication = {").append("'class':'").append(replicatioonStrategy).append("','replication_factor':").append(numberOfReplicas).append("};");
+
+ final String query = sb.toString();
+
+ session.execute(query);
+ }
+
+ public void useKeyspace(String keyspace) {
+ session.execute("USE " + keyspace);
+ }
+
+ /**
+ * Method used to delete the specified schema.
+ * It results in the immediate, irreversable removal of the keyspace, including all tables and data contained in the keyspace.
+ *
+ * @param schemaName the name of the keyspace to delete.
+ */
+ public void deleteKeyspace(String keyspaceName) {
+ StringBuilder sb = new StringBuilder("DROP KEYSPACE ").append(keyspaceName);
+
+ final String query = sb.toString();
+
+ session.execute(query);
+ }
+}
diff --git a/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/BookRepositoryIntegrationTest.java b/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/BookRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..62eae94c7c
--- /dev/null
+++ b/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/BookRepositoryIntegrationTest.java
@@ -0,0 +1,174 @@
+package com.baeldung.cassandra.java.client.repository;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.thrift.transport.TTransportException;
+import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.baeldung.cassandra.java.client.CassandraConnector;
+import com.baeldung.cassandra.java.client.domain.Book;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.exceptions.InvalidQueryException;
+import com.datastax.driver.core.utils.UUIDs;
+
+public class BookRepositoryIntegrationTest {
+
+ private KeyspaceRepository schemaRepository;
+
+ private BookRepository bookRepository;
+
+ private Session session;
+
+ final String KEYSPACE_NAME = "testLibrary";
+ final String BOOKS = "books";
+ final String BOOKS_BY_TITLE = "booksByTitle";
+
+ @BeforeClass
+ public static void init() throws ConfigurationException, TTransportException, IOException, InterruptedException {
+ // Start an embedded Cassandra Server
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
+ }
+
+ @Before
+ public void connect() {
+ CassandraConnector client = new CassandraConnector();
+ client.connect("127.0.0.1", 9142);
+ this.session = client.getSession();
+ schemaRepository = new KeyspaceRepository(session);
+ schemaRepository.createKeyspace(KEYSPACE_NAME, "SimpleStrategy", 1);
+ schemaRepository.useKeyspace(KEYSPACE_NAME);
+ bookRepository = new BookRepository(session);
+ }
+
+ @Test
+ public void whenCreatingATable_thenCreatedCorrectly() {
+ bookRepository.deleteTable(BOOKS);
+ bookRepository.createTable();
+
+ ResultSet result = session.execute("SELECT * FROM " + KEYSPACE_NAME + "." + BOOKS + ";");
+
+ // Collect all the column names in one list.
+ List columnNames = result.getColumnDefinitions().asList().stream().map(cl -> cl.getName()).collect(Collectors.toList());
+ assertEquals(columnNames.size(), 4);
+ assertTrue(columnNames.contains("id"));
+ assertTrue(columnNames.contains("title"));
+ assertTrue(columnNames.contains("author"));
+ assertTrue(columnNames.contains("subject"));
+ }
+
+ @Test
+ public void whenAlteringTable_thenAddedColumnExists() {
+ bookRepository.deleteTable(BOOKS);
+ bookRepository.createTable();
+
+ bookRepository.alterTablebooks("publisher", "text");
+
+ ResultSet result = session.execute("SELECT * FROM " + KEYSPACE_NAME + "." + BOOKS + ";");
+
+ boolean columnExists = result.getColumnDefinitions().asList().stream().anyMatch(cl -> cl.getName().equals("publisher"));
+ assertTrue(columnExists);
+ }
+
+ @Test
+ public void whenAddingANewBook_thenBookExists() {
+ bookRepository.deleteTable(BOOKS_BY_TITLE);
+ bookRepository.createTableBooksByTitle();
+
+ String title = "Effective Java";
+ String author = "Joshua Bloch";
+ Book book = new Book(UUIDs.timeBased(), title, author, "Programming");
+ bookRepository.insertbookByTitle(book);
+
+ Book savedBook = bookRepository.selectByTitle(title);
+ assertEquals(book.getTitle(), savedBook.getTitle());
+ }
+
+ @Test
+ public void whenAddingANewBookBatch_ThenBookAddedInAllTables() {
+ // Create table books
+ bookRepository.deleteTable(BOOKS);
+ bookRepository.createTable();
+
+ // Create table booksByTitle
+ bookRepository.deleteTable(BOOKS_BY_TITLE);
+ bookRepository.createTableBooksByTitle();
+
+ String title = "Effective Java";
+ String author = "Joshua Bloch";
+ Book book = new Book(UUIDs.timeBased(), title, author, "Programming");
+ bookRepository.insertBookBatch(book);
+
+ List books = bookRepository.selectAll();
+
+ assertEquals(1, books.size());
+ assertTrue(books.stream().anyMatch(b -> b.getTitle().equals("Effective Java")));
+
+ List booksByTitle = bookRepository.selectAllBookByTitle();
+
+ assertEquals(1, booksByTitle.size());
+ assertTrue(booksByTitle.stream().anyMatch(b -> b.getTitle().equals("Effective Java")));
+ }
+
+ @Test
+ public void whenSelectingAll_thenReturnAllRecords() {
+ bookRepository.deleteTable(BOOKS);
+ bookRepository.createTable();
+
+ Book book = new Book(UUIDs.timeBased(), "Effective Java", "Joshua Bloch", "Programming");
+ bookRepository.insertbook(book);
+
+ book = new Book(UUIDs.timeBased(), "Clean Code", "Robert C. Martin", "Programming");
+ bookRepository.insertbook(book);
+
+ List books = bookRepository.selectAll();
+
+ assertEquals(2, books.size());
+ assertTrue(books.stream().anyMatch(b -> b.getTitle().equals("Effective Java")));
+ assertTrue(books.stream().anyMatch(b -> b.getTitle().equals("Clean Code")));
+ }
+
+ @Test
+ public void whenDeletingABookByTitle_thenBookIsDeleted() {
+ bookRepository.deleteTable(BOOKS_BY_TITLE);
+ bookRepository.createTableBooksByTitle();
+
+ Book book = new Book(UUIDs.timeBased(), "Effective Java", "Joshua Bloch", "Programming");
+ bookRepository.insertbookByTitle(book);
+
+ book = new Book(UUIDs.timeBased(), "Clean Code", "Robert C. Martin", "Programming");
+ bookRepository.insertbookByTitle(book);
+
+ bookRepository.deletebookByTitle("Clean Code");
+
+ List books = bookRepository.selectAllBookByTitle();
+ assertEquals(1, books.size());
+ assertTrue(books.stream().anyMatch(b -> b.getTitle().equals("Effective Java")));
+ assertFalse(books.stream().anyMatch(b -> b.getTitle().equals("Clean Code")));
+
+ }
+
+ @Test(expected = InvalidQueryException.class)
+ public void whenDeletingATable_thenUnconfiguredTable() {
+ bookRepository.createTable();
+ bookRepository.deleteTable(BOOKS);
+
+ session.execute("SELECT * FROM " + KEYSPACE_NAME + "." + BOOKS + ";");
+ }
+
+ @AfterClass
+ public static void cleanup() {
+ EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
+ }
+}
diff --git a/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepositoryIntegrationTest.java b/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..9df46b3176
--- /dev/null
+++ b/java-cassandra/src/test/java/com/baeldung/cassandra/java/client/repository/KeyspaceRepositoryIntegrationTest.java
@@ -0,0 +1,77 @@
+package com.baeldung.cassandra.java.client.repository;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.thrift.transport.TTransportException;
+import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.baeldung.cassandra.java.client.CassandraConnector;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class KeyspaceRepositoryIntegrationTest {
+
+ private KeyspaceRepository schemaRepository;
+
+ private Session session;
+
+ @BeforeClass
+ public static void init() throws ConfigurationException, TTransportException, IOException, InterruptedException {
+ // Start an embedded Cassandra Server
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
+ }
+
+ @Before
+ public void connect() {
+ CassandraConnector client = new CassandraConnector();
+ client.connect("127.0.0.1", 9142);
+ this.session = client.getSession();
+ schemaRepository = new KeyspaceRepository(session);
+ }
+
+ @Test
+ public void whenCreatingAKeyspace_thenCreated() {
+ String keyspaceName = "testBaeldungKeyspace";
+ schemaRepository.createKeyspace(keyspaceName, "SimpleStrategy", 1);
+
+ // ResultSet result = session.execute("SELECT * FROM system_schema.keyspaces WHERE keyspace_name = 'testBaeldungKeyspace';");
+
+ ResultSet result = session.execute("SELECT * FROM system_schema.keyspaces;");
+
+ // Check if the Keyspace exists in the returned keyspaces.
+ List matchedKeyspaces = result.all().stream().filter(r -> r.getString(0).equals(keyspaceName.toLowerCase())).map(r -> r.getString(0)).collect(Collectors.toList());
+ assertEquals(matchedKeyspaces.size(), 1);
+ assertTrue(matchedKeyspaces.get(0).equals(keyspaceName.toLowerCase()));
+ }
+
+ @Test
+ public void whenDeletingAKeyspace_thenDoesNotExist() {
+ String keyspaceName = "testBaeldungKeyspace";
+
+ // schemaRepository.createKeyspace(keyspaceName, "SimpleStrategy", 1);
+ schemaRepository.deleteKeyspace(keyspaceName);
+
+ ResultSet result = session.execute("SELECT * FROM system_schema.keyspaces;");
+ boolean isKeyspaceCreated = result.all().stream().anyMatch(r -> r.getString(0).equals(keyspaceName.toLowerCase()));
+ assertFalse(isKeyspaceCreated);
+ }
+
+ @AfterClass
+ public static void cleanup() {
+ EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
+ }
+}
diff --git a/log4j/pom.xml b/log4j/pom.xml
index 76c05b36c1..586769aa71 100644
--- a/log4j/pom.xml
+++ b/log4j/pom.xml
@@ -15,7 +15,13 @@
log4j
1.2.17
-
+
@@ -28,22 +34,34 @@
log4j-core
2.6
-
-
+
com.lmax
disruptor
3.3.4
-
+
-
ch.qos.logback
logback-classic
1.1.7
+
+
diff --git a/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java
new file mode 100644
index 0000000000..6ecc7b887a
--- /dev/null
+++ b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java
@@ -0,0 +1,20 @@
+package com.baeldung.slf4j;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * To switch between logging frameworks you need only to uncomment needed framework dependencies in pom.xml
+ */
+public class Slf4jExample {
+ private static Logger logger = LoggerFactory.getLogger(Slf4jExample.class);
+
+ public static void main(String[] args) {
+ logger.debug("Debug log message");
+ logger.info("Info log message");
+ logger.error("Error log message");
+
+ String variable = "Hello John";
+ logger.debug("Printing variable value {} ", variable);
+ }
+}
diff --git a/play-framework/student-api/.gitignore b/play-framework/student-api/.gitignore
new file mode 100644
index 0000000000..eb372fc719
--- /dev/null
+++ b/play-framework/student-api/.gitignore
@@ -0,0 +1,8 @@
+logs
+target
+/.idea
+/.idea_modules
+/.classpath
+/.project
+/.settings
+/RUNNING_PID
diff --git a/play-framework/student-api/LICENSE b/play-framework/student-api/LICENSE
new file mode 100644
index 0000000000..4baedcb95f
--- /dev/null
+++ b/play-framework/student-api/LICENSE
@@ -0,0 +1,8 @@
+This software is licensed under the Apache 2 license, quoted below.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with
+the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+language governing permissions and limitations under the License.
\ No newline at end of file
diff --git a/play-framework/student-api/README b/play-framework/student-api/README
new file mode 100644
index 0000000000..f21d092edf
--- /dev/null
+++ b/play-framework/student-api/README
@@ -0,0 +1,49 @@
+This is your new Play application
+=================================
+
+This file will be packaged with your application when using `activator dist`.
+
+There are several demonstration files available in this template.
+
+Controllers
+===========
+
+- HomeController.java:
+
+ Shows how to handle simple HTTP requests.
+
+- AsyncController.java:
+
+ Shows how to do asynchronous programming when handling a request.
+
+- CountController.java:
+
+ Shows how to inject a component into a controller and use the component when
+ handling requests.
+
+Components
+==========
+
+- Module.java:
+
+ Shows how to use Guice to bind all the components needed by your application.
+
+- Counter.java:
+
+ An example of a component that contains state, in this case a simple counter.
+
+- ApplicationTimer.java:
+
+ An example of a component that starts when the application starts and stops
+ when the application stops.
+
+Filters
+=======
+
+- Filters.java:
+
+ Creates the list of HTTP filters used by your application.
+
+- ExampleFilter.java
+
+ A simple filter that adds a header to every response.
\ No newline at end of file
diff --git a/play-framework/student-api/app/Filters.java b/play-framework/student-api/app/Filters.java
new file mode 100644
index 0000000000..255de8ca93
--- /dev/null
+++ b/play-framework/student-api/app/Filters.java
@@ -0,0 +1,46 @@
+import javax.inject.*;
+import play.*;
+import play.mvc.EssentialFilter;
+import play.http.HttpFilters;
+import play.mvc.*;
+
+import filters.ExampleFilter;
+
+/**
+ * This class configures filters that run on every request. This
+ * class is queried by Play to get a list of filters.
+ *
+ * Play will automatically use filters from any class called
+ * Filters that is placed the root package. You can load filters
+ * from a different class by adding a `play.http.filters` setting to
+ * the application.conf configuration file.
+ */
+@Singleton
+public class Filters implements HttpFilters {
+
+ private final Environment env;
+ private final EssentialFilter exampleFilter;
+
+ /**
+ * @param env Basic environment settings for the current application.
+ * @param exampleFilter A demonstration filter that adds a header to
+ */
+ @Inject
+ public Filters(Environment env, ExampleFilter exampleFilter) {
+ this.env = env;
+ this.exampleFilter = exampleFilter;
+ }
+
+ @Override
+ public EssentialFilter[] filters() {
+ // Use the example filter if we're running development mode. If
+ // we're running in production or test mode then don't use any
+ // filters at all.
+ if (env.mode().equals(Mode.DEV)) {
+ return new EssentialFilter[] { exampleFilter };
+ } else {
+ return new EssentialFilter[] {};
+ }
+ }
+
+}
diff --git a/play-framework/student-api/app/Module.java b/play-framework/student-api/app/Module.java
new file mode 100644
index 0000000000..6e7d1766ef
--- /dev/null
+++ b/play-framework/student-api/app/Module.java
@@ -0,0 +1,31 @@
+import com.google.inject.AbstractModule;
+import java.time.Clock;
+
+import services.ApplicationTimer;
+import services.AtomicCounter;
+import services.Counter;
+
+/**
+ * This class is a Guice module that tells Guice how to bind several
+ * different types. This Guice module is created when the Play
+ * application starts.
+ *
+ * Play will automatically use any class called `Module` that is in
+ * the root package. You can create modules in other locations by
+ * adding `play.modules.enabled` settings to the `application.conf`
+ * configuration file.
+ */
+public class Module extends AbstractModule {
+
+ @Override
+ public void configure() {
+ // Use the system clock as the default implementation of Clock
+ bind(Clock.class).toInstance(Clock.systemDefaultZone());
+ // Ask Guice to create an instance of ApplicationTimer when the
+ // application starts.
+ bind(ApplicationTimer.class).asEagerSingleton();
+ // Set AtomicCounter as the implementation for Counter.
+ bind(Counter.class).to(AtomicCounter.class);
+ }
+
+}
diff --git a/play-framework/student-api/app/controllers/AsyncController.java b/play-framework/student-api/app/controllers/AsyncController.java
new file mode 100644
index 0000000000..33cd112837
--- /dev/null
+++ b/play-framework/student-api/app/controllers/AsyncController.java
@@ -0,0 +1,60 @@
+package controllers;
+
+import akka.actor.ActorSystem;
+import javax.inject.*;
+import play.*;
+import play.mvc.*;
+import java.util.concurrent.Executor;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.TimeUnit;
+import scala.concurrent.duration.Duration;
+import scala.concurrent.ExecutionContextExecutor;
+
+/**
+ * This controller contains an action that demonstrates how to write
+ * simple asynchronous code in a controller. It uses a timer to
+ * asynchronously delay sending a response for 1 second.
+ *
+ * @param actorSystem We need the {@link ActorSystem}'s
+ * {@link Scheduler} to run code after a delay.
+ * @param exec We need a Java {@link Executor} to apply the result
+ * of the {@link CompletableFuture} and a Scala
+ * {@link ExecutionContext} so we can use the Akka {@link Scheduler}.
+ * An {@link ExecutionContextExecutor} implements both interfaces.
+ */
+@Singleton
+public class AsyncController extends Controller {
+
+ private final ActorSystem actorSystem;
+ private final ExecutionContextExecutor exec;
+
+ @Inject
+ public AsyncController(ActorSystem actorSystem, ExecutionContextExecutor exec) {
+ this.actorSystem = actorSystem;
+ this.exec = exec;
+ }
+
+ /**
+ * An action that returns a plain text message after a delay
+ * of 1 second.
+ *
+ * The configuration in the routes file means that this method
+ * will be called when the application receives a GET request with
+ * a path of /message.
+ */
+ public CompletionStage message() {
+ return getFutureMessage(1, TimeUnit.SECONDS).thenApplyAsync(Results::ok, exec);
+ }
+
+ private CompletionStage getFutureMessage(long time, TimeUnit timeUnit) {
+ CompletableFuture future = new CompletableFuture<>();
+ actorSystem.scheduler().scheduleOnce(
+ Duration.create(time, timeUnit),
+ () -> future.complete("Hi!"),
+ exec
+ );
+ return future;
+ }
+
+}
diff --git a/play-framework/student-api/app/controllers/CountController.java b/play-framework/student-api/app/controllers/CountController.java
new file mode 100644
index 0000000000..02fcb15f8e
--- /dev/null
+++ b/play-framework/student-api/app/controllers/CountController.java
@@ -0,0 +1,35 @@
+package controllers;
+
+import javax.inject.*;
+import play.*;
+import play.mvc.*;
+
+import services.Counter;
+
+/**
+ * This controller demonstrates how to use dependency injection to
+ * bind a component into a controller class. The class contains an
+ * action that shows an incrementing count to users. The {@link Counter}
+ * object is injected by the Guice dependency injection system.
+ */
+@Singleton
+public class CountController extends Controller {
+
+ private final Counter counter;
+
+ @Inject
+ public CountController(Counter counter) {
+ this.counter = counter;
+ }
+
+ /**
+ * An action that responds with the {@link Counter}'s current
+ * count. The result is plain text. This action is mapped to
+ * GET requests with a path of /count
+ * requests by an entry in the routes config file.
+ */
+ public Result count() {
+ return ok(Integer.toString(counter.nextCount()));
+ }
+
+}
diff --git a/play-framework/student-api/app/controllers/HomeController.java b/play-framework/student-api/app/controllers/HomeController.java
new file mode 100644
index 0000000000..6a79856eb4
--- /dev/null
+++ b/play-framework/student-api/app/controllers/HomeController.java
@@ -0,0 +1,23 @@
+package controllers;
+
+import play.mvc.*;
+
+import views.html.*;
+
+/**
+ * This controller contains an action to handle HTTP requests
+ * to the application's home page.
+ */
+public class HomeController extends Controller {
+
+ /**
+ * An action that renders an HTML page with a welcome message.
+ * The configuration in the routes file means that
+ * this method will be called when the application receives a
+ * GET request with a path of /.
+ */
+ public Result index() {
+ return ok(index.render("Your new application is ready."));
+ }
+
+}
diff --git a/play-framework/student-api/app/controllers/StudentController.java b/play-framework/student-api/app/controllers/StudentController.java
new file mode 100644
index 0000000000..0adedfa432
--- /dev/null
+++ b/play-framework/student-api/app/controllers/StudentController.java
@@ -0,0 +1,56 @@
+package controllers;
+import models.*;
+import util.*;
+import play.mvc.*;
+import play.libs.Json;
+import play.libs.Json.*;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.List;
+
+public class StudentController extends Controller {
+ public Result create() {
+ JsonNode json = request().body().asJson();
+ if(json == null)
+ return badRequest(Util.createResponse("Expecting Json data",false));
+ Student student=StudentStore.getInstance().addStudent((Student)Json.fromJson(json,Student.class));
+ JsonNode jsonObject=Json.toJson(student);
+ return created(Util.createResponse(jsonObject,true));
+ }
+ public Result update() {
+ JsonNode json = request().body().asJson();
+ if(json == null)
+ return badRequest(Util.createResponse("Expecting Json data",false));
+ Student student=StudentStore.getInstance().updateStudent((Student)Json.fromJson(json,Student.class));
+ if(student==null){
+ return notFound(Util.createResponse("Student not found",false));
+ }
+
+ JsonNode jsonObject=Json.toJson(student);
+ return ok(Util.createResponse(jsonObject,true));
+ }
+ public Result retrieve(int id) {
+ Student student=StudentStore.getInstance().getStudent(id);
+ if(student==null){
+ return notFound(Util.createResponse("Student with id:"+id+" not found",false));
+ }
+ JsonNode jsonObjects=Json.toJson(student);
+ return ok(Util.createResponse(jsonObjects,true));
+ }
+ public Result listStudents() {
+ List result=StudentStore.getInstance().getAllStudents();
+ ObjectMapper mapper = new ObjectMapper();
+
+ JsonNode jsonData=mapper.convertValue(result, JsonNode.class);
+ return ok(Util.createResponse(jsonData,true));
+
+ }
+ public Result delete(int id) {
+ boolean status=StudentStore.getInstance().deleteStudent(id);
+ if(!status){
+ return notFound(Util.createResponse("Student with id:"+id+" not found",false));
+ }
+ return ok(Util.createResponse("Student with id:"+id+" deleted",true));
+ }
+
+}
diff --git a/play-framework/student-api/app/filters/ExampleFilter.java b/play-framework/student-api/app/filters/ExampleFilter.java
new file mode 100644
index 0000000000..67a6a36cc3
--- /dev/null
+++ b/play-framework/student-api/app/filters/ExampleFilter.java
@@ -0,0 +1,45 @@
+package filters;
+
+import akka.stream.Materializer;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.Executor;
+import java.util.function.Function;
+import javax.inject.*;
+import play.mvc.*;
+import play.mvc.Http.RequestHeader;
+
+
+/**
+ * This is a simple filter that adds a header to all requests. It's
+ * added to the application's list of filters by the
+ * {@link Filters} class.
+ */
+@Singleton
+public class ExampleFilter extends Filter {
+
+ private final Executor exec;
+
+ /**
+ * @param mat This object is needed to handle streaming of requests
+ * and responses.
+ * @param exec This class is needed to execute code asynchronously.
+ * It is used below by the thenAsyncApply method.
+ */
+ @Inject
+ public ExampleFilter(Materializer mat, Executor exec) {
+ super(mat);
+ this.exec = exec;
+ }
+
+ @Override
+ public CompletionStage apply(
+ Function> next,
+ RequestHeader requestHeader) {
+
+ return next.apply(requestHeader).thenApplyAsync(
+ result -> result.withHeader("X-ExampleFilter", "foo"),
+ exec
+ );
+ }
+
+}
diff --git a/play-framework/student-api/app/models/Student.java b/play-framework/student-api/app/models/Student.java
new file mode 100644
index 0000000000..dc539767bd
--- /dev/null
+++ b/play-framework/student-api/app/models/Student.java
@@ -0,0 +1,47 @@
+package models;
+public class Student {
+ private String firstName;
+ private String lastName;
+ private int age;
+ private int id;
+ public Student(){}
+ public Student(String firstName, String lastName, int age) {
+ super();
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
diff --git a/play-framework/student-api/app/models/StudentStore.java b/play-framework/student-api/app/models/StudentStore.java
new file mode 100644
index 0000000000..3290e141cd
--- /dev/null
+++ b/play-framework/student-api/app/models/StudentStore.java
@@ -0,0 +1,52 @@
+package models;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class StudentStore {
+ private static StudentStore instance;
+ private Map students = new HashMap<>();
+
+ public static StudentStore getInstance() {
+ if (instance == null)
+ instance = new StudentStore();
+ return instance;
+ }
+
+ public Student addStudent(Student student) {
+ int id = students.size() + 1;
+ student.setId(id);
+ students.put(id, student);
+ return student;
+ }
+
+ public Student getStudent(int id) {
+ if (students.containsKey(id))
+ return students.get(id);
+ return null;
+ }
+
+ public List getAllStudents() {
+ return new ArrayList(students.values());
+ }
+
+ public Student updateStudent(Student student) {
+ int id=student.getId();
+ if (students.containsKey(id)) {
+ student.setId(id);
+ students.put(id, student);
+ return student;
+ }
+ return null;
+ }
+
+ public boolean deleteStudent(int id) {
+
+ if (!students.containsKey(id))
+ return false;
+ students.remove(id);
+ return true;
+
+ }
+}
\ No newline at end of file
diff --git a/play-framework/student-api/app/services/ApplicationTimer.java b/play-framework/student-api/app/services/ApplicationTimer.java
new file mode 100644
index 0000000000..a951562b1d
--- /dev/null
+++ b/play-framework/student-api/app/services/ApplicationTimer.java
@@ -0,0 +1,50 @@
+package services;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.util.concurrent.CompletableFuture;
+import javax.inject.*;
+import play.Logger;
+import play.inject.ApplicationLifecycle;
+
+/**
+ * This class demonstrates how to run code when the
+ * application starts and stops. It starts a timer when the
+ * application starts. When the application stops it prints out how
+ * long the application was running for.
+ *
+ * This class is registered for Guice dependency injection in the
+ * {@link Module} class. We want the class to start when the application
+ * starts, so it is registered as an "eager singleton". See the code
+ * in the {@link Module} class to see how this happens.
+ *
+ * This class needs to run code when the server stops. It uses the
+ * application's {@link ApplicationLifecycle} to register a stop hook.
+ */
+@Singleton
+public class ApplicationTimer {
+
+ private final Clock clock;
+ private final ApplicationLifecycle appLifecycle;
+ private final Instant start;
+
+ @Inject
+ public ApplicationTimer(Clock clock, ApplicationLifecycle appLifecycle) {
+ this.clock = clock;
+ this.appLifecycle = appLifecycle;
+ // This code is called when the application starts.
+ start = clock.instant();
+ Logger.info("ApplicationTimer demo: Starting application at " + start);
+
+ // When the application starts, register a stop hook with the
+ // ApplicationLifecycle object. The code inside the stop hook will
+ // be run when the application stops.
+ appLifecycle.addStopHook(() -> {
+ Instant stop = clock.instant();
+ Long runningTime = stop.getEpochSecond() - start.getEpochSecond();
+ Logger.info("ApplicationTimer demo: Stopping application at " + clock.instant() + " after " + runningTime + "s.");
+ return CompletableFuture.completedFuture(null);
+ });
+ }
+
+}
diff --git a/play-framework/student-api/app/services/AtomicCounter.java b/play-framework/student-api/app/services/AtomicCounter.java
new file mode 100644
index 0000000000..41f741cbf7
--- /dev/null
+++ b/play-framework/student-api/app/services/AtomicCounter.java
@@ -0,0 +1,26 @@
+package services;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.inject.*;
+
+/**
+ * This class is a concrete implementation of the {@link Counter} trait.
+ * It is configured for Guice dependency injection in the {@link Module}
+ * class.
+ *
+ * This class has a {@link Singleton} annotation because we need to make
+ * sure we only use one counter per application. Without this
+ * annotation we would get a new instance every time a {@link Counter} is
+ * injected.
+ */
+@Singleton
+public class AtomicCounter implements Counter {
+
+ private final AtomicInteger atomicCounter = new AtomicInteger();
+
+ @Override
+ public int nextCount() {
+ return atomicCounter.getAndIncrement();
+ }
+
+}
diff --git a/play-framework/student-api/app/services/Counter.java b/play-framework/student-api/app/services/Counter.java
new file mode 100644
index 0000000000..dadad8b09d
--- /dev/null
+++ b/play-framework/student-api/app/services/Counter.java
@@ -0,0 +1,13 @@
+package services;
+
+/**
+ * This interface demonstrates how to create a component that is injected
+ * into a controller. The interface represents a counter that returns a
+ * incremented number each time it is called.
+ *
+ * The {@link Modules} class binds this interface to the
+ * {@link AtomicCounter} implementation.
+ */
+public interface Counter {
+ int nextCount();
+}
diff --git a/play-framework/student-api/app/util/Util.java b/play-framework/student-api/app/util/Util.java
new file mode 100644
index 0000000000..3718b50677
--- /dev/null
+++ b/play-framework/student-api/app/util/Util.java
@@ -0,0 +1,17 @@
+package util;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import play.libs.Json;
+import play.libs.Json.*;
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class Util{
+ public static ObjectNode createResponse(Object response,boolean ok){
+ ObjectNode result = Json.newObject();
+ result.put("isSuccessfull", ok);
+ if(response instanceof String)
+ result.put("body",(String)response);
+ else result.put("body",(JsonNode)response);
+
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/play-framework/student-api/app/views/index.scala.html b/play-framework/student-api/app/views/index.scala.html
new file mode 100644
index 0000000000..4539f5a10b
--- /dev/null
+++ b/play-framework/student-api/app/views/index.scala.html
@@ -0,0 +1,20 @@
+@*
+ * This template takes a single argument, a String containing a
+ * message to display.
+ *@
+@(message: String)
+
+@*
+ * Call the `main` template with two arguments. The first
+ * argument is a `String` with the title of the page, the second
+ * argument is an `Html` object containing the body of the page.
+ *@
+@main("Welcome to Play") {
+
+ @*
+ * Get an `Html` object by calling the built-in Play welcome
+ * template and passing a `String` message.
+ *@
+ @play20.welcome(message, style = "Java")
+
+}
diff --git a/play-framework/student-api/app/views/main.scala.html b/play-framework/student-api/app/views/main.scala.html
new file mode 100644
index 0000000000..9414f4be6e
--- /dev/null
+++ b/play-framework/student-api/app/views/main.scala.html
@@ -0,0 +1,23 @@
+@*
+ * This template is called from the `index` template. This template
+ * handles the rendering of the page header and body tags. It takes
+ * two arguments, a `String` for the title of the page and an `Html`
+ * object to insert into the body of the page.
+ *@
+@(title: String)(content: Html)
+
+
+
+
+ @* Here's where we render the page title `String`. *@
+ @title
+
+
+
+
+
+ @* And here's where we render the `Html` object containing
+ * the page content. *@
+ @content
+
+
diff --git a/play-framework/student-api/bin/activator b/play-framework/student-api/bin/activator
new file mode 100644
index 0000000000..a8b11d482f
--- /dev/null
+++ b/play-framework/student-api/bin/activator
@@ -0,0 +1,397 @@
+#!/usr/bin/env bash
+
+### ------------------------------- ###
+### Helper methods for BASH scripts ###
+### ------------------------------- ###
+
+realpath () {
+(
+ TARGET_FILE="$1"
+ FIX_CYGPATH="$2"
+
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE=$(basename "$TARGET_FILE")
+
+ COUNT=0
+ while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
+ do
+ TARGET_FILE=$(readlink "$TARGET_FILE")
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE=$(basename "$TARGET_FILE")
+ COUNT=$(($COUNT + 1))
+ done
+
+ # make sure we grab the actual windows path, instead of cygwin's path.
+ if [[ "x$FIX_CYGPATH" != "x" ]]; then
+ echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")"
+ else
+ echo "$(pwd -P)/$TARGET_FILE"
+ fi
+)
+}
+
+
+# Uses uname to detect if we're in the odd cygwin environment.
+is_cygwin() {
+ local os=$(uname -s)
+ case "$os" in
+ CYGWIN*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+# TODO - Use nicer bash-isms here.
+CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi)
+
+
+# This can fix cygwin style /cygdrive paths so we get the
+# windows style paths.
+cygwinpath() {
+ local file="$1"
+ if [[ "$CYGWIN_FLAG" == "true" ]]; then
+ echo $(cygpath -w $file)
+ else
+ echo $file
+ fi
+}
+
+# Make something URI friendly
+make_url() {
+ url="$1"
+ local nospaces=${url// /%20}
+ if is_cygwin; then
+ echo "/${nospaces//\\//}"
+ else
+ echo "$nospaces"
+ fi
+}
+
+declare -a residual_args
+declare -a java_args
+declare -a scalac_args
+declare -a sbt_commands
+declare java_cmd=java
+declare java_version
+declare -r real_script_path="$(realpath "$0")"
+declare -r sbt_home="$(realpath "$(dirname "$(dirname "$real_script_path")")")"
+declare -r sbt_bin_dir="$(dirname "$real_script_path")"
+declare -r app_version="1.3.10"
+
+declare -r script_name=activator
+declare -r java_opts=( "${ACTIVATOR_OPTS[@]}" "${SBT_OPTS[@]}" "${JAVA_OPTS[@]}" "${java_opts[@]}" )
+userhome="$HOME"
+if is_cygwin; then
+ # cygwin sets home to something f-d up, set to real windows homedir
+ userhome="$USERPROFILE"
+fi
+declare -r activator_user_home_dir="${userhome}/.activator"
+declare -r java_opts_config_home="${activator_user_home_dir}/activatorconfig.txt"
+declare -r java_opts_config_version="${activator_user_home_dir}/${app_version}/activatorconfig.txt"
+
+echoerr () {
+ echo 1>&2 "$@"
+}
+vlog () {
+ [[ $verbose || $debug ]] && echoerr "$@"
+}
+dlog () {
+ [[ $debug ]] && echoerr "$@"
+}
+
+jar_file () {
+ echo "$(cygwinpath "${sbt_home}/libexec/activator-launch-${app_version}.jar")"
+}
+
+acquire_sbt_jar () {
+ sbt_jar="$(jar_file)"
+
+ if [[ ! -f "$sbt_jar" ]]; then
+ echoerr "Could not find launcher jar: $sbt_jar"
+ exit 2
+ fi
+}
+
+execRunner () {
+ # print the arguments one to a line, quoting any containing spaces
+ [[ $verbose || $debug ]] && echo "# Executing command line:" && {
+ for arg; do
+ if printf "%s\n" "$arg" | grep -q ' '; then
+ printf "\"%s\"\n" "$arg"
+ else
+ printf "%s\n" "$arg"
+ fi
+ done
+ echo ""
+ }
+
+ # THis used to be exec, but we loose the ability to re-hook stty then
+ # for cygwin... Maybe we should flag the feature here...
+ "$@"
+}
+
+addJava () {
+ dlog "[addJava] arg = '$1'"
+ java_args=( "${java_args[@]}" "$1" )
+}
+addSbt () {
+ dlog "[addSbt] arg = '$1'"
+ sbt_commands=( "${sbt_commands[@]}" "$1" )
+}
+addResidual () {
+ dlog "[residual] arg = '$1'"
+ residual_args=( "${residual_args[@]}" "$1" )
+}
+addDebugger () {
+ addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
+}
+
+get_mem_opts () {
+ # if we detect any of these settings in ${JAVA_OPTS} we need to NOT output our settings.
+ # The reason is the Xms/Xmx, if they don't line up, cause errors.
+ if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then
+ echo ""
+ else
+ # a ham-fisted attempt to move some memory settings in concert
+ # so they need not be messed around with individually.
+ local mem=${1:-1024}
+ local codecache=$(( $mem / 8 ))
+ (( $codecache > 128 )) || codecache=128
+ (( $codecache < 512 )) || codecache=512
+ local class_metadata_size=$(( $codecache * 2 ))
+ local class_metadata_opt=$([[ "$java_version" < "1.8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize")
+
+ echo "-Xms${mem}m -Xmx${mem}m -XX:ReservedCodeCacheSize=${codecache}m -XX:${class_metadata_opt}=${class_metadata_size}m"
+ fi
+}
+
+require_arg () {
+ local type="$1"
+ local opt="$2"
+ local arg="$3"
+ if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
+ echo "$opt requires <$type> argument"
+ exit 1
+ fi
+}
+
+is_function_defined() {
+ declare -f "$1" > /dev/null
+}
+
+# If we're *not* running in a terminal, and we don't have any arguments, then we need to add the 'ui' parameter
+detect_terminal_for_ui() {
+ [[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && {
+ addResidual "ui"
+ }
+ # SPECIAL TEST FOR MAC
+ [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && {
+ echo "Detected MAC OSX launched script...."
+ echo "Swapping to UI"
+ addResidual "ui"
+ }
+}
+
+process_args () {
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -h|-help) usage; exit 1 ;;
+ -v|-verbose) verbose=1 && shift ;;
+ -d|-debug) debug=1 && shift ;;
+
+ -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
+ -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;;
+ -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
+ -batch) exec &1 | awk -F '"' '/version/ {print $2}')
+ vlog "[process_args] java_version = '$java_version'"
+}
+
+# Detect that we have java installed.
+checkJava() {
+ local required_version="$1"
+ # Now check to see if it's a good enough version
+ if [[ "$java_version" == "" ]]; then
+ echo
+ echo No java installations was detected.
+ echo Please go to http://www.java.com/getjava/ and download
+ echo
+ exit 1
+ elif [[ ! "$java_version" > "$required_version" ]]; then
+ echo
+ echo The java installation you have is not up to date
+ echo $script_name requires at least version $required_version+, you have
+ echo version $java_version
+ echo
+ echo Please go to http://www.java.com/getjava/ and download
+ echo a valid Java Runtime and install before running $script_name.
+ echo
+ exit 1
+ fi
+}
+
+
+run() {
+ # no jar? download it.
+ [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || {
+ # still no jar? uh-oh.
+ echo "Download failed. Obtain the sbt-launch.jar manually and place it at $sbt_jar"
+ exit 1
+ }
+
+ # process the combined args, then reset "$@" to the residuals
+ process_args "$@"
+ detect_terminal_for_ui
+ set -- "${residual_args[@]}"
+ argumentCount=$#
+
+ # TODO - java check should be configurable...
+ checkJava "1.6"
+
+ #If we're in cygwin, we should use the windows config, and terminal hacks
+ if [[ "$CYGWIN_FLAG" == "true" ]]; then
+ stty -icanon min 1 -echo > /dev/null 2>&1
+ addJava "-Djline.terminal=jline.UnixTerminal"
+ addJava "-Dsbt.cygwin=true"
+ fi
+
+ # run sbt
+ execRunner "$java_cmd" \
+ "-Dactivator.home=$(make_url "$sbt_home")" \
+ ${SBT_OPTS:-$default_sbt_opts} \
+ $(get_mem_opts $sbt_mem) \
+ ${JAVA_OPTS} \
+ ${java_args[@]} \
+ -jar "$sbt_jar" \
+ "${sbt_commands[@]}" \
+ "${residual_args[@]}"
+
+ exit_code=$?
+
+ # Clean up the terminal from cygwin hacks.
+ if [[ "$CYGWIN_FLAG" == "true" ]]; then
+ stty icanon echo > /dev/null 2>&1
+ fi
+ exit $exit_code
+}
+
+
+declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
+declare -r sbt_opts_file=".sbtopts"
+declare -r etc_sbt_opts_file="${sbt_home}/conf/sbtopts"
+declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt"
+
+usage() {
+ cat < path to global settings/plugins directory (default: ~/.sbt)
+ -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
+ -ivy path to local Ivy repository (default: ~/.ivy2)
+ -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem))
+ -no-share use all local caches; no sharing
+ -no-global uses global caches, but does not use global ~/.sbt directory.
+ -jvm-debug Turn on JVM debugging, open at the given port.
+ -batch Disable interactive mode
+
+ # sbt version (default: from project/build.properties if present, else latest release)
+ -sbt-version use the specified version of sbt
+ -sbt-jar use the specified jar as the sbt launcher
+ -sbt-rc use an RC version of sbt
+ -sbt-snapshot use a snapshot version of sbt
+
+ # java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
+ -java-home alternate JAVA_HOME
+
+ # jvm options and output control
+ JAVA_OPTS environment variable, if unset uses "$java_opts"
+ SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
+ ACTIVATOR_OPTS Environment variable, if unset uses ""
+ .sbtopts if this file exists in the current directory, it is
+ prepended to the runner args
+ /etc/sbt/sbtopts if this file exists, it is prepended to the runner args
+ -Dkey=val pass -Dkey=val directly to the java runtime
+ -J-X pass option -X directly to the java runtime
+ (-J is stripped)
+ -S-X add -X to sbt's scalacOptions (-S is stripped)
+
+In the case of duplicated or conflicting options, the order above
+shows precedence: JAVA_OPTS lowest, command line options highest.
+EOM
+}
+
+
+
+process_my_args () {
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
+ -no-share) addJava "$noshare_opts" && shift ;;
+ -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;;
+ -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
+ -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;;
+ -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
+ -batch) exec ^&1') do (
+ if %%~j==java set JAVAINSTALLED=1
+ if %%~j==openjdk set JAVAINSTALLED=1
+)
+
+rem Detect the same thing about javac
+if "%_JAVACCMD%"=="" (
+ if not "%JAVA_HOME%"=="" (
+ if exist "%JAVA_HOME%\bin\javac.exe" set "_JAVACCMD=%JAVA_HOME%\bin\javac.exe"
+ )
+)
+if "%_JAVACCMD%"=="" set _JAVACCMD=javac
+for /F %%j in ('"%_JAVACCMD%" -version 2^>^&1') do (
+ if %%~j==javac set JAVACINSTALLED=1
+)
+
+rem BAT has no logical or, so we do it OLD SCHOOL! Oppan Redmond Style
+set JAVAOK=true
+if not defined JAVAINSTALLED set JAVAOK=false
+if not defined JAVACINSTALLED set JAVAOK=false
+
+if "%JAVAOK%"=="false" (
+ echo.
+ echo A Java JDK is not installed or can't be found.
+ if not "%JAVA_HOME%"=="" (
+ echo JAVA_HOME = "%JAVA_HOME%"
+ )
+ echo.
+ echo Please go to
+ echo http://www.oracle.com/technetwork/java/javase/downloads/index.html
+ echo and download a valid Java JDK and install before running Activator.
+ echo.
+ echo If you think this message is in error, please check
+ echo your environment variables to see if "java.exe" and "javac.exe" are
+ echo available via JAVA_HOME or PATH.
+ echo.
+ if defined DOUBLECLICKED pause
+ exit /B 1
+)
+
+rem Check what Java version is being used to determine what memory options to use
+for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
+ set JAVA_VERSION=%%g
+)
+
+rem Strips away the " characters
+set JAVA_VERSION=%JAVA_VERSION:"=%
+
+rem TODO Check if there are existing mem settings in JAVA_OPTS/CFG_OPTS and use those instead of the below
+for /f "delims=. tokens=1-3" %%v in ("%JAVA_VERSION%") do (
+ set MAJOR=%%v
+ set MINOR=%%w
+ set BUILD=%%x
+
+ set META_SIZE=-XX:MetaspaceSize=64M -XX:MaxMetaspaceSize=256M
+ if "!MINOR!" LSS "8" (
+ set META_SIZE=-XX:PermSize=64M -XX:MaxPermSize=256M
+ )
+
+ set MEM_OPTS=!META_SIZE!
+ )
+
+rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
+set _JAVA_OPTS=%JAVA_OPTS%
+if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS%
+
+set DEBUG_OPTS=
+
+rem Loop through the arguments, building remaining args in args variable
+set args=
+:argsloop
+if not "%~1"=="" (
+ rem Checks if the argument contains "-D" and if true, adds argument 1 with 2 and puts an equal sign between them.
+ rem This is done since batch considers "=" to be a delimiter so we need to circumvent this behavior with a small hack.
+ set arg1=%~1
+ if "!arg1:~0,2!"=="-D" (
+ set "args=%args% "%~1"="%~2""
+ shift
+ shift
+ goto argsloop
+ )
+
+ if "%~1"=="-jvm-debug" (
+ if not "%~2"=="" (
+ rem This piece of magic somehow checks that an argument is a number
+ for /F "delims=0123456789" %%i in ("%~2") do (
+ set var="%%i"
+ )
+ if defined var (
+ rem Not a number, assume no argument given and default to 9999
+ set JPDA_PORT=9999
+ ) else (
+ rem Port was given, shift arguments
+ set JPDA_PORT=%~2
+ shift
+ )
+ ) else (
+ set JPDA_PORT=9999
+ )
+ shift
+
+ set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=!JPDA_PORT!
+ goto argsloop
+ )
+ rem else
+ set "args=%args% "%~1""
+ shift
+ goto argsloop
+)
+
+:run
+
+if "!args!"=="" (
+ if defined DOUBLECLICKED (
+ set CMDS="ui"
+ ) else set CMDS=!args!
+) else set CMDS=!args!
+
+rem We add a / in front, so we get file:///C: instead of file://C:
+rem Java considers the later a UNC path.
+rem We also attempt a solid effort at making it URI friendly.
+rem We don't even bother with UNC paths.
+set JAVA_FRIENDLY_HOME_1=/!ACTIVATOR_HOME:\=/!
+set JAVA_FRIENDLY_HOME=/!JAVA_FRIENDLY_HOME_1: =%%20!
+
+rem Checks if the command contains spaces to know if it should be wrapped in quotes or not
+set NON_SPACED_CMD=%_JAVACMD: =%
+if "%_JAVACMD%"=="%NON_SPACED_CMD%" %_JAVACMD% %DEBUG_OPTS% %MEM_OPTS% %ACTIVATOR_OPTS% %SBT_OPTS% %_JAVA_OPTS% "-Dactivator.home=%JAVA_FRIENDLY_HOME%" -jar "%ACTIVATOR_HOME%\libexec\%ACTIVATOR_LAUNCH_JAR%" %CMDS%
+if NOT "%_JAVACMD%"=="%NON_SPACED_CMD%" "%_JAVACMD%" %DEBUG_OPTS% %MEM_OPTS% %ACTIVATOR_OPTS% %SBT_OPTS% %_JAVA_OPTS% "-Dactivator.home=%JAVA_FRIENDLY_HOME%" -jar "%ACTIVATOR_HOME%\libexec\%ACTIVATOR_LAUNCH_JAR%" %CMDS%
+
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+
+@endlocal
+
+exit /B %ERROR_CODE%
diff --git a/play-framework/student-api/build.sbt b/play-framework/student-api/build.sbt
new file mode 100644
index 0000000000..0f5ea736f6
--- /dev/null
+++ b/play-framework/student-api/build.sbt
@@ -0,0 +1,13 @@
+name := """student-api"""
+
+version := "1.0-SNAPSHOT"
+
+lazy val root = (project in file(".")).enablePlugins(PlayJava)
+
+scalaVersion := "2.11.7"
+
+libraryDependencies ++= Seq(
+ javaJdbc,
+ cache,
+ javaWs
+)
diff --git a/play-framework/student-api/conf/application.conf b/play-framework/student-api/conf/application.conf
new file mode 100644
index 0000000000..489d3f9b3e
--- /dev/null
+++ b/play-framework/student-api/conf/application.conf
@@ -0,0 +1,353 @@
+# This is the main configuration file for the application.
+# https://www.playframework.com/documentation/latest/ConfigFile
+# ~~~~~
+# Play uses HOCON as its configuration file format. HOCON has a number
+# of advantages over other config formats, but there are two things that
+# can be used when modifying settings.
+#
+# You can include other configuration files in this main application.conf file:
+#include "extra-config.conf"
+#
+# You can declare variables and substitute for them:
+#mykey = ${some.value}
+#
+# And if an environment variable exists when there is no other subsitution, then
+# HOCON will fall back to substituting environment variable:
+#mykey = ${JAVA_HOME}
+
+## Akka
+# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration
+# https://www.playframework.com/documentation/latest/JavaAkka#Configuration
+# ~~~~~
+# Play uses Akka internally and exposes Akka Streams and actors in Websockets and
+# other streaming HTTP responses.
+akka {
+ # "akka.log-config-on-start" is extraordinarly useful because it log the complete
+ # configuration at INFO level, including defaults and overrides, so it s worth
+ # putting at the very top.
+ #
+ # Put the following in your conf/logback.xml file:
+ #
+ #
+ #
+ # And then uncomment this line to debug the configuration.
+ #
+ #log-config-on-start = true
+}
+
+## Secret key
+# http://www.playframework.com/documentation/latest/ApplicationSecret
+# ~~~~~
+# The secret key is used to sign Play's session cookie.
+# This must be changed for production, but we don't recommend you change it in this file.
+play.crypto.secret = "changeme"
+
+## Modules
+# https://www.playframework.com/documentation/latest/Modules
+# ~~~~~
+# Control which modules are loaded when Play starts. Note that modules are
+# the replacement for "GlobalSettings", which are deprecated in 2.5.x.
+# Please see https://www.playframework.com/documentation/latest/GlobalSettings
+# for more information.
+#
+# You can also extend Play functionality by using one of the publically available
+# Play modules: https://playframework.com/documentation/latest/ModuleDirectory
+play.modules {
+ # By default, Play will load any class called Module that is defined
+ # in the root package (the "app" directory), or you can define them
+ # explicitly below.
+ # If there are any built-in modules that you want to disable, you can list them here.
+ #enabled += my.application.Module
+
+ # If there are any built-in modules that you want to disable, you can list them here.
+ #disabled += ""
+}
+
+## IDE
+# https://www.playframework.com/documentation/latest/IDE
+# ~~~~~
+# Depending on your IDE, you can add a hyperlink for errors that will jump you
+# directly to the code location in the IDE in dev mode. The following line makes
+# use of the IntelliJ IDEA REST interface:
+#play.editor="http://localhost:63342/api/file/?file=%s&line=%s"
+
+## Internationalisation
+# https://www.playframework.com/documentation/latest/JavaI18N
+# https://www.playframework.com/documentation/latest/ScalaI18N
+# ~~~~~
+# Play comes with its own i18n settings, which allow the user's preferred language
+# to map through to internal messages, or allow the language to be stored in a cookie.
+play.i18n {
+ # The application languages
+ langs = [ "en" ]
+
+ # Whether the language cookie should be secure or not
+ #langCookieSecure = true
+
+ # Whether the HTTP only attribute of the cookie should be set to true
+ #langCookieHttpOnly = true
+}
+
+## Play HTTP settings
+# ~~~~~
+play.http {
+ ## Router
+ # https://www.playframework.com/documentation/latest/JavaRouting
+ # https://www.playframework.com/documentation/latest/ScalaRouting
+ # ~~~~~
+ # Define the Router object to use for this application.
+ # This router will be looked up first when the application is starting up,
+ # so make sure this is the entry point.
+ # Furthermore, it's assumed your route file is named properly.
+ # So for an application router like `my.application.Router`,
+ # you may need to define a router file `conf/my.application.routes`.
+ # Default to Routes in the root package (aka "apps" folder) (and conf/routes)
+ #router = my.application.Router
+
+ ## Action Creator
+ # https://www.playframework.com/documentation/latest/JavaActionCreator
+ # ~~~~~
+ #actionCreator = null
+
+ ## ErrorHandler
+ # https://www.playframework.com/documentation/latest/JavaRouting
+ # https://www.playframework.com/documentation/latest/ScalaRouting
+ # ~~~~~
+ # If null, will attempt to load a class called ErrorHandler in the root package,
+ #errorHandler = null
+
+ ## Filters
+ # https://www.playframework.com/documentation/latest/ScalaHttpFilters
+ # https://www.playframework.com/documentation/latest/JavaHttpFilters
+ # ~~~~~
+ # Filters run code on every request. They can be used to perform
+ # common logic for all your actions, e.g. adding common headers.
+ # Defaults to "Filters" in the root package (aka "apps" folder)
+ # Alternatively you can explicitly register a class here.
+ #filters = my.application.Filters
+
+ ## Session & Flash
+ # https://www.playframework.com/documentation/latest/JavaSessionFlash
+ # https://www.playframework.com/documentation/latest/ScalaSessionFlash
+ # ~~~~~
+ session {
+ # Sets the cookie to be sent only over HTTPS.
+ #secure = true
+
+ # Sets the cookie to be accessed only by the server.
+ #httpOnly = true
+
+ # Sets the max-age field of the cookie to 5 minutes.
+ # NOTE: this only sets when the browser will discard the cookie. Play will consider any
+ # cookie value with a valid signature to be a valid session forever. To implement a server side session timeout,
+ # you need to put a timestamp in the session and check it at regular intervals to possibly expire it.
+ #maxAge = 300
+
+ # Sets the domain on the session cookie.
+ #domain = "example.com"
+ }
+
+ flash {
+ # Sets the cookie to be sent only over HTTPS.
+ #secure = true
+
+ # Sets the cookie to be accessed only by the server.
+ #httpOnly = true
+ }
+}
+
+## Netty Provider
+# https://www.playframework.com/documentation/latest/SettingsNetty
+# ~~~~~
+play.server.netty {
+ # Whether the Netty wire should be logged
+ #log.wire = true
+
+ # If you run Play on Linux, you can use Netty's native socket transport
+ # for higher performance with less garbage.
+ #transport = "native"
+}
+
+## WS (HTTP Client)
+# https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS
+# ~~~~~
+# The HTTP client primarily used for REST APIs. The default client can be
+# configured directly, but you can also create different client instances
+# with customized settings. You must enable this by adding to build.sbt:
+#
+# libraryDependencies += ws // or javaWs if using java
+#
+play.ws {
+ # Sets HTTP requests not to follow 302 requests
+ #followRedirects = false
+
+ # Sets the maximum number of open HTTP connections for the client.
+ #ahc.maxConnectionsTotal = 50
+
+ ## WS SSL
+ # https://www.playframework.com/documentation/latest/WsSSL
+ # ~~~~~
+ ssl {
+ # Configuring HTTPS with Play WS does not require programming. You can
+ # set up both trustManager and keyManager for mutual authentication, and
+ # turn on JSSE debugging in development with a reload.
+ #debug.handshake = true
+ #trustManager = {
+ # stores = [
+ # { type = "JKS", path = "exampletrust.jks" }
+ # ]
+ #}
+ }
+}
+
+## Cache
+# https://www.playframework.com/documentation/latest/JavaCache
+# https://www.playframework.com/documentation/latest/ScalaCache
+# ~~~~~
+# Play comes with an integrated cache API that can reduce the operational
+# overhead of repeated requests. You must enable this by adding to build.sbt:
+#
+# libraryDependencies += cache
+#
+play.cache {
+ # If you want to bind several caches, you can bind the individually
+ #bindCaches = ["db-cache", "user-cache", "session-cache"]
+}
+
+## Filters
+# https://www.playframework.com/documentation/latest/Filters
+# ~~~~~
+# There are a number of built-in filters that can be enabled and configured
+# to give Play greater security. You must enable this by adding to build.sbt:
+#
+# libraryDependencies += filters
+#
+play.filters {
+ ## CORS filter configuration
+ # https://www.playframework.com/documentation/latest/CorsFilter
+ # ~~~~~
+ # CORS is a protocol that allows web applications to make requests from the browser
+ # across different domains.
+ # NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has
+ # dependencies on CORS settings.
+ cors {
+ # Filter paths by a whitelist of path prefixes
+ #pathPrefixes = ["/some/path", ...]
+
+ # The allowed origins. If null, all origins are allowed.
+ #allowedOrigins = ["http://www.example.com"]
+
+ # The allowed HTTP methods. If null, all methods are allowed
+ #allowedHttpMethods = ["GET", "POST"]
+ }
+
+ ## CSRF Filter
+ # https://www.playframework.com/documentation/latest/ScalaCsrf#Applying-a-global-CSRF-filter
+ # https://www.playframework.com/documentation/latest/JavaCsrf#Applying-a-global-CSRF-filter
+ # ~~~~~
+ # Play supports multiple methods for verifying that a request is not a CSRF request.
+ # The primary mechanism is a CSRF token. This token gets placed either in the query string
+ # or body of every form submitted, and also gets placed in the users session.
+ # Play then verifies that both tokens are present and match.
+ csrf {
+ # Sets the cookie to be sent only over HTTPS
+ #cookie.secure = true
+
+ # Defaults to CSRFErrorHandler in the root package.
+ #errorHandler = MyCSRFErrorHandler
+ }
+
+ ## Security headers filter configuration
+ # https://www.playframework.com/documentation/latest/SecurityHeaders
+ # ~~~~~
+ # Defines security headers that prevent XSS attacks.
+ # If enabled, then all options are set to the below configuration by default:
+ headers {
+ # The X-Frame-Options header. If null, the header is not set.
+ #frameOptions = "DENY"
+
+ # The X-XSS-Protection header. If null, the header is not set.
+ #xssProtection = "1; mode=block"
+
+ # The X-Content-Type-Options header. If null, the header is not set.
+ #contentTypeOptions = "nosniff"
+
+ # The X-Permitted-Cross-Domain-Policies header. If null, the header is not set.
+ #permittedCrossDomainPolicies = "master-only"
+
+ # The Content-Security-Policy header. If null, the header is not set.
+ #contentSecurityPolicy = "default-src 'self'"
+ }
+
+ ## Allowed hosts filter configuration
+ # https://www.playframework.com/documentation/latest/AllowedHostsFilter
+ # ~~~~~
+ # Play provides a filter that lets you configure which hosts can access your application.
+ # This is useful to prevent cache poisoning attacks.
+ hosts {
+ # Allow requests to example.com, its subdomains, and localhost:9000.
+ #allowed = [".example.com", "localhost:9000"]
+ }
+}
+
+## Evolutions
+# https://www.playframework.com/documentation/latest/Evolutions
+# ~~~~~
+# Evolutions allows database scripts to be automatically run on startup in dev mode
+# for database migrations. You must enable this by adding to build.sbt:
+#
+# libraryDependencies += evolutions
+#
+play.evolutions {
+ # You can disable evolutions for a specific datasource if necessary
+ #db.default.enabled = false
+}
+
+## Database Connection Pool
+# https://www.playframework.com/documentation/latest/SettingsJDBC
+# ~~~~~
+# Play doesn't require a JDBC database to run, but you can easily enable one.
+#
+# libraryDependencies += jdbc
+#
+play.db {
+ # The combination of these two settings results in "db.default" as the
+ # default JDBC pool:
+ #config = "db"
+ #default = "default"
+
+ # Play uses HikariCP as the default connection pool. You can override
+ # settings by changing the prototype:
+ prototype {
+ # Sets a fixed JDBC connection pool size of 50
+ #hikaricp.minimumIdle = 50
+ #hikaricp.maximumPoolSize = 50
+ }
+}
+
+## JDBC Datasource
+# https://www.playframework.com/documentation/latest/JavaDatabase
+# https://www.playframework.com/documentation/latest/ScalaDatabase
+# ~~~~~
+# Once JDBC datasource is set up, you can work with several different
+# database options:
+#
+# Slick (Scala preferred option): https://www.playframework.com/documentation/latest/PlaySlick
+# JPA (Java preferred option): https://playframework.com/documentation/latest/JavaJPA
+# EBean: https://playframework.com/documentation/latest/JavaEbean
+# Anorm: https://www.playframework.com/documentation/latest/ScalaAnorm
+#
+db {
+ # You can declare as many datasources as you want.
+ # By convention, the default datasource is named `default`
+
+ # https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
+ #default.driver = org.h2.Driver
+ #default.url = "jdbc:h2:mem:play"
+ #default.username = sa
+ #default.password = ""
+
+ # You can turn on SQL logging for any datasource
+ # https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
+ #default.logSql=true
+}
diff --git a/play-framework/student-api/conf/logback.xml b/play-framework/student-api/conf/logback.xml
new file mode 100644
index 0000000000..86ec12c0af
--- /dev/null
+++ b/play-framework/student-api/conf/logback.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ ${application.home:-.}/logs/application.log
+
+ %date [%level] from %logger in %thread - %message%n%xException
+
+
+
+
+
+ %coloredLevel %logger{15} - %message%n%xException{10}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/play-framework/student-api/conf/routes b/play-framework/student-api/conf/routes
new file mode 100644
index 0000000000..ab55792683
--- /dev/null
+++ b/play-framework/student-api/conf/routes
@@ -0,0 +1,12 @@
+# Routes
+# This file defines all application routes (Higher priority routes first)
+# ~~~~
+
+GET / controllers.StudentController.listStudents()
+POST /:id controllers.StudentController.retrieve(id:Int)
+POST / controllers.StudentController.create()
+PUT / controllers.StudentController.update()
+DELETE /:id controllers.StudentController.delete(id:Int)
+
+# Map static resources from the /public folder to the /assets URL path
+GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
diff --git a/play-framework/student-api/libexec/activator-launch-1.3.10.jar b/play-framework/student-api/libexec/activator-launch-1.3.10.jar
new file mode 100644
index 0000000000..69050e7dec
Binary files /dev/null and b/play-framework/student-api/libexec/activator-launch-1.3.10.jar differ
diff --git a/play-framework/student-api/project/build.properties b/play-framework/student-api/project/build.properties
new file mode 100644
index 0000000000..6d9fa6badb
--- /dev/null
+++ b/play-framework/student-api/project/build.properties
@@ -0,0 +1,4 @@
+#Activator-generated Properties
+#Wed Sep 07 12:29:40 EAT 2016
+template.uuid=c373963b-f5ad-433b-8e74-178e7ae25b1c
+sbt.version=0.13.11
diff --git a/play-framework/student-api/project/plugins.sbt b/play-framework/student-api/project/plugins.sbt
new file mode 100644
index 0000000000..51c5b2a35a
--- /dev/null
+++ b/play-framework/student-api/project/plugins.sbt
@@ -0,0 +1,21 @@
+// The Play plugin
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.6")
+
+// Web plugins
+addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
+addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
+addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
+addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
+addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
+addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
+addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2")
+
+// Play enhancer - this automatically generates getters/setters for public fields
+// and rewrites accessors of these fields to use the getters/setters. Remove this
+// plugin if you prefer not to have this feature, or disable on a per project
+// basis using disablePlugins(PlayEnhancer) in your build.sbt
+addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
+
+// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
+// enablePlugins(PlayEbean).
+// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")
diff --git a/play-framework/student-api/public/images/favicon.png b/play-framework/student-api/public/images/favicon.png
new file mode 100644
index 0000000000..c7d92d2ae4
Binary files /dev/null and b/play-framework/student-api/public/images/favicon.png differ
diff --git a/play-framework/student-api/public/javascripts/hello.js b/play-framework/student-api/public/javascripts/hello.js
new file mode 100644
index 0000000000..02ee13c7ca
--- /dev/null
+++ b/play-framework/student-api/public/javascripts/hello.js
@@ -0,0 +1,3 @@
+if (window.console) {
+ console.log("Welcome to your Play application's JavaScript!");
+}
diff --git a/spring-cloud-data-flow/data-flow-server/src/main/resources/application.properties b/play-framework/student-api/public/stylesheets/main.css
similarity index 100%
rename from spring-cloud-data-flow/data-flow-server/src/main/resources/application.properties
rename to play-framework/student-api/public/stylesheets/main.css
diff --git a/play-framework/student-api/test/ApplicationTest.java b/play-framework/student-api/test/ApplicationTest.java
new file mode 100644
index 0000000000..3d7c4875aa
--- /dev/null
+++ b/play-framework/student-api/test/ApplicationTest.java
@@ -0,0 +1,45 @@
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.*;
+
+import play.mvc.*;
+import play.test.*;
+import play.data.DynamicForm;
+import play.data.validation.ValidationError;
+import play.data.validation.Constraints.RequiredValidator;
+import play.i18n.Lang;
+import play.libs.F;
+import play.libs.F.*;
+import play.twirl.api.Content;
+
+import static play.test.Helpers.*;
+import static org.junit.Assert.*;
+
+
+/**
+ *
+ * Simple (JUnit) tests that can call all parts of a play app.
+ * If you are interested in mocking a whole application, see the wiki for more details.
+ *
+ */
+public class ApplicationTest {
+
+ @Test
+ public void simpleCheck() {
+ int a = 1 + 1;
+ assertEquals(2, a);
+ }
+
+ @Test
+ public void renderTemplate() {
+ Content html = views.html.index.render("Your new application is ready.");
+ assertEquals("text/html", html.contentType());
+ assertTrue(html.body().contains("Your new application is ready."));
+ }
+
+
+}
diff --git a/play-framework/student-api/test/IntegrationTest.java b/play-framework/student-api/test/IntegrationTest.java
new file mode 100644
index 0000000000..c53c71e124
--- /dev/null
+++ b/play-framework/student-api/test/IntegrationTest.java
@@ -0,0 +1,25 @@
+import org.junit.*;
+
+import play.mvc.*;
+import play.test.*;
+
+import static play.test.Helpers.*;
+import static org.junit.Assert.*;
+
+import static org.fluentlenium.core.filter.FilterConstructor.*;
+
+public class IntegrationTest {
+
+ /**
+ * add your integration test here
+ * in this example we just check if the welcome page is being shown
+ */
+ @Test
+ public void test() {
+ running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, browser -> {
+ browser.goTo("http://localhost:3333");
+ assertTrue(browser.pageSource().contains("Your new application is ready."));
+ });
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index a98ecc682b..8115c1e902 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
parent-modules
@@ -16,16 +16,22 @@
assertj
apache-cxf
- apache-fop
+
autovalue-tutorial
+
cdi
core-java
core-java-8
+
couchbase-sdk-intro
couchbase-sdk-spring-service
+ dozer
dependency-injection
deltaspike
+
+ enterprise-patterns
+ feign-client
gson
@@ -33,9 +39,12 @@
guava
guava18
guava19
+
handling-spring-static-resources
httpclient
+
immutables
+
jackson
javaxval
jjwt
@@ -44,16 +53,23 @@
json
json-path
junit5
- mockito
- mocks
jee7schedule
+
+ log4j
+
+ mockito
+ mocks
+ mutation-testing
+
+ orika
+
querydsl
+
rest-assured
rest-testing
resteasy
- log4j
spring-all
spring-akka
@@ -89,6 +105,7 @@
spring-rest-angular
spring-rest-docs
spring-cloud
+ spring-cloud-data-flow
spring-security-basic-auth
spring-security-custom-permission
@@ -106,17 +123,16 @@
spring-security-x509
spring-thymeleaf
spring-zuul
+ spring-mvc-velocity
+
jsf
xml
lombok
redis
-
- mutation-testing
- spring-mvc-velocity
+ wicket
xstream
- dozer
- orika
+ java-cassandra
diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml
new file mode 100644
index 0000000000..c6bd2b042c
--- /dev/null
+++ b/selenium-junit-testng/pom.xml
@@ -0,0 +1,36 @@
+
+ 4.0.0
+ com.baeldung
+ selenium-junit-testng
+ 0.0.1-SNAPSHOT
+
+ src
+
+
+ maven-compiler-plugin
+ 3.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 2.53.1
+
+
+ junit
+ junit
+ 4.8.1
+
+
+ org.testng
+ testng
+ 6.9.10
+
+
+
\ No newline at end of file
diff --git a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
new file mode 100644
index 0000000000..6020b6bd2c
--- /dev/null
+++ b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java
@@ -0,0 +1,29 @@
+package main.java.com.baeldung.selenium;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+public class SeleniumExample {
+
+ private WebDriver webDriver;
+ private final String url = "http://www.baeldung.com/";
+ private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
+
+ public SeleniumExample() {
+ webDriver = new FirefoxDriver();
+ webDriver.get(url);
+ }
+
+ public void closeWindow() {
+ webDriver.close();
+ }
+
+ public String getActualTitle() {
+ return webDriver.getTitle();
+ }
+
+ public String getExpectedTitle() {
+ return expectedTitle;
+ }
+
+}
diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java
new file mode 100644
index 0000000000..371f730eb9
--- /dev/null
+++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java
@@ -0,0 +1,30 @@
+package test.java.com.baeldung.selenium.junit;
+
+import static org.testng.Assert.assertEquals;
+import main.java.com.baeldung.selenium.SeleniumExample;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestSeleniumWithJUnit {
+
+ private SeleniumExample seleniumExample;
+
+ @Before
+ public void setUp() {
+ seleniumExample = new SeleniumExample();
+ }
+
+ @After
+ public void tearDown() {
+ seleniumExample.closeWindow();
+ }
+
+ @Test
+ public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
+ String expectedTitle = seleniumExample.getExpectedTitle();
+ String actualTitle = seleniumExample.getActualTitle();
+ assertEquals(actualTitle, expectedTitle);
+ }
+}
diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java
new file mode 100644
index 0000000000..ec10f9ca82
--- /dev/null
+++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java
@@ -0,0 +1,30 @@
+package test.java.com.baeldung.selenium.testng;
+
+import static org.testng.Assert.assertEquals;
+import main.java.com.baeldung.selenium.SeleniumExample;
+
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+public class TestSeleniumWithTestNG {
+
+ private SeleniumExample seleniumExample;
+
+ @BeforeSuite
+ public void setUp() {
+ seleniumExample = new SeleniumExample();
+ }
+
+ @AfterSuite
+ public void tearDown() {
+ seleniumExample.closeWindow();
+ }
+
+ @Test
+ public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
+ String expectedTitle = seleniumExample.getExpectedTitle();
+ String actualTitle = seleniumExample.getActualTitle();
+ assertEquals(actualTitle, expectedTitle);
+ }
+}
diff --git a/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java
new file mode 100644
index 0000000000..dcdfafc4f1
--- /dev/null
+++ b/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java
@@ -0,0 +1,34 @@
+package com.baeldun.selenium.testng;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+public class TestSeleniumWithTestNG {
+
+ private WebDriver webDriver;
+ private final String url = "http://www.baeldung.com/";
+ private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
+
+ @BeforeSuite
+ public void setUp() {
+ webDriver = new FirefoxDriver();
+ webDriver.get(url);
+ }
+
+ @AfterSuite
+ public void tearDown() {
+ webDriver.close();
+ }
+
+ @Test
+ public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
+ String actualTitleReturned = webDriver.getTitle();
+ assertNotNull(actualTitleReturned);
+ assertEquals(expectedTitle, actualTitleReturned);
+ }
+}
diff --git a/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java
new file mode 100644
index 0000000000..a7b36c4e4e
--- /dev/null
+++ b/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java
@@ -0,0 +1,34 @@
+package com.baeldung.selenium.junit;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+public class TestSeleniumWithJUnit {
+
+ private WebDriver webDriver;
+ private final String url = "http://www.baeldung.com/";
+ private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
+
+ @Before
+ public void setUp() {
+ webDriver = new FirefoxDriver();
+ webDriver.get(url);
+ }
+
+ @After
+ public void tearDown() {
+ webDriver.close();
+ }
+
+ @Test
+ public void whenPageIsLoaded_thenTitleIsAsPerExpectation() {
+ String actualTitleReturned = webDriver.getTitle();
+ assertNotNull(actualTitleReturned);
+ assertEquals(expectedTitle, actualTitleReturned);
+ }
+}
diff --git a/spring-cloud-config/client-config/config-client-development.properties b/spring-cloud-config/client-config/config-client-development.properties
deleted file mode 100644
index 6401d1be7f..0000000000
--- a/spring-cloud-config/client-config/config-client-development.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-user.role=Developer
-user.password=pass
diff --git a/spring-cloud-config/client-config/config-client-production.properties b/spring-cloud-config/client-config/config-client-production.properties
deleted file mode 100644
index cd2e14fcc3..0000000000
--- a/spring-cloud-config/client-config/config-client-production.properties
+++ /dev/null
@@ -1 +0,0 @@
-user.role=User
diff --git a/spring-cloud-config/docker/Dockerfile b/spring-cloud-config/docker/Dockerfile
deleted file mode 100644
index bdb37abf80..0000000000
--- a/spring-cloud-config/docker/Dockerfile
+++ /dev/null
@@ -1,4 +0,0 @@
-FROM alpine:edge
-MAINTAINER baeldung.com
-RUN apk add --no-cache openjdk8
-COPY files/UnlimitedJCEPolicyJDK8/* /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
diff --git a/spring-cloud-config/docker/docker-compose.scale.yml b/spring-cloud-config/docker/docker-compose.scale.yml
deleted file mode 100644
index f74153bea3..0000000000
--- a/spring-cloud-config/docker/docker-compose.scale.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-version: '2'
-services:
- config-server:
- build:
- context: .
- dockerfile: Dockerfile.server
- image: config-server:latest
- expose:
- - 8888
- networks:
- - spring-cloud-network
- volumes:
- - spring-cloud-config-repo:/var/lib/spring-cloud/config-repo
- logging:
- driver: json-file
- config-client:
- build:
- context: .
- dockerfile: Dockerfile.client
- image: config-client:latest
- entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh
- environment:
- SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}'
- expose:
- - 8080
- ports:
- - 8080
- networks:
- - spring-cloud-network
- links:
- - config-server:config-server
- depends_on:
- - config-server
- logging:
- driver: json-file
-networks:
- spring-cloud-network:
- driver: bridge
-volumes:
- spring-cloud-config-repo:
- external: true
diff --git a/spring-cloud-config/docker/docker-compose.yml b/spring-cloud-config/docker/docker-compose.yml
deleted file mode 100644
index 74c71b651c..0000000000
--- a/spring-cloud-config/docker/docker-compose.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-version: '2'
-services:
- config-server:
- container_name: config-server
- build:
- context: .
- dockerfile: Dockerfile.server
- image: config-server:latest
- expose:
- - 8888
- networks:
- - spring-cloud-network
- volumes:
- - spring-cloud-config-repo:/var/lib/spring-cloud/config-repo
- logging:
- driver: json-file
- config-client:
- container_name: config-client
- build:
- context: .
- dockerfile: Dockerfile.client
- image: config-client:latest
- entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh
- environment:
- SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}'
- expose:
- - 8080
- ports:
- - 8080:8080
- networks:
- - spring-cloud-network
- links:
- - config-server:config-server
- depends_on:
- - config-server
- logging:
- driver: json-file
-networks:
- spring-cloud-network:
- driver: bridge
-volumes:
- spring-cloud-config-repo:
- external: true
diff --git a/spring-cloud-config/spring-cloud-config-client/pom.xml b/spring-cloud-config/spring-cloud-config-client/pom.xml
deleted file mode 100644
index 968489bce2..0000000000
--- a/spring-cloud-config/spring-cloud-config-client/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- 4.0.0
-
-
- com.baeldung.spring.cloud
- spring-cloud-config
- 1.0.0-SNAPSHOT
-
- spring-cloud-config-client
- jar
-
- spring-cloud-config-client
-
-
-
- org.springframework.cloud
- spring-cloud-starter-config
- 1.1.3.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- ../docker/files
-
-
-
-
-
diff --git a/spring-cloud-config/spring-cloud-config-client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java b/spring-cloud-config/spring-cloud-config-client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java
deleted file mode 100644
index 1dd3bbdab0..0000000000
--- a/spring-cloud-config/spring-cloud-config-client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.baeldung.spring.cloud.config.client;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-@SpringBootApplication
-@RestController
-public class ConfigClient {
- @Value("${user.role}")
- private String role;
-
- @Value("${user.password}")
- private String password;
-
- public static void main(String[] args) {
- SpringApplication.run(ConfigClient.class, args);
- }
-
- @RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
- public String whoami(@PathVariable("username") String username) {
- return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password);
- }
-}
diff --git a/spring-cloud-config/spring-cloud-config-client/src/main/resources/bootstrap.properties b/spring-cloud-config/spring-cloud-config-client/src/main/resources/bootstrap.properties
deleted file mode 100644
index 6c350bffcd..0000000000
--- a/spring-cloud-config/spring-cloud-config-client/src/main/resources/bootstrap.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-spring.application.name=config-client
-spring.profiles.active=development
-spring.cloud.config.uri=http://localhost:${PORT:8888}
-spring.cloud.config.username=root
-spring.cloud.config.password=s3cr3t
diff --git a/spring-cloud-config/spring-cloud-config-server/pom.xml b/spring-cloud-config/spring-cloud-config-server/pom.xml
deleted file mode 100644
index f2b8b69a6a..0000000000
--- a/spring-cloud-config/spring-cloud-config-server/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
- 4.0.0
-
-
- com.baeldung.spring.cloud
- spring-cloud-config
- 1.0.0-SNAPSHOT
-
- spring-cloud-config-server
-
- spring-cloud-config-server
-
-
-
- org.springframework.cloud
- spring-cloud-config-server
- 1.1.3.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-security
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- ../docker/files
-
-
-
-
-
diff --git a/spring-cloud-config/spring-cloud-config-server/src/main/resources/application.properties b/spring-cloud-config/spring-cloud-config-server/src/main/resources/application.properties
deleted file mode 100644
index c4f57f0a82..0000000000
--- a/spring-cloud-config/spring-cloud-config-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-server.port=${PORT:8888}
-spring.cloud.config.server.git.uri=${CONFIG_REPO}
-spring.cloud.config.server.git.clone-on-start=false
-spring.cloud.config.fail-fast=true
-security.user.name=root
-security.user.password=s3cr3t
-encrypt.key-store.location=classpath:/config-server.jks
-encrypt.key-store.password=my-s70r3-s3cr3t
-encrypt.key-store.alias=config-server-key
-encrypt.key-store.secret=my-k34-s3cr3t
diff --git a/spring-cloud-config/spring-cloud-config-server/src/main/resources/config-server.jks b/spring-cloud-config/spring-cloud-config-server/src/main/resources/config-server.jks
deleted file mode 100644
index f3dddb4a8f..0000000000
Binary files a/spring-cloud-config/spring-cloud-config-server/src/main/resources/config-server.jks and /dev/null differ
diff --git a/spring-cloud-data-flow/batch-job/pom.xml b/spring-cloud-data-flow/batch-job/pom.xml
new file mode 100644
index 0000000000..2ddb9d85a3
--- /dev/null
+++ b/spring-cloud-data-flow/batch-job/pom.xml
@@ -0,0 +1,74 @@
+
+
+ 4.0.0
+
+ org.baeldung.spring.cloud
+ batch-job
+ 0.0.1-SNAPSHOT
+ jar
+
+ batch-job
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.0.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-task-starter
+ 1.0.1.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-batch
+
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Brixton.SR5
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/BatchJobApplication.java b/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/BatchJobApplication.java
new file mode 100644
index 0000000000..f717f0f644
--- /dev/null
+++ b/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/BatchJobApplication.java
@@ -0,0 +1,16 @@
+package org.baeldung.spring.cloud;
+
+import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.task.configuration.EnableTask;
+
+@EnableTask
+@EnableBatchProcessing
+@SpringBootApplication
+public class BatchJobApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BatchJobApplication.class, args);
+ }
+}
diff --git a/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/JobConfiguration.java b/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/JobConfiguration.java
new file mode 100644
index 0000000000..dc6a5e2827
--- /dev/null
+++ b/spring-cloud-data-flow/batch-job/src/main/java/org/baeldung/spring/cloud/JobConfiguration.java
@@ -0,0 +1,38 @@
+package org.baeldung.spring.cloud;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
+import org.springframework.batch.core.scope.context.ChunkContext;
+import org.springframework.batch.core.step.tasklet.Tasklet;
+import org.springframework.batch.repeat.RepeatStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class JobConfiguration {
+
+ private static final Log logger = LogFactory.getLog(JobConfiguration.class);
+
+ @Autowired
+ public JobBuilderFactory jobBuilderFactory;
+
+ @Autowired
+ public StepBuilderFactory stepBuilderFactory;
+
+ @Bean
+ public Job job() {
+ return jobBuilderFactory.get("job").start(stepBuilderFactory.get("jobStep1").tasklet(new Tasklet() {
+ @Override
+ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
+ logger.info("Job was run");
+ return RepeatStatus.FINISHED;
+ }
+ }).build()).build();
+ }
+}
diff --git a/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/spring/cloud/BatchJobApplicationTests.java b/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/spring/cloud/BatchJobApplicationTests.java
new file mode 100644
index 0000000000..5f18ec75c4
--- /dev/null
+++ b/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/spring/cloud/BatchJobApplicationTests.java
@@ -0,0 +1,16 @@
+package org.baeldung.spring.cloud;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class BatchJobApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.jar b/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index 5fd4d5023f..0000000000
Binary files a/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index c954cec91c..0000000000
--- a/spring-cloud-data-flow/data-flow-server/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/spring-cloud-data-flow/data-flow-server/mvnw b/spring-cloud-data-flow/data-flow-server/mvnw
deleted file mode 100644
index a1ba1bf554..0000000000
--- a/spring-cloud-data-flow/data-flow-server/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/spring-cloud-data-flow/data-flow-server/mvnw.cmd b/spring-cloud-data-flow/data-flow-server/mvnw.cmd
deleted file mode 100644
index 2b934e89dd..0000000000
--- a/spring-cloud-data-flow/data-flow-server/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.jar b/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index 5fd4d5023f..0000000000
Binary files a/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index c954cec91c..0000000000
--- a/spring-cloud-data-flow/data-flow-shell/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/spring-cloud-data-flow/data-flow-shell/mvnw b/spring-cloud-data-flow/data-flow-shell/mvnw
deleted file mode 100644
index a1ba1bf554..0000000000
--- a/spring-cloud-data-flow/data-flow-shell/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/spring-cloud-data-flow/data-flow-shell/mvnw.cmd b/spring-cloud-data-flow/data-flow-shell/mvnw.cmd
deleted file mode 100644
index 2b934e89dd..0000000000
--- a/spring-cloud-data-flow/data-flow-shell/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/spring-cloud-data-flow/data-flow-shell/src/main/resources/application.properties b/spring-cloud-data-flow/data-flow-shell/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.jar b/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index 5fd4d5023f..0000000000
Binary files a/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index c954cec91c..0000000000
--- a/spring-cloud-data-flow/log-sink/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/spring-cloud-data-flow/log-sink/mvnw b/spring-cloud-data-flow/log-sink/mvnw
deleted file mode 100644
index a1ba1bf554..0000000000
--- a/spring-cloud-data-flow/log-sink/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/spring-cloud-data-flow/log-sink/mvnw.cmd b/spring-cloud-data-flow/log-sink/mvnw.cmd
deleted file mode 100644
index 2b934e89dd..0000000000
--- a/spring-cloud-data-flow/log-sink/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/spring-cloud-data-flow/log-sink/src/main/resources/application.properties b/spring-cloud-data-flow/log-sink/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud-data-flow/pom.xml b/spring-cloud-data-flow/pom.xml
index 9651c0b826..509c185d61 100644
--- a/spring-cloud-data-flow/pom.xml
+++ b/spring-cloud-data-flow/pom.xml
@@ -10,5 +10,6 @@
time-source
time-processor
log-sink
+ batch-job
diff --git a/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.jar b/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index 5fd4d5023f..0000000000
Binary files a/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index c954cec91c..0000000000
--- a/spring-cloud-data-flow/time-processor/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/spring-cloud-data-flow/time-processor/mvnw b/spring-cloud-data-flow/time-processor/mvnw
deleted file mode 100644
index a1ba1bf554..0000000000
--- a/spring-cloud-data-flow/time-processor/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/spring-cloud-data-flow/time-processor/mvnw.cmd b/spring-cloud-data-flow/time-processor/mvnw.cmd
deleted file mode 100644
index 2b934e89dd..0000000000
--- a/spring-cloud-data-flow/time-processor/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/spring-cloud-data-flow/time-processor/src/main/resources/application.properties b/spring-cloud-data-flow/time-processor/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.jar b/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index 5fd4d5023f..0000000000
Binary files a/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.properties b/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index c954cec91c..0000000000
--- a/spring-cloud-data-flow/time-source/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
diff --git a/spring-cloud-data-flow/time-source/mvnw b/spring-cloud-data-flow/time-source/mvnw
deleted file mode 100644
index a1ba1bf554..0000000000
--- a/spring-cloud-data-flow/time-source/mvnw
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Migwn, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- wdir=$(cd "$wdir/.."; pwd)
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} "$@"
diff --git a/spring-cloud-data-flow/time-source/mvnw.cmd b/spring-cloud-data-flow/time-source/mvnw.cmd
deleted file mode 100644
index 2b934e89dd..0000000000
--- a/spring-cloud-data-flow/time-source/mvnw.cmd
+++ /dev/null
@@ -1,145 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-set MAVEN_CMD_LINE_ARGS=%*
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
\ No newline at end of file
diff --git a/spring-cloud-data-flow/time-source/src/main/resources/application.properties b/spring-cloud-data-flow/time-source/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud-eureka/pom.xml b/spring-cloud-eureka/pom.xml
deleted file mode 100644
index 86e0354070..0000000000
--- a/spring-cloud-eureka/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
- 4.0.0
-
- com.baeldung.spring.cloud
- spring-cloud-eureka
- 1.0.0-SNAPSHOT
-
- spring-cloud-eureka-server
- spring-cloud-eureka-client
- spring-cloud-eureka-feign-client
-
- pom
-
- Spring Cloud Eureka
- Spring Cloud Eureka Server and Sample Clients
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
- ..
-
-
-
- UTF-8
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.5.1
-
- 1.8
- 1.8
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- 1.4.0.RELEASE
-
-
-
-
-
diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java
deleted file mode 100644
index 48099eeaa2..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.baeldung.spring.cloud.eureka.client;
-
-import com.netflix.discovery.EurekaClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@SpringBootApplication
-@EnableEurekaClient
-@RestController
-public class EurekaClientApplication implements GreetingController {
- @Autowired
- @Lazy
- private EurekaClient eurekaClient;
-
- @Value("${spring.application.name}")
- private String appName;
-
- public static void main(String[] args) {
- SpringApplication.run(EurekaClientApplication.class, args);
- }
-
- @Override
- public String greeting() {
- return String.format("Hello from '%s'!", eurekaClient.getApplication(appName).getName());
- }
-}
diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java
deleted file mode 100644
index 33ee2574b7..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.baeldung.spring.cloud.eureka.client;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-public interface GreetingController {
- @RequestMapping("/greeting")
- String greeting();
-}
diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml
deleted file mode 100644
index 08624aa159..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-spring:
- application:
- name: spring-cloud-eureka-client
-
-server:
- port: 0
-
-eureka:
- client:
- serviceUrl:
- defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
- instance:
- preferIpAddress: true
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml b/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml
deleted file mode 100644
index 9e639c666a..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
- 4.0.0
-
- spring-cloud-eureka-feign-client
- 1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Eureka Feign Client
- Spring Cloud Eureka - Sample Feign Client
-
-
- com.baeldung.spring.cloud
- spring-cloud-eureka
- 1.0.0-SNAPSHOT
- ..
-
-
-
-
- com.baeldung.spring.cloud
- spring-cloud-eureka-client
- 1.0.0-SNAPSHOT
-
-
- org.springframework.cloud
- spring-cloud-starter-feign
- 1.1.5.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Brixton.SR4
- pom
- import
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java
deleted file mode 100644
index 7beb51d1ac..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.baeldung.spring.cloud.feign.client;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@SpringBootApplication
-@EnableEurekaClient
-@EnableFeignClients
-@Controller
-public class FeignClientApplication {
- @Autowired
- private GreetingClient greetingClient;
-
- public static void main(String[] args) {
- SpringApplication.run(FeignClientApplication.class, args);
- }
-
- @RequestMapping("/get-greeting")
- public String greeting(Model model) {
- model.addAttribute("greeting", greetingClient.greeting());
- return "greeting-view";
- }
-}
diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java
deleted file mode 100644
index 6bd444b347..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.baeldung.spring.cloud.feign.client;
-
-import com.baeldung.spring.cloud.eureka.client.GreetingController;
-import org.springframework.cloud.netflix.feign.FeignClient;
-
-@FeignClient("spring-cloud-eureka-client")
-public interface GreetingClient extends GreetingController {
-}
diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml
deleted file mode 100644
index d053ef7a7e..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-spring:
- application:
- name: spring-cloud-eureka-feign-client
-
-server:
- port: 8080
-
-eureka:
- client:
- serviceUrl:
- defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html
deleted file mode 100644
index 42cdadb487..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- Greeting Page
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml
deleted file mode 100644
index 49c3179bb5..0000000000
--- a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-server:
- port: 8761
-
-eureka:
- client:
- registerWithEureka: false
- fetchRegistry: false
\ No newline at end of file
diff --git a/spring-cloud-hystrix/pom.xml b/spring-cloud-hystrix/pom.xml
deleted file mode 100644
index 2768a4f05b..0000000000
--- a/spring-cloud-hystrix/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
- 4.0.0
-
- com.baeldung.spring.cloud
- spring-cloud-hystrix
- 1.0.0-SNAPSHOT
-
- spring-cloud-hystrix-rest-producer
- spring-cloud-hystrix-rest-consumer
- spring-cloud-hystrix-feign-rest-consumer
-
- pom
-
- Spring Cloud Hystrix
- Spring Cloud Hystrix Demo
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
- ..
-
-
-
- UTF-8
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.5.1
-
- 1.8
- 1.8
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- 1.4.0.RELEASE
-
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml
deleted file mode 100644
index d2716e897e..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
- 4.0.0
-
- spring-cloud-hystrix-feign-rest-consumer
- 1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Hystrix Feign REST Consumer
- Spring Cloud Hystrix Feign Sample Implementation
-
-
- com.baeldung.spring.cloud
- spring-cloud-hystrix
- 1.0.0-SNAPSHOT
- ..
-
-
-
-
- com.baeldung.spring.cloud
- spring-cloud-hystrix-rest-producer
- 1.0.0-SNAPSHOT
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix
- 1.1.5.RELEASE
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix-dashboard
- 1.1.5.RELEASE
-
-
- org.springframework.cloud
- spring-cloud-starter-feign
- 1.1.5.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-actuator
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Brixton.SR4
- pom
- import
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java
deleted file mode 100644
index b715e8c052..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.consumer;
-
-import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController;
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.PathVariable;
-
-@FeignClient(
- name = "rest-producer",
- url = "http://localhost:9090",
- fallback = GreetingClient.GreetingClientFallback.class
-)
-public interface GreetingClient extends GreetingController {
- @Component
- public static class GreetingClientFallback implements GreetingClient {
- @Override
- public String greeting(@PathVariable("username") String username) {
- return "Hello User!";
- }
- }
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java
deleted file mode 100644
index b97d84eaf2..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.consumer;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@SpringBootApplication
-@EnableCircuitBreaker
-@EnableHystrixDashboard
-@EnableFeignClients
-@Controller
-public class RestConsumerFeignApplication {
- @Autowired
- private GreetingClient greetingClient;
-
- public static void main(String[] args) {
- SpringApplication.run(RestConsumerFeignApplication.class, args);
- }
-
- @RequestMapping("/get-greeting/{username}")
- public String getGreeting(Model model, @PathVariable("username") String username) {
- model.addAttribute("greeting", greetingClient.greeting(username));
- return "greeting-view";
- }
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties
deleted file mode 100644
index 3cf12afeb9..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-server.port=8082
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html
deleted file mode 100644
index 302390fde0..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- Greetings from Hystrix
-
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml
deleted file mode 100644
index c9be67c302..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
- 4.0.0
-
- spring-cloud-hystrix-rest-consumer
- 1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Hystrix REST Consumer
- Spring Cloud Hystrix Sample Implementation
-
-
- com.baeldung.spring.cloud
- spring-cloud-hystrix
- 1.0.0-SNAPSHOT
- ..
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix
- 1.1.5.RELEASE
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix-dashboard
- 1.1.5.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
- 1.4.0.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter-actuator
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Brixton.SR4
- pom
- import
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java
deleted file mode 100644
index d3d5e6e047..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.consumer;
-
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-@Service
-public class GreetingService {
- @HystrixCommand(fallbackMethod = "defaultGreeting")
- public String getGreeting(String username) {
- return new RestTemplate().getForObject("http://localhost:9090/greeting/{username}", String.class, username);
- }
-
- private String defaultGreeting(String username) {
- return "Hello User!";
- }
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java
deleted file mode 100644
index 9df745b1c6..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.consumer;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
-import org.springframework.cloud.netflix.hystrix.EnableHystrix;
-import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@SpringBootApplication
-@EnableCircuitBreaker
-@EnableHystrixDashboard
-@Controller
-public class RestConsumerApplication {
- @Autowired
- private GreetingService greetingService;
-
- public static void main(String[] args) {
- SpringApplication.run(RestConsumerApplication.class, args);
- }
-
- @RequestMapping("/get-greeting/{username}")
- public String getGreeting(Model model, @PathVariable("username") String username) {
- model.addAttribute("greeting", greetingService.getGreeting(username));
- return "greeting-view";
- }
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties
deleted file mode 100644
index 4c00e40deb..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-server.port=8080
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html
deleted file mode 100644
index 302390fde0..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- Greetings from Hystrix
-
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml
deleted file mode 100644
index 44e373c8ac..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- 4.0.0
-
- spring-cloud-hystrix-rest-producer
- 1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Hystrix REST Producer
- Spring Cloud Hystrix Sample REST Producer Implementation
-
-
- com.baeldung.spring.cloud
- spring-cloud-hystrix
- 1.0.0-SNAPSHOT
- ..
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
- 1.4.0.RELEASE
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java
deleted file mode 100644
index 81541b4f8f..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.producer;
-
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-public interface GreetingController {
- @RequestMapping("/greeting/{username}")
- String greeting(@PathVariable("username") String username);
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java
deleted file mode 100644
index 9496d4760d..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.baeldung.spring.cloud.hystrix.rest.producer;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-@SpringBootApplication
-@RestController
-public class RestProducerApplication implements GreetingController {
- public static void main(String[] args) {
- SpringApplication.run(RestProducerApplication.class, args);
- }
-
- @Override
- public String greeting(@PathVariable("username") String username) {
- return String.format("Hello %s!\n", username);
- }
-}
diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties
deleted file mode 100644
index 9ce9d88ffb..0000000000
--- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-spring.application.name=rest-producer
-server.port=9090
diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml
index 4f6b37a76f..340923cbdf 100644
--- a/spring-cloud/pom.xml
+++ b/spring-cloud/pom.xml
@@ -10,6 +10,7 @@
spring-cloud-config
spring-cloud-eureka
spring-cloud-hystrix
+ spring-cloud-integration
pom
diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties
new file mode 100644
index 0000000000..7f3df86c7e
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties
@@ -0,0 +1,8 @@
+spring.application.name=discovery
+server.port=8082
+
+eureka.instance.hostname=localhost
+
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/
+eureka.client.register-with-eureka=false
+eureka.client.fetch-registry=false
diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties
new file mode 100644
index 0000000000..77faec8421
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties
@@ -0,0 +1,10 @@
+spring.application.name=gateway
+server.port=8080
+
+eureka.client.region = default
+eureka.client.registryFetchIntervalSeconds = 5
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/
+
+zuul.routes.resource.path=/resource/**
+hystrix.command.resource.execution.isolation.thread.timeoutInMilliseconds: 5000
+
diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties
new file mode 100644
index 0000000000..4e6cf3817c
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties
@@ -0,0 +1,8 @@
+spring.application.name=resource
+server.port=8083
+
+resource.returnString=hello cloud
+
+eureka.client.region = default
+eureka.client.registryFetchIntervalSeconds = 5
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/
diff --git a/spring-cloud/spring-cloud-integration/part-1/config/pom.xml b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml
new file mode 100644
index 0000000000..0cb217acfb
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+ config
+ 1.0.0-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.0.RELEASE
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-config-server
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Brixton.RELEASE
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java b/spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java
similarity index 53%
rename from spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java
rename to spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java
index 4dd34ae3ff..ff6c093b8b 100644
--- a/spring-cloud-config/spring-cloud-config-server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java
+++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java
@@ -1,15 +1,15 @@
-package com.baeldung.spring.cloud.config.server;
+package com.baeldung.spring.cloud.integration.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableConfigServer
-@EnableWebSecurity
-public class ConfigServer {
+@EnableEurekaClient
+public class ConfigApplication {
public static void main(String[] args) {
- SpringApplication.run(ConfigServer.class, args);
+ SpringApplication.run(ConfigApplication.class, args);
}
}
diff --git a/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties
new file mode 100644
index 0000000000..6f614d0690
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+server.port=8081
+spring.application.name=config
+
+spring.cloud.config.server.git.uri=file:///${user.home}/application-config
+
+eureka.client.region = default
+eureka.client.registryFetchIntervalSeconds = 5
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml
similarity index 53%
rename from spring-cloud-eureka/spring-cloud-eureka-server/pom.xml
rename to spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml
index f4d655f708..ee7c589549 100644
--- a/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml
+++ b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml
@@ -1,27 +1,32 @@
-
4.0.0
- spring-cloud-eureka-server
+ discovery
1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Eureka Server
- Spring Cloud Eureka Server Demo
- com.baeldung.spring.cloud
- spring-cloud-eureka
- 1.0.0-SNAPSHOT
- ..
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.0.RELEASE
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
org.springframework.cloud
spring-cloud-starter-eureka-server
- 1.1.5.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
@@ -29,8 +34,8 @@
org.springframework.cloud
- spring-cloud-starter-parent
- Brixton.SR4
+ spring-cloud-dependencies
+ Brixton.RELEASE
pom
import
@@ -39,14 +44,10 @@
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
org.springframework.boot
spring-boot-maven-plugin
-
+
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java
similarity index 64%
rename from spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java
rename to spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java
index d55145448d..a21c65312f 100644
--- a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java
+++ b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring.cloud.eureka.server;
+package com.baeldung.spring.cloud.integration.discovery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -6,8 +6,8 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
-public class EurekaServerApplication {
+public class DiscoveryApplication {
public static void main(String[] args) {
- SpringApplication.run(EurekaServerApplication.class, args);
+ SpringApplication.run(DiscoveryApplication.class, args);
}
}
diff --git a/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties
new file mode 100644
index 0000000000..ca9d59c9ed
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties
@@ -0,0 +1,2 @@
+spring.cloud.config.name=discovery
+spring.cloud.config.uri=http://localhost:8081
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml
new file mode 100644
index 0000000000..8e56d0fd35
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml
@@ -0,0 +1,57 @@
+
+
+ 4.0.0
+
+ gateway
+ 1.0.0-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.0.RELEASE
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+ org.springframework.cloud
+ spring-cloud-starter-zuul
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Brixton.RELEASE
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java
new file mode 100644
index 0000000000..66e7c36f2a
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.spring.cloud.integration.resource;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+
+@SpringBootApplication
+@EnableZuulProxy
+@EnableEurekaClient
+public class GatewayApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(GatewayApplication.class, args);
+ }
+}
diff --git a/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties
new file mode 100644
index 0000000000..9610d72675
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties
@@ -0,0 +1,5 @@
+spring.cloud.config.name=gateway
+spring.cloud.config.discovery.service-id=config
+spring.cloud.config.discovery.enabled=true
+
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-integration/part-1/pom.xml b/spring-cloud/spring-cloud-integration/part-1/pom.xml
new file mode 100644
index 0000000000..770e26bca2
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/pom.xml
@@ -0,0 +1,25 @@
+
+
+ 4.0.0
+
+
+ com.baeldung.spring.cloud
+ spring-cloud-integration
+ 1.0.0-SNAPSHOT
+
+
+
+ config
+ discovery
+ gateway
+ resource
+
+
+ part-1
+ 1.0.0-SNAPSHOT
+ pom
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml
similarity index 56%
rename from spring-cloud-eureka/spring-cloud-eureka-client/pom.xml
rename to spring-cloud/spring-cloud-integration/part-1/resource/pom.xml
index 720b49ddc2..78112fa3e0 100644
--- a/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml
+++ b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml
@@ -1,32 +1,36 @@
-
4.0.0
- spring-cloud-eureka-client
+ resource
1.0.0-SNAPSHOT
- jar
-
- Spring Cloud Eureka Client
- Spring Cloud Eureka Sample Client
- com.baeldung.spring.cloud
- spring-cloud-eureka
- 1.0.0-SNAPSHOT
- ..
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.4.0.RELEASE
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
org.springframework.cloud
spring-cloud-starter-eureka
- 1.1.5.RELEASE
org.springframework.boot
spring-boot-starter-web
- 1.4.0.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
@@ -34,8 +38,8 @@
org.springframework.cloud
- spring-cloud-starter-parent
- Brixton.SR4
+ spring-cloud-dependencies
+ Brixton.RELEASE
pom
import
@@ -44,14 +48,10 @@
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
org.springframework.boot
spring-boot-maven-plugin
-
+
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java
new file mode 100644
index 0000000000..107a9d199f
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java
@@ -0,0 +1,25 @@
+package com.baeldung.spring.cloud.integration.resource;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@SpringBootApplication
+@EnableEurekaClient
+@RestController
+public class ResourceApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ResourceApplication.class, args);
+ }
+
+ @Value("${resource.returnString}")
+ private String returnString;
+
+ @RequestMapping("/hello/cloud")
+ public String getString() {
+ return returnString;
+ }
+}
diff --git a/spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties
new file mode 100644
index 0000000000..3c88a0b520
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties
@@ -0,0 +1,5 @@
+spring.cloud.config.name=resource
+spring.cloud.config.discovery.service-id=config
+spring.cloud.config.discovery.enabled=true
+
+eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml
new file mode 100644
index 0000000000..1d56995009
--- /dev/null
+++ b/spring-cloud/spring-cloud-integration/pom.xml
@@ -0,0 +1,15 @@
+
+
+ 4.0.0
+
+ com.baeldung.spring.cloud
+ spring-cloud-integration
+ 1.0.0-SNAPSHOT
+ pom
+
+
+ part-1
+
+
\ No newline at end of file
diff --git a/spring-data-elasticsearch/pom.xml b/spring-data-elasticsearch/pom.xml
index 3a6e330564..084695c2f3 100644
--- a/spring-data-elasticsearch/pom.xml
+++ b/spring-data-elasticsearch/pom.xml
@@ -69,6 +69,17 @@
log4j-over-slf4j
${org.slf4j.version}
+
+
+ org.elasticsearch
+ elasticsearch
+ 2.3.5
+
+
+ com.alibaba
+ fastjson
+ 1.2.13
+
diff --git a/spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java b/spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java
new file mode 100644
index 0000000000..b8ad59e2e2
--- /dev/null
+++ b/spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java
@@ -0,0 +1,52 @@
+package com.baeldung.elasticsearch;
+
+import java.util.Date;
+
+public class Person {
+
+ private int age;
+
+ private String fullName;
+
+ private Date dateOfBirth;
+
+ public Person() {
+
+ }
+
+ public Person(int age, String fullName, Date dateOfBirth) {
+ super();
+ this.age = age;
+ this.fullName = fullName;
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+ public Date getDateOfBirth() {
+ return dateOfBirth;
+ }
+
+ public void setDateOfBirth(Date dateOfBirth) {
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ @Override
+ public String toString() {
+ return "Person [age=" + age + ", fullName=" + fullName + ", dateOfBirth=" + dateOfBirth + "]";
+ }
+}
diff --git a/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java
new file mode 100644
index 0000000000..db304ee78d
--- /dev/null
+++ b/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java
@@ -0,0 +1,127 @@
+package com.baeldung.elasticsearch;
+
+import static org.elasticsearch.node.NodeBuilder.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.elasticsearch.action.delete.DeleteResponse;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.search.SearchType;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.search.SearchHit;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.alibaba.fastjson.JSON;
+
+public class ElasticSearchUnitTests {
+ private List listOfPersons = new ArrayList();
+ String jsonString = null;
+ Client client = null;
+
+ @Before
+ public void setUp() {
+ Person person1 = new Person(10, "John Doe", new Date());
+ Person person2 = new Person(25, "Janette Doe", new Date());
+ listOfPersons.add(person1);
+ listOfPersons.add(person2);
+ jsonString = JSON.toJSONString(listOfPersons);
+ Node node = nodeBuilder().clusterName("elasticsearch").client(true).node();
+ client = node.client();
+ }
+
+ @Test
+ public void givenJsonString_whenJavaObject_thenIndexDocument() {
+ String jsonObject = "{\"age\":20,\"dateOfBirth\":1471466076564,\"fullName\":\"John Doe\"}";
+ IndexResponse response = client.prepareIndex("people", "Doe")
+ .setSource(jsonObject).get();
+ String index = response.getIndex();
+ String type = response.getType();
+ assertTrue(response.isCreated());
+ assertEquals(index, "people");
+ assertEquals(type, "Doe");
+ }
+
+ @Test
+ public void givenDocumentId_whenJavaObject_thenDeleteDocument() {
+ String jsonObject = "{\"age\":10,\"dateOfBirth\":1471455886564,\"fullName\":\"Johan Doe\"}";
+ IndexResponse response = client.prepareIndex("people", "Doe")
+ .setSource(jsonObject).get();
+ String id = response.getId();
+ DeleteResponse deleteResponse = client.prepareDelete("people", "Doe", id).get();
+ assertTrue(deleteResponse.isFound());
+ }
+
+ @Test
+ public void givenSearchRequest_whenMatchAll_thenReturnAllResults() {
+ SearchResponse response = client.prepareSearch().execute().actionGet();
+ SearchHit[] searchHits = response.getHits().getHits();
+ List results = new ArrayList();
+ for (SearchHit hit : searchHits) {
+ String sourceAsString = hit.getSourceAsString();
+ Person person = JSON.parseObject(sourceAsString, Person.class);
+ results.add(person);
+ }
+ }
+
+ @Test
+ public void givenSearchParamters_thenReturnResults() {
+ boolean isExecutedSuccessfully = true;
+ SearchResponse response = client.prepareSearch()
+ .setTypes()
+ .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
+ .setPostFilter(QueryBuilders.rangeQuery("age").from(5).to(15))
+ .setFrom(0).setSize(60).setExplain(true)
+ .execute()
+ .actionGet();
+
+ SearchResponse response2 = client.prepareSearch()
+ .setTypes()
+ .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
+ .setPostFilter(QueryBuilders.simpleQueryStringQuery("+John -Doe OR Janette"))
+ .setFrom(0).setSize(60).setExplain(true)
+ .execute()
+ .actionGet();
+
+ SearchResponse response3 = client.prepareSearch()
+ .setTypes()
+ .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
+ .setPostFilter(QueryBuilders.matchQuery("John", "Name*"))
+ .setFrom(0).setSize(60).setExplain(true)
+ .execute()
+ .actionGet();
+ try {
+ response2.getHits();
+ response3.getHits();
+ List searchHits = Arrays.asList(response.getHits().getHits());
+ final List results = new ArrayList();
+ searchHits.forEach(hit -> results.add(JSON.parseObject(hit.getSourceAsString(), Person.class)));
+ } catch (Exception e) {
+ isExecutedSuccessfully = false;
+ }
+ assertTrue(isExecutedSuccessfully);
+ }
+
+ @Test
+ public void givenContentBuilder_whenHelpers_thanIndexJson() throws IOException {
+ XContentBuilder builder = XContentFactory.jsonBuilder()
+ .startObject()
+ .field("fullName", "Test")
+ .field("salary", "11500")
+ .field("age", "10")
+ .endObject();
+ IndexResponse response = client.prepareIndex("people", "Doe")
+ .setSource(builder).get();
+ assertTrue(response.isCreated());
+ }
+}
diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml
index f7f28aa9f1..5ae694a04f 100644
--- a/spring-data-rest/pom.xml
+++ b/spring-data-rest/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
@@ -15,7 +15,7 @@
org.springframework.boot
spring-boot-starter-parent
1.3.3.RELEASE
-
+
diff --git a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java b/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java
index 6e8e62f52c..94eddc5b3e 100644
--- a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java
+++ b/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java
@@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringDataRestApplication {
- public static void main(String[] args) {
- SpringApplication.run(SpringDataRestApplication.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(SpringDataRestApplication.class, args);
+ }
}
diff --git a/spring-data-rest/src/main/java/com/baeldung/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/UserRepository.java
deleted file mode 100644
index ebbf0d49ab..0000000000
--- a/spring-data-rest/src/main/java/com/baeldung/UserRepository.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.baeldung;
-
-import org.springframework.data.repository.PagingAndSortingRepository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-
-import java.util.List;
-
-@RepositoryRestResource(collectionResourceRel = "users", path = "users")
-public interface UserRepository extends PagingAndSortingRepository {
- List findByName(@Param("name") String name);
-}
diff --git a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java
new file mode 100644
index 0000000000..89ab848e81
--- /dev/null
+++ b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java
@@ -0,0 +1,30 @@
+package com.baeldung.config;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
+import org.springframework.validation.Validator;
+
+@Configuration
+public class ValidatorEventRegister implements InitializingBean {
+
+ @Autowired
+ ValidatingRepositoryEventListener validatingRepositoryEventListener;
+
+ @Autowired
+ private Map validators;
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ List events = Arrays.asList("beforeCreate", "afterCreate", "beforeSave", "afterSave", "beforeLinkSave", "afterLinkSave", "beforeDelete", "afterDelete");
+
+ for (Map.Entry entry : validators.entrySet()) {
+ events.stream().filter(p -> entry.getKey().startsWith(p)).findFirst().ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue()));
+ }
+ }
+}
diff --git a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java
new file mode 100644
index 0000000000..ee84738e7a
--- /dev/null
+++ b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java
@@ -0,0 +1,25 @@
+package com.baeldung.exception.handlers;
+
+import java.util.stream.Collectors;
+
+import org.springframework.data.rest.core.RepositoryConstraintViolationException;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.context.request.WebRequest;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+@ControllerAdvice
+public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @ExceptionHandler({ RepositoryConstraintViolationException.class })
+ public ResponseEntity
+
+
+ live
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+
+
+ start-server
+ pre-integration-test
+
+ start
+
+
+
+ stop-server
+ post-integration-test
+
+ stop
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ none
+
+
+ **/*LiveTest.java
+
+
+ cargo
+
+
+
+
+
+
+
+
+
+
+
@@ -231,10 +293,6 @@
4.3.11.Final
5.1.39
-
-
- 2.7.2
-
5.2.2.Final
@@ -260,7 +318,7 @@
3.5.1
2.6
2.19.1
- 1.4.18
+ 1.6.0
diff --git a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
index d5cd6e1eae..d116148f09 100644
--- a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
+++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
@@ -15,6 +15,11 @@ import org.springframework.oxm.xstream.XStreamMarshaller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+/*
+ * Please note that main web configuration is in src/main/webapp/WEB-INF/api-servlet.xml
+ *
+ */
+
@Configuration
@EnableWebMvc
@ComponentScan({ "org.baeldung.web" })
diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java
index 386c64bb09..dd1e3ca222 100644
--- a/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java
+++ b/spring-rest/src/main/java/org/baeldung/web/controller/FooController.java
@@ -35,7 +35,6 @@ public class FooController {
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public Foo updateFoo(@PathVariable("id") final String id, @RequestBody final Foo foo) {
- System.out.println(foo);
return foo;
}
diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
index 1d4aff2ebf..348ee6d596 100644
--- a/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
+++ b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java
@@ -5,5 +5,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.FORBIDDEN, reason="To show an example of a custom message")
public class ForbiddenException extends RuntimeException {
+ private static final long serialVersionUID = 6826605655586311552L;
}
diff --git a/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml b/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml
index 5afc637ece..21136b62c6 100644
--- a/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml
+++ b/spring-rest/src/main/webapp/WEB-INF/api-servlet.xml
@@ -8,7 +8,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-rest/src/main/webapp/WEB-INF/web.xml b/spring-rest/src/main/webapp/WEB-INF/web.xml
index 01e7620c44..a439de8a05 100644
--- a/spring-rest/src/main/webapp/WEB-INF/web.xml
+++ b/spring-rest/src/main/webapp/WEB-INF/web.xml
@@ -8,7 +8,7 @@
Spring MVC Application
-
+
contextClass
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
@@ -18,7 +18,7 @@
contextConfigLocation
org.baeldung.config
-
+
org.springframework.web.context.ContextLoaderListener
diff --git a/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java b/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java
new file mode 100644
index 0000000000..3155b5cda9
--- /dev/null
+++ b/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java
@@ -0,0 +1,62 @@
+package org.baeldung.web.test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+import org.junit.Test;
+
+import com.jayway.restassured.RestAssured;
+
+public class RequestMappingLiveTest {
+ private static String BASE_URI = "http://localhost:8082/spring-rest/ex/";
+
+ @Test
+ public void givenSimplePath_whenGetFoos_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "foos").then().assertThat().body(equalTo("Simple Get some Foos"));
+ }
+
+ @Test
+ public void whenPostFoos_thenOk() {
+ RestAssured.given().accept("text/html").post(BASE_URI + "foos").then().assertThat().body(equalTo("Post some Foos"));
+ }
+
+ @Test
+ public void givenOneHeader_whenGetFoos_thenOk() {
+ RestAssured.given().accept("text/html").header("key", "val").get(BASE_URI + "foos").then().assertThat().body(equalTo("Get some Foos with Header"));
+ }
+
+ @Test
+ public void givenMultipleHeaders_whenGetFoos_thenOk() {
+ RestAssured.given().accept("text/html").headers("key1", "val1", "key2", "val2").get(BASE_URI + "foos").then().assertThat().body(equalTo("Get some Foos with Header"));
+ }
+
+ @Test
+ public void givenAcceptHeader_whenGetFoos_thenOk() {
+ RestAssured.given().accept("application/json").get(BASE_URI + "foos").then().assertThat().body(equalTo("Get some Foos with Header New"));
+ }
+
+ @Test
+ public void givenPathVariable_whenGetFoos_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "foos/1").then().assertThat().body(equalTo("Get a specific Foo with id=1"));
+ }
+
+ @Test
+ public void givenMultiplePathVariable_whenGetFoos_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "foos/1/bar/2").then().assertThat().body(equalTo("Get a specific Bar with id=2 from a Foo with id=1"));
+ }
+
+ @Test
+ public void givenPathVariable_whenGetBars_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "bars/1").then().assertThat().body(equalTo("Get a specific Bar with id=1"));
+ }
+
+ @Test
+ public void givenParams_whenGetBars_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "bars?id=100&second=something").then().assertThat().body(equalTo("Get a specific Bar with id=100"));
+ }
+
+ @Test
+ public void whenGetFoosOrBars_thenOk() {
+ RestAssured.given().accept("text/html").get(BASE_URI + "advanced/foos").then().assertThat().body(equalTo("Advanced - Get some Foos or Bars"));
+ RestAssured.given().accept("text/html").get(BASE_URI + "advanced/bars").then().assertThat().body(equalTo("Advanced - Get some Foos or Bars"));
+ }
+}
diff --git a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java
similarity index 78%
rename from spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java
rename to spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java
index 1536f14bc8..7f250653ab 100644
--- a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java
+++ b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java
@@ -3,9 +3,7 @@ package org.baeldung.web.test;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import org.baeldung.config.converter.KryoHttpMessageConverter;
import org.baeldung.web.dto.Foo;
@@ -17,19 +15,15 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
-import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
-import org.springframework.oxm.xstream.XStreamMarshaller;
import org.springframework.web.client.RestTemplate;
/**
* Integration Test class. Tests methods hits the server's rest services.
*/
-public class SpringHttpMessageConvertersIntegrationTestsCase {
+public class SpringHttpMessageConvertersLiveTest {
- private static String BASE_URI = "http://localhost:8080/spring-rest/";
+ private static String BASE_URI = "http://localhost:8082/spring-rest/";
/**
* Without specifying Accept Header, uses the default response from the
@@ -50,7 +44,6 @@ public class SpringHttpMessageConvertersIntegrationTestsCase {
final String URI = BASE_URI + "foos/{id}";
final RestTemplate restTemplate = new RestTemplate();
- restTemplate.setMessageConverters(getMessageConverters());
final HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_XML));
@@ -67,7 +60,6 @@ public class SpringHttpMessageConvertersIntegrationTestsCase {
final String URI = BASE_URI + "foos/{id}";
final RestTemplate restTemplate = new RestTemplate();
- restTemplate.setMessageConverters(getMessageConverters());
final HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
@@ -83,7 +75,6 @@ public class SpringHttpMessageConvertersIntegrationTestsCase {
public void givenConsumingXml_whenWritingTheFoo_thenCorrect() {
final String URI = BASE_URI + "foos/{id}";
final RestTemplate restTemplate = new RestTemplate();
- restTemplate.setMessageConverters(getMessageConverters());
final Foo resource = new Foo(4, "jason");
final HttpHeaders headers = new HttpHeaders();
@@ -129,20 +120,4 @@ public class SpringHttpMessageConvertersIntegrationTestsCase {
assertThat(resource, notNullValue());
}
- // UTIL
-
- private List> getMessageConverters() {
- final List> converters = new ArrayList>();
-
- final MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter();
- final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
- xmlConverter.setMarshaller(xstreamMarshaller);
- xmlConverter.setUnmarshaller(xstreamMarshaller);
-
- converters.add(xmlConverter);
- converters.add(new MappingJackson2HttpMessageConverter());
-
- return converters;
- }
-
}
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/ListenerConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/ListenerConfig.java
new file mode 100644
index 0000000000..80af01aeeb
--- /dev/null
+++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/ListenerConfig.java
@@ -0,0 +1,16 @@
+package org.baeldung.spring;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.request.RequestContextListener;
+
+public class ListenerConfig implements WebApplicationInitializer {
+
+ @Override
+ public void onStartup(ServletContext sc) throws ServletException {
+ // Manages the lifecycle of the root application context
+ sc.addListener(new RequestContextListener());
+ }
+}
\ No newline at end of file
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
index fa8bdddb4e..57e9b32a62 100644
--- a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
+++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
@@ -1,6 +1,7 @@
package org.baeldung.spring;
import org.baeldung.web.interceptor.LoggerInterceptor;
+import org.baeldung.web.interceptor.SessionTimerInterceptor;
import org.baeldung.web.interceptor.UserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -15,7 +16,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@ComponentScan("org.baeldung.web")
@EnableWebMvc
-public class WebConfig extends WebMvcConfigurerAdapter {
+public class WebConfig extends WebMvcConfigurerAdapter{
public WebConfig() {
super();
@@ -42,5 +43,7 @@ public class WebConfig extends WebMvcConfigurerAdapter {
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(new LoggerInterceptor());
registry.addInterceptor(new UserInterceptor());
+ registry.addInterceptor(new SessionTimerInterceptor());
}
+
}
\ No newline at end of file
diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java b/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java
new file mode 100644
index 0000000000..8d967ed1ef
--- /dev/null
+++ b/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java
@@ -0,0 +1,57 @@
+package org.baeldung.web.interceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+public class SessionTimerInterceptor extends HandlerInterceptorAdapter {
+
+ private static Logger log = LoggerFactory.getLogger(SessionTimerInterceptor.class);
+
+ private static final long MAX_INACTIVE_SESSION_TIME = 5 * 10000;
+
+ @Autowired
+ private HttpSession session;
+
+ /**
+ * Executed before actual handler is executed
+ **/
+ @Override
+ public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler)
+ throws Exception {
+ log.info("Pre handle method - check handling start time");
+ long startTime = System.currentTimeMillis();
+ request.setAttribute("executionTime", startTime);
+ if (UserInterceptor.isUserLogged()) {
+ session = request.getSession();
+ log.info("Who is logged in: " + SecurityContextHolder.getContext().getAuthentication().getName());
+ log.info("Time since last request in this session: "
+ + (System.currentTimeMillis() - request.getSession().getLastAccessedTime()) + " ms");
+ if (System.currentTimeMillis() - session.getLastAccessedTime() > MAX_INACTIVE_SESSION_TIME) {
+ log.warn("Logging out, due to inactive session");
+ SecurityContextHolder.clearContext();
+ request.logout();
+ response.sendRedirect("/spring-security-rest-full/logout");
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executed before after handler is executed
+ **/
+ @Override
+ public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler,
+ final ModelAndView model) throws Exception {
+ log.info("Post handle method - check execution time of handling");
+ long startTime = (Long) request.getAttribute("executionTime");
+ log.info("Execution time for handling the request was: " + (System.currentTimeMillis() - startTime) + " ms");
+ }
+}
diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java
index 1b5f7cd894..13cb92a745 100644
--- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java
+++ b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java
@@ -14,6 +14,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -21,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
+@Transactional
public class CsrfAbstractIntegrationTest {
@Autowired
diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorTest.java
new file mode 100644
index 0000000000..a29de04bb4
--- /dev/null
+++ b/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorTest.java
@@ -0,0 +1,56 @@
+package org.baeldung.web.interceptor;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import javax.servlet.http.HttpSession;
+
+import org.baeldung.spring.PersistenceConfig;
+import org.baeldung.spring.SecurityWithoutCsrfConfig;
+import org.baeldung.spring.WebConfig;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpSession;
+import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.WebApplicationContext;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@Transactional
+@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, PersistenceConfig.class, WebConfig.class })
+@WithMockUser(username = "admin", roles = { "USER", "ADMIN" })
+public class SessionTimerInterceptorTest {
+
+ @Autowired
+ WebApplicationContext wac;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
+ }
+
+ /**
+ * After execution of HTTP GET logs from interceptor will be displayed in
+ * the console
+ */
+ @Test
+ public void testInterceptors() throws Exception {
+ HttpSession session = mockMvc.perform(get("/auth/admin")).andExpect(status().is2xxSuccessful()).andReturn()
+ .getRequest().getSession();
+ Thread.sleep(51000);
+ mockMvc.perform(get("/auth/admin").session((MockHttpSession) session)).andExpect(status().is2xxSuccessful());
+ }
+
+}
diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml
index 51e26fdfdd..35d8c37176 100644
--- a/spring-thymeleaf/pom.xml
+++ b/spring-thymeleaf/pom.xml
@@ -8,24 +8,24 @@
1.7
- 4.1.8.RELEASE
+ 4.3.3.RELEASE
3.0.1
- 1.7.12
- 1.1.3
+ 1.7.12
+ 1.1.3
2.1.4.RELEASE
1.1.0.Final
5.1.2.Final
-
+
3.5.1
2.6
2.19.1
1.4.18
-
+
@@ -45,6 +45,17 @@
spring-webmvc
${org.springframework-version}
+
+
+ org.springframework.security
+ spring-security-web
+ 4.1.3.RELEASE
+
+
+ org.springframework.security
+ spring-security-config
+ 4.1.3.RELEASE
+
org.thymeleaf
@@ -57,29 +68,29 @@
${org.thymeleaf-version}
-
-
- org.slf4j
- slf4j-api
- ${org.slf4j.version}
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
-
-
- org.slf4j
- jcl-over-slf4j
- ${org.slf4j.version}
-
-
-
- org.slf4j
- log4j-over-slf4j
- ${org.slf4j.version}
-
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${org.slf4j.version}
+
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
javax.servlet
@@ -98,6 +109,31 @@
hibernate-validator
${org.hibernate-version}
+
+
+
+ org.springframework
+ spring-test
+ 4.1.3.RELEASE
+ test
+
+
+
+
+ org.springframework.security
+ spring-security-test
+ 4.1.3.RELEASE
+ test
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
@@ -129,25 +165,25 @@
-
- org.codehaus.cargo
- cargo-maven2-plugin
- ${cargo-maven2-plugin.version}
-
- true
-
- jetty8x
- embedded
-
-
-
-
-
- 8082
-
-
-
-
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+ true
+
+ jetty8x
+ embedded
+
+
+
+
+
+ 8082
+
+
+
+
diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java
new file mode 100644
index 0000000000..956db4a0e5
--- /dev/null
+++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java
@@ -0,0 +1,11 @@
+package com.baeldung.thymeleaf.config;
+
+import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
+
+public class InitSecurity extends AbstractSecurityWebApplicationInitializer {
+
+ public InitSecurity() {
+ super(WebMVCSecurity.class);
+
+ }
+}
diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java
index 89ad7e601e..c7d5e33cb8 100644
--- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java
+++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java
@@ -20,7 +20,7 @@ public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer
@Override
protected Class>[] getServletConfigClasses() {
- return new Class>[] { WebMVCConfig.class };
+ return new Class>[] { WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class };
}
@Override
diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java
index 51c60247a1..50c9cf06fe 100644
--- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java
+++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java
@@ -1,6 +1,5 @@
package com.baeldung.thymeleaf.config;
-import com.baeldung.thymeleaf.formatter.NameFormatter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -14,6 +13,8 @@ import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
+import com.baeldung.thymeleaf.formatter.NameFormatter;
+
@Configuration
@EnableWebMvc
@ComponentScan({ "com.baeldung.thymeleaf" })
diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java
new file mode 100644
index 0000000000..00c42831de
--- /dev/null
+++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java
@@ -0,0 +1,49 @@
+package com.baeldung.thymeleaf.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
+public class WebMVCSecurity extends WebSecurityConfigurerAdapter {
+
+ @Bean
+ @Override
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ public WebMVCSecurity() {
+ super();
+ }
+
+ @Override
+ protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
+ auth.inMemoryAuthentication().withUser("user1").password("user1Pass").authorities("ROLE_USER");
+ }
+
+ @Override
+ public void configure(final WebSecurity web) throws Exception {
+ web.ignoring().antMatchers("/resources/**");
+ }
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http
+ .authorizeRequests()
+ .anyRequest()
+ .authenticated()
+ .and()
+ .httpBasic()
+ ;
+ }
+
+}
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html
new file mode 100644
index 0000000000..7674caa854
--- /dev/null
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java
new file mode 100644
index 0000000000..bd70881dd8
--- /dev/null
+++ b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java
@@ -0,0 +1,63 @@
+package org.baeldung.security.csrf;
+
+import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
+import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import javax.servlet.Filter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockHttpSession;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.RequestPostProcessor;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+import com.baeldung.thymeleaf.config.InitSecurity;
+import com.baeldung.thymeleaf.config.WebApp;
+import com.baeldung.thymeleaf.config.WebMVCConfig;
+import com.baeldung.thymeleaf.config.WebMVCSecurity;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class })
+public class CsrfEnabledIntegrationTest {
+
+ @Autowired
+ WebApplicationContext wac;
+ @Autowired
+ MockHttpSession session;
+
+ private MockMvc mockMvc;
+
+ @Autowired
+ private Filter springSecurityFilterChain;
+
+ protected RequestPostProcessor testUser() {
+ return user("user1").password("user1Pass").roles("USER");
+ }
+
+ @Before
+ public void setup() {
+ mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
+ }
+
+ @Test
+ public void addStudentWithoutCSRF() throws Exception {
+ mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser())).andExpect(status().isForbidden());
+ }
+
+ @Test
+ public void addStudentWithCSRF() throws Exception {
+ mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser()).with(csrf())).andExpect(status().isOk());
+ }
+
+}
diff --git a/wicket/README.md b/wicket/README.md
new file mode 100644
index 0000000000..614446e7ba
--- /dev/null
+++ b/wicket/README.md
@@ -0,0 +1,4 @@
+
+From the same directory where pom.xml is, execute the following command to run the project:
+
+mvn jetty:run
diff --git a/wicket/pom.xml b/wicket/pom.xml
new file mode 100644
index 0000000000..929f723c2c
--- /dev/null
+++ b/wicket/pom.xml
@@ -0,0 +1,106 @@
+
+
+
+ 4.0.0
+ com.baeldung.wicket.examples
+ wicket-intro
+ war
+ 1.0-SNAPSHOT
+ WicketIntro
+
+ 7.4.0
+ 9.2.13.v20150730
+ 2.5
+ 4.12
+ 3.5.1
+ 2.6
+ UTF-8
+
+
+
+
+ org.apache.wicket
+ wicket-core
+ ${wicket.version}
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+ org.eclipse.jetty.aggregate
+ jetty-all
+ ${jetty9.version}
+ test
+
+
+
+
+
+ false
+ src/main/resources
+
+
+ false
+ src/main/java
+
+ **
+
+
+ **/*.java
+
+
+
+
+
+ false
+ src/test/resources
+
+
+ false
+ src/test/java
+
+ **
+
+
+ **/*.java
+
+
+
+
+
+ true
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.8
+ 1.8
+ UTF-8
+ true
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ false
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ ${jetty9.version}
+
+
+
+
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/Examples.html b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.html
new file mode 100644
index 0000000000..497e98e01a
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.html
@@ -0,0 +1,52 @@
+
+
+
+
+Wicket Intro Examples
+
+
+
+
+
+
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java
new file mode 100644
index 0000000000..358e4f7b19
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java
@@ -0,0 +1,9 @@
+package com.baeldung.wicket.examples;
+
+import org.apache.wicket.markup.html.WebPage;
+
+public class Examples extends WebPage {
+
+ private static final long serialVersionUID = 1L;
+
+}
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java b/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java
new file mode 100644
index 0000000000..711e8f01fd
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java
@@ -0,0 +1,27 @@
+package com.baeldung.wicket.examples;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.protocol.http.WebApplication;
+
+import com.baeldung.wicket.examples.cafeaddress.CafeAddress;
+import com.baeldung.wicket.examples.helloworld.HelloWorld;
+
+public class ExamplesApplication extends WebApplication {
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class extends WebPage> getHomePage() {
+ return Examples.class;
+ }
+
+ /**
+ * @see org.apache.wicket.Application#init()
+ */
+ @Override
+ public void init() {
+ super.init();
+ mountPage("/examples/helloworld", HelloWorld.class);
+ mountPage("/examples/cafes", CafeAddress.class);
+ }
+}
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html
new file mode 100644
index 0000000000..c5ada2323d
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html
@@ -0,0 +1,15 @@
+
+
+
+
+Cafes
+
+
+
+
+
+ Address: address
+
+
+
+
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java
new file mode 100644
index 0000000000..ce26c5a1ad
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java
@@ -0,0 +1,72 @@
+package com.baeldung.wicket.examples.cafeaddress;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+public class CafeAddress extends WebPage {
+
+ private static final long serialVersionUID = 1L;
+
+ String selectedCafe;
+ Address address;
+ Map cafeNamesAndAddresses = new HashMap<>();
+
+ public CafeAddress(final PageParameters parameters) {
+ super(parameters);
+ initCafes();
+
+ ArrayList cafeNames = new ArrayList<>(this.cafeNamesAndAddresses.keySet());
+ this.selectedCafe = cafeNames.get(0);
+ this.address = new Address(this.cafeNamesAndAddresses.get(this.selectedCafe).getAddress());
+
+ final Label addressLabel = new Label("address", new PropertyModel(this.address, "address"));
+ addressLabel.setOutputMarkupId(true);
+
+ final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel(this, "selectedCafe"), cafeNames);
+ cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ String name = (String) cafeDropdown.getDefaultModel().getObject();
+ address.setAddress(cafeNamesAndAddresses.get(name).getAddress());
+ target.add(addressLabel);
+ }
+ });
+
+ add(addressLabel);
+ add(cafeDropdown);
+
+ }
+
+ private void initCafes() {
+ this.cafeNamesAndAddresses.put("Linda's Cafe", new Address("35 Bower St."));
+ this.cafeNamesAndAddresses.put("Old Tree", new Address("2 Edgware Rd."));
+ }
+
+ class Address implements Serializable {
+ private String sAddress = "";
+
+ public Address(String address) {
+ this.sAddress = address;
+ }
+
+ public String getAddress() {
+ return this.sAddress;
+ }
+
+ public void setAddress(String address) {
+ this.sAddress = address;
+ }
+ }
+}
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html
new file mode 100644
index 0000000000..c56d07fc10
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..f819e05be6
--- /dev/null
+++ b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java
@@ -0,0 +1,13 @@
+package com.baeldung.wicket.examples.helloworld;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+public class HelloWorld extends WebPage {
+
+ private static final long serialVersionUID = 1L;
+
+ public HelloWorld() {
+ add(new Label("hello", "Hello World!"));
+ }
+}
diff --git a/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java
new file mode 100644
index 0000000000..a393f1d178
--- /dev/null
+++ b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java
@@ -0,0 +1,23 @@
+package com.baeldung.wicket.examples;
+
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestHomePage {
+ private WicketTester tester;
+
+ @Before
+ public void setUp() {
+ tester = new WicketTester(new ExamplesApplication());
+ }
+
+ @Test
+ public void whenPageInvoked_thanRenderedOK() {
+ //start and render the test page
+ tester.startPage(Examples.class);
+
+ //assert rendered page class
+ tester.assertRenderedPage(Examples.class);
+ }
+}
diff --git a/wicket/src/main/webapp/WEB-INF/web.xml b/wicket/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..8a4451c80e
--- /dev/null
+++ b/wicket/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,32 @@
+
+
+
+ CafeAddress
+
+
+
+
+ wicket.examples
+ org.apache.wicket.protocol.http.WicketFilter
+
+ applicationClassName
+ com.baeldung.wicket.examples.ExamplesApplication
+
+
+
+
+ wicket.examples
+ /*
+
+
\ No newline at end of file