diff --git a/annotations/pom.xml b/annotations/pom.xml
index f691674cf1..0ddc17f8a7 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -1,7 +1,6 @@
-
+
parent-modules
com.baeldung
diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml
index e2cd7d344a..6849452908 100644
--- a/apache-cxf/pom.xml
+++ b/apache-cxf/pom.xml
@@ -5,20 +5,20 @@
apache-cxf
0.0.1-SNAPSHOT
pom
-
+
cxf-introduction
cxf-spring
cxf-jaxrs-implementation
cxf-aegis
-
+
4.12
3.6.0
1.5.0
-
+
junit
@@ -27,7 +27,7 @@
test
-
+
install
diff --git a/apache-fop/pom.xml b/apache-fop/pom.xml
index 4dd61d8f4e..6f89497a7d 100644
--- a/apache-fop/pom.xml
+++ b/apache-fop/pom.xml
@@ -1,154 +1,155 @@
-
- 4.0.0
- com.baeldung
- apache-fop
- 0.1-SNAPSHOT
+
+ 4.0.0
+ com.baeldung
+ apache-fop
+ 0.1-SNAPSHOT
- apache-fop
+ apache-fop
-
+
-
+
-
- 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}
+
-
+
-
- junit
- junit
- ${junit.version}
- test
-
+
+ junit
+ junit
+ ${junit.version}
+ test
+
-
- org.hamcrest
- hamcrest-core
- ${org.hamcrest.version}
- test
-
-
- org.hamcrest
- hamcrest-library
- ${org.hamcrest.version}
- test
-
+
+ org.hamcrest
+ hamcrest-core
+ ${org.hamcrest.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
-
+
-
- org.apache.xmlgraphics
- fop
- ${fop.version}
-
-
- org.apache.avalon.framework
- avalon-framework-api
-
-
- org.apache.avalon.framework
- avalon-framework-impl
-
-
-
+
+ org.apache.xmlgraphics
+ fop
+ ${fop.version}
+
+
+ org.apache.avalon.framework
+ avalon-framework-api
+
+
+ org.apache.avalon.framework
+ avalon-framework-impl
+
+
+
-
- avalon-framework
- avalon-framework-api
- ${avalon-framework.version}
-
-
- avalon-framework
- avalon-framework-impl
- ${avalon-framework.version}
-
+
+ avalon-framework
+ avalon-framework-api
+ ${avalon-framework.version}
+
+
+ avalon-framework
+ avalon-framework-impl
+ ${avalon-framework.version}
+
-
- org.dbdoclet
- dbdoclet
- ${dbdoclet.version}
-
+
+ org.dbdoclet
+ dbdoclet
+ ${dbdoclet.version}
+
-
- org.dbdoclet
- herold
- 6.1.0
- system
- ${basedir}/src/test/resources/jars/herold.jar
-
-
-
- net.sf.jtidy
- jtidy
- ${jtidy.version}
-
+
+ org.dbdoclet
+ herold
+ 6.1.0
+ system
+ ${basedir}/src/test/resources/jars/herold.jar
+
-
+
+ net.sf.jtidy
+ jtidy
+ ${jtidy.version}
+
-
- apache-fop
-
-
- src/main/resources
- true
-
-
+
-
+
+ apache-fop
+
+
+ src/main/resources
+ true
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- 1.7
-
-
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ 1.7
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
**/*IntegrationTest.java
**/*LiveTest.java
-
-
-
+
+
+
-
+
-
+
@@ -170,7 +171,7 @@
**/*IntegrationTest.java
- **/*LiveTest.java
+ **/*LiveTest.java
@@ -185,25 +186,25 @@
-
-
- 1.1
- 4.3
- 8.0.2
- r938
-
- 1.7.21
- 1.1.7
-
- 1.3
- 4.12
- 1.10.19
+
+ 1.1
+ 4.3
+ 8.0.2
+ r938
+
+ 1.7.21
+ 1.1.7
-
- 3.6.0
- 2.19.1
+
+ 1.3
+ 4.12
+ 1.10.19
-
+
+ 3.6.0
+ 2.19.1
+
+
\ No newline at end of file
diff --git a/aspectj/pom.xml b/aspectj/pom.xml
index 6e7ef1b961..90b527c14f 100644
--- a/aspectj/pom.xml
+++ b/aspectj/pom.xml
@@ -12,32 +12,32 @@
aspectjrt
${aspectj.version}
-
+
org.aspectj
aspectjweaver
${aspectj.version}
-
+
org.slf4j
slf4j-api
${org.slf4j.version}
-
+
ch.qos.logback
logback-classic
${logback.version}
-
+
ch.qos.logback
logback-core
${logback.version}
-
+
junit
@@ -46,34 +46,34 @@
- org.springframework
- spring-context
- 4.3.4.RELEASE
+ org.springframework
+ spring-context
+ 4.3.4.RELEASE
- org.springframework
- spring-beans
- 4.3.4.RELEASE
+ org.springframework
+ spring-beans
+ 4.3.4.RELEASE
- org.springframework
- spring-core
- 4.3.4.RELEASE
+ org.springframework
+ spring-core
+ 4.3.4.RELEASE
- cglib
- cglib
- 3.2.4
+ cglib
+ cglib
+ 3.2.4
- org.springframework
- spring-aop
- 4.3.4.RELEASE
+ org.springframework
+ spring-aop
+ 4.3.4.RELEASE
- log4j
- log4j
- 1.2.17
+ log4j
+ log4j
+ 1.2.17
@@ -95,9 +95,9 @@
${source.version}
-
+
-
+
org.codehaus.mojo
aspectj-maven-plugin
@@ -111,41 +111,22 @@
ignore
${project.build.sourceEncoding}
-
-
+
+
compile
- test-compile
+ test-compile
-
-
-
+
+
diff --git a/assertj/pom.xml b/assertj/pom.xml
index 0b3bcbacdb..032f33c89d 100644
--- a/assertj/pom.xml
+++ b/assertj/pom.xml
@@ -54,8 +54,8 @@
3.1.0
4.12
3.6.1
-
+
3.6.0
-
+
\ No newline at end of file
diff --git a/autovalue/pom.xml b/autovalue/pom.xml
index 57c4662e5c..32616dc8bc 100644
--- a/autovalue/pom.xml
+++ b/autovalue/pom.xml
@@ -41,5 +41,5 @@
4.12
3.6.0
-
+
diff --git a/cdi/pom.xml b/cdi/pom.xml
index 231390ea5c..e5aaeb2c7b 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -45,7 +45,7 @@
-
+
@@ -61,7 +61,7 @@
-
+
integration
@@ -101,7 +101,7 @@
1.8.9
2.4.1.Final
4.12
- 2.19.1
+ 2.19.1
\ No newline at end of file
diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml
index bf9325c935..decba19c53 100644
--- a/core-java-9/pom.xml
+++ b/core-java-9/pom.xml
@@ -1,91 +1,88 @@
-
- 4.0.0
- com.baeldung
- core-java9
- 0.2-SNAPSHOT
+
+ 4.0.0
+ com.baeldung
+ core-java9
+ 0.2-SNAPSHOT
- core-java9
+ core-java9
-
-
- apache.snapshots
- http://repository.apache.org/snapshots/
-
-
+
+
+ apache.snapshots
+ http://repository.apache.org/snapshots/
+
+
-
+
-
- org.slf4j
- slf4j-api
- ${org.slf4j.version}
-
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
-
- org.hamcrest
- hamcrest-library
- ${org.hamcrest.version}
- test
-
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
-
- junit
- junit
- ${junit.version}
- test
-
+
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
+
+ core-java-9
-
+
-
- core-java-9
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ 1.9
+ true
+
+
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- 1.9
- true
-
-
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
+
-
+
+
+ 1.7.21
-
+
+ 3.6-jigsaw-SNAPSHOT
+ 2.19.1
-
-
- 1.7.21
-
-
- 3.6-jigsaw-SNAPSHOT
- 2.19.1
-
-
- 1.3
- 4.12
- 1.10.19
-
+
+ 1.3
+ 4.12
+ 1.10.19
+
diff --git a/couchbase-sdk/pom.xml b/couchbase-sdk/pom.xml
index 6462cfb57a..301fd81c51 100644
--- a/couchbase-sdk/pom.xml
+++ b/couchbase-sdk/pom.xml
@@ -1,91 +1,91 @@
- 4.0.0
- com.baeldung
- couchbase-sdk
- 0.1-SNAPSHOT
- jar
- couchbase-sdk
- Couchbase SDK Tutorials
+ 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
+ couchbase-sdk
+ 0.1-SNAPSHOT
+ jar
+ couchbase-sdk
+ Couchbase SDK Tutorials
-
-
-
- com.couchbase.client
- java-client
- ${couchbase.client.version}
-
+
+
+
+ com.couchbase.client
+ java-client
+ ${couchbase.client.version}
+
-
-
- org.springframework
- spring-context
- ${spring-framework.version}
-
-
- org.springframework
- spring-context-support
- ${spring-framework.version}
-
+
+
+ org.springframework
+ spring-context
+ ${spring-framework.version}
+
+
+ org.springframework
+ spring-context-support
+ ${spring-framework.version}
+
-
-
- org.slf4j
- slf4j-api
- ${org.slf4j.version}
- compile
-
-
- 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}
+ compile
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${org.slf4j.version}
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
-
-
- org.springframework
- spring-test
- ${spring-framework.version}
- test
-
-
- junit
- junit
- ${junit.version}
- test
-
-
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
- test
-
-
+
+
+ org.springframework
+ spring-test
+ ${spring-framework.version}
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
-
-
-
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- ${java.version}
-
-
-
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+ test
+
+
+
+
+
+
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ ${java.version}
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
${maven-surefire-plugin.version}
@@ -96,20 +96,20 @@
-
-
+
+
-
- 1.8
- UTF-8
- 2.3.6
- 4.3.4.RELEASE
- 1.1.7
- 1.7.21
- 4.12
- 3.5
- 3.6.0
+
+ 1.8
+ UTF-8
+ 2.3.6
+ 4.3.4.RELEASE
+ 1.1.7
+ 1.7.21
+ 4.12
+ 3.5
+ 3.6.0
2.19.1
-
+
diff --git a/deltaspike/pom.xml b/deltaspike/pom.xml
index b4a7657e97..141b5b0da6 100644
--- a/deltaspike/pom.xml
+++ b/deltaspike/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.baeldung
deltaspike
@@ -19,21 +19,19 @@
-
-
- UTF-8
+
+
+
+ UTF-8
1.7.21
3.7.4
1.7.2
-
+
1.0.2.Final
-
+
8.2.2.Final
@@ -50,14 +48,11 @@
-
+
org.wildfly.bom
jboss-javaee-7.0-with-tools
@@ -77,43 +72,37 @@
-
+
-
+
javax.enterprise
cdi-api
provided
-
+
org.jboss.spec.javax.annotation
jboss-annotations-api_1.2_spec
provided
-
+
org.jboss.resteasy
jaxrs-api
provided
-
+
org.hibernate.javax.persistence
hibernate-jpa-2.1-api
provided
-
+
org.jboss.spec.javax.ejb
jboss-ejb-api_3.2_spec
@@ -135,8 +124,7 @@
-
+
org.jboss.spec.javax.faces
jboss-jsf-api_2.2_spec
@@ -145,16 +133,14 @@
-
+
org.hibernate
hibernate-jpamodelgen
provided
-
+
org.hibernate
hibernate-validator-annotation-processor
@@ -169,8 +155,7 @@
-
+
org.jboss.arquillian.junit
arquillian-junit-container
@@ -225,8 +210,7 @@
-
+
${project.artifactId}
@@ -265,10 +249,8 @@
-
-
+
+
default
true
@@ -288,10 +270,8 @@
-
-
+
+
arq-wildfly-managed
diff --git a/dozer/pom.xml b/dozer/pom.xml
index 363285f619..56d5e889c3 100644
--- a/dozer/pom.xml
+++ b/dozer/pom.xml
@@ -1,11 +1,11 @@
4.0.0
-
+
com.baeldung
dozer
1.0
-
+
dozer
@@ -54,7 +54,7 @@
-
+
1.7.21
3.5
@@ -62,5 +62,5 @@
4.12
3.6.0
-
+
diff --git a/ejb/pom.xml b/ejb/pom.xml
index b00f80a817..bfcc972417 100755
--- a/ejb/pom.xml
+++ b/ejb/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.ejb
ejb
@@ -75,8 +75,8 @@
-
- ejb-remote
- ejb-client
-
+
+ ejb-remote
+ ejb-client
+
\ No newline at end of file
diff --git a/enterprise-patterns/pom.xml b/enterprise-patterns/pom.xml
index 763227e45b..1c895095dc 100644
--- a/enterprise-patterns/pom.xml
+++ b/enterprise-patterns/pom.xml
@@ -1,7 +1,6 @@
-
+
4.0.0
com.baeldung.enterprise.patterns
@@ -32,7 +31,7 @@
-
+
3.6.0
diff --git a/feign/pom.xml b/feign/pom.xml
index 721fa76682..160f37ec2c 100644
--- a/feign/pom.xml
+++ b/feign/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.feign
diff --git a/gradle-tutorial/build.gradle b/gradle-tutorial/build.gradle
new file mode 100644
index 0000000000..fc561987f7
--- /dev/null
+++ b/gradle-tutorial/build.gradle
@@ -0,0 +1,25 @@
+apply plugin: 'java'
+apply plugin: 'maven'
+
+repositories{
+ mavenCentral()
+}
+
+dependencies{
+ compile 'org.springframework:spring-context:4.3.5.RELEASE'
+}
+
+task hello {
+ println "this Baeldung's tutorial is ${awesomeness}"
+}
+
+uploadArchives {
+ repositories {
+ mavenDeployer {
+ repository(url: 'http://yourmavenrepo/repository') {
+ authentication(userName: 'user', password: 'password');
+ }
+
+ }
+ }
+}
diff --git a/gradle-tutorial/gradle.properties b/gradle-tutorial/gradle.properties
new file mode 100644
index 0000000000..41701e5a19
--- /dev/null
+++ b/gradle-tutorial/gradle.properties
@@ -0,0 +1,3 @@
+awesomeness=awesome
+group=com.baeldung.tutorial
+version=1.0.1
diff --git a/gradle-tutorial/gradle/wrapper/gradle-wrapper.jar b/gradle-tutorial/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..3391a4cdf6
Binary files /dev/null and b/gradle-tutorial/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle-tutorial/gradle/wrapper/gradle-wrapper.properties b/gradle-tutorial/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..b601d97764
--- /dev/null
+++ b/gradle-tutorial/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sat Dec 31 15:46:08 BRT 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
diff --git a/gradle-tutorial/gradlew b/gradle-tutorial/gradlew
new file mode 100644
index 0000000000..9d82f78915
--- /dev/null
+++ b/gradle-tutorial/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+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
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+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
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradle-tutorial/gradlew.bat b/gradle-tutorial/gradlew.bat
new file mode 100644
index 0000000000..8a0b282aa6
--- /dev/null
+++ b/gradle-tutorial/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/gradle-tutorial/src/main/java/Main.java b/gradle-tutorial/src/main/java/Main.java
new file mode 100644
index 0000000000..10edd1840b
--- /dev/null
+++ b/gradle-tutorial/src/main/java/Main.java
@@ -0,0 +1,5 @@
+public class Main{
+ public static void main(String[] args){
+ System.out.println("Baeldung Rocks");
+ }
+}
diff --git a/guava19/src/test/java/com/baeldung/guava/MultimapTest.java b/guava19/src/test/java/com/baeldung/guava/MultimapTest.java
new file mode 100644
index 0000000000..c984ab1e4b
--- /dev/null
+++ b/guava19/src/test/java/com/baeldung/guava/MultimapTest.java
@@ -0,0 +1,62 @@
+package com.baeldung.guava;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.junit.Test;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class MultimapTest {
+
+ @Test
+ public void givenMap_whenAddTwoValuesForSameKey_shouldOverridePreviousKey() {
+ //given
+ String key = "a-key";
+ Map map = new LinkedHashMap<>();
+
+ //when
+ map.put(key, "firstValue");
+ map.put(key, "secondValue");
+
+ //then
+ assertEquals(1, map.size());
+ }
+
+ @Test
+ public void givenMultiMap_whenAddTwoValuesForSameKey_shouldHaveTwoEntriesInMap() {
+ //given
+ String key = "a-key";
+ Multimap map = ArrayListMultimap.create();
+
+ //when
+ map.put(key, "firstValue");
+ map.put(key, "secondValue");
+
+ //then
+ assertEquals(2, map.size());
+ }
+
+ @Test
+ public void givenMapOfListValues_whenAddTwoValuesForSameKey_shouldHaveTwoElementsInList() {
+ //given
+ String key = "a-key";
+ Map> map = new LinkedHashMap<>();
+
+ //when
+ List values = map.get(key);
+ if(values == null){
+ values = new LinkedList<>();
+ values.add("firstValue");
+ values.add("secondValue");
+ }
+ map.put(key, values);
+
+ //then
+ assertEquals(1, map.size());
+ }
+}
diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java
index 6fad126537..954236a56f 100644
--- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java
+++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java
@@ -28,13 +28,14 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-@Ignore("Server is not available")
public class HttpClientMultipartLiveTest {
- private static final String SERVER = "http://echo.200please.com";
+ // No longer available
+ // private static final String SERVER = "http://echo.200please.com";
+
+ private static final String SERVER = "http://posttestserver.com/post.php";
private static final String TEXTFILENAME = "temp.txt";
private static final String IMAGEFILENAME = "image.jpg";
private static final String ZIPFILENAME = "zipFile.zip";
@@ -46,7 +47,8 @@ public class HttpClientMultipartLiveTest {
@Before
public final void before() {
- client = HttpClientBuilder.create().build();
+ client = HttpClientBuilder.create()
+ .build();
post = new HttpPost(SERVER);
}
@@ -80,7 +82,9 @@ public class HttpClientMultipartLiveTest {
@Test
public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException {
- final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + TEXTFILENAME);
+ final URL url = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource("uploads/" + TEXTFILENAME);
final File file = new File(url.getPath());
final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
@@ -97,11 +101,12 @@ public class HttpClientMultipartLiveTest {
post.setEntity(entity);
response = client.execute(post);
- final int statusCode = response.getStatusLine().getStatusCode();
+ final int statusCode = response.getStatusLine()
+ .getStatusCode();
final String responseString = getContent();
final String contentTypeInHeader = getContentTypeHeader();
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
- assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
+ // assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
System.out.println(responseString);
System.out.println("POST Content Type: " + contentTypeInHeader);
@@ -109,7 +114,9 @@ public class HttpClientMultipartLiveTest {
@Test
public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException {
- final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + TEXTFILENAME);
+ final URL url = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource("uploads/" + TEXTFILENAME);
final File file = new File(url.getPath());
final String message = "This is a multipart post";
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
@@ -119,11 +126,12 @@ public class HttpClientMultipartLiveTest {
final HttpEntity entity = builder.build();
post.setEntity(entity);
response = client.execute(post);
- final int statusCode = response.getStatusLine().getStatusCode();
+ final int statusCode = response.getStatusLine()
+ .getStatusCode();
final String responseString = getContent();
final String contentTypeInHeader = getContentTypeHeader();
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
- assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
+ // assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
System.out.println(responseString);
System.out.println("POST Content Type: " + contentTypeInHeader);
@@ -131,8 +139,12 @@ public class HttpClientMultipartLiveTest {
@Test
public final void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException {
- final URL url = Thread.currentThread().getContextClassLoader().getResource("uploads/" + ZIPFILENAME);
- final URL url2 = Thread.currentThread().getContextClassLoader().getResource("uploads/" + IMAGEFILENAME);
+ final URL url = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource("uploads/" + ZIPFILENAME);
+ final URL url2 = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource("uploads/" + IMAGEFILENAME);
final InputStream inputStream = new FileInputStream(url.getPath());
final File file = new File(url2.getPath());
final String message = "This is a multipart post";
@@ -144,11 +156,12 @@ public class HttpClientMultipartLiveTest {
final HttpEntity entity = builder.build();
post.setEntity(entity);
response = client.execute(post);
- final int statusCode = response.getStatusLine().getStatusCode();
+ final int statusCode = response.getStatusLine()
+ .getStatusCode();
final String responseString = getContent();
final String contentTypeInHeader = getContentTypeHeader();
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
- assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
+ // assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
System.out.println(responseString);
System.out.println("POST Content Type: " + contentTypeInHeader);
@@ -166,11 +179,12 @@ public class HttpClientMultipartLiveTest {
final HttpEntity entity = builder.build();
post.setEntity(entity);
response = client.execute(post);
- final int statusCode = response.getStatusLine().getStatusCode();
+ final int statusCode = response.getStatusLine()
+ .getStatusCode();
final String responseString = getContent();
final String contentTypeInHeader = getContentTypeHeader();
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
- assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
+ // assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
System.out.println(responseString);
System.out.println("POST Content Type: " + contentTypeInHeader);
@@ -179,7 +193,8 @@ public class HttpClientMultipartLiveTest {
// UTIL
final String getContent() throws IOException {
- rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+ rd = new BufferedReader(new InputStreamReader(response.getEntity()
+ .getContent()));
String body = "";
String content = "";
while ((body = rd.readLine()) != null) {
@@ -189,7 +204,9 @@ public class HttpClientMultipartLiveTest {
}
final String getContentTypeHeader() throws IOException {
- return post.getEntity().getContentType().toString();
+ return post.getEntity()
+ .getContentType()
+ .toString();
}
}
diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java
index 278cdb3556..5dfecb85aa 100644
--- a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java
+++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java
@@ -1,11 +1,24 @@
package org.baeldung.httpclient;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLHandshakeException;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.*;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
@@ -15,14 +28,6 @@ import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.junit.Test;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-
/**
* This test requires a localhost server over HTTPS
* It should only be manually run, not part of the automated build
@@ -35,13 +40,15 @@ public class HttpsClientSslLiveTest {
// tests
- @Test(expected = SSLException.class)
+ @Test(expected = SSLHandshakeException.class)
public final void whenHttpsUrlIsConsumed_thenException() throws IOException {
- final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
+ final CloseableHttpClient httpClient = HttpClientBuilder.create()
+ .build();
final HttpGet getMethod = new HttpGet(HOST_WITH_SSL);
final HttpResponse response = httpClient.execute(getMethod);
- assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+ assertThat(response.getStatusLine()
+ .getStatusCode(), equalTo(200));
}
@SuppressWarnings("deprecation")
@@ -57,7 +64,8 @@ public class HttpsClientSslLiveTest {
final HttpGet getMethod = new HttpGet(HOST_WITH_SSL);
final HttpResponse response = httpClient.execute(getMethod);
- assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+ assertThat(response.getStatusLine()
+ .getStatusCode(), equalTo(200));
httpClient.close();
}
@@ -65,44 +73,62 @@ public class HttpsClientSslLiveTest {
@Test
public final void givenHttpClientAfter4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException {
final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true;
- final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
+ final SSLContext sslContext = SSLContexts.custom()
+ .loadTrustMaterial(null, acceptingTrustStrategy)
+ .build();
final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
- final CloseableHttpClient httpClient = HttpClients.custom().setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER).setSSLSocketFactory(sslsf).build();
+ final CloseableHttpClient httpClient = HttpClients.custom()
+ .setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
+ .setSSLSocketFactory(sslsf)
+ .build();
final HttpGet getMethod = new HttpGet(HOST_WITH_SSL);
final HttpResponse response = httpClient.execute(getMethod);
- assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+ assertThat(response.getStatusLine()
+ .getStatusCode(), equalTo(200));
httpClient.close();
}
@Test
public final void givenHttpClientPost4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException {
- final SSLContextBuilder builder = new SSLContextBuilder();
- builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
- final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
- final CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
+ .build();
+ final NoopHostnameVerifier hostnameVerifier = new NoopHostnameVerifier();
+
+ final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
+ final CloseableHttpClient httpClient = HttpClients.custom()
+ .setSSLHostnameVerifier(hostnameVerifier)
+ .setSSLSocketFactory(sslsf)
+ .build();
// new
final HttpGet getMethod = new HttpGet(HOST_WITH_SSL);
final HttpResponse response = httpClient.execute(getMethod);
- assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+ assertThat(response.getStatusLine()
+ .getStatusCode(), equalTo(200));
+ httpClient.close();
+
}
@Test
public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws Exception {
- SSLContext sslContext = new SSLContextBuilder()
- .loadTrustMaterial(null, (certificate, authType) -> true).build();
+ final SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (certificate, authType) -> true)
+ .build();
- final CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
+ final CloseableHttpClient client = HttpClients.custom()
+ .setSSLContext(sslContext)
+ .setSSLHostnameVerifier(new NoopHostnameVerifier())
+ .build();
final HttpGet httpGet = new HttpGet(HOST_WITH_SSL);
httpGet.setHeader("Accept", "application/xml");
final HttpResponse response = client.execute(httpGet);
- assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+ assertThat(response.getStatusLine()
+ .getStatusCode(), equalTo(200));
}
}
diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumSimple.java b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumSimple.java
new file mode 100644
index 0000000000..1118fb349a
--- /dev/null
+++ b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumSimple.java
@@ -0,0 +1,26 @@
+package com.baeldung.jackson.dtos.withEnum;
+
+public enum DistanceEnumSimple {
+ KILOMETER("km", 1000), MILE("miles", 1609.34), METER("meters", 1), INCH("inches", 0.0254), CENTIMETER("cm", 0.01), MILLIMETER("mm", 0.001);
+
+ private String unit;
+ private final double meters;
+
+ private DistanceEnumSimple(String unit, double meters) {
+ this.unit = unit;
+ this.meters = meters;
+ }
+
+ public double getMeters() {
+ return meters;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+}
\ No newline at end of file
diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithJsonFormat.java b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithJsonFormat.java
new file mode 100644
index 0000000000..7dc6bb559b
--- /dev/null
+++ b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithJsonFormat.java
@@ -0,0 +1,29 @@
+package com.baeldung.jackson.dtos.withEnum;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum DistanceEnumWithJsonFormat {
+ KILOMETER("km", 1000), MILE("miles", 1609.34), METER("meters", 1), INCH("inches", 0.0254), CENTIMETER("cm", 0.01), MILLIMETER("mm", 0.001);
+
+ private String unit;
+ private final double meters;
+
+ private DistanceEnumWithJsonFormat(String unit, double meters) {
+ this.unit = unit;
+ this.meters = meters;
+ }
+
+ public double getMeters() {
+ return meters;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+}
\ No newline at end of file
diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java
new file mode 100644
index 0000000000..69c476d8a5
--- /dev/null
+++ b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/DistanceEnumWithValue.java
@@ -0,0 +1,29 @@
+package com.baeldung.jackson.dtos.withEnum;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public enum DistanceEnumWithValue {
+ KILOMETER("km", 1000), MILE("miles", 1609.34), METER("meters", 1), INCH("inches", 0.0254), CENTIMETER("cm", 0.01), MILLIMETER("mm", 0.001);
+
+ private String unit;
+ private final double meters;
+
+ private DistanceEnumWithValue(String unit, double meters) {
+ this.unit = unit;
+ this.meters = meters;
+ }
+
+ @JsonValue
+ public double getMeters() {
+ return meters;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+}
\ No newline at end of file
diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java
new file mode 100644
index 0000000000..bf9b7db395
--- /dev/null
+++ b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumCustom.java
@@ -0,0 +1,59 @@
+package com.baeldung.jackson.dtos.withEnum;
+
+import com.baeldung.jackson.enums.Distance;
+
+public class MyDtoWithEnumCustom {
+
+ private String stringValue;
+ private int intValue;
+ private boolean booleanValue;
+ private Distance type;
+
+ public MyDtoWithEnumCustom() {
+ super();
+ }
+
+ public MyDtoWithEnumCustom(final String stringValue, final int intValue, final boolean booleanValue, final Distance type) {
+ super();
+
+ this.stringValue = stringValue;
+ this.intValue = intValue;
+ this.booleanValue = booleanValue;
+ this.type = type;
+ }
+
+ // API
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(final String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public void setIntValue(final int intValue) {
+ this.intValue = intValue;
+ }
+
+ public boolean isBooleanValue() {
+ return booleanValue;
+ }
+
+ public void setBooleanValue(final boolean booleanValue) {
+ this.booleanValue = booleanValue;
+ }
+
+ public Distance getType() {
+ return type;
+ }
+
+ public void setType(final Distance type) {
+ this.type = type;
+ }
+
+}
diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumJsonFormat.java b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumJsonFormat.java
new file mode 100644
index 0000000000..8e2f1b835f
--- /dev/null
+++ b/jackson/src/test/java/com/baeldung/jackson/dtos/withEnum/MyDtoWithEnumJsonFormat.java
@@ -0,0 +1,57 @@
+package com.baeldung.jackson.dtos.withEnum;
+
+public class MyDtoWithEnumJsonFormat {
+
+ private String stringValue;
+ private int intValue;
+ private boolean booleanValue;
+ private DistanceEnumWithJsonFormat distanceType;
+
+ public MyDtoWithEnumJsonFormat() {
+ super();
+ }
+
+ public MyDtoWithEnumJsonFormat(final String stringValue, final int intValue, final boolean booleanValue, final DistanceEnumWithJsonFormat type) {
+ super();
+
+ this.stringValue = stringValue;
+ this.intValue = intValue;
+ this.booleanValue = booleanValue;
+ this.distanceType = type;
+ }
+
+ // API
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(final String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public void setIntValue(final int intValue) {
+ this.intValue = intValue;
+ }
+
+ public boolean isBooleanValue() {
+ return booleanValue;
+ }
+
+ public void setBooleanValue(final boolean booleanValue) {
+ this.booleanValue = booleanValue;
+ }
+
+ public DistanceEnumWithJsonFormat getDistanceType() {
+ return distanceType;
+ }
+
+ public void setDistanceType(final DistanceEnumWithJsonFormat type) {
+ this.distanceType = type;
+ }
+
+}
diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationTest.java b/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationTest.java
index f2464d4251..9351b929d3 100644
--- a/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationTest.java
+++ b/jackson/src/test/java/com/baeldung/jackson/test/JacksonAnnotationTest.java
@@ -1,6 +1,32 @@
package com.baeldung.jackson.test;
-import com.baeldung.jackson.annotation.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.Test;
+
+import com.baeldung.jackson.annotation.BeanWithCreator;
+import com.baeldung.jackson.annotation.BeanWithCustomAnnotation;
+import com.baeldung.jackson.annotation.BeanWithFilter;
+import com.baeldung.jackson.annotation.BeanWithGetter;
+import com.baeldung.jackson.annotation.BeanWithIgnore;
+import com.baeldung.jackson.annotation.BeanWithInject;
+import com.baeldung.jackson.annotation.ExtendableBean;
+import com.baeldung.jackson.annotation.MyBean;
+import com.baeldung.jackson.annotation.PrivateBean;
+import com.baeldung.jackson.annotation.RawBean;
+import com.baeldung.jackson.annotation.UnwrappedUser;
+import com.baeldung.jackson.annotation.UserWithIgnoreType;
+import com.baeldung.jackson.annotation.Zoo;
import com.baeldung.jackson.bidirection.ItemWithIdentity;
import com.baeldung.jackson.bidirection.ItemWithRef;
import com.baeldung.jackson.bidirection.UserWithIdentity;
@@ -8,7 +34,7 @@ import com.baeldung.jackson.bidirection.UserWithRef;
import com.baeldung.jackson.date.EventWithFormat;
import com.baeldung.jackson.date.EventWithSerializer;
import com.baeldung.jackson.dtos.MyMixInForIgnoreType;
-import com.baeldung.jackson.dtos.withEnum.TypeEnumWithValue;
+import com.baeldung.jackson.dtos.withEnum.DistanceEnumWithValue;
import com.baeldung.jackson.exception.UserWithRoot;
import com.baeldung.jackson.jsonview.Item;
import com.baeldung.jackson.jsonview.Views;
@@ -20,17 +46,6 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
public class JacksonAnnotationTest {
@@ -85,10 +100,10 @@ public class JacksonAnnotationTest {
}
@Test
- public void whenSerializingUsingJsonValue_thenCorrect() throws JsonProcessingException {
- final String enumAsString = new ObjectMapper().writeValueAsString(TypeEnumWithValue.TYPE1);
+ public void whenSerializingUsingJsonValue_thenCorrect() throws IOException {
+ final String enumAsString = new ObjectMapper().writeValueAsString(DistanceEnumWithValue.MILE);
- assertThat(enumAsString, is("\"Type A\""));
+ assertThat(enumAsString, is("1609.34"));
}
@Test
diff --git a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java b/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java
index 78c6316aa6..0f57d26d8b 100644
--- a/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java
+++ b/jackson/src/test/java/com/baeldung/jackson/test/JacksonSerializationEnumsUnitTest.java
@@ -6,14 +6,14 @@ import static org.junit.Assert.assertThat;
import java.io.IOException;
-import com.baeldung.jackson.dtos.withEnum.MyDtoWithEnum;
-import com.baeldung.jackson.dtos.withEnum.TypeEnum;
-import com.baeldung.jackson.dtos.withEnum.TypeEnumSimple;
-import com.baeldung.jackson.dtos.withEnum.TypeEnumWithValue;
-import com.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom;
-import com.baeldung.jackson.dtos.withEnum.TypeEnumWithCustomSerializer;
import org.junit.Test;
+import com.baeldung.jackson.dtos.withEnum.DistanceEnumSimple;
+import com.baeldung.jackson.dtos.withEnum.DistanceEnumWithJsonFormat;
+import com.baeldung.jackson.dtos.withEnum.DistanceEnumWithValue;
+import com.baeldung.jackson.dtos.withEnum.MyDtoWithEnumCustom;
+import com.baeldung.jackson.dtos.withEnum.MyDtoWithEnumJsonFormat;
+import com.baeldung.jackson.enums.Distance;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -24,10 +24,9 @@ public class JacksonSerializationEnumsUnitTest {
@Test
public final void whenSerializingASimpleEnum_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String enumAsString = mapper.writeValueAsString(TypeEnumSimple.TYPE1);
- System.out.println(enumAsString);
+ final String enumAsString = mapper.writeValueAsString(DistanceEnumSimple.MILE);
- assertThat(enumAsString, containsString("TYPE1"));
+ assertThat(enumAsString, containsString("MILE"));
}
// tests - enum with main value
@@ -35,10 +34,9 @@ public class JacksonSerializationEnumsUnitTest {
@Test
public final void whenSerializingAEnumWithValue_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String enumAsString = mapper.writeValueAsString(TypeEnumWithValue.TYPE1);
- System.out.println(enumAsString);
+ final String enumAsString = mapper.writeValueAsString(DistanceEnumWithValue.MILE);
- assertThat(enumAsString, is("\"Type A\""));
+ assertThat(enumAsString, is("1609.34"));
}
// tests - enum
@@ -46,28 +44,25 @@ public class JacksonSerializationEnumsUnitTest {
@Test
public final void whenSerializingAnEnum_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String enumAsString = mapper.writeValueAsString(TypeEnum.TYPE1);
+ final String enumAsString = mapper.writeValueAsString(DistanceEnumWithJsonFormat.MILE);
- System.out.println(enumAsString);
- assertThat(enumAsString, containsString("\"name\":\"Type A\""));
+ assertThat(enumAsString, containsString("\"meters\":1609.34"));
}
@Test
public final void whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnum("a", 1, true, TypeEnum.TYPE1));
+ final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnumJsonFormat("a", 1, true, DistanceEnumWithJsonFormat.MILE));
- System.out.println(enumAsString);
- assertThat(enumAsString, containsString("\"name\":\"Type A\""));
+ assertThat(enumAsString, containsString("\"meters\":1609.34"));
}
@Test
public final void whenSerializingArrayOfEnums_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String json = mapper.writeValueAsString(new TypeEnum[] { TypeEnum.TYPE1, TypeEnum.TYPE2 });
+ final String json = mapper.writeValueAsString(new DistanceEnumWithJsonFormat[] { DistanceEnumWithJsonFormat.MILE, DistanceEnumWithJsonFormat.KILOMETER });
- System.out.println(json);
- assertThat(json, containsString("\"name\":\"Type A\""));
+ assertThat(json, containsString("\"meters\":1609.34"));
}
// tests - enum with custom serializer
@@ -75,10 +70,9 @@ public class JacksonSerializationEnumsUnitTest {
@Test
public final void givenCustomSerializer_whenSerializingEntityWithEnum_thenCorrect() throws JsonParseException, IOException {
final ObjectMapper mapper = new ObjectMapper();
- final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, TypeEnumWithCustomSerializer.TYPE1));
+ final String enumAsString = mapper.writeValueAsString(new MyDtoWithEnumCustom("a", 1, true, Distance.MILE));
- System.out.println(enumAsString);
- assertThat(enumAsString, containsString("\"name\":\"Type A\""));
+ assertThat(enumAsString, containsString("\"meters\":1609.34"));
}
}
diff --git a/jsoup/README.md b/jsoup/README.md
new file mode 100644
index 0000000000..8728cc7c4e
--- /dev/null
+++ b/jsoup/README.md
@@ -0,0 +1,10 @@
+=========
+
+## jsoup Example Project
+
+### Relevant Articles:
+- [Parsing HTML in Java with Jsoup](http://www.baeldung.com/java-with-jsoup)
+
+### Build the Project
+
+mvn clean install
diff --git a/jsoup/pom.xml b/jsoup/pom.xml
index 343e139b46..25551cb3d6 100644
--- a/jsoup/pom.xml
+++ b/jsoup/pom.xml
@@ -25,6 +25,6 @@
1.8
1.8
- 1.10.1
+ 1.10.2
diff --git a/jsoup/src/main/java/com/baeldung/jsoup/JsoupParser.java b/jsoup/src/main/java/com/baeldung/jsoup/JsoupParser.java
deleted file mode 100644
index cb86b16888..0000000000
--- a/jsoup/src/main/java/com/baeldung/jsoup/JsoupParser.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.baeldung.jsoup;
-
-import java.io.IOException;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-import org.jsoup.select.Elements;
-
-public class JsoupParser {
-
- Document doc;
-
- public void loadDocument(String blogUrl) throws IOException {
- doc = Jsoup.connect(blogUrl).get();
- }
-
- void loadDocumentCustomized(String blogUrl) throws IOException {
- doc = Jsoup.connect(blogUrl)
- .userAgent("Mozilla")
- .timeout(5000)
- .cookie("cookiename", "val234")
- .cookie("anothercookie", "ilovejsoup")
- .referrer("http://google.com")
- .header("headersecurity", "xyz123")
- .get();
- }
-
- void examplesSelectors() {
- Elements links = doc.select("a");
- Elements logo = doc.select(".spring-logo--container");
- Elements pagination = doc.select("#pagination_control");
- Elements divsDescendant = doc.select("header div");
- Elements divsDirect = doc.select("header > div");
-
- Element pag = doc.getElementById("pagination_control");
- Elements desktopOnly = doc.getElementsByClass("desktopOnly");
-
- Elements sections = doc.select("section");
- Element firstSection = sections.first();
- Elements sectionParagraphs = firstSection.select(".paragraph");
- }
-
- void examplesTraversing() {
- Elements sections = doc.select("section");
-
- Element firstSection = sections.first();
- Element lastSection = sections.last();
- Element secondSection = sections.get(2);
- Elements allParents = firstSection.parents();
- Element parent = firstSection.parent();
- Elements children = firstSection.children();
- Elements siblings = firstSection.siblingElements();
-
- sections.stream().forEach(el -> System.out.println("section: " + el));
- }
-
- void examplesExtracting() {
- Element firstArticle = doc.select("article").first();
- Element timeElement = firstArticle.select("time").first();
- String dateTimeOfFirstArticle = timeElement.attr("datetime");
- Element sectionDiv = firstArticle.select("section div").first();
- String sectionDivText = sectionDiv.text();
- String articleHtml = firstArticle.html();
- String outerHtml = firstArticle.outerHtml();
- }
-
- void examplesModifying() {
- Element firstArticle = doc.select("article").first();
- Element timeElement = firstArticle.select("time").first();
- Element sectionDiv = firstArticle.select("section div").first();
-
- String dateTimeOfFirstArticle = timeElement.attr("datetime");
- timeElement.attr("datetime", "2016-12-16 15:19:54.3");
- sectionDiv.text("foo bar");
- firstArticle.select("h2").html("
");
-
- Element link = new Element(Tag.valueOf("a"), "")
- .text("Checkout this amazing website!")
- .attr("href", "http://baeldung.com")
- .attr("target", "_blank");
- firstArticle.appendChild(link);
-
- doc.select("li.navbar-link").remove();
- firstArticle.select("img").remove();
- }
-
- String getTidyHtml() {
- return doc.html();
- }
-}
diff --git a/jsoup/src/test/java/com/baeldung/jsoup/JsoupParserTest.java b/jsoup/src/test/java/com/baeldung/jsoup/JsoupParserTest.java
index 85fd3c3459..ba6d7358bc 100644
--- a/jsoup/src/test/java/com/baeldung/jsoup/JsoupParserTest.java
+++ b/jsoup/src/test/java/com/baeldung/jsoup/JsoupParserTest.java
@@ -1,36 +1,111 @@
package com.baeldung.jsoup;
-import java.io.IOException;
import org.jsoup.HttpStatusException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+import org.jsoup.select.Elements;
import org.junit.Before;
import org.junit.Test;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class JsoupParserTest {
- JsoupParser jsoupParser;
+ Document doc;
@Before
- public void setUp() {
- jsoupParser = new JsoupParser();
+ public void setUp() throws IOException {
+ doc = Jsoup.connect("https://spring.io/blog").get();
}
@Test
- public void test404() throws IOException {
+ public void loadDocument404() throws IOException {
try {
- jsoupParser.loadDocument("https://spring.io/will-not-be-found");
+ doc = Jsoup.connect("https://spring.io/will-not-be-found").get();
} catch (HttpStatusException ex) {
assertEquals(404, ex.getStatusCode());
}
}
@Test
- public void testChange() throws IOException {
- jsoupParser.loadDocument("http://spring.io/blog");
+ public void loadDocumentCustomized() throws IOException {
+ doc = Jsoup.connect("https://spring.io/blog")
+ .userAgent("Mozilla")
+ .timeout(5000)
+ .cookie("cookiename", "val234")
+ .cookie("anothercookie", "ilovejsoup")
+ .referrer("http://google.com")
+ .header("headersecurity", "xyz123")
+ .get();
+ }
- jsoupParser.examplesModifying();
+ @Test
+ public void examplesSelectors() {
+ Elements links = doc.select("a");
+ Elements logo = doc.select(".spring-logo--container");
+ Elements pagination = doc.select("#pagination_control");
+ Elements divsDescendant = doc.select("header div");
+ Elements divsDirect = doc.select("header > div");
- assertTrue(jsoupParser.getTidyHtml().contains("http://baeldung.com"));
+ Element pag = doc.getElementById("pagination_control");
+ Elements desktopOnly = doc.getElementsByClass("desktopOnly");
+
+ Elements sections = doc.select("section");
+ Element firstSection = sections.first();
+ Elements sectionParagraphs = firstSection.select(".paragraph");
+ }
+
+ @Test
+ public void examplesTraversing() {
+ Elements sections = doc.select("section");
+
+ Element firstSection = sections.first();
+ Element lastSection = sections.last();
+ Element secondSection = sections.get(2);
+ Elements allParents = firstSection.parents();
+ Element parent = firstSection.parent();
+ Elements children = firstSection.children();
+ Elements siblings = firstSection.siblingElements();
+
+ sections.forEach(el -> System.out.println("section: " + el));
+ }
+
+ @Test
+ public void examplesExtracting() {
+ Element firstArticle = doc.select("article").first();
+ Element timeElement = firstArticle.select("time").first();
+ String dateTimeOfFirstArticle = timeElement.attr("datetime");
+ Element sectionDiv = firstArticle.select("section div").first();
+ String sectionDivText = sectionDiv.text();
+ String articleHtml = firstArticle.html();
+ String outerHtml = firstArticle.outerHtml();
+ }
+
+ @Test
+ public void examplesModifying() {
+ Element firstArticle = doc.select("article").first();
+ Element timeElement = firstArticle.select("time").first();
+ Element sectionDiv = firstArticle.select("section div").first();
+
+ String dateTimeOfFirstArticle = timeElement.attr("datetime");
+ timeElement.attr("datetime", "2016-12-16 15:19:54.3");
+ sectionDiv.text("foo bar");
+ firstArticle.select("h2").html("
");
+
+ Element link = new Element(Tag.valueOf("a"), "")
+ .text("Checkout this amazing website!")
+ .attr("href", "http://baeldung.com")
+ .attr("target", "_blank");
+ firstArticle.appendChild(link);
+
+ doc.select("li.navbar-link").remove();
+ firstArticle.select("img").remove();
+
+ assertTrue(doc.html().contains("http://baeldung.com"));
}
}
diff --git a/pom.xml b/pom.xml
index 4ae672d6c8..6a0514da4d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,7 @@
spring-hibernate3
spring-hibernate4
spring-integration
+ spring-jersey
spring-jms
spring-jooq
spring-jpa
diff --git a/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java
new file mode 100644
index 0000000000..342a5fe3e6
--- /dev/null
+++ b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java
@@ -0,0 +1,41 @@
+package org.baeldung.taskscheduler;
+
+import java.util.concurrent.TimeUnit;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import org.springframework.scheduling.support.CronTrigger;
+import org.springframework.scheduling.support.PeriodicTrigger;
+
+@Configuration
+@ComponentScan(basePackages = "org.baeldung.taskscheduler", basePackageClasses = { ThreadPoolTaskSchedulerExamples.class })
+public class ThreadPoolTaskSchedulerConfig {
+
+ @Bean
+ public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
+ ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
+ threadPoolTaskScheduler.setPoolSize(5);
+ threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler");
+ return threadPoolTaskScheduler;
+ }
+
+ @Bean
+ public CronTrigger cronTrigger() {
+ return new CronTrigger("10 * * * * ?");
+ }
+
+ @Bean
+ public PeriodicTrigger periodicTrigger() {
+ return new PeriodicTrigger(2000, TimeUnit.MICROSECONDS);
+ }
+
+ @Bean
+ public PeriodicTrigger periodicFixedDelayTrigger() {
+ PeriodicTrigger periodicTrigger = new PeriodicTrigger(2000, TimeUnit.MICROSECONDS);
+ periodicTrigger.setFixedRate(true);
+ periodicTrigger.setInitialDelay(1000);
+ return periodicTrigger;
+ }
+}
\ No newline at end of file
diff --git a/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java
new file mode 100644
index 0000000000..7505b85516
--- /dev/null
+++ b/spring-all/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java
@@ -0,0 +1,47 @@
+package org.baeldung.taskscheduler;
+
+import java.util.Date;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import org.springframework.scheduling.support.CronTrigger;
+import org.springframework.scheduling.support.PeriodicTrigger;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ThreadPoolTaskSchedulerExamples {
+ @Autowired
+ private ThreadPoolTaskScheduler taskScheduler;
+
+ @Autowired
+ private CronTrigger cronTrigger;
+
+ @Autowired
+ private PeriodicTrigger periodicTrigger;
+
+ @PostConstruct
+ public void scheduleRunnableWithCronTrigger(){
+ taskScheduler.schedule(new RunnableTask("Current Date"), new Date());
+ taskScheduler.scheduleWithFixedDelay(new RunnableTask("Fixed 1 second Delay"), 1000);
+ taskScheduler.scheduleWithFixedDelay(new RunnableTask("Current Date Fixed 1 second Delay"),new Date() , 1000);
+ taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"),new Date(), 2000);
+ taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), 2000);
+ taskScheduler.schedule(new RunnableTask("Cron Trigger"), cronTrigger);
+ taskScheduler.schedule(new RunnableTask("Periodic Trigger"), periodicTrigger);
+ }
+
+ class RunnableTask implements Runnable{
+
+ private String message;
+
+ public RunnableTask(String message){
+ this.message = message;
+ }
+ @Override
+ public void run() {
+ System.out.println("Runnable Task with "+message+" on thread "+Thread.currentThread().getName());
+ }
+ }
+}
\ No newline at end of file
diff --git a/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerTest.java b/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerTest.java
new file mode 100644
index 0000000000..cc247cb384
--- /dev/null
+++ b/spring-all/src/test/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerTest.java
@@ -0,0 +1,16 @@
+package org.baeldung.taskscheduler;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { ThreadPoolTaskSchedulerConfig.class }, loader = AnnotationConfigContextLoader.class)
+public class ThreadPoolTaskSchedulerTest {
+ @Test
+ public void testThreadPoolTaskSchedulerAnnotation() throws InterruptedException {
+ Thread.sleep(2550);
+ }
+}
\ No newline at end of file
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index 7d7c9cd590..726fcf5f25 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -1,4 +1,5 @@
-
+
4.0.0
com.baeldung
@@ -160,10 +161,10 @@
-
+
UTF-8
-
+
4.3.4.RELEASE
1.8.6.RELEASE
@@ -177,7 +178,7 @@
1.7.21
1.1.7
3.6.0
- 2.19.1
+ 2.19.1
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java
similarity index 99%
rename from spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java
index bb4b268ca7..3853a406fb 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java
@@ -33,7 +33,7 @@ import com.mongodb.gridfs.GridFSDBFile;
@ContextConfiguration("file:src/main/resources/mongoConfig.xml")
@RunWith(SpringJUnit4ClassRunner.class)
-public class GridFSIntegrationTest {
+public class GridFSLiveTest {
private final Logger logger = LoggerFactory.getLogger(getClass());
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java
similarity index 99%
rename from spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java
index cf46c6ed6e..df3ebcb2d2 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java
@@ -25,7 +25,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class DocumentQueryIntegrationTest {
+public class DocumentQueryLiveTest {
@Autowired
private MongoTemplate mongoTemplate;
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java
similarity index 99%
rename from spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java
index 1701b9ac5a..76162c6096 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java
@@ -28,7 +28,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class MongoTemplateQueryIntegrationTest {
+public class MongoTemplateQueryLiveTest {
@Autowired
private MongoTemplate mongoTemplate;
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryLiveTest.java
similarity index 94%
rename from spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryLiveTest.java
index 8572cc858e..afd7259c6c 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/repository/BaseQueryLiveTest.java
@@ -7,7 +7,7 @@ import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
-public class BaseQueryIntegrationTest {
+public class BaseQueryLiveTest {
@Autowired
protected UserRepository userRepository;
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryLiveTest.java
similarity index 97%
rename from spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryLiveTest.java
index ca8d46a97a..03fd38c796 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/repository/DSLQueryLiveTest.java
@@ -17,7 +17,7 @@ import com.mysema.query.types.Predicate;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
+public class DSLQueryLiveTest extends BaseQueryLiveTest {
@Test
public void givenUsersExist_whenFindingUsersByName_thenUserAreFound() {
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryLiveTest.java
similarity index 97%
rename from spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryLiveTest.java
index ed88429792..9464a4eb52 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/repository/JSONQueryLiveTest.java
@@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class JSONQueryIntegrationTest extends BaseQueryIntegrationTest {
+public class JSONQueryLiveTest extends BaseQueryLiveTest {
@Test
public void givenUsersExist_whenFindingUsersByName_thenUsersAreFound() {
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsLiveTest.java
similarity index 97%
rename from spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsLiveTest.java
index f7c35c8de2..5705c119b8 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/repository/QueryMethodsLiveTest.java
@@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
+public class QueryMethodsLiveTest extends BaseQueryLiveTest {
@Test
public void givenUsersExist_whenFindingUsersByName_thenUsersAreFound() {
diff --git a/spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java b/spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryLiveTest.java
similarity index 99%
rename from spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java
rename to spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryLiveTest.java
index 53cadc09bc..1543b847ba 100644
--- a/spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java
+++ b/spring-data-mongodb/src/test/java/org/baeldung/repository/UserRepositoryLiveTest.java
@@ -24,7 +24,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
-public class UserRepositoryIntegrationTest {
+public class UserRepositoryLiveTest {
@Autowired
private UserRepository userRepository;
diff --git a/spring-jersey/.gitignore b/spring-jersey/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/spring-jersey/.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/spring-jersey/README.md b/spring-jersey/README.md
new file mode 100644
index 0000000000..2767ceb9a7
--- /dev/null
+++ b/spring-jersey/README.md
@@ -0,0 +1,3 @@
+=========
+
+## REST API with Jersey & Spring Example Project
diff --git a/spring-jersey/pom.xml b/spring-jersey/pom.xml
new file mode 100644
index 0000000000..00d67febec
--- /dev/null
+++ b/spring-jersey/pom.xml
@@ -0,0 +1,210 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ jersey-api
+ 0.1-SNAPSHOT
+ war
+
+
+ 2.25
+ 1.7.22
+ 1.1.8
+ 4.12
+ 3.0.0
+ 2.19.1
+ 1.6.1
+ 4.12
+ 4.4.5
+ 4.5.2
+ 3.1.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ **/*IntegrationTest.java
+ **/*LiveTest.java
+
+
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+ true
+
+ jetty8x
+ embedded
+
+
+
+ 8082
+
+
+
+
+
+
+
+
+
+
+
+
+ org.glassfish.jersey.core
+ jersey-server
+ ${jersey.version}
+
+
+ org.glassfish.jersey.containers
+ jersey-container-servlet
+ ${jersey.version}
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ ${jersey.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ ${servlet-api-version}
+ provided
+
+
+
+
+ org.glassfish.jersey.ext
+ jersey-spring3
+ ${jersey.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${jcl.slf4j.version}
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+ test
+
+
+
+ org.apache.httpcomponents
+ httpcore
+ ${httpcore.version}
+ test
+
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+
+ live
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*IntegrationTest.java
+
+
+ **/*LiveTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+ false
+
+
+
+ start-server
+ pre-integration-test
+
+ start
+
+
+
+ stop-server
+ post-integration-test
+
+ stop
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-jersey/src/main/java/com/baeldung/server/config/ApplicationInitializer.java b/spring-jersey/src/main/java/com/baeldung/server/config/ApplicationInitializer.java
new file mode 100644
index 0000000000..d91d4d5f38
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/config/ApplicationInitializer.java
@@ -0,0 +1,22 @@
+package com.baeldung.server.config;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class ApplicationInitializer implements WebApplicationInitializer {
+
+ @Override
+ public void onStartup(ServletContext servletContext) throws ServletException {
+ AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
+ servletContext.addListener(new ContextLoaderListener(context));
+ servletContext.setInitParameter("contextConfigLocation", "com.baeldung.server");
+ }
+
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/config/RestConfig.java b/spring-jersey/src/main/java/com/baeldung/server/config/RestConfig.java
new file mode 100644
index 0000000000..34d8948f59
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/config/RestConfig.java
@@ -0,0 +1,19 @@
+package com.baeldung.server.config;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+import com.baeldung.server.exception.AlreadyExistsExceptionHandler;
+import com.baeldung.server.exception.NotFoundExceptionHandler;
+import com.baeldung.server.rest.EmployeeResource;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/resources")
+public class RestConfig extends Application {
+ public Set> getClasses() {
+ return new HashSet>(Arrays.asList(EmployeeResource.class, NotFoundExceptionHandler.class, AlreadyExistsExceptionHandler.class));
+ }
+}
\ No newline at end of file
diff --git a/spring-jersey/src/main/java/com/baeldung/server/exception/AlreadyExistsExceptionHandler.java b/spring-jersey/src/main/java/com/baeldung/server/exception/AlreadyExistsExceptionHandler.java
new file mode 100644
index 0000000000..4603372807
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/exception/AlreadyExistsExceptionHandler.java
@@ -0,0 +1,12 @@
+package com.baeldung.server.exception;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class AlreadyExistsExceptionHandler implements ExceptionMapper {
+ public Response toResponse(EmployeeAlreadyExists ex) {
+ return Response.status(Response.Status.CONFLICT.getStatusCode()).build();
+ }
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeAlreadyExists.java b/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeAlreadyExists.java
new file mode 100644
index 0000000000..827e4bf1e7
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeAlreadyExists.java
@@ -0,0 +1,5 @@
+package com.baeldung.server.exception;
+
+public class EmployeeAlreadyExists extends RuntimeException {
+
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeNotFound.java b/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeNotFound.java
new file mode 100644
index 0000000000..f205b5dfae
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/exception/EmployeeNotFound.java
@@ -0,0 +1,5 @@
+package com.baeldung.server.exception;
+
+public class EmployeeNotFound extends RuntimeException {
+
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/exception/NotFoundExceptionHandler.java b/spring-jersey/src/main/java/com/baeldung/server/exception/NotFoundExceptionHandler.java
new file mode 100644
index 0000000000..5de9b53c30
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/exception/NotFoundExceptionHandler.java
@@ -0,0 +1,12 @@
+package com.baeldung.server.exception;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class NotFoundExceptionHandler implements ExceptionMapper {
+ public Response toResponse(EmployeeNotFound ex) {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/model/Employee.java b/spring-jersey/src/main/java/com/baeldung/server/model/Employee.java
new file mode 100644
index 0000000000..1801134f68
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/model/Employee.java
@@ -0,0 +1,34 @@
+package com.baeldung.server.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Employee {
+ private int id;
+ private String firstName;
+
+ public Employee() {
+
+ }
+
+ public Employee(int id, String firstName) {
+ this.id = id;
+ this.firstName = firstName;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepository.java b/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepository.java
new file mode 100644
index 0000000000..15132cd618
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepository.java
@@ -0,0 +1,18 @@
+package com.baeldung.server.repository;
+
+import java.util.List;
+
+import com.baeldung.server.model.Employee;
+
+public interface EmployeeRepository {
+
+ public List getAllEmployees();
+
+ public Employee getEmployee(int id);
+
+ public void updateEmployee(Employee employee, int id);
+
+ public void deleteEmployee(int id);
+
+ public void addEmployee(Employee employee);
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepositoryImpl.java b/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepositoryImpl.java
new file mode 100644
index 0000000000..8e61e1395b
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/repository/EmployeeRepositoryImpl.java
@@ -0,0 +1,65 @@
+package com.baeldung.server.repository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.stereotype.Component;
+
+import com.baeldung.server.exception.EmployeeAlreadyExists;
+import com.baeldung.server.exception.EmployeeNotFound;
+import com.baeldung.server.model.Employee;
+
+@Component
+public class EmployeeRepositoryImpl implements EmployeeRepository {
+ private List employeeList;
+
+ public EmployeeRepositoryImpl() {
+ employeeList = new ArrayList();
+ employeeList.add(new Employee(1, "Jane"));
+ employeeList.add(new Employee(2, "Jack"));
+ employeeList.add(new Employee(3, "George"));
+ }
+
+ public List getAllEmployees() {
+ return employeeList;
+ }
+
+ public Employee getEmployee(int id) {
+ for (Employee emp : employeeList) {
+ if (emp.getId() == id) {
+ return emp;
+ }
+ }
+ throw new EmployeeNotFound();
+ }
+
+ public void updateEmployee(Employee employee, int id) {
+ for (Employee emp : employeeList) {
+ if (emp.getId() == id) {
+ emp.setId(employee.getId());
+ emp.setFirstName(employee.getFirstName());
+ return;
+ }
+ }
+ throw new EmployeeNotFound();
+ }
+
+ public void deleteEmployee(int id) {
+ for (Employee emp : employeeList) {
+ if (emp.getId() == id) {
+ employeeList.remove(emp);
+ return;
+ }
+ }
+ throw new EmployeeNotFound();
+ }
+
+ public void addEmployee(Employee employee) {
+ for (Employee emp : employeeList) {
+ if (emp.getId() == employee.getId()) {
+ throw new EmployeeAlreadyExists();
+ }
+ }
+ employeeList.add(employee);
+ }
+}
diff --git a/spring-jersey/src/main/java/com/baeldung/server/rest/EmployeeResource.java b/spring-jersey/src/main/java/com/baeldung/server/rest/EmployeeResource.java
new file mode 100644
index 0000000000..2301f3eaf3
--- /dev/null
+++ b/spring-jersey/src/main/java/com/baeldung/server/rest/EmployeeResource.java
@@ -0,0 +1,64 @@
+package com.baeldung.server.rest;
+
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.baeldung.server.model.Employee;
+import com.baeldung.server.repository.EmployeeRepository;
+
+@Path("/employees")
+public class EmployeeResource {
+
+ @Autowired
+ private EmployeeRepository employeeRepository;
+
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public List getAllEmployees() {
+ return employeeRepository.getAllEmployees();
+ }
+
+ @GET
+ @Path("/{id}")
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public Employee getEmployee(@PathParam("id") int id) {
+ return employeeRepository.getEmployee(id);
+ }
+
+ @PUT
+ @Path("/{id}")
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public Response updateEmployee(Employee employee, @PathParam("id") int id) {
+ employeeRepository.updateEmployee(employee, id);
+ return Response.status(Response.Status.OK.getStatusCode()).build();
+ }
+
+ @DELETE
+ @Path("/{id}")
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public Response deleteEmployee(@PathParam("id") int id) {
+ employeeRepository.deleteEmployee(id);
+ return Response.status(Response.Status.OK.getStatusCode()).build();
+ }
+
+ @POST
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ public Response addEmployee(Employee employee, @Context UriInfo uriInfo) {
+ employeeRepository.addEmployee(new Employee(employee.getId(), employee.getFirstName()));
+ return Response.status(Response.Status.CREATED.getStatusCode()).header("Location", String.format("%s/%s", uriInfo.getAbsolutePath().toString(), employee.getId())).build();
+ }
+}
diff --git a/spring-jersey/src/main/resources/logback.xml b/spring-jersey/src/main/resources/logback.xml
new file mode 100644
index 0000000000..788096686a
--- /dev/null
+++ b/spring-jersey/src/main/resources/logback.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ web - %date [%thread] %-5level %logger{36} -
+ %message%n
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-jersey/src/test/java/com/baeldung/server/JerseyApiLiveTest.java b/spring-jersey/src/test/java/com/baeldung/server/JerseyApiLiveTest.java
new file mode 100644
index 0000000000..80c4e94b50
--- /dev/null
+++ b/spring-jersey/src/test/java/com/baeldung/server/JerseyApiLiveTest.java
@@ -0,0 +1,91 @@
+package com.baeldung.server;
+
+import java.io.IOException;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.junit.Test;
+
+import com.baeldung.server.model.Employee;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class JerseyApiLiveTest {
+
+ private static final String SERVICE_URL = "http://localhost:8082/jersey-api/resources/employees";
+
+ @Test
+ public void givenGetAllEmployees_whenCorrectRequest_thenResponseCodeSuccess() throws ClientProtocolException, IOException {
+ final HttpUriRequest request = new HttpGet(SERVICE_URL);
+
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+
+ assert(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
+ }
+
+ @Test
+ public void givenGetEmployee_whenEmployeeExists_thenResponseCodeSuccess() throws ClientProtocolException, IOException {
+ final HttpUriRequest request = new HttpGet(SERVICE_URL + "/1");
+
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+
+ assert(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
+ }
+
+ @Test
+ public void givenGetEmployee_whenEmployeeDoesNotExist_thenResponseCodeNotFound() throws ClientProtocolException, IOException {
+ final HttpUriRequest request = new HttpGet(SERVICE_URL + "/1000");
+
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+
+ assert(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND);
+ }
+
+ @Test
+ public void givenGetEmployee_whenJsonRequested_thenCorrectDataRetrieved() throws ClientProtocolException, IOException {
+ final HttpUriRequest request = new HttpGet(SERVICE_URL + "/1");
+
+ request.setHeader("Accept", "application/json");
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+ ObjectMapper mapper = new ObjectMapper();
+ Employee emp = mapper.readValue(httpResponse.getEntity().getContent(), Employee.class);
+
+ assert(emp.getFirstName().equals("Jane"));
+ }
+
+ @Test
+ public void givenAddEmployee_whenJsonRequestSent_thenResponseCodeCreated() throws ClientProtocolException, IOException {
+ final HttpPost request = new HttpPost(SERVICE_URL);
+
+ Employee emp = new Employee(5, "Johny");
+ ObjectMapper mapper = new ObjectMapper();
+ String empJson = mapper.writeValueAsString(emp);
+ StringEntity input = new StringEntity(empJson);
+ input.setContentType("application/json");
+ request.setEntity(input);
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+
+ assert(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
+ }
+
+ @Test
+ public void givenAddEmployee_whenRequestForExistingObjectSent_thenResponseCodeConflict() throws ClientProtocolException, IOException {
+ final HttpPost request = new HttpPost(SERVICE_URL);
+
+ Employee emp = new Employee(1, "Johny");
+ ObjectMapper mapper = new ObjectMapper();
+ String empJson = mapper.writeValueAsString(emp);
+ StringEntity input = new StringEntity(empJson);
+ input.setContentType("application/json");
+ request.setEntity(input);
+ final HttpResponse httpResponse = HttpClientBuilder.create().build().execute(request);
+
+ assert(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CONFLICT);
+ }
+
+}
\ No newline at end of file
diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml
index 38443f2022..7d0cc24d41 100644
--- a/spring-mvc-java/pom.xml
+++ b/spring-mvc-java/pom.xml
@@ -323,9 +323,9 @@
-
+
-
+
4.3.4.RELEASE
diff --git a/spring-remoting/pom.xml b/spring-remoting/pom.xml
new file mode 100644
index 0000000000..cfb4af9d85
--- /dev/null
+++ b/spring-remoting/pom.xml
@@ -0,0 +1,109 @@
+
+
+ 4.0.0
+ com.baeldung
+ spring-remoting
+ 1.0-SNAPSHOT
+ pom
+
+
+ 3.6.0
+ 3.0.0
+
+ 3.1.0
+ 1.1.7
+ 4.2.4.RELEASE
+
+
+
+
+
+
+
+ org.springframework
+ spring-core
+ ${spring.version}
+
+
+ org.springframework
+ spring-context
+ ${spring.version}
+
+
+ org.springframework
+ spring-web
+ ${spring.version}
+
+
+ org.springframework
+ spring-webmvc
+ ${spring.version}
+
+
+
+
+ ch.qos.logback
+ logback-core
+ ${logback.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ ${servlet.version}
+ provided
+
+
+
+
+ ${project.groupId}
+ api
+ ${project.version}
+
+
+
+
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ true
+ true
+
+ 1.8
+ UTF-8
+ true
+ true
+
+
+
+
+ maven-war-plugin
+ 3.0.0
+
+ false
+
+
+
+
+
+
+
+ remoting-http
+
+
+
\ No newline at end of file
diff --git a/spring-remoting/remoting-http/api/pom.xml b/spring-remoting/remoting-http/api/pom.xml
new file mode 100644
index 0000000000..633217f7de
--- /dev/null
+++ b/spring-remoting/remoting-http/api/pom.xml
@@ -0,0 +1,14 @@
+
+
+
+ spring-remoting-http
+ com.baeldung
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ api
+ spring-remoting-http-api
+ API definition shared between client and server.
+
\ No newline at end of file
diff --git a/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Address.java b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Address.java
new file mode 100644
index 0000000000..f2382fabd9
--- /dev/null
+++ b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Address.java
@@ -0,0 +1,26 @@
+package com.baeldung.api;
+
+import java.io.Serializable;
+
+public class Address implements Serializable{
+
+ private String address;
+ private String countryCode;
+
+ public Address(String address, String countryCode) {
+ this.address = address;
+ this.countryCode = countryCode;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public String getCountryCode() {
+ return countryCode;
+ }
+
+ @Override public String toString() {
+ return address + " (" + countryCode + ")";
+ }
+}
diff --git a/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Booking.java b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Booking.java
new file mode 100644
index 0000000000..0f52a7bfbd
--- /dev/null
+++ b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/Booking.java
@@ -0,0 +1,53 @@
+package com.baeldung.api;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class Booking implements Serializable {
+
+ private int costInCent;
+ private int etaInSeconds;
+ private String bookingCode;
+ private Date pickUptime;
+ private Address pickUpAddress;
+ private Address dropOffAddress;
+
+ public Booking(Address pickUpAddress, Date pickUptime, Address dropOffAddress, int costInCent, int etaInSeconds, String bookingCode) {
+ this.costInCent = costInCent;
+ this.etaInSeconds = etaInSeconds;
+ this.bookingCode = bookingCode;
+ this.pickUptime = pickUptime;
+ this.pickUpAddress = pickUpAddress;
+ this.dropOffAddress = dropOffAddress;
+ }
+
+ public int getCostInCent() {
+ return costInCent;
+ }
+
+ public int getEtaInSeconds() {
+ return etaInSeconds;
+ }
+
+ public String getBookingCode() {
+ return bookingCode;
+ }
+
+ public Date getPickUptime() {
+ return pickUptime;
+ }
+
+ public Address getDropOffAddress() {
+ return dropOffAddress;
+ }
+
+ @Override public String toString() {
+ return String.format("Booking: pick up @ %tr in %s, drop down in %s after %d minutes, %.2f $.", pickUptime, pickUpAddress, dropOffAddress, etaInSeconds/60, costInCent/100.0);
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ System.out.println(
+ new Booking(new Address("a", "b"), new Date(), new Address("c", "d"), 123_00, 600, "abc")
+ );
+ }
+}
diff --git a/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/BookingException.java b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/BookingException.java
new file mode 100644
index 0000000000..4099db2908
--- /dev/null
+++ b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/BookingException.java
@@ -0,0 +1,7 @@
+package com.baeldung.api;
+
+public class BookingException extends Exception {
+ public BookingException(String message) {
+ super(message);
+ }
+}
diff --git a/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/CabBookingService.java b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/CabBookingService.java
new file mode 100644
index 0000000000..25b27264e8
--- /dev/null
+++ b/spring-remoting/remoting-http/api/src/main/java/com/baeldung/api/CabBookingService.java
@@ -0,0 +1,5 @@
+package com.baeldung.api;
+
+public interface CabBookingService {
+ Booking bookPickUp(Address pickUpLocation, Address dropOffLocation, int pax) throws BookingException;
+}
diff --git a/spring-remoting/remoting-http/client/pom.xml b/spring-remoting/remoting-http/client/pom.xml
new file mode 100644
index 0000000000..77891c106a
--- /dev/null
+++ b/spring-remoting/remoting-http/client/pom.xml
@@ -0,0 +1,30 @@
+
+
+ 4.0.0
+
+
+ com.baeldung
+ spring-remoting-http
+ 1.0-SNAPSHOT
+
+
+ spring-remoting-http-client
+ Shows how to invoke a remote service using Spring Remoting.
+
+
+
+
+ org.springframework
+ spring-web
+
+
+
+
+ ${project.groupId}
+ api
+
+
+
+
\ No newline at end of file
diff --git a/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/CabBookingClient.java b/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/CabBookingClient.java
new file mode 100644
index 0000000000..7cc8e5183c
--- /dev/null
+++ b/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/CabBookingClient.java
@@ -0,0 +1,25 @@
+package com.baeldug.client;
+
+import com.baeldung.api.*;
+
+public class CabBookingClient {
+
+ private CabBookingService cabService;
+
+ public CabBookingClient(CabBookingService cabService) {
+ this.cabService = cabService;
+ }
+
+ public void run() {
+
+ Address pickUp = new Address("13 Seagate Blvd, Key Largo, FL 33037", "US");
+ Address dropDown = new Address("91831 Overseas Hwy, Tavernier, FL 33070", "US");
+ try {
+ System.out.println( cabService.bookPickUp(pickUp, dropDown, 3) );
+ } catch (BookingException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/Main.java b/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/Main.java
new file mode 100644
index 0000000000..0ddb37c508
--- /dev/null
+++ b/spring-remoting/remoting-http/client/src/main/java/com/baeldug/client/Main.java
@@ -0,0 +1,34 @@
+package com.baeldug.client;
+
+import com.baeldung.api.CabBookingService;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
+
+@Configuration
+public class Main {
+
+ @Bean
+ public HttpInvokerProxyFactoryBean invoker() {
+ HttpInvokerProxyFactoryBean invoker = new HttpInvokerProxyFactoryBean();
+ invoker.setServiceUrl("http://localhost:9090/spring-remoting-http-server/booking");
+ invoker.setServiceInterface(CabBookingService.class);
+ return invoker;
+ }
+
+ @Bean
+ public CabBookingClient client(CabBookingService service){
+ return new CabBookingClient(service);
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ AnnotationConfigApplicationContext rootContext =
+ new AnnotationConfigApplicationContext();
+ rootContext.scan(Main.class.getPackage().getName());
+ rootContext.refresh();
+ CabBookingClient bean = rootContext.getBean(CabBookingClient.class);
+ bean.run();
+ }
+
+}
diff --git a/spring-remoting/remoting-http/pom.xml b/spring-remoting/remoting-http/pom.xml
new file mode 100644
index 0000000000..0d08779bd7
--- /dev/null
+++ b/spring-remoting/remoting-http/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ spring-remoting
+ 1.0-SNAPSHOT
+
+ spring-remoting-http
+ Parent for all modules related to HTTP Spring Remoting
+ pom
+
+
+ server
+ client
+ api
+
+
\ No newline at end of file
diff --git a/spring-remoting/remoting-http/server/pom.xml b/spring-remoting/remoting-http/server/pom.xml
new file mode 100644
index 0000000000..32a99716a5
--- /dev/null
+++ b/spring-remoting/remoting-http/server/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ spring-remoting-http
+ 1.0-SNAPSHOT
+
+ war
+
+ spring-remoting-http-server
+ Shows how to expose a service using Spring Remoting
+
+
+ 2.2
+
+
+
+
+
+
+
+
+ org.springframework
+ spring-webmvc
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+
+
+ ${project.groupId}
+ api
+
+
+
+
+
+
+
+ maven-compiler-plugin
+
+
+
+ maven-war-plugin
+
+
+
+ org.apache.tomcat.maven
+ tomcat7-maven-plugin
+ ${tomcat7-maven-plugin.version}
+
+ 9090
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-remoting/remoting-http/server/readme.md b/spring-remoting/remoting-http/server/readme.md
new file mode 100644
index 0000000000..4a2abb5d03
--- /dev/null
+++ b/spring-remoting/remoting-http/server/readme.md
@@ -0,0 +1,12 @@
+Build and launch with the following command.
+
+ mvn clean package tomcat7:run-war
+
+Exposed service is available at following URL.
+
+ http://localhost:9090/spring-remoting-http-server/account
+
+## References
+
+
+
diff --git a/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingConfig.java b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingConfig.java
new file mode 100644
index 0000000000..146d2ecadb
--- /dev/null
+++ b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingConfig.java
@@ -0,0 +1,10 @@
+package com.baeldung.server;
+
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class CabBookingConfig {
+
+
+
+}
diff --git a/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingInitializer.java b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingInitializer.java
new file mode 100644
index 0000000000..53b3fd5faf
--- /dev/null
+++ b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingInitializer.java
@@ -0,0 +1,34 @@
+package com.baeldung.server;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRegistration;
+
+public class CabBookingInitializer implements WebApplicationInitializer {
+
+ @Override
+ public void onStartup(ServletContext container) {
+ AnnotationConfigWebApplicationContext rootContext =
+ new AnnotationConfigWebApplicationContext();
+ rootContext.register(CabBookingConfig.class);
+
+ // Manage the lifecycle of the root application context
+ container.addListener(new ContextLoaderListener(rootContext));
+
+ // Create the dispatcher servlet's Spring application context
+ AnnotationConfigWebApplicationContext dispatcherContext =
+ new AnnotationConfigWebApplicationContext();
+ dispatcherContext.register(DispatcherConfig.class);
+
+ // Register and map the dispatcher servlet
+ ServletRegistration.Dynamic dispatcher =
+ container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));
+ dispatcher.setLoadOnStartup(1);
+ dispatcher.addMapping("/*");
+ }
+
+}
diff --git a/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java
new file mode 100644
index 0000000000..5f43c7e707
--- /dev/null
+++ b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java
@@ -0,0 +1,26 @@
+package com.baeldung.server;
+
+import com.baeldung.api.Address;
+import com.baeldung.api.Booking;
+import com.baeldung.api.BookingException;
+import com.baeldung.api.CabBookingService;
+
+import java.util.Date;
+
+import static java.lang.Math.random;
+import static java.lang.System.currentTimeMillis;
+import static java.util.UUID.randomUUID;
+
+public class CabBookingServiceImpl implements CabBookingService {
+
+ @Override public Booking bookPickUp(Address pickUpLocation, Address dropOffLocation, int pax) throws BookingException {
+ if(random()<0.3){
+ throw new BookingException("Cab unavailable");
+ }
+ int tripTimeInMinutes = (int) (5 + random() * 15);
+ int costInCent = 15_00 + tripTimeInMinutes * 5 * pax;
+ Date pickUpDate = new Date((long) (currentTimeMillis() + (1000 * 60 * random() * 15)));
+ return new Booking(pickUpLocation, pickUpDate, dropOffLocation, costInCent, tripTimeInMinutes * 60,
+ randomUUID().toString());
+ }
+}
diff --git a/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/DispatcherConfig.java b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/DispatcherConfig.java
new file mode 100644
index 0000000000..8f9391f8ac
--- /dev/null
+++ b/spring-remoting/remoting-http/server/src/main/java/com/baeldung/server/DispatcherConfig.java
@@ -0,0 +1,18 @@
+package com.baeldung.server;
+
+import com.baeldung.api.CabBookingService;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
+
+@Configuration
+public class DispatcherConfig {
+
+ @Bean(name = "/booking") HttpInvokerServiceExporter accountService() {
+ HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
+ exporter.setService( new CabBookingServiceImpl() );
+ exporter.setServiceInterface( CabBookingService.class );
+ return exporter;
+ }
+
+}
diff --git a/spring-remoting/remoting-http/server/src/main/resources/logback.xml b/spring-remoting/remoting-http/server/src/main/resources/logback.xml
new file mode 100644
index 0000000000..7a03574f40
--- /dev/null
+++ b/spring-remoting/remoting-http/server/src/main/resources/logback.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+ ${logPattern}
+
+
+
+
+ C:\Users\danidemi\tmp\baledung\app.log
+ false
+
+ ${logPattern}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md
index 6b12bb676c..67bdddaf64 100644
--- a/spring-thymeleaf/README.md
+++ b/spring-thymeleaf/README.md
@@ -8,6 +8,7 @@
- [Thymeleaf: Custom Layout Dialect](http://www.baeldung.com/thymeleaf-spring-layouts)
- [Spring and Thymeleaf 3: Expressions](http://www.baeldung.com/spring-thymeleaf-3-expressions)
- [Spring MVC + Thymeleaf 3.0: New Features](http://www.baeldung.com/spring-thymeleaf-3)
+- [How to Work with Dates in Thymeleaef](http://www.baeldung.com/dates-in-thymeleaf)
### Build the Project