products = service.getProducts();
+
+ context.put("products", products);
+
+ Template template = null;
+
+ try {
+ template = getTemplate("templates/index.vm");
+ response.setHeader("Template Returned", "Success");
+ } catch (Exception e) {
+ logger.error("Error while reading the template ", e);
+ }
+
+ return template;
+
+ }
+}
diff --git a/apache-velocity/src/main/resources/logback.xml b/apache-velocity/src/main/resources/logback.xml
new file mode 100644
index 0000000000..70a420a57a
--- /dev/null
+++ b/apache-velocity/src/main/resources/logback.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apache-velocity/src/main/webapp/WEB-INF/velocity.properties b/apache-velocity/src/main/webapp/WEB-INF/velocity.properties
new file mode 100644
index 0000000000..00e0b7e410
--- /dev/null
+++ b/apache-velocity/src/main/webapp/WEB-INF/velocity.properties
@@ -0,0 +1,4 @@
+resource.loader=webapp
+webapp.resource.loader.class=org.apache.velocity.tools.view.WebappResourceLoader
+webapp.resource.loader.path = .
+webapp.resource.loader.cache = true
\ No newline at end of file
diff --git a/apache-velocity/src/main/webapp/WEB-INF/web.xml b/apache-velocity/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..95b41b36dd
--- /dev/null
+++ b/apache-velocity/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,49 @@
+
+
+
+ apache-velocity
+
+ ProductServlet
+ com.baeldung.apache.velocity.servlet.ProductServlet
+
+
+
+ LayoutServlet
+ com.baeldung.apache.velocity.servlet.LayoutServlet
+
+
+ velocityLayout
+ org.apache.velocity.tools.view.VelocityLayoutServlet
+
+
+ org.apache.velocity.properties
+ /WEB-INF/velocity.properties
+
+
+
+ ProductServlet
+ /
+
+
+
+ LayoutServlet
+ /layout
+
+
+ velocityLayout
+ *.vm
+
+
+
+
+ 30
+
+
+
+
+
+ index.html
+
+
diff --git a/apache-velocity/src/main/webapp/fragments/footer.vm b/apache-velocity/src/main/webapp/fragments/footer.vm
new file mode 100644
index 0000000000..41bb36ce5e
--- /dev/null
+++ b/apache-velocity/src/main/webapp/fragments/footer.vm
@@ -0,0 +1,4 @@
+
+ @Copyright baeldung.com
+
\ No newline at end of file
diff --git a/apache-velocity/src/main/webapp/fragments/header.vm b/apache-velocity/src/main/webapp/fragments/header.vm
new file mode 100644
index 0000000000..96700d3baf
--- /dev/null
+++ b/apache-velocity/src/main/webapp/fragments/header.vm
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/apache-velocity/src/main/webapp/layout/Default.vm b/apache-velocity/src/main/webapp/layout/Default.vm
new file mode 100644
index 0000000000..39a8b277a5
--- /dev/null
+++ b/apache-velocity/src/main/webapp/layout/Default.vm
@@ -0,0 +1,22 @@
+
+
+ Velocity
+
+
+
+ #parse("/fragments/header.vm")
+
+
+
+
+
+
+ $screen_content
+
+
+
+
+ #parse("/fragments/footer.vm")
+
+
+
\ No newline at end of file
diff --git a/apache-velocity/src/main/webapp/templates/index.vm b/apache-velocity/src/main/webapp/templates/index.vm
new file mode 100644
index 0000000000..0ca07caf42
--- /dev/null
+++ b/apache-velocity/src/main/webapp/templates/index.vm
@@ -0,0 +1,63 @@
+
+
+ Online Electronic Store
+
+
+
+
+
+ Today's Offers
+
+
+ $products.size() Products on Sale!
+
+ We are proud to offer these fine products
+ at these amazing prices.
+
+
+ #set( $count = 1 )
+
+
+ | Serial # | Product Name | Price |
+
+ #foreach( $product in $products )
+
+ | $count) |
+ $product.getName() |
+ $product.getPrice() |
+
+ #set( $count = $count + 1 )
+ #end
+
+
+
+
+
+
diff --git a/apache-velocity/src/main/webapp/templates/layoutdemo.vm b/apache-velocity/src/main/webapp/templates/layoutdemo.vm
new file mode 100644
index 0000000000..0626b655c9
--- /dev/null
+++ b/apache-velocity/src/main/webapp/templates/layoutdemo.vm
@@ -0,0 +1,27 @@
+#set( $layout = "layout.vm" )
+
+ Today's Offers
+
+
+ $products.size() Products on Sale!
+
+ We are proud to offer these fine products
+ at these amazing prices.
+
+
+ #set( $count = 1 )
+
+
+ | Serial # | Product Name | Price |
+
+ #foreach( $product in $products )
+
+ | $count) |
+ $product.getName() |
+ $product.getPrice() |
+
+ #set( $count = $count + 1 )
+ #end
+
+
+
\ No newline at end of file
diff --git a/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/LayoutServletLiveTest.java b/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/LayoutServletLiveTest.java
new file mode 100644
index 0000000000..f1f166b119
--- /dev/null
+++ b/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/LayoutServletLiveTest.java
@@ -0,0 +1,26 @@
+package com.baeldung.apache.velocity.servlet;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+
+public class LayoutServletLiveTest {
+
+ @Test
+ public void whenRequestUsingHttpClient_thenCorrectResponse() throws Exception {
+
+ HttpClient client = new DefaultHttpClient();
+ HttpGet method= new HttpGet("http://localhost:8080/layout");
+
+ HttpResponse httpResponse = client.execute(method);
+
+ assertEquals("Success", httpResponse.getHeaders("Template Returned")[0].getValue());
+
+ }
+
+}
diff --git a/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/ProductServletLiveTest.java b/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/ProductServletLiveTest.java
new file mode 100644
index 0000000000..397e575d4d
--- /dev/null
+++ b/apache-velocity/src/test/java/com/baeldung/apache/velocity/servlet/ProductServletLiveTest.java
@@ -0,0 +1,24 @@
+package com.baeldung.apache.velocity.servlet;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ProductServletLiveTest {
+
+ @Test
+ public void whenRequestUsingHttpClient_thenCorrectResponse() throws Exception {
+
+ HttpClient client = new DefaultHttpClient();
+ HttpGet method= new HttpGet("http://localhost:8080/");
+
+ HttpResponse httpResponse = client.execute(method);
+
+ assertEquals("Success", httpResponse.getHeaders("Template Returned")[0].getValue());
+
+ }
+}
diff --git a/core-java/pom.xml b/core-java/pom.xml
index 2b6f065c85..b2c59989f1 100644
--- a/core-java/pom.xml
+++ b/core-java/pom.xml
@@ -9,45 +9,7 @@
core-java
-
-
- org.neo4j
- neo4j
- 3.1.0
-
-
-
- org.neo4j.driver
- neo4j-java-driver
- 1.1.1
-
-
-
- org.neo4j
- neo4j-jdbc-driver
- 3.0.1
-
-
-
- org.neo4j
- neo4j-ogm-core
- 2.1.1
-
-
-
- org.neo4j
- neo4j-ogm-embedded-driver
- 2.1.1
-
-
-
- com.google.inject
- guice
- 4.1.0
- no_aop
- test
-
-
+
net.sourceforge.collections
diff --git a/core-java/src/main/java/com/baeldung/java_8_features/Person.java b/core-java/src/main/java/com/baeldung/java_8_features/Person.java
new file mode 100644
index 0000000000..83b5530ee8
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/java_8_features/Person.java
@@ -0,0 +1,27 @@
+package com.baeldung.java_8_features;
+
+public class Person {
+ private String name;
+ private Integer age;
+
+ public Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/java8/Java8MaxMinTest.java b/core-java/src/test/java/com/baeldung/java8/Java8MaxMinTest.java
new file mode 100644
index 0000000000..b0e514124d
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/java8/Java8MaxMinTest.java
@@ -0,0 +1,47 @@
+package com.baeldung.java8;
+
+import com.baeldung.java_8_features.Person;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import static org.junit.Assert.assertEquals;
+
+public class Java8MaxMinTest {
+
+ @Test
+ public void whenListIsOfIntegerThenMaxCanBeDoneUsingIntegerComparator() {
+ //given
+ final List listOfIntegers = Arrays.asList(1, 2, 3, 4, 56, 7, 89, 10);
+ final Integer expectedResult = 89;
+
+ //then
+ final Integer max = listOfIntegers
+ .stream()
+ .mapToInt(v -> v)
+ .max().orElseThrow(NoSuchElementException::new);
+
+ assertEquals("Should be 89", expectedResult, max);
+ }
+
+ @Test
+ public void whenListIsOfPersonObjectThenMinCanBeDoneUsingCustomComparatorThroughLambda() {
+ //given
+ final Person alex = new Person("Alex", 23);
+ final Person john = new Person("John", 40);
+ final Person peter = new Person("Peter", 32);
+ final List people = Arrays.asList(alex, john, peter);
+
+ //then
+ final Person minByAge = people
+ .stream()
+ .min(Comparator.comparing(Person::getAge))
+ .orElseThrow(NoSuchElementException::new);
+
+ assertEquals("Should be Alex", alex, minByAge);
+ }
+
+}
diff --git a/core-java/src/test/java/com/baeldung/string/JoinerSplitterTest.java b/core-java/src/test/java/com/baeldung/string/JoinerSplitterTest.java
index 9ccff40558..a89f89b8d5 100644
--- a/core-java/src/test/java/com/baeldung/string/JoinerSplitterTest.java
+++ b/core-java/src/test/java/com/baeldung/string/JoinerSplitterTest.java
@@ -12,7 +12,7 @@ import com.baeldung.string.JoinerSplitter;
public class JoinerSplitterTest {
@Test
- public void givenArray_transformedToStream_convertToString() {
+ public void provided_array_convert_to_stream_and_convert_to_string() {
String[] programming_languages = {"java", "python", "nodejs", "ruby"};
@@ -24,6 +24,7 @@ public class JoinerSplitterTest {
@Test
public void givenArray_transformedToStream_convertToPrefixPostfixString() {
+
String[] programming_languages = {"java", "python",
"nodejs", "ruby"};
String expectation = "[java,python,nodejs,ruby]";
@@ -34,6 +35,7 @@ public class JoinerSplitterTest {
@Test
public void givenString_transformedToStream_convertToList() {
+
String programming_languages = "java,python,nodejs,ruby";
List expectation = new ArrayList();
@@ -49,6 +51,7 @@ public class JoinerSplitterTest {
@Test
public void givenString_transformedToStream_convertToListOfChar() {
+
String programming_languages = "java,python,nodejs,ruby";
List expectation = new ArrayList();
diff --git a/guava/src/main/java/org/baeldung/guava/EventBusWrapper.java b/guava/src/main/java/org/baeldung/guava/EventBusWrapper.java
deleted file mode 100644
index 243bc9e6ea..0000000000
--- a/guava/src/main/java/org/baeldung/guava/EventBusWrapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.baeldung.guava;
-
-import com.google.common.eventbus.EventBus;
-
-class EventBusWrapper {
-
- private static EventBus eventBus = new EventBus();
-
- static void register(Object object) {
- eventBus.register(object);
- }
-
- static void unregister(Object object) {
- eventBus.unregister(object);
- }
-
- static void post(Object object) {
- eventBus.post(object);
- }
-
-}
diff --git a/guava/src/main/java/org/baeldung/guava/EventListener.java b/guava/src/main/java/org/baeldung/guava/EventListener.java
index 02f22ce6b9..438fcade63 100644
--- a/guava/src/main/java/org/baeldung/guava/EventListener.java
+++ b/guava/src/main/java/org/baeldung/guava/EventListener.java
@@ -1,5 +1,6 @@
package org.baeldung.guava;
+import com.google.common.eventbus.DeadEvent;
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,6 +22,12 @@ public class EventListener {
eventsHandled++;
}
+ @Subscribe
+ public void handleDeadEvent(DeadEvent deadEvent) {
+ LOG.info("unhandled event [" + deadEvent.getEvent() + "]");
+ eventsHandled++;
+ }
+
public int getEventsHandled() {
return eventsHandled;
}
diff --git a/guava/src/test/java/org/baeldung/guava/GuavaEventBusTest.java b/guava/src/test/java/org/baeldung/guava/GuavaEventBusTest.java
index 1db361d22c..1390eb05aa 100644
--- a/guava/src/test/java/org/baeldung/guava/GuavaEventBusTest.java
+++ b/guava/src/test/java/org/baeldung/guava/GuavaEventBusTest.java
@@ -1,5 +1,6 @@
package org.baeldung.guava;
+import com.google.common.eventbus.EventBus;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -9,25 +10,27 @@ import static org.junit.Assert.*;
public class GuavaEventBusTest {
private EventListener listener;
+ private EventBus eventBus;
@Before
public void setUp() {
+ eventBus = new EventBus();
listener = new EventListener();
- EventBusWrapper.register(listener);
+
+ eventBus.register(listener);
}
@After
public void tearDown() {
- EventBusWrapper.unregister(listener);
+ eventBus.unregister(listener);
}
@Test
public void givenStringEvent_whenEventHandled_thenSuccess() {
listener.resetEventsHandled();
- EventBusWrapper.post("String Event");
+ eventBus.post("String Event");
assertEquals(1, listener.getEventsHandled());
-
}
@Test
@@ -35,8 +38,18 @@ public class GuavaEventBusTest {
listener.resetEventsHandled();
CustomEvent customEvent = new CustomEvent("Custom Event");
- EventBusWrapper.post(customEvent);
+ eventBus.post(customEvent);
assertEquals(1, listener.getEventsHandled());
}
+
+ @Test
+ public void givenUnSubscribedEvent_whenEventHandledByDeadEvent_thenSuccess() throws InterruptedException {
+ listener.resetEventsHandled();
+
+ eventBus.post(12345);
+
+ assertEquals(1, listener.getEventsHandled());
+ }
+
}
diff --git a/httpclient/pom.xml b/httpclient/pom.xml
index be0daae995..eec705b224 100644
--- a/httpclient/pom.xml
+++ b/httpclient/pom.xml
@@ -1,4 +1,5 @@
-
+
4.0.0
com.baeldung
httpclient
@@ -113,6 +114,13 @@
${mockito.version}
test
+
+ com.github.tomakehurst
+ wiremock
+ ${wiremock.version}
+ test
+
+
@@ -145,7 +153,7 @@
**/*LiveTest.java
-
+
@@ -202,6 +210,7 @@
1.3
4.12
1.10.19
+ 2.5.1
4.4.5
4.5.2
diff --git a/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfiguration.java b/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfiguration.java
new file mode 100644
index 0000000000..9b5cb3f293
--- /dev/null
+++ b/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfiguration.java
@@ -0,0 +1,154 @@
+package org.baeldung.httpclient.advancedconfig;
+
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.Assert.assertEquals;
+
+public class HttpClientAdvancedConfiguration {
+
+ @Rule
+ public WireMockRule serviceMock = new WireMockRule(8089);
+
+ @Rule
+ public WireMockRule proxyMock = new WireMockRule(8090);
+
+ @Test
+ public void givenClientWithCustomUserAgentHeader_whenExecuteRequest_shouldReturn200() throws IOException {
+ //given
+ String userAgent = "BaeldungAgent/1.0";
+ serviceMock.stubFor(get(urlEqualTo("/detail"))
+ .withHeader("User-Agent", equalTo(userAgent))
+ .willReturn(aResponse()
+ .withStatus(200)));
+
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpGet httpGet = new HttpGet("http://localhost:8089/detail");
+ httpGet.setHeader(HttpHeaders.USER_AGENT, userAgent);
+
+ //when
+ HttpResponse response = httpClient.execute(httpGet);
+
+ //then
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+ }
+
+ @Test
+ public void givenClientThatSendDataInBody_whenSendXmlInBody_shouldReturn200() throws IOException {
+ //given
+ String xmlBody = "1";
+ serviceMock.stubFor(post(urlEqualTo("/person"))
+ .withHeader("Content-Type", equalTo("application/xml"))
+ .withRequestBody(equalTo(xmlBody))
+ .willReturn(aResponse()
+ .withStatus(200)));
+
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpPost httpPost = new HttpPost("http://localhost:8089/person");
+ httpPost.setHeader("Content-Type", "application/xml");
+ StringEntity xmlEntity = new StringEntity(xmlBody);
+ httpPost.setEntity(xmlEntity);
+
+ //when
+ HttpResponse response = httpClient.execute(httpPost);
+
+ //then
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+
+ }
+
+ @Test
+ public void givenServerThatIsBehindProxy_whenClientIsConfiguredToSendRequestViaProxy_shouldReturn200() throws IOException {
+ //given
+ proxyMock.stubFor(get(urlMatching(".*"))
+ .willReturn(aResponse().proxiedFrom("http://localhost:8089/")));
+
+ serviceMock.stubFor(get(urlEqualTo("/private"))
+ .willReturn(aResponse().withStatus(200)));
+
+
+ HttpHost proxy = new HttpHost("localhost", 8090);
+ DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
+ HttpClient httpclient = HttpClients.custom()
+ .setRoutePlanner(routePlanner)
+ .build();
+
+ //when
+ final HttpGet httpGet = new HttpGet("http://localhost:8089/private");
+ HttpResponse response = httpclient.execute(httpGet);
+
+ //then
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+ proxyMock.verify(getRequestedFor(urlEqualTo("/private")));
+ serviceMock.verify(getRequestedFor(urlEqualTo("/private")));
+ }
+
+ @Test
+ public void givenServerThatIsBehindAuthorizationProxy_whenClientSendRequest_shouldAuthorizeProperly() throws IOException {
+ //given
+ proxyMock.stubFor(get(urlMatching("/private"))
+ .willReturn(aResponse().proxiedFrom("http://localhost:8089/")));
+ serviceMock.stubFor(get(urlEqualTo("/private"))
+ .willReturn(aResponse().withStatus(200)));
+
+
+ HttpHost proxy = new HttpHost("localhost", 8090);
+ DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
+
+ // Client credentials
+ CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+ credentialsProvider.setCredentials(new AuthScope(proxy),
+ new UsernamePasswordCredentials("username_admin", "secret_password"));
+
+
+ // Create AuthCache instance
+ AuthCache authCache = new BasicAuthCache();
+
+ // Generate BASIC scheme object and add it to the local auth cache
+ BasicScheme basicAuth = new BasicScheme();
+ authCache.put(proxy, basicAuth);
+ HttpClientContext context = HttpClientContext.create();
+ context.setCredentialsProvider(credentialsProvider);
+ context.setAuthCache(authCache);
+
+
+ HttpClient httpclient = HttpClients.custom()
+ .setRoutePlanner(routePlanner)
+ .setDefaultCredentialsProvider(credentialsProvider)
+ .build();
+
+
+ //when
+ final HttpGet httpGet = new HttpGet("http://localhost:8089/private");
+ HttpResponse response = httpclient.execute(httpGet, context);
+
+ //then
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+ proxyMock.verify(getRequestedFor(urlEqualTo("/private")).withHeader("Authorization", containing("Basic")));
+ serviceMock.verify(getRequestedFor(urlEqualTo("/private")));
+ }
+
+
+}
diff --git a/mesos-marathon/Dockerfile b/mesos-marathon/Dockerfile
new file mode 100644
index 0000000000..ca79f2dc82
--- /dev/null
+++ b/mesos-marathon/Dockerfile
@@ -0,0 +1,4 @@
+FROM openjdk:8-jre-alpine
+ADD target/mesos-marathon-0.0.1-SNAPSHOT.jar app.jar
+EXPOSE 8082
+ENTRYPOINT ["java","-jar","/app.jar"]
\ No newline at end of file
diff --git a/mesos-marathon/dockerise.sh b/mesos-marathon/dockerise.sh
new file mode 100755
index 0000000000..50f5d38306
--- /dev/null
+++ b/mesos-marathon/dockerise.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -e
+docker login -u mogronalol -p $DOCKER_PASSWORD
+docker build -t baeldung/mesos-marathon-demo:$BUILD_NUMBER .
+docker push baeldung/mesos-marathon-demo:$BUILD_NUMBER
diff --git a/mesos-marathon/marathon.json b/mesos-marathon/marathon.json
new file mode 100644
index 0000000000..6471259e92
--- /dev/null
+++ b/mesos-marathon/marathon.json
@@ -0,0 +1,14 @@
+{
+ "id": "mesos-marathon-demo",
+ "container": {
+ "type": "DOCKER",
+ "docker": {
+ "image": "",
+ "network": "BRIDGE",
+ "portMappings": [
+ { "containerPort": 8082, "hostPort": 0 }
+ ]
+ },
+ "volumes": []
+ }
+}
\ No newline at end of file
diff --git a/mesos-marathon/pom.xml b/mesos-marathon/pom.xml
new file mode 100644
index 0000000000..ca17a5c4c4
--- /dev/null
+++ b/mesos-marathon/pom.xml
@@ -0,0 +1,46 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ mesos-marathon
+ 0.0.1-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.1.RELEASE
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.5.1.RELEASE
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mesos-marathon/src/main/java/com/mogronalol/DemoApplication.java b/mesos-marathon/src/main/java/com/mogronalol/DemoApplication.java
new file mode 100644
index 0000000000..f757178026
--- /dev/null
+++ b/mesos-marathon/src/main/java/com/mogronalol/DemoApplication.java
@@ -0,0 +1,14 @@
+package com.mogronalol;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import javax.annotation.PostConstruct;
+
+@SpringBootApplication
+public class DemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DemoApplication.class, args);
+ }
+}
diff --git a/mesos-marathon/src/main/java/com/mogronalol/HelloController.java b/mesos-marathon/src/main/java/com/mogronalol/HelloController.java
new file mode 100644
index 0000000000..2059280ba0
--- /dev/null
+++ b/mesos-marathon/src/main/java/com/mogronalol/HelloController.java
@@ -0,0 +1,17 @@
+package com.mogronalol;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController(value = "/")
+public class HelloController {
+
+ @GetMapping
+ @ResponseBody
+ public String getMapping() {
+ return "Hello world";
+ }
+
+}
diff --git a/mesos-marathon/src/main/resources/application.properties b/mesos-marathon/src/main/resources/application.properties
new file mode 100644
index 0000000000..8d51d0c619
--- /dev/null
+++ b/mesos-marathon/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.port=8082
\ No newline at end of file
diff --git a/mesos-marathon/src/test/java/com/mogronalol/DemoApplicationTests.java b/mesos-marathon/src/test/java/com/mogronalol/DemoApplicationTests.java
new file mode 100644
index 0000000000..5e88f9a70f
--- /dev/null
+++ b/mesos-marathon/src/test/java/com/mogronalol/DemoApplicationTests.java
@@ -0,0 +1,34 @@
+package com.mogronalol;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = {DemoApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class DemoApplicationTests {
+
+ private RestTemplate restTemplate;
+
+ @LocalServerPort
+ private int port;
+
+ @Before
+ public void setUp() {
+ restTemplate = new RestTemplate();
+ }
+
+ @Test
+ public void contextLoads() {
+ final String result = restTemplate.getForObject("http://localhost:" + port + "/", String.class);
+ assertThat(result).isEqualTo("Hello world");
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 5bf0d4ad02..a32a204304 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,6 +81,7 @@
mapstruct
metrics
+ mesos-marathon
mockito
mocks
@@ -192,6 +193,8 @@
struts2
cglib
+ apache-velocity
+
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index b6a24b6cb7..e77ab10aff 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -24,26 +24,6 @@
org.springframework.boot
spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
-
-
-
-
-
- org.apache.geronimo.specs
- geronimo-osgi-locator
- 1.1
- test
-
-
-
- org.apache.geronimo.components
- geronimo-jaspi
- 2.0.0
- test
@@ -109,18 +89,12 @@
- org.apache.tomee
- arquillian-tomee-embedded
- ${arquillian-tomee-embedded.version}
- test
-
-
-
- org.apache.tomee
- javaee-api
- ${tomee-javaee-api.version}
+ org.apache.tomcat
+ tomcat-servlet-api
+ ${tomee-servlet-api.version}
provided
+
@@ -220,8 +194,7 @@
3.1.1
3.3.7-1
3.1.7
- 7.0.2
- 7.0-1
+ 8.5.11
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/JavaEEApp.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/JavaEEApp.java
deleted file mode 100644
index 773503c5af..0000000000
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/JavaEEApp.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.baeldung.annotation.servletcomponentscan;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.Initialized;
-import javax.enterprise.event.Observes;
-import javax.servlet.ServletContext;
-
-@ApplicationScoped
-public class JavaEEApp {
-
- private ServletContext context;
-
- /**
- * act as a servletContext provider
- */
- private void setContext(@Observes @Initialized(ApplicationScoped.class) final ServletContext context) {
- if (this.context != null) {
- throw new IllegalStateException("app context started twice");
- }
-
- this.context = context;
- }
-
- public ServletContext getContext() {
- return context;
- }
-
-}
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java
index 9fd66ee12a..b4d416dd96 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java
@@ -9,13 +9,13 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
* -
*
@ServletComponentScan
* -
- *
@ServletComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.javaee")
+ * @ServletComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.components")
* -
*
@ServletComponentScan(basePackageClasses = {AttrListener.class, HelloFilter.class, HelloServlet.class, EchoServlet.class})
*
*/
@SpringBootApplication
-@ServletComponentScan("com.baeldung.annotation.servletcomponentscan.javaee")
+@ServletComponentScan("com.baeldung.annotation.servletcomponentscan.components")
public class SpringBootAnnotatedApp {
public static void main(String[] args) {
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java
index 9ce1c296e6..8a39078aac 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java
@@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
-@ComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.javaee")
+@ComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.components")
public class SpringBootPlainApp {
public static void main(String[] args) {
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/AttrListener.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java
similarity index 90%
rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/AttrListener.java
rename to spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java
index 321ddd59d1..bad39c52c4 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/AttrListener.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java
@@ -1,4 +1,4 @@
-package com.baeldung.annotation.servletcomponentscan.javaee;
+package com.baeldung.annotation.servletcomponentscan.components;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/EchoServlet.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java
similarity index 90%
rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/EchoServlet.java
rename to spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java
index b9fed314c7..3419cd0eaf 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/EchoServlet.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java
@@ -1,4 +1,4 @@
-package com.baeldung.annotation.servletcomponentscan.javaee;
+package com.baeldung.annotation.servletcomponentscan.components;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
@@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
-import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloFilter.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java
similarity index 94%
rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloFilter.java
rename to spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java
index 81e90d69ad..dc2368c5b2 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloFilter.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java
@@ -1,4 +1,4 @@
-package com.baeldung.annotation.servletcomponentscan.javaee;
+package com.baeldung.annotation.servletcomponentscan.components;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloServlet.java b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java
similarity index 90%
rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloServlet.java
rename to spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java
index 4a46a56107..aeae7aecc9 100644
--- a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/javaee/HelloServlet.java
+++ b/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java
@@ -1,7 +1,6 @@
-package com.baeldung.annotation.servletcomponentscan.javaee;
+package com.baeldung.annotation.servletcomponentscan.components;
import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
diff --git a/spring-boot/src/main/java/com/baeldung/utils/Application.java b/spring-boot/src/main/java/com/baeldung/utils/Application.java
new file mode 100644
index 0000000000..1f637eec11
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/utils/Application.java
@@ -0,0 +1,18 @@
+package com.baeldung.utils;
+
+import javax.annotation.security.RolesAllowed;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackages="com.baeldung.utils")
+public class Application {
+
+ @RolesAllowed("*")
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java b/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java
new file mode 100644
index 0000000000..a14d0b26c6
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java
@@ -0,0 +1,49 @@
+package com.baeldung.utils.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.ServletRequestBindingException;
+import org.springframework.web.bind.ServletRequestUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.util.WebUtils;
+
+@Controller
+public class UtilsController {
+
+ @GetMapping("/utils")
+ public String webUtils(Model model) {
+ return "utils";
+ }
+
+ @PostMapping("/setParam")
+ public String post(HttpServletRequest request, Model model) {
+ String param = ServletRequestUtils.getStringParameter(request, "param", "DEFAULT");
+
+// Long param = ServletRequestUtils.getLongParameter(request, "param",1L);
+// boolean param = ServletRequestUtils.getBooleanParameter(request, "param", true);
+// double param = ServletRequestUtils.getDoubleParameter(request, "param", 1000);
+// float param = ServletRequestUtils.getFloatParameter(request, "param", (float) 1.00);
+// int param = ServletRequestUtils.getIntParameter(request, "param", 100);
+
+// try {
+// ServletRequestUtils.getRequiredStringParameter(request, "param");
+// } catch (ServletRequestBindingException e) {
+// e.printStackTrace();
+// }
+
+ WebUtils.setSessionAttribute(request, "parameter", param);
+ model.addAttribute("parameter", "You set: "+(String) WebUtils.getSessionAttribute(request, "parameter"));
+ return "utils";
+ }
+
+ @GetMapping("/other")
+ public String other(HttpServletRequest request, Model model) {
+ String param = (String) WebUtils.getSessionAttribute(request, "parameter");
+ model.addAttribute("parameter", param);
+ return "other";
+ }
+
+}
diff --git a/spring-boot/src/main/resources/templates/other.html b/spring-boot/src/main/resources/templates/other.html
new file mode 100644
index 0000000000..d13373f9fe
--- /dev/null
+++ b/spring-boot/src/main/resources/templates/other.html
@@ -0,0 +1,16 @@
+
+
+
+
+Spring Utils Demo
+
+
+
+ Parameter set by you:
+
+
\ No newline at end of file
diff --git a/spring-boot/src/main/resources/templates/utils.html b/spring-boot/src/main/resources/templates/utils.html
new file mode 100644
index 0000000000..93030f424f
--- /dev/null
+++ b/spring-boot/src/main/resources/templates/utils.html
@@ -0,0 +1,23 @@
+
+
+
+
+Spring Utils Demo
+
+
+
+
+
+Another Page
+
+
\ No newline at end of file
diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/JavaEEAppIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/JavaEEAppIntegrationTest.java
deleted file mode 100644
index 95106d2dc8..0000000000
--- a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/JavaEEAppIntegrationTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.baeldung.annotation.servletcomponentscan;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-
-import javax.inject.Inject;
-import javax.servlet.FilterRegistration;
-import javax.servlet.ServletContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.container.test.api.RunAsClient;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.baeldung.annotation.servletcomponentscan.javaee.AttrListener;
-import com.baeldung.annotation.servletcomponentscan.javaee.EchoServlet;
-import com.baeldung.annotation.servletcomponentscan.javaee.HelloFilter;
-import com.baeldung.annotation.servletcomponentscan.javaee.HelloServlet;
-
-@RunWith(Arquillian.class)
-public class JavaEEAppIntegrationTest {
-
- @Deployment
- public static WebArchive createDeployment() {
- return ShrinkWrap.create(WebArchive.class).addClass(JavaEEApp.class).addClasses(AttrListener.class, HelloFilter.class, HelloServlet.class, EchoServlet.class);
- }
-
- @Inject
- private ServletContext servletContext;
-
- @Test
- public void givenServletContextListener_whenAccessSpecialAttrs_thenFound() throws MalformedURLException {
- assertNotNull(servletContext);
- assertNotNull(servletContext.getAttribute("servlet-context-attr"));
- assertEquals("test", servletContext.getAttribute("servlet-context-attr"));
- }
-
- @Test
- public void givenServletContext_whenCheckHelloFilterMappings_thenCorrect() throws MalformedURLException {
- assertNotNull(servletContext);
- FilterRegistration filterRegistration = servletContext.getFilterRegistration("hello filter");
-
- assertNotNull(filterRegistration);
- assertTrue(filterRegistration.getServletNameMappings().contains("echo servlet"));
- }
-
- @ArquillianResource
- private URL base;
-
- @Test
- @RunAsClient
- public void givenFilterAndServlet_whenGetHello_thenRespondFilteringHello() throws MalformedURLException {
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(URI.create(new URL(base, "hello").toExternalForm()));
- Response response = target.request().get();
-
- assertEquals("filtering hello", response.readEntity(String.class));
- }
-
- @Test
- @RunAsClient
- public void givenFilterAndServlet_whenPostEcho_thenEchoFiltered() throws MalformedURLException {
- Client client = ClientBuilder.newClient();
- WebTarget target = client.target(URI.create(new URL(base, "echo").toExternalForm()));
- Response response = target.request().post(Entity.entity("echo", MediaType.TEXT_PLAIN_TYPE));
-
- assertEquals("filtering echo", response.readEntity(String.class));
- }
-
-}
diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java
index 81ac3c9841..8d5eb56bf4 100644
--- a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java
+++ b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java
@@ -19,7 +19,7 @@ import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringBootAnnotatedApp.class)
@AutoConfigureMockMvc
-@TestPropertySource(properties = { "security.basic.enabled=false", "server.tomcat.additional-tld-skip-patterns=tomee-*.jar,tomcat-*.jar,openejb-*.jar,cxf-*.jar,activemq-*.jar" })
+@TestPropertySource(properties = { "security.basic.enabled=false" })
public class SpringBootWithServletComponentIntegrationTest {
@Autowired private ServletContext servletContext;
diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java
index b2dea25864..64507ad02c 100644
--- a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java
+++ b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java
@@ -19,7 +19,7 @@ import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringBootPlainApp.class)
@AutoConfigureMockMvc
-@TestPropertySource(properties = { "security.basic.enabled=false", "server.tomcat.additional-tld-skip-patterns=tomee-*.jar,tomcat-*.jar,openejb-*.jar,cxf-*.jar,activemq-*.jar" })
+@TestPropertySource(properties = { "security.basic.enabled=false" })
public class SpringBootWithoutServletComponentIntegrationTest {
@Autowired private ServletContext servletContext;
diff --git a/spring-data-neo4j/pom.xml b/spring-data-neo4j/pom.xml
index ce10313b2e..96606d597b 100644
--- a/spring-data-neo4j/pom.xml
+++ b/spring-data-neo4j/pom.xml
@@ -7,10 +7,41 @@
1.0
+
+ org.neo4j
+ neo4j
+ 3.1.0
+
+
+
+ org.neo4j
+ neo4j-ogm-core
+ 2.1.1
+
+
+
+ org.neo4j
+ neo4j-ogm-embedded-driver
+ 2.1.1
+
+
+
+ org.neo4j.driver
+ neo4j-java-driver
+ 1.1.1
+
+
+
+ org.springframework.data
+ spring-data-neo4j
+ 4.2.0.RELEASE
+
+
org.springframework.data
spring-data-neo4j
${spring-data-neo4j.version}
+ test-jar
@@ -27,13 +58,6 @@
test
-
- org.springframework.data
- spring-data-neo4j
- ${spring-data-neo4j.version}
- test-jar
-
-
org.neo4j
neo4j-kernel
@@ -72,9 +96,9 @@
spring-test
${spring-test.version}
-
+
@@ -130,16 +154,18 @@
+ 1.8
+ 1.8
1.8
UTF-8
UTF-8
- 3.0.7
+ 3.1.0
4.1.6.RELEASE
1.1
1.4.3.RELEASE
4.3.5.RELEASE
- 2.0.6
+ 2.1.1
4.12
diff --git a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jConfiguration.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jConfiguration.java
index fb4fda1497..344282d665 100644
--- a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jConfiguration.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jConfiguration.java
@@ -4,15 +4,12 @@ import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "com.baeldung.spring.data.neo4j.services" })
@Configuration
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
-public class MovieDatabaseNeo4jConfiguration extends Neo4jConfiguration {
+public class MovieDatabaseNeo4jConfiguration {
public static final String URL = System.getenv("NEO4J_URL") != null ? System.getenv("NEO4J_URL") : "http://neo4j:movies@localhost:7474";
@@ -23,7 +20,7 @@ public class MovieDatabaseNeo4jConfiguration extends Neo4jConfiguration {
return config;
}
- @Override
+ @Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "com.baeldung.spring.data.neo4j.domain");
}
diff --git a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jTestConfiguration.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jTestConfiguration.java
index 81935b2293..7bb1b78a09 100644
--- a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jTestConfiguration.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/config/MovieDatabaseNeo4jTestConfiguration.java
@@ -5,9 +5,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
-import org.springframework.data.neo4j.server.Neo4jServer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@@ -15,7 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
@Profile({ "embedded", "test" })
-public class MovieDatabaseNeo4jTestConfiguration extends Neo4jConfiguration {
+public class MovieDatabaseNeo4jTestConfiguration {
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
@@ -24,7 +22,7 @@ public class MovieDatabaseNeo4jTestConfiguration extends Neo4jConfiguration {
return config;
}
- @Override
+ @Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "com.baeldung.spring.data.neo4j.domain");
}
diff --git a/core-java/src/main/java/com/baeldung/graph/Car.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Car.java
similarity index 89%
rename from core-java/src/main/java/com/baeldung/graph/Car.java
rename to spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Car.java
index 1dc65a0d4b..f2325a334f 100644
--- a/core-java/src/main/java/com/baeldung/graph/Car.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Car.java
@@ -1,12 +1,9 @@
-package com.baeldung.graph;
+package com.baeldung.spring.data.neo4j.domain;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
-/**
- * @author Danil Kornishev (danil.kornishev@mastercard.com)
- */
@NodeEntity
public class Car {
@GraphId
diff --git a/core-java/src/main/java/com/baeldung/graph/Company.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Company.java
similarity index 87%
rename from core-java/src/main/java/com/baeldung/graph/Company.java
rename to spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Company.java
index 1fe892b331..4422ade44f 100644
--- a/core-java/src/main/java/com/baeldung/graph/Company.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/domain/Company.java
@@ -1,11 +1,8 @@
-package com.baeldung.graph;
+package com.baeldung.spring.data.neo4j.domain;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
-/**
- * @author Danil Kornishev (danil.kornishev@mastercard.com)
- */
@NodeEntity
public class Company {
private Long id;
diff --git a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/MovieRepository.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/MovieRepository.java
index 1bd605a7bc..afb82551e7 100644
--- a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/MovieRepository.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/MovieRepository.java
@@ -12,6 +12,7 @@ import java.util.Map;
@Repository
public interface MovieRepository extends GraphRepository {
+
Movie findByTitle(@Param("title") String title);
@Query("MATCH (m:Movie) WHERE m.title =~ ('(?i).*'+{title}+'.*') RETURN m")
diff --git a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/PersonRepository.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/PersonRepository.java
index f7f694c07f..4ac40ef75b 100644
--- a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/PersonRepository.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/repostory/PersonRepository.java
@@ -6,5 +6,4 @@ import org.springframework.stereotype.Repository;
@Repository
public interface PersonRepository extends GraphRepository {
-
}
diff --git a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/services/MovieService.java b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/services/MovieService.java
index d760d19066..ae1f6eb8e5 100644
--- a/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/services/MovieService.java
+++ b/spring-data-neo4j/src/main/java/com/baeldung/spring/data/neo4j/services/MovieService.java
@@ -12,11 +12,11 @@ import java.util.*;
public class MovieService {
@Autowired
- MovieRepository movieRepository;
+ private MovieRepository movieRepository;
private Map toD3Format(Iterator