From 01b75f259b1259b299700543e58ea24d9ef1b579 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 1 Aug 2016 18:53:03 +0200 Subject: [PATCH 01/56] Wicket Hello World application --- pom.xml | 1 + wicket-intro/pom.xml | 26 +++++++++++++++++++ .../baeldung/wicket/examples/HelloWorld.html | 5 ++++ .../baeldung/wicket/examples/HelloWorld.java | 10 +++++++ .../examples/HelloWorldApplication.java | 11 ++++++++ wicket-intro/src/main/webapp/WEB-INF/web.xml | 20 ++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 wicket-intro/pom.xml create mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html create mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java create mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java create mode 100644 wicket-intro/src/main/webapp/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml index d2f5d83b46..8533a0d976 100644 --- a/pom.xml +++ b/pom.xml @@ -101,6 +101,7 @@ lombok redis webjars + wicket-intro mutation-testing spring-mvc-velocity diff --git a/wicket-intro/pom.xml b/wicket-intro/pom.xml new file mode 100644 index 0000000000..119dee8bf6 --- /dev/null +++ b/wicket-intro/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + com.baeldung.wicket.examples + HelloWorld + war + 1.0-SNAPSHOT + HelloWorld Maven Webapp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + org.apache.wicket + wicket-core + 8.0.0-M1 + + + + HelloWorld + + diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html new file mode 100644 index 0000000000..36afa6bf19 --- /dev/null +++ b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html @@ -0,0 +1,5 @@ + + + + + diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java new file mode 100644 index 0000000000..bb11a8cb6d --- /dev/null +++ b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java @@ -0,0 +1,10 @@ +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +package com.baeldung.wicket.examples; + +public class HelloWorld extends WebPage { + public HelloWorld() { + add(new Label("hello", "Hello World!")); + } +} diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java new file mode 100644 index 0000000000..3b50ece908 --- /dev/null +++ b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java @@ -0,0 +1,11 @@ +import org.apache.wicket.Page; +import org.apache.wicket.protocol.http.WebApplication; + +package com.baeldung.wicket.examples; + +public class HelloWorldApplication extends WebApplication { + @Override + public Class getHomePage() { + return HelloWorld.class; + } +} diff --git a/wicket-intro/src/main/webapp/WEB-INF/web.xml b/wicket-intro/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..37d1ebd24f --- /dev/null +++ b/wicket-intro/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,20 @@ + + + + Hello World + + HelloWorldApplication + org.apache.wicket.protocol.http.WicketFilter + + applicationClassName + com.baeldung.wicket.examples.HelloWorldApplication + + + + HelloWorldApplication + /* + + + From 05bef7c9a24320d0ac1d98a5b4f9db2cf41219b6 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 1 Aug 2016 19:22:54 +0200 Subject: [PATCH 02/56] fixed syntax error --- .../main/java/com/baeldung/wicket/examples/HelloWorld.java | 3 ++- .../com/baeldung/wicket/examples/HelloWorldApplication.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java index bb11a8cb6d..976136c70b 100644 --- a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java +++ b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java @@ -1,7 +1,8 @@ +package com.baeldung.wicket.examples; + import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; -package com.baeldung.wicket.examples; public class HelloWorld extends WebPage { public HelloWorld() { diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java index 3b50ece908..51def5be32 100644 --- a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java +++ b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java @@ -1,8 +1,8 @@ +package com.baeldung.wicket.examples; + import org.apache.wicket.Page; import org.apache.wicket.protocol.http.WebApplication; -package com.baeldung.wicket.examples; - public class HelloWorldApplication extends WebApplication { @Override public Class getHomePage() { From fbff04cbc5799a2a1f3bad5be0106539e8156332 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 8 Aug 2016 23:50:08 +0200 Subject: [PATCH 03/56] deleted previous project to refactor the code --- wicket-intro/pom.xml | 26 ------------------- .../baeldung/wicket/examples/HelloWorld.html | 5 ---- .../baeldung/wicket/examples/HelloWorld.java | 11 -------- .../examples/HelloWorldApplication.java | 11 -------- wicket-intro/src/main/webapp/WEB-INF/web.xml | 20 -------------- 5 files changed, 73 deletions(-) delete mode 100644 wicket-intro/pom.xml delete mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html delete mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java delete mode 100644 wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java delete mode 100644 wicket-intro/src/main/webapp/WEB-INF/web.xml diff --git a/wicket-intro/pom.xml b/wicket-intro/pom.xml deleted file mode 100644 index 119dee8bf6..0000000000 --- a/wicket-intro/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - 4.0.0 - com.baeldung.wicket.examples - HelloWorld - war - 1.0-SNAPSHOT - HelloWorld Maven Webapp - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - org.apache.wicket - wicket-core - 8.0.0-M1 - - - - HelloWorld - - diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html deleted file mode 100644 index 36afa6bf19..0000000000 --- a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java deleted file mode 100644 index 976136c70b..0000000000 --- a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorld.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.wicket.examples; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; - - -public class HelloWorld extends WebPage { - public HelloWorld() { - add(new Label("hello", "Hello World!")); - } -} diff --git a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java b/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java deleted file mode 100644 index 51def5be32..0000000000 --- a/wicket-intro/src/main/java/com/baeldung/wicket/examples/HelloWorldApplication.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.wicket.examples; - -import org.apache.wicket.Page; -import org.apache.wicket.protocol.http.WebApplication; - -public class HelloWorldApplication extends WebApplication { - @Override - public Class getHomePage() { - return HelloWorld.class; - } -} diff --git a/wicket-intro/src/main/webapp/WEB-INF/web.xml b/wicket-intro/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 37d1ebd24f..0000000000 --- a/wicket-intro/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - Hello World - - HelloWorldApplication - org.apache.wicket.protocol.http.WicketFilter - - applicationClassName - com.baeldung.wicket.examples.HelloWorldApplication - - - - HelloWorldApplication - /* - - - From a47564a0c902df0d04d90e29e0fececd81988f61 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 8 Aug 2016 23:52:39 +0200 Subject: [PATCH 04/56] examples in the wicket intro article --- wicket-intro/CafeAddress/pom.xml | 180 ++++++++++++++++++ .../examples/cafeaddress/CafeAddress.html | 20 ++ .../examples/cafeaddress/CafeAddress.java | 72 +++++++ .../cafeaddress/CafeAddressApplication.java | 33 ++++ .../CafeAddress/src/main/resources/log4j2.xml | 16 ++ .../src/main/webapp/WEB-INF/web.xml | 32 ++++ .../CafeAddress/src/main/webapp/logo.png | Bin 0 -> 12244 bytes .../CafeAddress/src/main/webapp/style.css | 68 +++++++ .../wicket/examples/cafeaddress/Start.java | 108 +++++++++++ .../examples/cafeaddress/TestHomePage.java | 29 +++ .../CafeAddress/src/test/jetty/jetty-http.xml | 38 ++++ .../src/test/jetty/jetty-https.xml | 45 +++++ .../CafeAddress/src/test/jetty/jetty-ssl.xml | 36 ++++ .../CafeAddress/src/test/jetty/jetty.xml | 23 +++ .../CafeAddress/src/test/resources/keystore | Bin 0 -> 1481 bytes wicket-intro/HelloWorld/pom.xml | 26 +++ .../examples/helloworld/HelloWorld.html | 5 + .../examples/helloworld/HelloWorld.java | 10 + .../helloworld/HelloWorldApplication.java | 12 ++ .../src/main/webapp/WEB-INF/web.xml | 19 ++ 20 files changed, 772 insertions(+) create mode 100644 wicket-intro/CafeAddress/pom.xml create mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html create mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java create mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java create mode 100644 wicket-intro/CafeAddress/src/main/resources/log4j2.xml create mode 100644 wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml create mode 100644 wicket-intro/CafeAddress/src/main/webapp/logo.png create mode 100644 wicket-intro/CafeAddress/src/main/webapp/style.css create mode 100644 wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java create mode 100644 wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java create mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml create mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml create mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml create mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty.xml create mode 100644 wicket-intro/CafeAddress/src/test/resources/keystore create mode 100644 wicket-intro/HelloWorld/pom.xml create mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html create mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java create mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java create mode 100644 wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml diff --git a/wicket-intro/CafeAddress/pom.xml b/wicket-intro/CafeAddress/pom.xml new file mode 100644 index 0000000000..2966105404 --- /dev/null +++ b/wicket-intro/CafeAddress/pom.xml @@ -0,0 +1,180 @@ + + + + + 4.0.0 + com.baeldung.wicket.examples.cafeaddress + CafeAddress + war + 1.0-SNAPSHOT + + quickstart + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + 7.4.0 + 9.2.13.v20150730 + 2.5 + 4.12 + UTF-8 + + none + + + + + org.apache.wicket + wicket-core + ${wicket.version} + + + + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + + + junit + junit + ${junit.version} + test + + + + + org.eclipse.jetty.aggregate + jetty-all + ${jetty9.version} + test + + + + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/resources + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + UTF-8 + true + true + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty9.version} + + + + maven.project.build.directory.test-classes + ${project.build.directory}/test-classes + + + ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.9 + + true + ${wtp.version} + + + + + + + + Apache Nexus + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html new file mode 100644 index 0000000000..954ff551f1 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html @@ -0,0 +1,20 @@ + + + + +Apache Wicket Quickstart + + + + +
+ +

+ Address: address +

+
+ + diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java new file mode 100644 index 0000000000..ce26c5a1ad --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java @@ -0,0 +1,72 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.DropDownChoice; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.request.mapper.parameter.PageParameters; + +public class CafeAddress extends WebPage { + + private static final long serialVersionUID = 1L; + + String selectedCafe; + Address address; + Map cafeNamesAndAddresses = new HashMap<>(); + + public CafeAddress(final PageParameters parameters) { + super(parameters); + initCafes(); + + ArrayList cafeNames = new ArrayList<>(this.cafeNamesAndAddresses.keySet()); + this.selectedCafe = cafeNames.get(0); + this.address = new Address(this.cafeNamesAndAddresses.get(this.selectedCafe).getAddress()); + + final Label addressLabel = new Label("address", new PropertyModel(this.address, "address")); + addressLabel.setOutputMarkupId(true); + + final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel(this, "selectedCafe"), cafeNames); + cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + String name = (String) cafeDropdown.getDefaultModel().getObject(); + address.setAddress(cafeNamesAndAddresses.get(name).getAddress()); + target.add(addressLabel); + } + }); + + add(addressLabel); + add(cafeDropdown); + + } + + private void initCafes() { + this.cafeNamesAndAddresses.put("Linda's Cafe", new Address("35 Bower St.")); + this.cafeNamesAndAddresses.put("Old Tree", new Address("2 Edgware Rd.")); + } + + class Address implements Serializable { + private String sAddress = ""; + + public Address(String address) { + this.sAddress = address; + } + + public String getAddress() { + return this.sAddress; + } + + public void setAddress(String address) { + this.sAddress = address; + } + } +} diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java new file mode 100644 index 0000000000..189ef14558 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java @@ -0,0 +1,33 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.protocol.http.WebApplication; + +/** + * Application object for your web application. + * If you want to run this application without deploying, run the Start class. + * + * @see com.baeldung.wicket.examples.Start#main(String[]) + */ +public class CafeAddressApplication extends WebApplication +{ + /** + * @see org.apache.wicket.Application#getHomePage() + */ + @Override + public Class getHomePage() + { + return CafeAddress.class; + } + + /** + * @see org.apache.wicket.Application#init() + */ + @Override + public void init() + { + super.init(); + + // add your configuration here + } +} diff --git a/wicket-intro/CafeAddress/src/main/resources/log4j2.xml b/wicket-intro/CafeAddress/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..5596dd5f40 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/resources/log4j2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml b/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..03e600188b --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + CafeAddress + + + + + wicket.CafeAddress + org.apache.wicket.protocol.http.WicketFilter + + applicationClassName + com.baeldung.wicket.examples.cafeaddress.CafeAddressApplication + + + + + wicket.CafeAddress + /* + + diff --git a/wicket-intro/CafeAddress/src/main/webapp/logo.png b/wicket-intro/CafeAddress/src/main/webapp/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..39ec54854b748ab6aeb6b3965d88f452772d7d8e GIT binary patch literal 12244 zcmV;_FDuZAP)4Tx0C)j~RL^S@K@|QrZmG~B2wH0nvUrdpNm;9CMbtL^5n^i$+aIn^?(HA4aZWV5ov6ELTdbo0FI&wK{O>*+w4vx20?>!`FrQsdJlnHR>OPy zcd~b_n$otK2Za4V;76L-DzNVtaSB-y0*E}{p()372;bw_^6ZZ}PI-92wGS&j#91PI zKs7DSe@(bk%_Y-7gGe}(^>I=@oY#w#*Bu9GZf3^F5WP>3rn}7Ut74&?PWBFvy`A)a zPP5)V!Xd&78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htd8WZ5I+da)iRs8lGYQ<-l$L@;^!<@ zfpaq)512N#ny~yVbb#w*=F`ZRSyrPr<9e i1O^!^0gjqN1OFf9qq%!F8)!QK0000`K literal 0 HcmV?d00001 diff --git a/wicket-intro/CafeAddress/src/main/webapp/style.css b/wicket-intro/CafeAddress/src/main/webapp/style.css new file mode 100644 index 0000000000..fc137cadb0 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/webapp/style.css @@ -0,0 +1,68 @@ +body, p, li, a { font-family: georgia, times, serif;font-size:13pt;} +h1, h2, h3 { font-family: 'Yanone Kaffeesatz', arial, serif; } +body { margin:0;padding:0;} +#hd { + width : 100%; + height : 87px; + background-color : #092E67; + margin-top : 0; + padding-top : 10px; + border-bottom : 1px solid #888; + z-index : 0; +} +#ft { + position : absolute; + bottom : 0; + width : 100%; + height : 99px; + background-color : #6493D2; + border-top : 1px solid #888; + z-index : 0; +} +#logo,#bd { + width : 650px; + margin: 0 auto; + padding: 25px 50px 0 50px; +} +#logo h1 { + color : white; + font-size:36pt; + display: inline; +} +#logo img { + display:inline; + vertical-align: bottom; + margin-left : 50px; + margin-right : 5px; +} +body { margin-top : 0; padding-top : 0;} +#logo, #logo h1 { margin-top : 0; padding-top : 0;} +#bd { + position : absolute; + top : 75px; + bottom : 75px; + left : 50%; + margin-left : -325px; + z-index : 1; + overflow: auto; + background-color : #fff; + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + -moz-box-shadow: 0px 0px 10px #888; + -webkit-box-shadow: 0px 0px 10px #888; + box-shadow: 0px 0px 10px #888; +} +a, a:visited, a:hover, a:active { + color : #6493D2; +} +h2 { + padding : 0; margin:0; + font-size:36pt; + color:#FF5500; +} +h3 { + padding : 0; margin:0; + font-size:24pt; + color:#092E67; +} \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java new file mode 100644 index 0000000000..b2be405124 --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java @@ -0,0 +1,108 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import java.lang.management.ManagementFactory; + +import javax.management.MBeanServer; + +import org.eclipse.jetty.jmx.MBeanContainer; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.webapp.WebAppContext; + +/** + * Separate startup class for people that want to run the examples directly. Use parameter + * -Dcom.sun.management.jmxremote to startup JMX (and e.g. connect with jconsole). + */ +public class Start +{ + /** + * Main function, starts the jetty server. + * + * @param args + */ + public static void main(String[] args) + { + System.setProperty("wicket.configuration", "development"); + + Server server = new Server(); + + HttpConfiguration http_config = new HttpConfiguration(); + http_config.setSecureScheme("https"); + http_config.setSecurePort(8443); + http_config.setOutputBufferSize(32768); + + ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config)); + http.setPort(8080); + http.setIdleTimeout(1000 * 60 * 60); + + server.addConnector(http); + + Resource keystore = Resource.newClassPathResource("/keystore"); + if (keystore != null && keystore.exists()) + { + // if a keystore for a SSL certificate is available, start a SSL + // connector on port 8443. + // By default, the quickstart comes with a Apache Wicket Quickstart + // Certificate that expires about half way september 2021. Do not + // use this certificate anywhere important as the passwords are + // available in the source. + + SslContextFactory sslContextFactory = new SslContextFactory(); + sslContextFactory.setKeyStoreResource(keystore); + sslContextFactory.setKeyStorePassword("wicket"); + sslContextFactory.setKeyManagerPassword("wicket"); + + HttpConfiguration https_config = new HttpConfiguration(http_config); + https_config.addCustomizer(new SecureRequestCustomizer()); + + ServerConnector https = new ServerConnector(server, new SslConnectionFactory( + sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); + https.setPort(8443); + https.setIdleTimeout(500000); + + server.addConnector(https); + System.out.println("SSL access to the examples has been enabled on port 8443"); + System.out + .println("You can access the application using SSL on https://localhost:8443"); + System.out.println(); + } + + WebAppContext bb = new WebAppContext(); + bb.setServer(server); + bb.setContextPath("/"); + bb.setWar("src/main/webapp"); + + // uncomment the next two lines if you want to start Jetty with WebSocket (JSR-356) support + // you need org.apache.wicket:wicket-native-websocket-javax in the classpath! + // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); + // serverContainer.addEndpoint(new WicketServerEndpointConfig()); + + // uncomment next line if you want to test with JSESSIONID encoded in the urls + // ((AbstractSessionManager) + // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); + + server.setHandler(bb); + + MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); + server.addEventListener(mBeanContainer); + server.addBean(mBeanContainer); + + try + { + server.start(); + server.join(); + } + catch (Exception e) + { + e.printStackTrace(); + System.exit(100); + } + } +} diff --git a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java new file mode 100644 index 0000000000..9b186ce52b --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java @@ -0,0 +1,29 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import org.apache.wicket.util.tester.WicketTester; +import org.junit.Before; +import org.junit.Test; + +/** + * Simple test using the WicketTester + */ +public class TestHomePage +{ + private WicketTester tester; + + @Before + public void setUp() + { + tester = new WicketTester(new CafeAddressApplication()); + } + + @Test + public void homepageRendersSuccessfully() + { + //start and render the test page + tester.startPage(CafeAddress.class); + + //assert rendered page class + tester.assertRenderedPage(CafeAddress.class); + } +} diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml new file mode 100644 index 0000000000..9f3256b15c --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml new file mode 100644 index 0000000000..58f7d53d2d --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + + 30000 + + + + \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml new file mode 100644 index 0000000000..49e558bb47 --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml @@ -0,0 +1,36 @@ + + + + + + + + + / + + + + + + SSL_RSA_WITH_DES_CBC_SHA + SSL_DHE_RSA_WITH_DES_CBC_SHA + SSL_DHE_DSS_WITH_DES_CBC_SHA + SSL_RSA_EXPORT_WITH_RC4_40_MD5 + SSL_RSA_EXPORT_WITH_DES40_CBC_SHA + SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA + SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty.xml new file mode 100644 index 0000000000..1a6293b405 --- /dev/null +++ b/wicket-intro/CafeAddress/src/test/jetty/jetty.xml @@ -0,0 +1,23 @@ + + + + + + + + https + + + + 32768 + 8192 + 8192 + true + false + 512 + + + + + + \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/resources/keystore b/wicket-intro/CafeAddress/src/test/resources/keystore new file mode 100644 index 0000000000000000000000000000000000000000..30bbc90ccffcc2745adf09077df16fc3db9c0b47 GIT binary patch literal 1481 zcmezO_TO6u1_mY|W&~r_tkjZ{N+8cDIXV0qP-d4w6Vo;WJ~l3GHbxdkEha%mMpg!v zCZXF+L+yeb(_D>eh5NdK;{zR}$;>(o{ zE3dg|o8B)~5ILLXvtIl5>N#JOOd1Wnqs3o|CH&_3)%k6yk>9%q<*Th*+pP{h`8MfJ zi*YvUmF+Z?t0^x!WMEPBj(9H=gC$Rl(ii9d&)j3 zbTLZUo^$C9pTUfx#bzsWYP%dfFaJ7`%~pJY<=Y|t;J>bqocFORJ8`)y%bsft`MuQV z>{(ffqGR9Jv){6}VE@M8vig|blV9STFXpbA!u05_iEyhlhqkKZ;q9M!rpxs*tJ<*3 zhiWIa`fr}ezEJ&I{ND#6cX8iNm8;zH2RodQ=n#@cCCOr| zTXCYzlEX`7T5ANh+?d0qlI6dJ@sW+nZle@FF~#KRKmX0;w|%=dD0Q*hi_hY5Y{CW4 zrOJiNd#@bdbya1dHCyZRTmE&^ii4i-IJn9!!^(ZV)t=3cyTYEANN&*o!@WvnMVp(G z{s(U^qqZe`enoqQPhO)mduP*#-L_kTKzrv7mI-@Dg3P;OV0 z+>^?;+IITpTAR2zDn5LAd`IV(R$N{5^Homy`Hv1=mC|&FBxtu~Lg@4UcN&B|cVxXe%hnAVv?S=fZxL-Vrp^2_sJA{-bZ z>z> zKgGsI?`g4Czs|(W$iRr~JYW)G2D&RF+G&cYMyt~S#qC>9Yo8yjfwPfwA z__FOSvwctPaoU&=rO7Hf`?L)EoW48GpSg3HG`N>Wh@H&bQ>GZp6P=NEzJCF4QTtMF zyCu^XE;=4q;eAoe&u6Fp<&$m~Ic0x)r`Sfd8H?)QbE`9U3bGFi_@iY1?tkt>-^;Q{1ps`KMkD|L literal 0 HcmV?d00001 diff --git a/wicket-intro/HelloWorld/pom.xml b/wicket-intro/HelloWorld/pom.xml new file mode 100644 index 0000000000..08586375ce --- /dev/null +++ b/wicket-intro/HelloWorld/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + com.baeldung.wicket.examples.helloworld + HelloWorld + war + 1.0-SNAPSHOT + HelloWorld Maven Webapp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + org.apache.wicket + wicket-core + 8.0.0-M1 + + + + HelloWorld + + diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html new file mode 100644 index 0000000000..c56d07fc10 --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html @@ -0,0 +1,5 @@ + + + + + diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java new file mode 100644 index 0000000000..6dc7295798 --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java @@ -0,0 +1,10 @@ +package com.baeldung.wicket.examples.helloworld; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +public class HelloWorld extends WebPage { + public HelloWorld() { + add(new Label("hello", "Hello World!")); + } +} diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java new file mode 100644 index 0000000000..618496e5f7 --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java @@ -0,0 +1,12 @@ + +package com.baeldung.wicket.examples.helloworld; + +import org.apache.wicket.Page; +import org.apache.wicket.protocol.http.WebApplication; + +public class HelloWorldApplication extends WebApplication { + @Override + public Class getHomePage() { + return HelloWorld.class; + } +} diff --git a/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml b/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..c68ca09241 --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + Hello World + + HelloWorldApplication + org.apache.wicket.protocol.http.WicketFilter + + applicationClassName + com.baeldung.wicket.examples.helloworld.HelloWorldApplication + + + + HelloWorldApplication + /* + + From f2ed42bcd22a803943410c1a9c7ffdfc0289d834 Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 26 Aug 2016 04:07:09 +0200 Subject: [PATCH 05/56] Added Web Initializer to Cafe Address application --- wicket-intro/CafeAddress/pom.xml | 71 ++++++++-------- .../cafeaddress/ApplicationConfiguration.java | 10 +++ .../cafeaddress/WebAppInitializer.java | 26 ++++++ .../src/main/webapp/WEB-INF/web.xml | 32 -------- wicket-intro/HelloWorld/pom.xml | 82 +++++++++++++------ .../helloworld/ApplicationConfiguration.java | 10 +++ .../helloworld/HelloWorldApplication.java | 10 +++ .../helloworld/WebAppInitializer.java | 26 ++++++ .../src/main/webapp/WEB-INF/web.xml | 19 ----- 9 files changed, 173 insertions(+), 113 deletions(-) create mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java create mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java delete mode 100644 wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml create mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java create mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java delete mode 100644 wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml diff --git a/wicket-intro/CafeAddress/pom.xml b/wicket-intro/CafeAddress/pom.xml index 2966105404..d0e238bbb9 100644 --- a/wicket-intro/CafeAddress/pom.xml +++ b/wicket-intro/CafeAddress/pom.xml @@ -1,52 +1,20 @@ - 4.0.0 - com.baeldung.wicket.examples.cafeaddress - CafeAddress + com.baeldung.wicket.examples + cafe-address war 1.0-SNAPSHOT - - quickstart - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - + CafeAddress 7.4.0 9.2.13.v20150730 2.5 4.12 UTF-8 - none @@ -63,6 +31,24 @@ ${wicket.version} --> + + + + + org.springframework + spring-web + 4.1.1.RELEASE + + + javax.servlet + javax.servlet-api + 3.1.0 + + + org.apache.wicket + wicket-spring + 8.0.0-M1 + @@ -93,6 +79,7 @@ + CafeAddress false @@ -130,15 +117,23 @@ true org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.5.1 - 1.7 - 1.7 + 1.8 + 1.8 UTF-8 true true + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + false + + org.eclipse.jetty jetty-maven-plugin diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java new file mode 100644 index 0000000000..c0e34c6dc1 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +public class ApplicationConfiguration { + +} diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java new file mode 100644 index 0000000000..f1465e05b9 --- /dev/null +++ b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java @@ -0,0 +1,26 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import javax.servlet.FilterRegistration; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import org.apache.wicket.protocol.http.WicketFilter; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +public class WebAppInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext container) throws ServletException { + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + container.addListener(new ContextLoaderListener(context)); + context.register(ApplicationConfiguration.class); + + FilterRegistration filter = container.addFilter("CafeAddressApplication", WicketFilter.class); + filter.setInitParameter("applicationClassName", CafeAddressApplication.class.getName()); + filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); + filter.addMappingForUrlPatterns(null, false, "/*"); + } + +} \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml b/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 03e600188b..0000000000 --- a/wicket-intro/CafeAddress/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - CafeAddress - - - - - wicket.CafeAddress - org.apache.wicket.protocol.http.WicketFilter - - applicationClassName - com.baeldung.wicket.examples.cafeaddress.CafeAddressApplication - - - - - wicket.CafeAddress - /* - - diff --git a/wicket-intro/HelloWorld/pom.xml b/wicket-intro/HelloWorld/pom.xml index 08586375ce..2aff59dd93 100644 --- a/wicket-intro/HelloWorld/pom.xml +++ b/wicket-intro/HelloWorld/pom.xml @@ -1,26 +1,60 @@ - 4.0.0 - com.baeldung.wicket.examples.helloworld - HelloWorld - war - 1.0-SNAPSHOT - HelloWorld Maven Webapp - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - org.apache.wicket - wicket-core - 8.0.0-M1 - - - - HelloWorld - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + com.baeldung.wicket.examples + hello-world + war + 1.0-SNAPSHOT + HelloWorld + + + junit + junit + 3.8.1 + test + + + org.apache.wicket + wicket-core + 8.0.0-M1 + + + org.springframework + spring-web + 4.1.1.RELEASE + + + javax.servlet + javax.servlet-api + 3.1.0 + + + org.apache.wicket + wicket-spring + 8.0.0-M1 + + + + HelloWorld + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + false + + + + diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java new file mode 100644 index 0000000000..f9de7adb2a --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.wicket.examples.helloworld; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +public class ApplicationConfiguration { + +} diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java index 618496e5f7..64bfcadd29 100644 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java @@ -3,10 +3,20 @@ package com.baeldung.wicket.examples.helloworld; import org.apache.wicket.Page; import org.apache.wicket.protocol.http.WebApplication; +import org.apache.wicket.spring.injection.annot.SpringComponentInjector; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; public class HelloWorldApplication extends WebApplication { @Override public Class getHomePage() { return HelloWorld.class; } + + @Override + public void init() { + super.init(); + getComponentInstantiationListeners().add(new SpringComponentInjector(this)); + } + } diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java new file mode 100644 index 0000000000..362502e264 --- /dev/null +++ b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java @@ -0,0 +1,26 @@ +package com.baeldung.wicket.examples.helloworld; + +import javax.servlet.FilterRegistration; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import org.apache.wicket.protocol.http.WicketFilter; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +public class WebAppInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext container) throws ServletException { + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + container.addListener(new ContextLoaderListener(context)); + context.register(ApplicationConfiguration.class); + + FilterRegistration filter = container.addFilter("HelloWorldApplication", WicketFilter.class); + filter.setInitParameter("applicationClassName", HelloWorldApplication.class.getName()); + filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); + filter.addMappingForUrlPatterns(null, false, "/*"); + } + +} \ No newline at end of file diff --git a/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml b/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index c68ca09241..0000000000 --- a/wicket-intro/HelloWorld/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - Hello World - - HelloWorldApplication - org.apache.wicket.protocol.http.WicketFilter - - applicationClassName - com.baeldung.wicket.examples.helloworld.HelloWorldApplication - - - - HelloWorldApplication - /* - - From 42aac4bb4d651db52934edc8b7c3b93770e744a8 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 27 Aug 2016 01:16:11 +0200 Subject: [PATCH 06/56] added readme with execution instructions --- wicket-intro/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 wicket-intro/README.md diff --git a/wicket-intro/README.md b/wicket-intro/README.md new file mode 100644 index 0000000000..614446e7ba --- /dev/null +++ b/wicket-intro/README.md @@ -0,0 +1,4 @@ + +From the same directory where pom.xml is, execute the following command to run the project: + +mvn jetty:run From c1667fe02458364d4935c16aeae0b609a54dc2b0 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 27 Aug 2016 01:16:48 +0200 Subject: [PATCH 07/56] removed unnecesary config from project --- wicket-intro/CafeAddress/pom.xml | 19 ------------------- .../CafeAddress/src/main/resources/log4j2.xml | 16 ---------------- 2 files changed, 35 deletions(-) delete mode 100644 wicket-intro/CafeAddress/src/main/resources/log4j2.xml diff --git a/wicket-intro/CafeAddress/pom.xml b/wicket-intro/CafeAddress/pom.xml index d0e238bbb9..8fb0fbd05a 100644 --- a/wicket-intro/CafeAddress/pom.xml +++ b/wicket-intro/CafeAddress/pom.xml @@ -24,13 +24,6 @@ wicket-core ${wicket.version} - @@ -50,18 +43,6 @@ 8.0.0-M1 - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - - junit diff --git a/wicket-intro/CafeAddress/src/main/resources/log4j2.xml b/wicket-intro/CafeAddress/src/main/resources/log4j2.xml deleted file mode 100644 index 5596dd5f40..0000000000 --- a/wicket-intro/CafeAddress/src/main/resources/log4j2.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file From 4e6d70d2cdec3c5aa62a9dc218008038b9575180 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 30 Aug 2016 22:04:37 +0530 Subject: [PATCH 08/56] BAEL 298 | Intro to Selenium with JUnit / TestNg --- selenium-junit-testng/pom.xml | 36 +++++++++++++++++++ .../testng/TestSeleniumWithTestNG.java | 34 ++++++++++++++++++ .../selenium/junit/TestSeleniumWithJUnit.java | 34 ++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 selenium-junit-testng/pom.xml create mode 100644 selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java create mode 100644 selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml new file mode 100644 index 0000000000..c6bd2b042c --- /dev/null +++ b/selenium-junit-testng/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + com.baeldung + selenium-junit-testng + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + + org.seleniumhq.selenium + selenium-java + 2.53.1 + + + junit + junit + 4.8.1 + + + org.testng + testng + 6.9.10 + + + \ No newline at end of file diff --git a/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java new file mode 100644 index 0000000000..dcdfafc4f1 --- /dev/null +++ b/selenium-junit-testng/test/com/baeldun/selenium/testng/TestSeleniumWithTestNG.java @@ -0,0 +1,34 @@ +package com.baeldun.selenium.testng; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +public class TestSeleniumWithTestNG { + + private WebDriver webDriver; + private final String url = "http://www.baeldung.com/"; + private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials"; + + @BeforeSuite + public void setUp() { + webDriver = new FirefoxDriver(); + webDriver.get(url); + } + + @AfterSuite + public void tearDown() { + webDriver.close(); + } + + @Test + public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { + String actualTitleReturned = webDriver.getTitle(); + assertNotNull(actualTitleReturned); + assertEquals(expectedTitle, actualTitleReturned); + } +} diff --git a/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java new file mode 100644 index 0000000000..a7b36c4e4e --- /dev/null +++ b/selenium-junit-testng/test/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java @@ -0,0 +1,34 @@ +package com.baeldung.selenium.junit; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public class TestSeleniumWithJUnit { + + private WebDriver webDriver; + private final String url = "http://www.baeldung.com/"; + private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials"; + + @Before + public void setUp() { + webDriver = new FirefoxDriver(); + webDriver.get(url); + } + + @After + public void tearDown() { + webDriver.close(); + } + + @Test + public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { + String actualTitleReturned = webDriver.getTitle(); + assertNotNull(actualTitleReturned); + assertEquals(expectedTitle, actualTitleReturned); + } +} From 574cd84f8975cc4a0df051dcc4ad9c8159197ca2 Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Tue, 30 Aug 2016 20:30:14 +0100 Subject: [PATCH 09/56] Add ElasticSearch module --- elasticsearch/pom.xml | 40 ++++++ .../com/baeldung/elasticsearch/Person.java | 52 ++++++++ .../elasticsearch/ElasticSearchUnitTests.java | 117 ++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 elasticsearch/pom.xml create mode 100644 elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java create mode 100644 elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml new file mode 100644 index 0000000000..cb66042052 --- /dev/null +++ b/elasticsearch/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + + com.baeldung + elasticsearch + 0.0.1-SNAPSHOT + jar + + elasticsearch + http://maven.apache.org + + + UTF-8 + + + + + org.elasticsearch + elasticsearch + 2.3.5 + + + com.alibaba + fastjson + 1.2.13 + + + junit + junit + 4.12 + test + + + com.google.code.gson + gson + 2.6.2 + + + diff --git a/elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java b/elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java new file mode 100644 index 0000000000..8f0b19a186 --- /dev/null +++ b/elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java @@ -0,0 +1,52 @@ +package com.baeldung.elasticsearch; + +import java.util.Date; + +public class Person { + + private int age; + + private String fullName; + + private Date dateOfBirth; + + public Person() { + + } + + public Person(int age, String fullName, Date dateOfBirth) { + super(); + this.age = age; + this.fullName = fullName; + this.dateOfBirth = dateOfBirth; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public Date getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Date dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + @Override + public String toString() { + return "Person [age=" + age + ", fullName=" + fullName + ", dateOfBirth=" + dateOfBirth + "]"; + } +} diff --git a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java new file mode 100644 index 0000000000..9a6bfb19a2 --- /dev/null +++ b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java @@ -0,0 +1,117 @@ +package com.baeldung.elasticsearch; + +import static org.elasticsearch.node.NodeBuilder.*; +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.elasticsearch.action.delete.DeleteResponse; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.node.Node; +import org.elasticsearch.search.SearchHit; +import org.junit.Before; +import org.junit.Test; + +import com.alibaba.fastjson.JSON; + +public class ElasticSearchUnitTests { + private List listOfPersons = new ArrayList(); + String jsonString = null; + + @Before + public void setUp() { + Person person1 = new Person(10, "John Doe", new Date()); + Person person2 = new Person(25, "Janette Doe", new Date()); + listOfPersons.add(person1); + listOfPersons.add(person2); + jsonString = JSON.toJSONString(listOfPersons); + System.out.println(jsonString); + } + + @Test + public void givenJsonString_whenJavaObject_thenIndexDocument() { + String jsonObject = "{\"age\":20,\"dateOfBirth\":1471466076564,\"fullName\":\"John Doe\"}"; + + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + Client client = node.client(); + IndexResponse response = client.prepareIndex("people", "Doe") + .setSource(jsonObject).get(); + String id = response.getId(); + String index = response.getIndex(); + String type = response.getType(); + assertTrue(response.isCreated()); + assertEquals(index, "people"); + assertEquals(type, "Doe"); + } + + @Test + public void givenDocumentId_whenJavaObject_thenDeleteDocument() { + String jsonObject = "{\"age\":10,\"dateOfBirth\":1471455886564,\"fullName\":\"Johan Doe\"}"; + + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + Client client = node.client(); + IndexResponse response = client.prepareIndex("people", "Doe") + .setSource(jsonObject).get(); + String id = response.getId(); + DeleteResponse deleteResponse = client.prepareDelete("people", "Doe", id).get(); + assertTrue(deleteResponse.isFound()); + } + + @Test + public void givenSearchRequest_whenMatchAll_thenReturnAllResults() { + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + Client client = node.client(); + SearchResponse response = client.prepareSearch().execute().actionGet(); + SearchHit[] searchHits = response.getHits().getHits(); + List results = new ArrayList(); + for(SearchHit hit : searchHits){ + String sourceAsString = hit.getSourceAsString(); + Person person = JSON.parseObject(sourceAsString, Person.class); + results.add(person); + } + } + + @Test + public void givenSearchParamters_thenReturnResults() { + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + Client client = node.client(); + SearchResponse response = client.prepareSearch() + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders.rangeQuery("age").from(5).to(15)) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); + SearchHit[] searchHits = response.getHits().getHits(); + List results = new ArrayList(); + for(SearchHit hit : searchHits){ + String sourceAsString = hit.getSourceAsString(); + Person person = JSON.parseObject(sourceAsString, Person.class); + results.add(person); + } + } + + @Test + public void givenContentBuilder_whenHelpers_thanIndexJson() throws IOException { + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + Client client = node.client(); + XContentBuilder builder = XContentFactory.jsonBuilder() + .startObject() + .field("fullName", "Test") + .field("salary", "11500") + .field("age", "10") + .endObject(); + IndexResponse response = client.prepareIndex("people", "Doe") + .setSource(builder).get(); + assertTrue(response.isCreated()); + } +} From aab38dc10d5ca400fc2fe505e7463852ec5ee2ce Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Tue, 30 Aug 2016 20:31:31 +0100 Subject: [PATCH 10/56] Create README.md file --- elasticsearch/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 elasticsearch/README.md diff --git a/elasticsearch/README.md b/elasticsearch/README.md new file mode 100644 index 0000000000..e21070dbee --- /dev/null +++ b/elasticsearch/README.md @@ -0,0 +1,6 @@ +========= + +## ElasticSearch + +### Relevant Articles: +- [A Guide to ElasticSearch](http://www.baeldung.com/????????) From ec0eb9c804c402e15b9502df4c01c90ae1654a32 Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Tue, 30 Aug 2016 20:32:30 +0100 Subject: [PATCH 11/56] Delete Gson dependency --- elasticsearch/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml index cb66042052..c12f258b98 100644 --- a/elasticsearch/pom.xml +++ b/elasticsearch/pom.xml @@ -31,10 +31,5 @@ 4.12 test - - com.google.code.gson - gson - 2.6.2 - From 0c1ad4f7c3177d1bb1690e240a75703050abc709 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 31 Aug 2016 04:29:24 +0200 Subject: [PATCH 12/56] New project with both examples included and a home page that contains a link for each. --- .../wicket/examples/cafeaddress/Start.java | 134 ++++++++--------- wicket-intro/WicketIntro/pom.xml | 136 ++++++++++++++++++ .../examples/ApplicationConfiguration.java | 10 ++ .../baeldung/wicket/examples/Examples.html | 52 +++++++ .../baeldung/wicket/examples/Examples.java | 9 ++ .../wicket/examples/ExamplesApplication.java | 27 ++++ .../wicket/examples/WebAppInitializer.java | 26 ++++ .../examples/cafeaddress/CafeAddress.html | 15 ++ .../examples/cafeaddress/CafeAddress.java | 72 ++++++++++ .../examples/helloworld/HelloWorld.html | 5 + .../examples/helloworld/HelloWorld.java | 13 ++ .../WicketIntro/src/test/jetty/jetty-http.xml | 38 +++++ .../src/test/jetty/jetty-https.xml | 45 ++++++ .../WicketIntro/src/test/jetty/jetty-ssl.xml | 36 +++++ .../WicketIntro/src/test/jetty/jetty.xml | 23 +++ .../WicketIntro/src/test/resources/keystore | Bin 0 -> 1481 bytes 16 files changed, 570 insertions(+), 71 deletions(-) create mode 100644 wicket-intro/WicketIntro/pom.xml create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html create mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java create mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml create mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml create mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml create mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty.xml create mode 100644 wicket-intro/WicketIntro/src/test/resources/keystore diff --git a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java index b2be405124..bb67ac56a5 100644 --- a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java +++ b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java @@ -19,90 +19,82 @@ import org.eclipse.jetty.webapp.WebAppContext; * Separate startup class for people that want to run the examples directly. Use parameter * -Dcom.sun.management.jmxremote to startup JMX (and e.g. connect with jconsole). */ -public class Start -{ - /** - * Main function, starts the jetty server. - * - * @param args - */ - public static void main(String[] args) - { - System.setProperty("wicket.configuration", "development"); +public class Start { + /** + * Main function, starts the jetty server. + * + * @param args + */ + public static void main(String[] args) { + System.setProperty("wicket.configuration", "development"); - Server server = new Server(); + Server server = new Server(); - HttpConfiguration http_config = new HttpConfiguration(); - http_config.setSecureScheme("https"); - http_config.setSecurePort(8443); - http_config.setOutputBufferSize(32768); + HttpConfiguration http_config = new HttpConfiguration(); + http_config.setSecureScheme("https"); + http_config.setSecurePort(8443); + http_config.setOutputBufferSize(32768); - ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config)); - http.setPort(8080); - http.setIdleTimeout(1000 * 60 * 60); + ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config)); + http.setPort(8080); + http.setIdleTimeout(1000 * 60 * 60); - server.addConnector(http); + server.addConnector(http); - Resource keystore = Resource.newClassPathResource("/keystore"); - if (keystore != null && keystore.exists()) - { - // if a keystore for a SSL certificate is available, start a SSL - // connector on port 8443. - // By default, the quickstart comes with a Apache Wicket Quickstart - // Certificate that expires about half way september 2021. Do not - // use this certificate anywhere important as the passwords are - // available in the source. + Resource keystore = Resource.newClassPathResource("/keystore"); + if (keystore != null && keystore.exists()) { + // if a keystore for a SSL certificate is available, start a SSL + // connector on port 8443. + // By default, the quickstart comes with a Apache Wicket Quickstart + // Certificate that expires about half way september 2021. Do not + // use this certificate anywhere important as the passwords are + // available in the source. - SslContextFactory sslContextFactory = new SslContextFactory(); - sslContextFactory.setKeyStoreResource(keystore); - sslContextFactory.setKeyStorePassword("wicket"); - sslContextFactory.setKeyManagerPassword("wicket"); + SslContextFactory sslContextFactory = new SslContextFactory(); + sslContextFactory.setKeyStoreResource(keystore); + sslContextFactory.setKeyStorePassword("wicket"); + sslContextFactory.setKeyManagerPassword("wicket"); - HttpConfiguration https_config = new HttpConfiguration(http_config); - https_config.addCustomizer(new SecureRequestCustomizer()); + HttpConfiguration https_config = new HttpConfiguration(http_config); + https_config.addCustomizer(new SecureRequestCustomizer()); - ServerConnector https = new ServerConnector(server, new SslConnectionFactory( - sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); - https.setPort(8443); - https.setIdleTimeout(500000); + ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); + https.setPort(8443); + https.setIdleTimeout(500000); - server.addConnector(https); - System.out.println("SSL access to the examples has been enabled on port 8443"); - System.out - .println("You can access the application using SSL on https://localhost:8443"); - System.out.println(); - } + server.addConnector(https); + System.out.println("SSL access to the examples has been enabled on port 8443"); + System.out.println("You can access the application using SSL on https://localhost:8443"); + System.out.println(); + } - WebAppContext bb = new WebAppContext(); - bb.setServer(server); - bb.setContextPath("/"); - bb.setWar("src/main/webapp"); + WebAppContext bb = new WebAppContext(); + bb.setServer(server); + bb.setContextPath("/"); + bb.setWar("src/main/webapp"); - // uncomment the next two lines if you want to start Jetty with WebSocket (JSR-356) support - // you need org.apache.wicket:wicket-native-websocket-javax in the classpath! - // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); - // serverContainer.addEndpoint(new WicketServerEndpointConfig()); + // uncomment the next two lines if you want to start Jetty with WebSocket (JSR-356) support + // you need org.apache.wicket:wicket-native-websocket-javax in the classpath! + // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); + // serverContainer.addEndpoint(new WicketServerEndpointConfig()); - // uncomment next line if you want to test with JSESSIONID encoded in the urls - // ((AbstractSessionManager) - // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); + // uncomment next line if you want to test with JSESSIONID encoded in the urls + // ((AbstractSessionManager) + // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); - server.setHandler(bb); + server.setHandler(bb); - MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); - server.addEventListener(mBeanContainer); - server.addBean(mBeanContainer); + MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); + server.addEventListener(mBeanContainer); + server.addBean(mBeanContainer); - try - { - server.start(); - server.join(); - } - catch (Exception e) - { - e.printStackTrace(); - System.exit(100); - } - } + try { + server.start(); + server.join(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(100); + } + } } diff --git a/wicket-intro/WicketIntro/pom.xml b/wicket-intro/WicketIntro/pom.xml new file mode 100644 index 0000000000..9b759eb1be --- /dev/null +++ b/wicket-intro/WicketIntro/pom.xml @@ -0,0 +1,136 @@ + + + + 4.0.0 + com.baeldung.wicket.examples + wicket-intro + war + 1.0-SNAPSHOT + WicketIntro + + 7.4.0 + 9.2.13.v20150730 + 2.5 + 4.12 + 4.1.1.RELEASE + 3.1.0 + 8.0.0-M1 + 3.5.1 + 2.6 + UTF-8 + none + + + + + org.apache.wicket + wicket-core + ${wicket.version} + + + + + + org.springframework + spring-web + ${spring-web.version} + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + + + org.apache.wicket + wicket-spring + ${wicket-spring.version} + + + + + junit + junit + ${junit.version} + test + + + + + org.eclipse.jetty.aggregate + jetty-all + ${jetty9.version} + test + + + + WicketIntro + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + UTF-8 + true + true + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty9.version} + + + + maven.project.build.directory.test-classes + ${project.build.directory}/test-classes + + + ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml + + + + + + + + Apache Nexus + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java new file mode 100644 index 0000000000..2b42af9065 --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.wicket.examples; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan +public class ApplicationConfiguration { + +} diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html new file mode 100644 index 0000000000..38eebbffe0 --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html @@ -0,0 +1,52 @@ + + + + +Wicket Intro Examples + + + +
+
+
+

Wicket Introduction Examples:

+ + Hello World! +
+
+ Cafes +
+
+
+
+ + diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java new file mode 100644 index 0000000000..358e4f7b19 --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java @@ -0,0 +1,9 @@ +package com.baeldung.wicket.examples; + +import org.apache.wicket.markup.html.WebPage; + +public class Examples extends WebPage { + + private static final long serialVersionUID = 1L; + +} diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java new file mode 100644 index 0000000000..711e8f01fd --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java @@ -0,0 +1,27 @@ +package com.baeldung.wicket.examples; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.protocol.http.WebApplication; + +import com.baeldung.wicket.examples.cafeaddress.CafeAddress; +import com.baeldung.wicket.examples.helloworld.HelloWorld; + +public class ExamplesApplication extends WebApplication { + /** + * @see org.apache.wicket.Application#getHomePage() + */ + @Override + public Class getHomePage() { + return Examples.class; + } + + /** + * @see org.apache.wicket.Application#init() + */ + @Override + public void init() { + super.init(); + mountPage("/examples/helloworld", HelloWorld.class); + mountPage("/examples/cafes", CafeAddress.class); + } +} diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java new file mode 100644 index 0000000000..1b2d06d2dc --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java @@ -0,0 +1,26 @@ +package com.baeldung.wicket.examples; + +import javax.servlet.FilterRegistration; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import org.apache.wicket.protocol.http.WicketFilter; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +public class WebAppInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext container) throws ServletException { + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + container.addListener(new ContextLoaderListener(context)); + context.register(ApplicationConfiguration.class); + + FilterRegistration filter = container.addFilter("ExamplesApplication", WicketFilter.class); + filter.setInitParameter("applicationClassName", ExamplesApplication.class.getName()); + filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); + filter.addMappingForUrlPatterns(null, false, "/*"); + } + +} \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html new file mode 100644 index 0000000000..b7e0368eaa --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html @@ -0,0 +1,15 @@ + + + + +Cafes + + +
+ +

+ Address: address +

+
+ + diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java new file mode 100644 index 0000000000..ce26c5a1ad --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java @@ -0,0 +1,72 @@ +package com.baeldung.wicket.examples.cafeaddress; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.DropDownChoice; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.request.mapper.parameter.PageParameters; + +public class CafeAddress extends WebPage { + + private static final long serialVersionUID = 1L; + + String selectedCafe; + Address address; + Map cafeNamesAndAddresses = new HashMap<>(); + + public CafeAddress(final PageParameters parameters) { + super(parameters); + initCafes(); + + ArrayList cafeNames = new ArrayList<>(this.cafeNamesAndAddresses.keySet()); + this.selectedCafe = cafeNames.get(0); + this.address = new Address(this.cafeNamesAndAddresses.get(this.selectedCafe).getAddress()); + + final Label addressLabel = new Label("address", new PropertyModel(this.address, "address")); + addressLabel.setOutputMarkupId(true); + + final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel(this, "selectedCafe"), cafeNames); + cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + String name = (String) cafeDropdown.getDefaultModel().getObject(); + address.setAddress(cafeNamesAndAddresses.get(name).getAddress()); + target.add(addressLabel); + } + }); + + add(addressLabel); + add(cafeDropdown); + + } + + private void initCafes() { + this.cafeNamesAndAddresses.put("Linda's Cafe", new Address("35 Bower St.")); + this.cafeNamesAndAddresses.put("Old Tree", new Address("2 Edgware Rd.")); + } + + class Address implements Serializable { + private String sAddress = ""; + + public Address(String address) { + this.sAddress = address; + } + + public String getAddress() { + return this.sAddress; + } + + public void setAddress(String address) { + this.sAddress = address; + } + } +} diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html new file mode 100644 index 0000000000..c56d07fc10 --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html @@ -0,0 +1,5 @@ + + + + + diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java new file mode 100644 index 0000000000..f819e05be6 --- /dev/null +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java @@ -0,0 +1,13 @@ +package com.baeldung.wicket.examples.helloworld; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +public class HelloWorld extends WebPage { + + private static final long serialVersionUID = 1L; + + public HelloWorld() { + add(new Label("hello", "Hello World!")); + } +} diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml new file mode 100644 index 0000000000..9f3256b15c --- /dev/null +++ b/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml new file mode 100644 index 0000000000..58f7d53d2d --- /dev/null +++ b/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + + 30000 + + + + \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml new file mode 100644 index 0000000000..49e558bb47 --- /dev/null +++ b/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml @@ -0,0 +1,36 @@ + + + + + + + + + / + + + + + + SSL_RSA_WITH_DES_CBC_SHA + SSL_DHE_RSA_WITH_DES_CBC_SHA + SSL_DHE_DSS_WITH_DES_CBC_SHA + SSL_RSA_EXPORT_WITH_RC4_40_MD5 + SSL_RSA_EXPORT_WITH_DES40_CBC_SHA + SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA + SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty.xml new file mode 100644 index 0000000000..1a6293b405 --- /dev/null +++ b/wicket-intro/WicketIntro/src/test/jetty/jetty.xml @@ -0,0 +1,23 @@ + + + + + + + + https + + + + 32768 + 8192 + 8192 + true + false + 512 + + + + + + \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/resources/keystore b/wicket-intro/WicketIntro/src/test/resources/keystore new file mode 100644 index 0000000000000000000000000000000000000000..30bbc90ccffcc2745adf09077df16fc3db9c0b47 GIT binary patch literal 1481 zcmezO_TO6u1_mY|W&~r_tkjZ{N+8cDIXV0qP-d4w6Vo;WJ~l3GHbxdkEha%mMpg!v zCZXF+L+yeb(_D>eh5NdK;{zR}$;>(o{ zE3dg|o8B)~5ILLXvtIl5>N#JOOd1Wnqs3o|CH&_3)%k6yk>9%q<*Th*+pP{h`8MfJ zi*YvUmF+Z?t0^x!WMEPBj(9H=gC$Rl(ii9d&)j3 zbTLZUo^$C9pTUfx#bzsWYP%dfFaJ7`%~pJY<=Y|t;J>bqocFORJ8`)y%bsft`MuQV z>{(ffqGR9Jv){6}VE@M8vig|blV9STFXpbA!u05_iEyhlhqkKZ;q9M!rpxs*tJ<*3 zhiWIa`fr}ezEJ&I{ND#6cX8iNm8;zH2RodQ=n#@cCCOr| zTXCYzlEX`7T5ANh+?d0qlI6dJ@sW+nZle@FF~#KRKmX0;w|%=dD0Q*hi_hY5Y{CW4 zrOJiNd#@bdbya1dHCyZRTmE&^ii4i-IJn9!!^(ZV)t=3cyTYEANN&*o!@WvnMVp(G z{s(U^qqZe`enoqQPhO)mduP*#-L_kTKzrv7mI-@Dg3P;OV0 z+>^?;+IITpTAR2zDn5LAd`IV(R$N{5^Homy`Hv1=mC|&FBxtu~Lg@4UcN&B|cVxXe%hnAVv?S=fZxL-Vrp^2_sJA{-bZ z>z> zKgGsI?`g4Czs|(W$iRr~JYW)G2D&RF+G&cYMyt~S#qC>9Yo8yjfwPfwA z__FOSvwctPaoU&=rO7Hf`?L)EoW48GpSg3HG`N>Wh@H&bQ>GZp6P=NEzJCF4QTtMF zyCu^XE;=4q;eAoe&u6Fp<&$m~Ic0x)r`Sfd8H?)QbE`9U3bGFi_@iY1?tkt>-^;Q{1ps`KMkD|L literal 0 HcmV?d00001 From 9b52b7a3ef22cc37122b1b56e375d270393d39a8 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 31 Aug 2016 04:30:51 +0200 Subject: [PATCH 13/56] Deleted individual projects for each example --- wicket-intro/CafeAddress/pom.xml | 156 ------------------ .../cafeaddress/ApplicationConfiguration.java | 10 -- .../examples/cafeaddress/CafeAddress.html | 20 --- .../examples/cafeaddress/CafeAddress.java | 72 -------- .../cafeaddress/CafeAddressApplication.java | 33 ---- .../cafeaddress/WebAppInitializer.java | 26 --- .../CafeAddress/src/main/webapp/logo.png | Bin 12244 -> 0 bytes .../CafeAddress/src/main/webapp/style.css | 68 -------- .../wicket/examples/cafeaddress/Start.java | 100 ----------- .../examples/cafeaddress/TestHomePage.java | 29 ---- .../CafeAddress/src/test/jetty/jetty-http.xml | 38 ----- .../src/test/jetty/jetty-https.xml | 45 ----- .../CafeAddress/src/test/jetty/jetty-ssl.xml | 36 ---- .../CafeAddress/src/test/jetty/jetty.xml | 23 --- .../CafeAddress/src/test/resources/keystore | Bin 1481 -> 0 bytes wicket-intro/HelloWorld/pom.xml | 60 ------- .../helloworld/ApplicationConfiguration.java | 10 -- .../examples/helloworld/HelloWorld.html | 5 - .../examples/helloworld/HelloWorld.java | 10 -- .../helloworld/HelloWorldApplication.java | 22 --- .../helloworld/WebAppInitializer.java | 26 --- 21 files changed, 789 deletions(-) delete mode 100644 wicket-intro/CafeAddress/pom.xml delete mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java delete mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html delete mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java delete mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java delete mode 100644 wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java delete mode 100644 wicket-intro/CafeAddress/src/main/webapp/logo.png delete mode 100644 wicket-intro/CafeAddress/src/main/webapp/style.css delete mode 100644 wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java delete mode 100644 wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java delete mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml delete mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml delete mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml delete mode 100644 wicket-intro/CafeAddress/src/test/jetty/jetty.xml delete mode 100644 wicket-intro/CafeAddress/src/test/resources/keystore delete mode 100644 wicket-intro/HelloWorld/pom.xml delete mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java delete mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html delete mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java delete mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java delete mode 100644 wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java diff --git a/wicket-intro/CafeAddress/pom.xml b/wicket-intro/CafeAddress/pom.xml deleted file mode 100644 index 8fb0fbd05a..0000000000 --- a/wicket-intro/CafeAddress/pom.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - 4.0.0 - com.baeldung.wicket.examples - cafe-address - war - 1.0-SNAPSHOT - CafeAddress - - 7.4.0 - 9.2.13.v20150730 - 2.5 - 4.12 - UTF-8 - none - - - - - org.apache.wicket - wicket-core - ${wicket.version} - - - - - - org.springframework - spring-web - 4.1.1.RELEASE - - - javax.servlet - javax.servlet-api - 3.1.0 - - - org.apache.wicket - wicket-spring - 8.0.0-M1 - - - - - junit - junit - ${junit.version} - test - - - - - org.eclipse.jetty.aggregate - jetty-all - ${jetty9.version} - test - - - - CafeAddress - - - false - src/main/resources - - - false - src/main/java - - ** - - - **/*.java - - - - - - false - src/test/resources - - - false - src/test/java - - ** - - - **/*.java - - - - - - true - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - UTF-8 - true - true - - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - false - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty9.version} - - - - maven.project.build.directory.test-classes - ${project.build.directory}/test-classes - - - ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - true - ${wtp.version} - - - - - - - - Apache Nexus - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - - diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java deleted file mode 100644 index c0e34c6dc1..0000000000 --- a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/ApplicationConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan -public class ApplicationConfiguration { - -} diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html deleted file mode 100644 index 954ff551f1..0000000000 --- a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - -Apache Wicket Quickstart - - - - -
- -

- Address: address -

-
- - diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java deleted file mode 100644 index ce26c5a1ad..0000000000 --- a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.request.mapper.parameter.PageParameters; - -public class CafeAddress extends WebPage { - - private static final long serialVersionUID = 1L; - - String selectedCafe; - Address address; - Map cafeNamesAndAddresses = new HashMap<>(); - - public CafeAddress(final PageParameters parameters) { - super(parameters); - initCafes(); - - ArrayList cafeNames = new ArrayList<>(this.cafeNamesAndAddresses.keySet()); - this.selectedCafe = cafeNames.get(0); - this.address = new Address(this.cafeNamesAndAddresses.get(this.selectedCafe).getAddress()); - - final Label addressLabel = new Label("address", new PropertyModel(this.address, "address")); - addressLabel.setOutputMarkupId(true); - - final DropDownChoice cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel(this, "selectedCafe"), cafeNames); - cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - String name = (String) cafeDropdown.getDefaultModel().getObject(); - address.setAddress(cafeNamesAndAddresses.get(name).getAddress()); - target.add(addressLabel); - } - }); - - add(addressLabel); - add(cafeDropdown); - - } - - private void initCafes() { - this.cafeNamesAndAddresses.put("Linda's Cafe", new Address("35 Bower St.")); - this.cafeNamesAndAddresses.put("Old Tree", new Address("2 Edgware Rd.")); - } - - class Address implements Serializable { - private String sAddress = ""; - - public Address(String address) { - this.sAddress = address; - } - - public String getAddress() { - return this.sAddress; - } - - public void setAddress(String address) { - this.sAddress = address; - } - } -} diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java deleted file mode 100644 index 189ef14558..0000000000 --- a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddressApplication.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.protocol.http.WebApplication; - -/** - * Application object for your web application. - * If you want to run this application without deploying, run the Start class. - * - * @see com.baeldung.wicket.examples.Start#main(String[]) - */ -public class CafeAddressApplication extends WebApplication -{ - /** - * @see org.apache.wicket.Application#getHomePage() - */ - @Override - public Class getHomePage() - { - return CafeAddress.class; - } - - /** - * @see org.apache.wicket.Application#init() - */ - @Override - public void init() - { - super.init(); - - // add your configuration here - } -} diff --git a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java b/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java deleted file mode 100644 index f1465e05b9..0000000000 --- a/wicket-intro/CafeAddress/src/main/java/com/baeldung/wicket/examples/cafeaddress/WebAppInitializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import org.apache.wicket.protocol.http.WicketFilter; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - -public class WebAppInitializer implements WebApplicationInitializer { - - @Override - public void onStartup(ServletContext container) throws ServletException { - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - container.addListener(new ContextLoaderListener(context)); - context.register(ApplicationConfiguration.class); - - FilterRegistration filter = container.addFilter("CafeAddressApplication", WicketFilter.class); - filter.setInitParameter("applicationClassName", CafeAddressApplication.class.getName()); - filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); - filter.addMappingForUrlPatterns(null, false, "/*"); - } - -} \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/main/webapp/logo.png b/wicket-intro/CafeAddress/src/main/webapp/logo.png deleted file mode 100644 index 39ec54854b748ab6aeb6b3965d88f452772d7d8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12244 zcmV;_FDuZAP)4Tx0C)j~RL^S@K@|QrZmG~B2wH0nvUrdpNm;9CMbtL^5n^i$+aIn^?(HA4aZWV5ov6ELTdbo0FI&wK{O>*+w4vx20?>!`FrQsdJlnHR>OPy zcd~b_n$otK2Za4V;76L-DzNVtaSB-y0*E}{p()372;bw_^6ZZ}PI-92wGS&j#91PI zKs7DSe@(bk%_Y-7gGe}(^>I=@oY#w#*Bu9GZf3^F5WP>3rn}7Ut74&?PWBFvy`A)a zPP5)V!Xd&78LdA?xQ(9mjMYElVd13a#D+Z_7&Y|xU=_C-srWU*6kiZcC!$nw*)9$7 zn6CX+@=AhmkT}X@VSsa5NKe;HZuq)~1$`#h6R+ZTR#D-3j}vF!)ZOnz+5)dI4jl{{ z44Mr{P!L4~VVJN`K!!XTF*LGrKO?IK8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ted file mode 100644 index fc137cadb0..0000000000 --- a/wicket-intro/CafeAddress/src/main/webapp/style.css +++ /dev/null @@ -1,68 +0,0 @@ -body, p, li, a { font-family: georgia, times, serif;font-size:13pt;} -h1, h2, h3 { font-family: 'Yanone Kaffeesatz', arial, serif; } -body { margin:0;padding:0;} -#hd { - width : 100%; - height : 87px; - background-color : #092E67; - margin-top : 0; - padding-top : 10px; - border-bottom : 1px solid #888; - z-index : 0; -} -#ft { - position : absolute; - bottom : 0; - width : 100%; - height : 99px; - background-color : #6493D2; - border-top : 1px solid #888; - z-index : 0; -} -#logo,#bd { - width : 650px; - margin: 0 auto; - padding: 25px 50px 0 50px; -} -#logo h1 { - color : white; - font-size:36pt; - display: inline; -} -#logo img { - display:inline; - vertical-align: bottom; - margin-left : 50px; - margin-right : 5px; -} -body { margin-top : 0; padding-top : 0;} -#logo, #logo h1 { margin-top : 0; padding-top : 0;} -#bd { - position : absolute; - top : 75px; - bottom : 75px; - left : 50%; - margin-left : -325px; - z-index : 1; - overflow: auto; - background-color : #fff; - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - border-radius: 10px; - -moz-box-shadow: 0px 0px 10px #888; - -webkit-box-shadow: 0px 0px 10px #888; - box-shadow: 0px 0px 10px #888; -} -a, a:visited, a:hover, a:active { - color : #6493D2; -} -h2 { - padding : 0; margin:0; - font-size:36pt; - color:#FF5500; -} -h3 { - padding : 0; margin:0; - font-size:24pt; - color:#092E67; -} \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java deleted file mode 100644 index bb67ac56a5..0000000000 --- a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/Start.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import java.lang.management.ManagementFactory; - -import javax.management.MBeanServer; - -import org.eclipse.jetty.jmx.MBeanContainer; -import org.eclipse.jetty.server.HttpConfiguration; -import org.eclipse.jetty.server.HttpConnectionFactory; -import org.eclipse.jetty.server.SecureRequestCustomizer; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.webapp.WebAppContext; - -/** - * Separate startup class for people that want to run the examples directly. Use parameter - * -Dcom.sun.management.jmxremote to startup JMX (and e.g. connect with jconsole). - */ -public class Start { - /** - * Main function, starts the jetty server. - * - * @param args - */ - public static void main(String[] args) { - System.setProperty("wicket.configuration", "development"); - - Server server = new Server(); - - HttpConfiguration http_config = new HttpConfiguration(); - http_config.setSecureScheme("https"); - http_config.setSecurePort(8443); - http_config.setOutputBufferSize(32768); - - ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config)); - http.setPort(8080); - http.setIdleTimeout(1000 * 60 * 60); - - server.addConnector(http); - - Resource keystore = Resource.newClassPathResource("/keystore"); - if (keystore != null && keystore.exists()) { - // if a keystore for a SSL certificate is available, start a SSL - // connector on port 8443. - // By default, the quickstart comes with a Apache Wicket Quickstart - // Certificate that expires about half way september 2021. Do not - // use this certificate anywhere important as the passwords are - // available in the source. - - SslContextFactory sslContextFactory = new SslContextFactory(); - sslContextFactory.setKeyStoreResource(keystore); - sslContextFactory.setKeyStorePassword("wicket"); - sslContextFactory.setKeyManagerPassword("wicket"); - - HttpConfiguration https_config = new HttpConfiguration(http_config); - https_config.addCustomizer(new SecureRequestCustomizer()); - - ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); - https.setPort(8443); - https.setIdleTimeout(500000); - - server.addConnector(https); - System.out.println("SSL access to the examples has been enabled on port 8443"); - System.out.println("You can access the application using SSL on https://localhost:8443"); - System.out.println(); - } - - WebAppContext bb = new WebAppContext(); - bb.setServer(server); - bb.setContextPath("/"); - bb.setWar("src/main/webapp"); - - // uncomment the next two lines if you want to start Jetty with WebSocket (JSR-356) support - // you need org.apache.wicket:wicket-native-websocket-javax in the classpath! - // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); - // serverContainer.addEndpoint(new WicketServerEndpointConfig()); - - // uncomment next line if you want to test with JSESSIONID encoded in the urls - // ((AbstractSessionManager) - // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); - - server.setHandler(bb); - - MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); - server.addEventListener(mBeanContainer); - server.addBean(mBeanContainer); - - try { - server.start(); - server.join(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(100); - } - } -} diff --git a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java b/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java deleted file mode 100644 index 9b186ce52b..0000000000 --- a/wicket-intro/CafeAddress/src/test/java/com/baeldung/wicket/examples/cafeaddress/TestHomePage.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.wicket.examples.cafeaddress; - -import org.apache.wicket.util.tester.WicketTester; -import org.junit.Before; -import org.junit.Test; - -/** - * Simple test using the WicketTester - */ -public class TestHomePage -{ - private WicketTester tester; - - @Before - public void setUp() - { - tester = new WicketTester(new CafeAddressApplication()); - } - - @Test - public void homepageRendersSuccessfully() - { - //start and render the test page - tester.startPage(CafeAddress.class); - - //assert rendered page class - tester.assertRenderedPage(CafeAddress.class); - } -} diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml deleted file mode 100644 index 9f3256b15c..0000000000 --- a/wicket-intro/CafeAddress/src/test/jetty/jetty-http.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml deleted file mode 100644 index 58f7d53d2d..0000000000 --- a/wicket-intro/CafeAddress/src/test/jetty/jetty-https.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - http/1.1 - - - - - - - - - - - - - 30000 - - - - \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml deleted file mode 100644 index 49e558bb47..0000000000 --- a/wicket-intro/CafeAddress/src/test/jetty/jetty-ssl.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - / - - - - - - SSL_RSA_WITH_DES_CBC_SHA - SSL_DHE_RSA_WITH_DES_CBC_SHA - SSL_DHE_DSS_WITH_DES_CBC_SHA - SSL_RSA_EXPORT_WITH_RC4_40_MD5 - SSL_RSA_EXPORT_WITH_DES40_CBC_SHA - SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA - SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/jetty/jetty.xml b/wicket-intro/CafeAddress/src/test/jetty/jetty.xml deleted file mode 100644 index 1a6293b405..0000000000 --- a/wicket-intro/CafeAddress/src/test/jetty/jetty.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - https - - - - 32768 - 8192 - 8192 - true - false - 512 - - - - - - \ No newline at end of file diff --git a/wicket-intro/CafeAddress/src/test/resources/keystore b/wicket-intro/CafeAddress/src/test/resources/keystore deleted file mode 100644 index 30bbc90ccffcc2745adf09077df16fc3db9c0b47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1481 zcmezO_TO6u1_mY|W&~r_tkjZ{N+8cDIXV0qP-d4w6Vo;WJ~l3GHbxdkEha%mMpg!v zCZXF+L+yeb(_D>eh5NdK;{zR}$;>(o{ zE3dg|o8B)~5ILLXvtIl5>N#JOOd1Wnqs3o|CH&_3)%k6yk>9%q<*Th*+pP{h`8MfJ zi*YvUmF+Z?t0^x!WMEPBj(9H=gC$Rl(ii9d&)j3 zbTLZUo^$C9pTUfx#bzsWYP%dfFaJ7`%~pJY<=Y|t;J>bqocFORJ8`)y%bsft`MuQV z>{(ffqGR9Jv){6}VE@M8vig|blV9STFXpbA!u05_iEyhlhqkKZ;q9M!rpxs*tJ<*3 zhiWIa`fr}ezEJ&I{ND#6cX8iNm8;zH2RodQ=n#@cCCOr| zTXCYzlEX`7T5ANh+?d0qlI6dJ@sW+nZle@FF~#KRKmX0;w|%=dD0Q*hi_hY5Y{CW4 zrOJiNd#@bdbya1dHCyZRTmE&^ii4i-IJn9!!^(ZV)t=3cyTYEANN&*o!@WvnMVp(G z{s(U^qqZe`enoqQPhO)mduP*#-L_kTKzrv7mI-@Dg3P;OV0 z+>^?;+IITpTAR2zDn5LAd`IV(R$N{5^Homy`Hv1=mC|&FBxtu~Lg@4UcN&B|cVxXe%hnAVv?S=fZxL-Vrp^2_sJA{-bZ z>z> zKgGsI?`g4Czs|(W$iRr~JYW)G2D&RF+G&cYMyt~S#qC>9Yo8yjfwPfwA z__FOSvwctPaoU&=rO7Hf`?L)EoW48GpSg3HG`N>Wh@H&bQ>GZp6P=NEzJCF4QTtMF zyCu^XE;=4q;eAoe&u6Fp<&$m~Ic0x)r`Sfd8H?)QbE`9U3bGFi_@iY1?tkt>-^;Q{1ps`KMkD|L diff --git a/wicket-intro/HelloWorld/pom.xml b/wicket-intro/HelloWorld/pom.xml deleted file mode 100644 index 2aff59dd93..0000000000 --- a/wicket-intro/HelloWorld/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - 4.0.0 - com.baeldung.wicket.examples - hello-world - war - 1.0-SNAPSHOT - HelloWorld - - - junit - junit - 3.8.1 - test - - - org.apache.wicket - wicket-core - 8.0.0-M1 - - - org.springframework - spring-web - 4.1.1.RELEASE - - - javax.servlet - javax.servlet-api - 3.1.0 - - - org.apache.wicket - wicket-spring - 8.0.0-M1 - - - - HelloWorld - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - false - - - - - diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java deleted file mode 100644 index f9de7adb2a..0000000000 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/ApplicationConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.wicket.examples.helloworld; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan -public class ApplicationConfiguration { - -} diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html deleted file mode 100644 index c56d07fc10..0000000000 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java deleted file mode 100644 index 6dc7295798..0000000000 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.wicket.examples.helloworld; - -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; - -public class HelloWorld extends WebPage { - public HelloWorld() { - add(new Label("hello", "Hello World!")); - } -} diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java deleted file mode 100644 index 64bfcadd29..0000000000 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorldApplication.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.baeldung.wicket.examples.helloworld; - -import org.apache.wicket.Page; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.spring.injection.annot.SpringComponentInjector; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -public class HelloWorldApplication extends WebApplication { - @Override - public Class getHomePage() { - return HelloWorld.class; - } - - @Override - public void init() { - super.init(); - getComponentInstantiationListeners().add(new SpringComponentInjector(this)); - } - -} diff --git a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java b/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java deleted file mode 100644 index 362502e264..0000000000 --- a/wicket-intro/HelloWorld/src/main/java/com/baeldung/wicket/examples/helloworld/WebAppInitializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.wicket.examples.helloworld; - -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import org.apache.wicket.protocol.http.WicketFilter; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - -public class WebAppInitializer implements WebApplicationInitializer { - - @Override - public void onStartup(ServletContext container) throws ServletException { - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - container.addListener(new ContextLoaderListener(context)); - context.register(ApplicationConfiguration.class); - - FilterRegistration filter = container.addFilter("HelloWorldApplication", WicketFilter.class); - filter.setInitParameter("applicationClassName", HelloWorldApplication.class.getName()); - filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); - filter.addMappingForUrlPatterns(null, false, "/*"); - } - -} \ No newline at end of file From cfebd40b429bc59f2451f47f0367079628b8f614 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 31 Aug 2016 05:04:15 +0200 Subject: [PATCH 14/56] proper formatting --- wicket-intro/WicketIntro/pom.xml | 261 +++++++++--------- .../baeldung/wicket/examples/Examples.html | 62 ++--- .../examples/cafeaddress/CafeAddress.html | 12 +- 3 files changed, 167 insertions(+), 168 deletions(-) diff --git a/wicket-intro/WicketIntro/pom.xml b/wicket-intro/WicketIntro/pom.xml index 9b759eb1be..c6a1a4985d 100644 --- a/wicket-intro/WicketIntro/pom.xml +++ b/wicket-intro/WicketIntro/pom.xml @@ -1,136 +1,135 @@ - + - 4.0.0 - com.baeldung.wicket.examples - wicket-intro - war - 1.0-SNAPSHOT - WicketIntro - - 7.4.0 - 9.2.13.v20150730 - 2.5 - 4.12 - 4.1.1.RELEASE - 3.1.0 - 8.0.0-M1 - 3.5.1 - 2.6 - UTF-8 - none - - - - - org.apache.wicket - wicket-core - ${wicket.version} - - - - - - org.springframework - spring-web - ${spring-web.version} - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - - - org.apache.wicket - wicket-spring - ${wicket-spring.version} - + 4.0.0 + com.baeldung.wicket.examples + wicket-intro + war + 1.0-SNAPSHOT + WicketIntro + + 7.4.0 + 9.2.13.v20150730 + 2.5 + 4.12 + 4.1.1.RELEASE + 3.1.0 + 8.0.0-M1 + 3.5.1 + 2.6 + UTF-8 + none + + + + + org.apache.wicket + wicket-core + ${wicket.version} + - - - junit - junit - ${junit.version} - test - + - - - org.eclipse.jetty.aggregate - jetty-all - ${jetty9.version} - test - - - - WicketIntro - - - false - src/main/resources - - - false - src/main/java - - ** - - - **/*.java - - - - - - true - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - UTF-8 - true - true - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - false - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty9.version} - - - - maven.project.build.directory.test-classes - ${project.build.directory}/test-classes - - - ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml - - - - + + org.springframework + spring-web + ${spring-web.version} + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + + + org.apache.wicket + wicket-spring + ${wicket-spring.version} + - - - Apache Nexus - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - - + + + junit + junit + ${junit.version} + test + + + + + org.eclipse.jetty.aggregate + jetty-all + ${jetty9.version} + test + + + + WicketIntro + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + UTF-8 + true + true + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty9.version} + + + + maven.project.build.directory.test-classes + ${project.build.directory}/test-classes + + + ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml + + + + + + + + Apache Nexus + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html index 38eebbffe0..497e98e01a 100644 --- a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html @@ -6,47 +6,47 @@ -
-
-
-

Wicket Introduction Examples:

- - Hello World! -
-
- Cafes -
-
-
-
+
+
+
+

Wicket Introduction Examples:

+ + Hello World! +
+
+ Cafes +
+
+
+
diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html index b7e0368eaa..c5ada2323d 100644 --- a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html +++ b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html @@ -5,11 +5,11 @@ Cafes -
- -

- Address: address -

-
+
+ +

+ Address: address +

+
From b8eb2a799a89c410a74b2f9943e184d57d76365b Mon Sep 17 00:00:00 2001 From: diego Date: Thu, 1 Sep 2016 23:50:24 +0200 Subject: [PATCH 15/56] Removed unnecessary configuration. --- wicket-intro/WicketIntro/pom.xml | 9 ---- .../WicketIntro/src/test/jetty/jetty-http.xml | 38 --------------- .../src/test/jetty/jetty-https.xml | 45 ------------------ .../WicketIntro/src/test/jetty/jetty-ssl.xml | 36 -------------- .../WicketIntro/src/test/jetty/jetty.xml | 23 --------- .../WicketIntro/src/test/resources/keystore | Bin 1481 -> 0 bytes 6 files changed, 151 deletions(-) delete mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml delete mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml delete mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml delete mode 100644 wicket-intro/WicketIntro/src/test/jetty/jetty.xml delete mode 100644 wicket-intro/WicketIntro/src/test/resources/keystore diff --git a/wicket-intro/WicketIntro/pom.xml b/wicket-intro/WicketIntro/pom.xml index c6a1a4985d..f4b1d0e11c 100644 --- a/wicket-intro/WicketIntro/pom.xml +++ b/wicket-intro/WicketIntro/pom.xml @@ -107,15 +107,6 @@ org.eclipse.jetty jetty-maven-plugin ${jetty9.version} - - - - maven.project.build.directory.test-classes - ${project.build.directory}/test-classes - - - ${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml - diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml deleted file mode 100644 index 9f3256b15c..0000000000 --- a/wicket-intro/WicketIntro/src/test/jetty/jetty-http.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml deleted file mode 100644 index 58f7d53d2d..0000000000 --- a/wicket-intro/WicketIntro/src/test/jetty/jetty-https.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - http/1.1 - - - - - - - - - - - - - 30000 - - - - \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml deleted file mode 100644 index 49e558bb47..0000000000 --- a/wicket-intro/WicketIntro/src/test/jetty/jetty-ssl.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - / - - - - - - SSL_RSA_WITH_DES_CBC_SHA - SSL_DHE_RSA_WITH_DES_CBC_SHA - SSL_DHE_DSS_WITH_DES_CBC_SHA - SSL_RSA_EXPORT_WITH_RC4_40_MD5 - SSL_RSA_EXPORT_WITH_DES40_CBC_SHA - SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA - SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/jetty/jetty.xml b/wicket-intro/WicketIntro/src/test/jetty/jetty.xml deleted file mode 100644 index 1a6293b405..0000000000 --- a/wicket-intro/WicketIntro/src/test/jetty/jetty.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - https - - - - 32768 - 8192 - 8192 - true - false - 512 - - - - - - \ No newline at end of file diff --git a/wicket-intro/WicketIntro/src/test/resources/keystore b/wicket-intro/WicketIntro/src/test/resources/keystore deleted file mode 100644 index 30bbc90ccffcc2745adf09077df16fc3db9c0b47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1481 zcmezO_TO6u1_mY|W&~r_tkjZ{N+8cDIXV0qP-d4w6Vo;WJ~l3GHbxdkEha%mMpg!v zCZXF+L+yeb(_D>eh5NdK;{zR}$;>(o{ zE3dg|o8B)~5ILLXvtIl5>N#JOOd1Wnqs3o|CH&_3)%k6yk>9%q<*Th*+pP{h`8MfJ zi*YvUmF+Z?t0^x!WMEPBj(9H=gC$Rl(ii9d&)j3 zbTLZUo^$C9pTUfx#bzsWYP%dfFaJ7`%~pJY<=Y|t;J>bqocFORJ8`)y%bsft`MuQV z>{(ffqGR9Jv){6}VE@M8vig|blV9STFXpbA!u05_iEyhlhqkKZ;q9M!rpxs*tJ<*3 zhiWIa`fr}ezEJ&I{ND#6cX8iNm8;zH2RodQ=n#@cCCOr| zTXCYzlEX`7T5ANh+?d0qlI6dJ@sW+nZle@FF~#KRKmX0;w|%=dD0Q*hi_hY5Y{CW4 zrOJiNd#@bdbya1dHCyZRTmE&^ii4i-IJn9!!^(ZV)t=3cyTYEANN&*o!@WvnMVp(G z{s(U^qqZe`enoqQPhO)mduP*#-L_kTKzrv7mI-@Dg3P;OV0 z+>^?;+IITpTAR2zDn5LAd`IV(R$N{5^Homy`Hv1=mC|&FBxtu~Lg@4UcN&B|cVxXe%hnAVv?S=fZxL-Vrp^2_sJA{-bZ z>z> zKgGsI?`g4Czs|(W$iRr~JYW)G2D&RF+G&cYMyt~S#qC>9Yo8yjfwPfwA z__FOSvwctPaoU&=rO7Hf`?L)EoW48GpSg3HG`N>Wh@H&bQ>GZp6P=NEzJCF4QTtMF zyCu^XE;=4q;eAoe&u6Fp<&$m~Ic0x)r`Sfd8H?)QbE`9U3bGFi_@iY1?tkt>-^;Q{1ps`KMkD|L From 1665013fc0199603f77f2c3e199c05a7f6816b40 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Thu, 1 Sep 2016 23:33:43 -0600 Subject: [PATCH 16/56] BAEL-312 Adding the config clients' properties files so that they are accessible in git. This is currently on my git account and will need to be switched to eugen's after the pull request has completed. --- spring-cloud/pom.xml | 1 + .../application-config/discovery.properties | 13 ++++ .../application-config/gateway.properties | 15 +++++ spring-cloud/spring-cloud-integration/pom.xml | 61 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 spring-cloud/spring-cloud-integration/application-config/discovery.properties create mode 100644 spring-cloud/spring-cloud-integration/application-config/gateway.properties create mode 100644 spring-cloud/spring-cloud-integration/pom.xml diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index 4f6b37a76f..340923cbdf 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -10,6 +10,7 @@ spring-cloud-config spring-cloud-eureka spring-cloud-hystrix + spring-cloud-integration pom diff --git a/spring-cloud/spring-cloud-integration/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/application-config/discovery.properties new file mode 100644 index 0000000000..40764d0ddb --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/discovery.properties @@ -0,0 +1,13 @@ +spring.application.name=discovery +server.port=8082 + +eureka.instance.hostname=localhost + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ +eureka.client.register-with-eureka=false +eureka.client.fetch-registry=false + +#management.context-path=/manage +#eureka.instance.status-page-url-path=${management.context-path}/info +#eureka.instance.health-check-url-path=${management.context-path}/health + diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/application-config/gateway.properties new file mode 100644 index 0000000000..308f6ace6c --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/gateway.properties @@ -0,0 +1,15 @@ +spring.application.name=gateway +server.port=8084 + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ + +#management.context-path=/manage +#eureka.instance.status-page-url-path=${management.context-path}/info +#eureka.instance.health-check-url-path=${management.context-path}/health + +zuul.routes.ui.path=/resource/** + +logging.level.org.springframework.cloud.netflix.zuul=debug + diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml new file mode 100644 index 0000000000..5417e83cbf --- /dev/null +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + pom + + + config + discovery + gateway + resource + + + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + org.springframework.data + spring-data-releasetrain + Hopper-SR2 + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file From e04b2adce9d7e60d6d90d012e87332581477a9a8 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Fri, 2 Sep 2016 00:30:14 -0600 Subject: [PATCH 17/56] BAEL-312 Committing the 4 projects for the first article. --- .../spring-cloud-integration/config/pom.xml | 27 ++++++++++++++++ .../integration/config/ConfigApplication.java | 15 +++++++++ .../src/main/resources/application.properties | 8 +++++ .../discovery/pom.xml | 28 ++++++++++++++++ .../discovery/DiscoveryApplication.java | 13 ++++++++ .../src/main/resources/bootstrap.properties | 2 ++ .../spring-cloud-integration/gateway/pom.xml | 32 +++++++++++++++++++ .../resource/GatewayApplication.java | 15 +++++++++ .../src/main/resources/bootstrap.properties | 5 +++ .../spring-cloud-integration/resource/pom.xml | 31 ++++++++++++++++++ .../resource/ResourceApplication.java | 25 +++++++++++++++ .../src/main/resources/bootstrap.properties | 5 +++ 12 files changed, 206 insertions(+) create mode 100644 spring-cloud/spring-cloud-integration/config/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java create mode 100644 spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties create mode 100644 spring-cloud/spring-cloud-integration/discovery/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java create mode 100644 spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties create mode 100644 spring-cloud/spring-cloud-integration/gateway/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java create mode 100644 spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties create mode 100644 spring-cloud/spring-cloud-integration/resource/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java create mode 100644 spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/config/pom.xml b/spring-cloud/spring-cloud-integration/config/pom.xml new file mode 100644 index 0000000000..b186a1d5ca --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + config + 1.0.0-SNAPSHOT + + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java b/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java new file mode 100644 index 0000000000..ff6c093b8b --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud.integration.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; + +@SpringBootApplication +@EnableConfigServer +@EnableEurekaClient +public class ConfigApplication { + public static void main(String[] args) { + SpringApplication.run(ConfigApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties new file mode 100644 index 0000000000..e3dd94c386 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties @@ -0,0 +1,8 @@ +server.port=8081 +spring.application.name=config + +spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/application-config + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/discovery/pom.xml b/spring-cloud/spring-cloud-integration/discovery/pom.xml new file mode 100644 index 0000000000..c827895547 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + discovery + 1.0.0-SNAPSHOT + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka-server + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java b/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java new file mode 100644 index 0000000000..a21c65312f --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.spring.cloud.integration.discovery; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@SpringBootApplication +@EnableEurekaServer +public class DiscoveryApplication { + public static void main(String[] args) { + SpringApplication.run(DiscoveryApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..ca9d59c9ed --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties @@ -0,0 +1,2 @@ +spring.cloud.config.name=discovery +spring.cloud.config.uri=http://localhost:8081 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/gateway/pom.xml b/spring-cloud/spring-cloud-integration/gateway/pom.xml new file mode 100644 index 0000000000..5e2db3a7af --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + gateway + 1.0.0-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.cloud + spring-cloud-starter-zuul + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java b/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java new file mode 100644 index 0000000000..66e7c36f2a --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud.integration.resource; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +@SpringBootApplication +@EnableZuulProxy +@EnableEurekaClient +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..9610d72675 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties @@ -0,0 +1,5 @@ +spring.cloud.config.name=gateway +spring.cloud.config.discovery.service-id=config +spring.cloud.config.discovery.enabled=true + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/pom.xml b/spring-cloud/spring-cloud-integration/resource/pom.xml new file mode 100644 index 0000000000..1b109022f4 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + resource + 1.0.0-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.boot + spring-boot-starter-web + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java b/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java new file mode 100644 index 0000000000..107a9d199f --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.cloud.integration.resource; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@EnableEurekaClient +@RestController +public class ResourceApplication { + public static void main(String[] args) { + SpringApplication.run(ResourceApplication.class, args); + } + + @Value("${resource.returnString}") + private String returnString; + + @RequestMapping("/hello/cloud") + public String getString() { + return returnString; + } +} diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..3c88a0b520 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties @@ -0,0 +1,5 @@ +spring.cloud.config.name=resource +spring.cloud.config.discovery.service-id=config +spring.cloud.config.discovery.enabled=true + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ \ No newline at end of file From ed1c7598dd750695dd71ecb0d5b8ea22cc299806 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Fri, 2 Sep 2016 00:32:12 -0600 Subject: [PATCH 18/56] BAEL-312 Adding the resource files that will need to be in a separate git repository. --- .../application-config/gateway.properties | 9 +++------ .../application-config/resource.properties | 8 ++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 spring-cloud/spring-cloud-integration/application-config/resource.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/application-config/gateway.properties index 308f6ace6c..8385c2c395 100644 --- a/spring-cloud/spring-cloud-integration/application-config/gateway.properties +++ b/spring-cloud/spring-cloud-integration/application-config/gateway.properties @@ -1,15 +1,12 @@ spring.application.name=gateway -server.port=8084 +server.port=8080 eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ -#management.context-path=/manage -#eureka.instance.status-page-url-path=${management.context-path}/info -#eureka.instance.health-check-url-path=${management.context-path}/health - -zuul.routes.ui.path=/resource/** +zuul.routes.resource.path=/resource/** +hystrix.command.resource.execution.isolation.thread.timeoutInMilliseconds: 5000 logging.level.org.springframework.cloud.netflix.zuul=debug diff --git a/spring-cloud/spring-cloud-integration/application-config/resource.properties b/spring-cloud/spring-cloud-integration/application-config/resource.properties new file mode 100644 index 0000000000..4e6cf3817c --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/resource.properties @@ -0,0 +1,8 @@ +spring.application.name=resource +server.port=8083 + +resource.returnString=hello cloud + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ From 5a3e078ae13038f97abc2ab904d8293b5d99f5ea Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Sat, 3 Sep 2016 22:10:22 -0600 Subject: [PATCH 19/56] BAEL-314 moving the project into a sub module to better organizae the article projects. --- .../application-config/discovery.properties | 0 .../application-config/gateway.properties | 0 .../application-config/resource.properties | 0 .../{ => part-1}/config/pom.xml | 2 +- .../integration/config/ConfigApplication.java | 0 .../src/main/resources/application.properties | 2 +- .../{ => part-1}/discovery/pom.xml | 2 +- .../discovery/DiscoveryApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 .../{ => part-1}/gateway/pom.xml | 2 +- .../resource/GatewayApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 .../spring-cloud-integration/part-1/pom.xml | 25 +++++++++++++++++++ .../{ => part-1}/resource/pom.xml | 2 +- .../resource/ResourceApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 spring-cloud/spring-cloud-integration/pom.xml | 12 +-------- 17 files changed, 31 insertions(+), 16 deletions(-) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/discovery.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/gateway.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/resource.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/pom.xml (92%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/src/main/resources/application.properties (78%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/src/main/resources/bootstrap.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/src/main/resources/bootstrap.properties (100%) create mode 100644 spring-cloud/spring-cloud-integration/part-1/pom.xml rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/src/main/resources/bootstrap.properties (100%) diff --git a/spring-cloud/spring-cloud-integration/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/discovery.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/gateway.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/resource.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/resource.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties diff --git a/spring-cloud/spring-cloud-integration/config/pom.xml b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml similarity index 92% rename from spring-cloud/spring-cloud-integration/config/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/config/pom.xml index b186a1d5ca..c64b3626b1 100644 --- a/spring-cloud/spring-cloud-integration/config/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java b/spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java rename to spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java diff --git a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties similarity index 78% rename from spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties rename to spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties index e3dd94c386..249ee471a6 100644 --- a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties @@ -1,7 +1,7 @@ server.port=8081 spring.application.name=config -spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/application-config +spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/part-1/application-config eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 diff --git a/spring-cloud/spring-cloud-integration/discovery/pom.xml b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/discovery/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml index c827895547..6fe5d807f8 100644 --- a/spring-cloud/spring-cloud-integration/discovery/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java rename to spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/gateway/pom.xml b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/gateway/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml index 5e2db3a7af..40f1884004 100644 --- a/spring-cloud/spring-cloud-integration/gateway/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java rename to spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/part-1/pom.xml b/spring-cloud/spring-cloud-integration/part-1/pom.xml new file mode 100644 index 0000000000..770e26bca2 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/part-1/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + + config + discovery + gateway + resource + + + part-1 + 1.0.0-SNAPSHOT + pom + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/pom.xml b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/resource/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/resource/pom.xml index 1b109022f4..f1a17918ef 100644 --- a/spring-cloud/spring-cloud-integration/resource/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java rename to spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml index 5417e83cbf..922875df14 100644 --- a/spring-cloud/spring-cloud-integration/pom.xml +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -10,10 +10,7 @@ pom - config - discovery - gateway - resource + part-1 @@ -40,13 +37,6 @@ pom import - - org.springframework.data - spring-data-releasetrain - Hopper-SR2 - pom - import - From 11f7c80a75780e0c3e2f6c7b02783d55607e1c1b Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Sat, 3 Sep 2016 22:55:42 -0600 Subject: [PATCH 20/56] BAEL-314 modifying the config application properties so that it points to a generic file location. --- .../part-1/config/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties index 249ee471a6..6f614d0690 100644 --- a/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties @@ -1,7 +1,7 @@ server.port=8081 spring.application.name=config -spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/part-1/application-config +spring.cloud.config.server.git.uri=file:///${user.home}/application-config eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 From 0b5184a358e1d94097dc9c956ed1a4febe6ad9c1 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Mon, 5 Sep 2016 17:40:29 -0600 Subject: [PATCH 21/56] BAEL-314 adding changes to the POM structure so that each project can run in isolation --- .../application-config/discovery.properties | 5 --- .../application-config/gateway.properties | 2 - .../part-1/config/pom.xml | 41 +++++++++++++++---- .../part-1/discovery/pom.xml | 41 +++++++++++++++---- .../part-1/gateway/pom.xml | 39 ++++++++++++++---- .../part-1/resource/pom.xml | 40 ++++++++++++++---- spring-cloud/spring-cloud-integration/pom.xml | 36 ---------------- 7 files changed, 132 insertions(+), 72 deletions(-) diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties index 40764d0ddb..7f3df86c7e 100644 --- a/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties +++ b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties @@ -6,8 +6,3 @@ eureka.instance.hostname=localhost eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ eureka.client.register-with-eureka=false eureka.client.fetch-registry=false - -#management.context-path=/manage -#eureka.instance.status-page-url-path=${management.context-path}/info -#eureka.instance.health-check-url-path=${management.context-path}/health - diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties index 8385c2c395..77faec8421 100644 --- a/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties +++ b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties @@ -8,5 +8,3 @@ eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ zuul.routes.resource.path=/resource/** hystrix.command.resource.execution.isolation.thread.timeoutInMilliseconds: 5000 -logging.level.org.springframework.cloud.netflix.zuul=debug - diff --git a/spring-cloud/spring-cloud-integration/part-1/config/pom.xml b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml index c64b3626b1..0cb217acfb 100644 --- a/spring-cloud/spring-cloud-integration/part-1/config/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml @@ -4,17 +4,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - config 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + - org.springframework.cloud spring-cloud-config-server @@ -23,5 +23,32 @@ org.springframework.cloud spring-cloud-starter-eureka + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml index 6fe5d807f8..ee7c589549 100644 --- a/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml @@ -4,17 +4,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - discovery 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + - org.springframework.cloud spring-cloud-starter-config @@ -23,6 +23,31 @@ org.springframework.cloud spring-cloud-starter-eureka-server + + org.springframework.boot + spring-boot-starter-test + test + - + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml index 40f1884004..8e56d0fd35 100644 --- a/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml @@ -4,15 +4,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - gateway 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + org.springframework.cloud @@ -26,7 +27,31 @@ org.springframework.cloud spring-cloud-starter-zuul + + org.springframework.boot + spring-boot-starter-test + test + - + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml index f1a17918ef..78112fa3e0 100644 --- a/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml @@ -4,15 +4,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - resource 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + org.springframework.cloud @@ -26,6 +27,31 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-test + test + - + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml index 922875df14..1d56995009 100644 --- a/spring-cloud/spring-cloud-integration/pom.xml +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -12,40 +12,4 @@ part-1 - - - org.springframework.boot - spring-boot-starter-parent - 1.4.0.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Brixton.RELEASE - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - \ No newline at end of file From 73fde40da0b9db4fd20c5327814a3dfa1e77d94f Mon Sep 17 00:00:00 2001 From: sanketmeghani Date: Mon, 12 Sep 2016 22:52:53 +0530 Subject: [PATCH 22/56] Adding version number for maven compiler plugin --- flyway-migration/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/flyway-migration/pom.xml b/flyway-migration/pom.xml index e3e29cd43f..6e9d683a0e 100644 --- a/flyway-migration/pom.xml +++ b/flyway-migration/pom.xml @@ -23,6 +23,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.5.1 1.8 1.8 From 3d66a5f28a04a05be41f184d8b62a33b4066b753 Mon Sep 17 00:00:00 2001 From: sanketmeghani Date: Mon, 12 Sep 2016 22:53:09 +0530 Subject: [PATCH 23/56] Adding second migration for department table --- .../db/migration/V2_0__create_department_schema.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 flyway-migration/db/migration/V2_0__create_department_schema.sql diff --git a/flyway-migration/db/migration/V2_0__create_department_schema.sql b/flyway-migration/db/migration/V2_0__create_department_schema.sql new file mode 100644 index 0000000000..2b9d3364a5 --- /dev/null +++ b/flyway-migration/db/migration/V2_0__create_department_schema.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS `department` ( + +`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, +`name` varchar(20) + +)ENGINE=InnoDB DEFAULT CHARSET=UTF8; + +ALTER TABLE `employee` ADD `dept_id` int AFTER `email`; \ No newline at end of file From 38b419d8e9f7927d1ff29cabf3ebba2594107ef7 Mon Sep 17 00:00:00 2001 From: Ante Pocedulic Date: Thu, 15 Sep 2016 07:55:11 +0200 Subject: [PATCH 24/56] Spring Data Rest Validators introduction (#650) * - created packages for each logical part of application - created validator for WebsiteUser rest API - created ValidatorEventRegister class which fixes known bug for not detecting generated events - created custom Exception Handler which creates better response messages * Code formatting * formated pom.xml replaced for loops with streams fixed bug while getting all beans * removed unnecessary code changed repository type * - added test for Spring Data REST APIs - changed bad request return code - formated code --- spring-data-rest/pom.xml | 4 +- .../baeldung/SpringDataRestApplication.java | 6 +- .../java/com/baeldung/UserRepository.java | 12 --- .../config/ValidatorEventRegister.java | 30 ++++++ .../RestResponseEntityExceptionHandler.java | 25 +++++ .../baeldung/{ => models}/WebsiteUser.java | 2 +- .../baeldung/repositories/UserRepository.java | 11 ++ .../validators/WebsiteUserValidator.java | 33 ++++++ .../SpringDataRestValidatorTest.java | 100 ++++++++++++++++++ 9 files changed, 205 insertions(+), 18 deletions(-) delete mode 100644 spring-data-rest/src/main/java/com/baeldung/UserRepository.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java rename spring-data-rest/src/main/java/com/baeldung/{ => models}/WebsiteUser.java (96%) create mode 100644 spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java create mode 100644 spring-data-rest/src/main/test/com/baeldung/validator/SpringDataRestValidatorTest.java diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index f7f28aa9f1..5ae694a04f 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent 1.3.3.RELEASE - + diff --git a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java b/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java index 6e8e62f52c..94eddc5b3e 100644 --- a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java +++ b/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SpringDataRestApplication { - public static void main(String[] args) { - SpringApplication.run(SpringDataRestApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(SpringDataRestApplication.class, args); + } } diff --git a/spring-data-rest/src/main/java/com/baeldung/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/UserRepository.java deleted file mode 100644 index ebbf0d49ab..0000000000 --- a/spring-data-rest/src/main/java/com/baeldung/UserRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -import java.util.List; - -@RepositoryRestResource(collectionResourceRel = "users", path = "users") -public interface UserRepository extends PagingAndSortingRepository { - List findByName(@Param("name") String name); -} diff --git a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java new file mode 100644 index 0000000000..89ab848e81 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java @@ -0,0 +1,30 @@ +package com.baeldung.config; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener; +import org.springframework.validation.Validator; + +@Configuration +public class ValidatorEventRegister implements InitializingBean { + + @Autowired + ValidatingRepositoryEventListener validatingRepositoryEventListener; + + @Autowired + private Map validators; + + @Override + public void afterPropertiesSet() throws Exception { + List events = Arrays.asList("beforeCreate", "afterCreate", "beforeSave", "afterSave", "beforeLinkSave", "afterLinkSave", "beforeDelete", "afterDelete"); + + for (Map.Entry entry : validators.entrySet()) { + events.stream().filter(p -> entry.getKey().startsWith(p)).findFirst().ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue())); + } + } +} diff --git a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java new file mode 100644 index 0000000000..ee84738e7a --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java @@ -0,0 +1,25 @@ +package com.baeldung.exception.handlers; + +import java.util.stream.Collectors; + +import org.springframework.data.rest.core.RepositoryConstraintViolationException; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +@ControllerAdvice +public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { + + @ExceptionHandler({ RepositoryConstraintViolationException.class }) + public ResponseEntity handleAccessDeniedException(Exception ex, WebRequest request) { + RepositoryConstraintViolationException nevEx = (RepositoryConstraintViolationException) ex; + + String errors = nevEx.getErrors().getAllErrors().stream().map(p -> p.toString()).collect(Collectors.joining("\n")); + return new ResponseEntity(errors, new HttpHeaders(), HttpStatus.NOT_ACCEPTABLE); + } + +} \ No newline at end of file diff --git a/spring-data-rest/src/main/java/com/baeldung/WebsiteUser.java b/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java similarity index 96% rename from spring-data-rest/src/main/java/com/baeldung/WebsiteUser.java rename to spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java index a7a35a2573..4eb9773e36 100644 --- a/spring-data-rest/src/main/java/com/baeldung/WebsiteUser.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.models; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java new file mode 100644 index 0000000000..0b55ac89b6 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java @@ -0,0 +1,11 @@ +package com.baeldung.repositories; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import com.baeldung.models.WebsiteUser; + +@RepositoryRestResource(collectionResourceRel = "users", path = "users") +public interface UserRepository extends CrudRepository { + +} diff --git a/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java b/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java new file mode 100644 index 0000000000..0380332708 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java @@ -0,0 +1,33 @@ +package com.baeldung.validators; + +import org.springframework.stereotype.Component; +import org.springframework.validation.Errors; +import org.springframework.validation.Validator; + +import com.baeldung.models.WebsiteUser; + +@Component("beforeCreateWebsiteUserValidator") +public class WebsiteUserValidator implements Validator { + + @Override + public boolean supports(Class clazz) { + return WebsiteUser.class.equals(clazz); + } + + @Override + public void validate(Object obj, Errors errors) { + + WebsiteUser user = (WebsiteUser) obj; + if (checkInputString(user.getName())) { + errors.rejectValue("name", "name.empty"); + } + + if (checkInputString(user.getEmail())) { + errors.rejectValue("email", "email.empty"); + } + } + + private boolean checkInputString(String input) { + return (input == null || input.trim().length() == 0); + } +} diff --git a/spring-data-rest/src/main/test/com/baeldung/validator/SpringDataRestValidatorTest.java b/spring-data-rest/src/main/test/com/baeldung/validator/SpringDataRestValidatorTest.java new file mode 100644 index 0000000000..b185c6d5ab --- /dev/null +++ b/spring-data-rest/src/main/test/com/baeldung/validator/SpringDataRestValidatorTest.java @@ -0,0 +1,100 @@ +package com.baeldung.validator; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.ResultMatcher; +import org.springframework.web.context.WebApplicationContext; + +import com.baeldung.SpringDataRestApplication; +import com.baeldung.models.WebsiteUser; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = SpringDataRestApplication.class) +@WebAppConfiguration +public class SpringDataRestValidatorTest { + public static final String URL = "http://localhost"; + + private MockMvc mockMvc; + + @Autowired + protected WebApplicationContext wac; + + @Before + public void setup() { + mockMvc = webAppContextSetup(wac).build(); + } + + @Test + public void whenStartingApplication_thenCorrectStatusCode() throws Exception { + mockMvc.perform(get("/users")).andExpect(status().is2xxSuccessful()); + }; + + @Test + public void whenAddingNewCorrectUser_thenCorrectStatusCodeAndResponse() throws Exception { + WebsiteUser user = new WebsiteUser(); + user.setEmail("john.doe@john.com"); + user.setName("John Doe"); + + mockMvc.perform(post("/users", user).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(user))) + .andExpect(status().is2xxSuccessful()) + .andExpect(redirectedUrl("http://localhost/users/1")); + } + + @Test + public void whenAddingNewUserWithoutName_thenErrorStatusCodeAndResponse() throws Exception { + WebsiteUser user = new WebsiteUser(); + user.setEmail("john.doe@john.com"); + + mockMvc.perform(post("/users", user).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(user))) + .andExpect(status().isNotAcceptable()) + .andExpect(redirectedUrl(null)); + } + + @Test + public void whenAddingNewUserWithEmptyName_thenErrorStatusCodeAndResponse() throws Exception { + WebsiteUser user = new WebsiteUser(); + user.setEmail("john.doe@john.com"); + user.setName(""); + mockMvc.perform(post("/users", user).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(user))) + .andExpect(status().isNotAcceptable()) + .andExpect(redirectedUrl(null)); + } + + @Test + public void whenAddingNewUserWithoutEmail_thenErrorStatusCodeAndResponse() throws Exception { + WebsiteUser user = new WebsiteUser(); + user.setName("John Doe"); + + mockMvc.perform(post("/users", user).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(user))) + .andExpect(status().isNotAcceptable()) + .andExpect(redirectedUrl(null)); + } + + @Test + public void whenAddingNewUserWithEmptyEmail_thenErrorStatusCodeAndResponse() throws Exception { + WebsiteUser user = new WebsiteUser(); + user.setName("John Doe"); + user.setEmail(""); + mockMvc.perform(post("/users", user).contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValueAsString(user))) + .andExpect(status().isNotAcceptable()) + .andExpect(redirectedUrl(null)); + } + +} From 5978c00dc98efeff43e723ef5fc70ff5e9b7e9fc Mon Sep 17 00:00:00 2001 From: Christian Raedel Date: Tue, 6 Sep 2016 02:58:53 +0200 Subject: [PATCH 25/56] BAEL-11: Implemented working Feign client. --- feign-hypermedia-client/README.md | 5 + feign-hypermedia-client/pom.xml | 91 +++++++++++++++++++ .../java/com/baeldung/feign/Controller.java | 26 ++++++ .../baeldung/feign/clients/BookClient.java | 21 +++++ .../java/com/baeldung/feign/models/Book.java | 18 ++++ .../baeldung/feign/models/BookResource.java | 14 +++ .../src/main/resources/log4j2.xml | 14 +++ .../feign/clients/BookClientTest.java | 54 +++++++++++ 8 files changed, 243 insertions(+) create mode 100644 feign-hypermedia-client/README.md create mode 100644 feign-hypermedia-client/pom.xml create mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java create mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java create mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java create mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java create mode 100644 feign-hypermedia-client/src/main/resources/log4j2.xml create mode 100644 feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java diff --git a/feign-hypermedia-client/README.md b/feign-hypermedia-client/README.md new file mode 100644 index 0000000000..e6ade4d161 --- /dev/null +++ b/feign-hypermedia-client/README.md @@ -0,0 +1,5 @@ +## Feign Hypermedia Client ## + +This is the implementation of a [spring-hypermedia-api][1] client using Feign. + +[1]: https://github.com/eugenp/spring-hypermedia-api diff --git a/feign-hypermedia-client/pom.xml b/feign-hypermedia-client/pom.xml new file mode 100644 index 0000000000..7e60e2ec7f --- /dev/null +++ b/feign-hypermedia-client/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + com.baeldung.feign + feign-hypermedia-client + 1.0.0-SNAPSHOT + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + .. + + + + UTF-8 + + + + + io.github.openfeign + feign-core + 9.3.1 + + + io.github.openfeign + feign-okhttp + 9.3.1 + + + io.github.openfeign + feign-gson + 9.3.1 + + + io.github.openfeign + feign-slf4j + 9.3.1 + + + org.slf4j + slf4j-api + 1.7.21 + + + org.apache.logging.log4j + log4j-core + 2.6.2 + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.6.2 + + + org.projectlombok + lombok + 1.16.10 + provided + + + junit + junit + 4.12 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.springframework.boot + spring-boot-maven-plugin + 1.4.0.RELEASE + + + + + diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java new file mode 100644 index 0000000000..f5405be87a --- /dev/null +++ b/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java @@ -0,0 +1,26 @@ +package com.baeldung.feign; + +import com.baeldung.feign.clients.BookClient; +import feign.Feign; +import feign.Logger; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.okhttp.OkHttpClient; +import feign.slf4j.Slf4jLogger; +import lombok.Getter; + +@Getter +public class Controller { + private BookClient bookClient = createClient(BookClient.class, + "http://localhost:8081/api/books"); + + private static T createClient(Class type, String uri) { + return Feign.builder() + .client(new OkHttpClient()) + .encoder(new GsonEncoder()) + .decoder(new GsonDecoder()) + .logger(new Slf4jLogger(type)) + .logLevel(Logger.Level.FULL) + .target(type, uri); + } +} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java new file mode 100644 index 0000000000..df20ef8f93 --- /dev/null +++ b/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java @@ -0,0 +1,21 @@ +package com.baeldung.feign.clients; + +import com.baeldung.feign.models.Book; +import com.baeldung.feign.models.BookResource; +import feign.Headers; +import feign.Param; +import feign.RequestLine; + +import java.util.List; + +public interface BookClient { + @RequestLine("GET /{isbn}") + BookResource findByIsbn(@Param("isbn") String isbn); + + @RequestLine("GET") + List findAll(); + + @RequestLine("POST") + @Headers("Content-Type: application/json") + void create(Book book); +} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java new file mode 100644 index 0000000000..cda4412e27 --- /dev/null +++ b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java @@ -0,0 +1,18 @@ +package com.baeldung.feign.models; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class Book { + private String isbn; + private String author; + private String title; + private String synopsis; + private String language; +} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java new file mode 100644 index 0000000000..7902db9fe8 --- /dev/null +++ b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java @@ -0,0 +1,14 @@ +package com.baeldung.feign.models; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class BookResource { + private Book book; +} diff --git a/feign-hypermedia-client/src/main/resources/log4j2.xml b/feign-hypermedia-client/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..659c5fda0e --- /dev/null +++ b/feign-hypermedia-client/src/main/resources/log4j2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java new file mode 100644 index 0000000000..dcebe7426f --- /dev/null +++ b/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java @@ -0,0 +1,54 @@ +package com.baeldung.feign.clients; + +import com.baeldung.feign.Controller; +import com.baeldung.feign.models.Book; +import com.baeldung.feign.models.BookResource; +import lombok.extern.slf4j.Slf4j; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +@Slf4j +@RunWith(JUnit4.class) +public class BookClientTest { + private Controller controller = new Controller(); + + @Test + public void givenBookClient_shouldRunSuccessfully() throws Exception { + BookClient bookClient = controller.getBookClient(); + List books = bookClient.findAll().stream() + .map(BookResource::getBook) + .collect(Collectors.toList()); + assertTrue(books.size() > 2); + log.info("{}", books); + } + + @Test + public void givenBookClient_shouldFindOneBook() throws Exception { + BookClient bookClient = controller.getBookClient(); + Book book = bookClient.findByIsbn("0151072558").getBook(); + assertThat(book.getAuthor(), containsString("Orwell")); + log.info("{}", book); + } + + @Test + public void givenBookClient_shouldPostBook() throws Exception { + BookClient bookClient = controller.getBookClient(); + String isbn = UUID.randomUUID().toString(); + Book book = new Book(isbn, "Me", "It's me!", null, null); + bookClient.create(book); + + book = bookClient.findByIsbn(isbn).getBook(); + assertThat(book.getAuthor(), is("Me")); + log.info("{}", book); + } +} From 674c783886ceffa2ba3fd80b18263926ef08a0ae Mon Sep 17 00:00:00 2001 From: Christian Raedel Date: Tue, 6 Sep 2016 19:06:39 +0200 Subject: [PATCH 26/56] BAEL-11: Added skip-tests configuration to pom.xml. --- feign-client/README.md | 5 + feign-client/pom.xml | 99 +++++++++++++++++++ .../java/com/baeldung/feign/Controller.java | 26 +++++ .../baeldung/feign/clients/BookClient.java | 21 ++++ .../java/com/baeldung/feign/models/Book.java | 18 ++++ .../baeldung/feign/models/BookResource.java | 14 +++ feign-client/src/main/resources/log4j2.xml | 14 +++ .../feign/clients/BookClientTest.java | 54 ++++++++++ pom.xml | 1 + 9 files changed, 252 insertions(+) create mode 100644 feign-client/README.md create mode 100644 feign-client/pom.xml create mode 100644 feign-client/src/main/java/com/baeldung/feign/Controller.java create mode 100644 feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java create mode 100644 feign-client/src/main/java/com/baeldung/feign/models/Book.java create mode 100644 feign-client/src/main/java/com/baeldung/feign/models/BookResource.java create mode 100644 feign-client/src/main/resources/log4j2.xml create mode 100644 feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java diff --git a/feign-client/README.md b/feign-client/README.md new file mode 100644 index 0000000000..e6ade4d161 --- /dev/null +++ b/feign-client/README.md @@ -0,0 +1,5 @@ +## Feign Hypermedia Client ## + +This is the implementation of a [spring-hypermedia-api][1] client using Feign. + +[1]: https://github.com/eugenp/spring-hypermedia-api diff --git a/feign-client/pom.xml b/feign-client/pom.xml new file mode 100644 index 0000000000..af61883f1b --- /dev/null +++ b/feign-client/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + com.baeldung.feign + feign-client + 1.0.0-SNAPSHOT + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + .. + + + + UTF-8 + + + + + io.github.openfeign + feign-core + 9.3.1 + + + io.github.openfeign + feign-okhttp + 9.3.1 + + + io.github.openfeign + feign-gson + 9.3.1 + + + io.github.openfeign + feign-slf4j + 9.3.1 + + + org.slf4j + slf4j-api + 1.7.21 + + + org.apache.logging.log4j + log4j-core + 2.6.2 + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.6.2 + + + org.projectlombok + lombok + 1.16.10 + provided + + + junit + junit + 4.12 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + true + + + + org.springframework.boot + spring-boot-maven-plugin + 1.4.0.RELEASE + + + + + diff --git a/feign-client/src/main/java/com/baeldung/feign/Controller.java b/feign-client/src/main/java/com/baeldung/feign/Controller.java new file mode 100644 index 0000000000..f5405be87a --- /dev/null +++ b/feign-client/src/main/java/com/baeldung/feign/Controller.java @@ -0,0 +1,26 @@ +package com.baeldung.feign; + +import com.baeldung.feign.clients.BookClient; +import feign.Feign; +import feign.Logger; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import feign.okhttp.OkHttpClient; +import feign.slf4j.Slf4jLogger; +import lombok.Getter; + +@Getter +public class Controller { + private BookClient bookClient = createClient(BookClient.class, + "http://localhost:8081/api/books"); + + private static T createClient(Class type, String uri) { + return Feign.builder() + .client(new OkHttpClient()) + .encoder(new GsonEncoder()) + .decoder(new GsonDecoder()) + .logger(new Slf4jLogger(type)) + .logLevel(Logger.Level.FULL) + .target(type, uri); + } +} diff --git a/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java b/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java new file mode 100644 index 0000000000..df20ef8f93 --- /dev/null +++ b/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java @@ -0,0 +1,21 @@ +package com.baeldung.feign.clients; + +import com.baeldung.feign.models.Book; +import com.baeldung.feign.models.BookResource; +import feign.Headers; +import feign.Param; +import feign.RequestLine; + +import java.util.List; + +public interface BookClient { + @RequestLine("GET /{isbn}") + BookResource findByIsbn(@Param("isbn") String isbn); + + @RequestLine("GET") + List findAll(); + + @RequestLine("POST") + @Headers("Content-Type: application/json") + void create(Book book); +} diff --git a/feign-client/src/main/java/com/baeldung/feign/models/Book.java b/feign-client/src/main/java/com/baeldung/feign/models/Book.java new file mode 100644 index 0000000000..cda4412e27 --- /dev/null +++ b/feign-client/src/main/java/com/baeldung/feign/models/Book.java @@ -0,0 +1,18 @@ +package com.baeldung.feign.models; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class Book { + private String isbn; + private String author; + private String title; + private String synopsis; + private String language; +} diff --git a/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java b/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java new file mode 100644 index 0000000000..7902db9fe8 --- /dev/null +++ b/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java @@ -0,0 +1,14 @@ +package com.baeldung.feign.models; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class BookResource { + private Book book; +} diff --git a/feign-client/src/main/resources/log4j2.xml b/feign-client/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..659c5fda0e --- /dev/null +++ b/feign-client/src/main/resources/log4j2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java new file mode 100644 index 0000000000..37f91c5b51 --- /dev/null +++ b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java @@ -0,0 +1,54 @@ +package com.baeldung.feign.clients; + +import com.baeldung.feign.Controller; +import com.baeldung.feign.models.Book; +import com.baeldung.feign.models.BookResource; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +@Slf4j +@RunWith(JUnit4.class) +public class BookClientTest { + private Controller controller = new Controller(); + + @Test + public void givenBookClient_shouldRunSuccessfully() throws Exception { + BookClient bookClient = controller.getBookClient(); + List books = bookClient.findAll().stream() + .map(BookResource::getBook) + .collect(Collectors.toList()); + assertTrue(books.size() > 2); + log.info("{}", books); + } + + @Test + public void givenBookClient_shouldFindOneBook() throws Exception { + BookClient bookClient = controller.getBookClient(); + Book book = bookClient.findByIsbn("0151072558").getBook(); + assertThat(book.getAuthor(), containsString("Orwell")); + log.info("{}", book); + } + + @Test + public void givenBookClient_shouldPostBook() throws Exception { + BookClient bookClient = controller.getBookClient(); + String isbn = UUID.randomUUID().toString(); + Book book = new Book(isbn, "Me", "It's me!", null, null); + bookClient.create(book); + + book = bookClient.findByIsbn(isbn).getBook(); + assertThat(book.getAuthor(), is("Me")); + log.info("{}", book); + } +} diff --git a/pom.xml b/pom.xml index d37be9136e..41b348c893 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ deltaspike enterprise-patterns + feign-client gson From 38eb1a5f45994bff063cd720c60979c47b59b6ad Mon Sep 17 00:00:00 2001 From: Christian Raedel Date: Tue, 6 Sep 2016 21:30:14 +0200 Subject: [PATCH 27/56] BAEL-11: Renamed project to feign-client. --- feign-hypermedia-client/README.md | 5 - feign-hypermedia-client/pom.xml | 91 ------------------- .../java/com/baeldung/feign/Controller.java | 26 ------ .../baeldung/feign/clients/BookClient.java | 21 ----- .../java/com/baeldung/feign/models/Book.java | 18 ---- .../baeldung/feign/models/BookResource.java | 14 --- .../src/main/resources/log4j2.xml | 14 --- .../feign/clients/BookClientTest.java | 54 ----------- 8 files changed, 243 deletions(-) delete mode 100644 feign-hypermedia-client/README.md delete mode 100644 feign-hypermedia-client/pom.xml delete mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java delete mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java delete mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java delete mode 100644 feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java delete mode 100644 feign-hypermedia-client/src/main/resources/log4j2.xml delete mode 100644 feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java diff --git a/feign-hypermedia-client/README.md b/feign-hypermedia-client/README.md deleted file mode 100644 index e6ade4d161..0000000000 --- a/feign-hypermedia-client/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Feign Hypermedia Client ## - -This is the implementation of a [spring-hypermedia-api][1] client using Feign. - -[1]: https://github.com/eugenp/spring-hypermedia-api diff --git a/feign-hypermedia-client/pom.xml b/feign-hypermedia-client/pom.xml deleted file mode 100644 index 7e60e2ec7f..0000000000 --- a/feign-hypermedia-client/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - 4.0.0 - - com.baeldung.feign - feign-hypermedia-client - 1.0.0-SNAPSHOT - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - .. - - - - UTF-8 - - - - - io.github.openfeign - feign-core - 9.3.1 - - - io.github.openfeign - feign-okhttp - 9.3.1 - - - io.github.openfeign - feign-gson - 9.3.1 - - - io.github.openfeign - feign-slf4j - 9.3.1 - - - org.slf4j - slf4j-api - 1.7.21 - - - org.apache.logging.log4j - log4j-core - 2.6.2 - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.6.2 - - - org.projectlombok - lombok - 1.16.10 - provided - - - junit - junit - 4.12 - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.springframework.boot - spring-boot-maven-plugin - 1.4.0.RELEASE - - - - - diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java deleted file mode 100644 index f5405be87a..0000000000 --- a/feign-hypermedia-client/src/main/java/com/baeldung/feign/Controller.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.feign; - -import com.baeldung.feign.clients.BookClient; -import feign.Feign; -import feign.Logger; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.okhttp.OkHttpClient; -import feign.slf4j.Slf4jLogger; -import lombok.Getter; - -@Getter -public class Controller { - private BookClient bookClient = createClient(BookClient.class, - "http://localhost:8081/api/books"); - - private static T createClient(Class type, String uri) { - return Feign.builder() - .client(new OkHttpClient()) - .encoder(new GsonEncoder()) - .decoder(new GsonDecoder()) - .logger(new Slf4jLogger(type)) - .logLevel(Logger.Level.FULL) - .target(type, uri); - } -} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java deleted file mode 100644 index df20ef8f93..0000000000 --- a/feign-hypermedia-client/src/main/java/com/baeldung/feign/clients/BookClient.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.feign.clients; - -import com.baeldung.feign.models.Book; -import com.baeldung.feign.models.BookResource; -import feign.Headers; -import feign.Param; -import feign.RequestLine; - -import java.util.List; - -public interface BookClient { - @RequestLine("GET /{isbn}") - BookResource findByIsbn(@Param("isbn") String isbn); - - @RequestLine("GET") - List findAll(); - - @RequestLine("POST") - @Headers("Content-Type: application/json") - void create(Book book); -} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java deleted file mode 100644 index cda4412e27..0000000000 --- a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/Book.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.feign.models; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; - -@Data -@ToString -@NoArgsConstructor -@AllArgsConstructor -public class Book { - private String isbn; - private String author; - private String title; - private String synopsis; - private String language; -} diff --git a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java b/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java deleted file mode 100644 index 7902db9fe8..0000000000 --- a/feign-hypermedia-client/src/main/java/com/baeldung/feign/models/BookResource.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.feign.models; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; - -@Data -@ToString -@NoArgsConstructor -@AllArgsConstructor -public class BookResource { - private Book book; -} diff --git a/feign-hypermedia-client/src/main/resources/log4j2.xml b/feign-hypermedia-client/src/main/resources/log4j2.xml deleted file mode 100644 index 659c5fda0e..0000000000 --- a/feign-hypermedia-client/src/main/resources/log4j2.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java deleted file mode 100644 index dcebe7426f..0000000000 --- a/feign-hypermedia-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.feign.clients; - -import com.baeldung.feign.Controller; -import com.baeldung.feign.models.Book; -import com.baeldung.feign.models.BookResource; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -@Slf4j -@RunWith(JUnit4.class) -public class BookClientTest { - private Controller controller = new Controller(); - - @Test - public void givenBookClient_shouldRunSuccessfully() throws Exception { - BookClient bookClient = controller.getBookClient(); - List books = bookClient.findAll().stream() - .map(BookResource::getBook) - .collect(Collectors.toList()); - assertTrue(books.size() > 2); - log.info("{}", books); - } - - @Test - public void givenBookClient_shouldFindOneBook() throws Exception { - BookClient bookClient = controller.getBookClient(); - Book book = bookClient.findByIsbn("0151072558").getBook(); - assertThat(book.getAuthor(), containsString("Orwell")); - log.info("{}", book); - } - - @Test - public void givenBookClient_shouldPostBook() throws Exception { - BookClient bookClient = controller.getBookClient(); - String isbn = UUID.randomUUID().toString(); - Book book = new Book(isbn, "Me", "It's me!", null, null); - bookClient.create(book); - - book = bookClient.findByIsbn(isbn).getBook(); - assertThat(book.getAuthor(), is("Me")); - log.info("{}", book); - } -} From 499d51e610a6518db2bc2a48a2dae2dae009ab2b Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Thu, 15 Sep 2016 11:40:46 +0200 Subject: [PATCH 28/56] BAEL-11: Minor refactorings --- ...ava => BookControllerFeignClientBuilder.java} | 2 +- .../baeldung/feign/clients/BookClientTest.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) rename feign-client/src/main/java/com/baeldung/feign/{Controller.java => BookControllerFeignClientBuilder.java} (93%) diff --git a/feign-client/src/main/java/com/baeldung/feign/Controller.java b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java similarity index 93% rename from feign-client/src/main/java/com/baeldung/feign/Controller.java rename to feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java index f5405be87a..9c0c359d88 100644 --- a/feign-client/src/main/java/com/baeldung/feign/Controller.java +++ b/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java @@ -10,7 +10,7 @@ import feign.slf4j.Slf4jLogger; import lombok.Getter; @Getter -public class Controller { +public class BookControllerFeignClientBuilder { private BookClient bookClient = createClient(BookClient.class, "http://localhost:8081/api/books"); diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java index 37f91c5b51..fa470cd0a0 100644 --- a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java +++ b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java @@ -1,9 +1,10 @@ package com.baeldung.feign.clients; -import com.baeldung.feign.Controller; +import com.baeldung.feign.BookControllerFeignClientBuilder; import com.baeldung.feign.models.Book; import com.baeldung.feign.models.BookResource; import lombok.extern.slf4j.Slf4j; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -20,11 +21,16 @@ import static org.junit.Assert.assertTrue; @Slf4j @RunWith(JUnit4.class) public class BookClientTest { - private Controller controller = new Controller(); + private BookControllerFeignClientBuilder feignClientBuilder; + + @Before + public void setup() { + feignClientBuilder = new BookControllerFeignClientBuilder(); + } @Test public void givenBookClient_shouldRunSuccessfully() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); List books = bookClient.findAll().stream() .map(BookResource::getBook) .collect(Collectors.toList()); @@ -34,7 +40,7 @@ public class BookClientTest { @Test public void givenBookClient_shouldFindOneBook() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); Book book = bookClient.findByIsbn("0151072558").getBook(); assertThat(book.getAuthor(), containsString("Orwell")); log.info("{}", book); @@ -42,7 +48,7 @@ public class BookClientTest { @Test public void givenBookClient_shouldPostBook() throws Exception { - BookClient bookClient = controller.getBookClient(); + BookClient bookClient = feignClientBuilder.getBookClient(); String isbn = UUID.randomUUID().toString(); Book book = new Book(isbn, "Me", "It's me!", null, null); bookClient.create(book); From ef3b18a7174fd93ee8c416c3250030cc91be4890 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Thu, 15 Sep 2016 12:23:14 +0200 Subject: [PATCH 29/56] BAEL-11: Minor refactorings --- .../java/com/baeldung/feign/clients/BookClientTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java index fa470cd0a0..e7e058a336 100644 --- a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java +++ b/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java @@ -21,16 +21,16 @@ import static org.junit.Assert.assertTrue; @Slf4j @RunWith(JUnit4.class) public class BookClientTest { - private BookControllerFeignClientBuilder feignClientBuilder; + private BookClient bookClient; @Before public void setup() { - feignClientBuilder = new BookControllerFeignClientBuilder(); + BookControllerFeignClientBuilder feignClientBuilder = new BookControllerFeignClientBuilder(); + bookClient = feignClientBuilder.getBookClient(); } @Test public void givenBookClient_shouldRunSuccessfully() throws Exception { - BookClient bookClient = feignClientBuilder.getBookClient(); List books = bookClient.findAll().stream() .map(BookResource::getBook) .collect(Collectors.toList()); @@ -40,7 +40,6 @@ public class BookClientTest { @Test public void givenBookClient_shouldFindOneBook() throws Exception { - BookClient bookClient = feignClientBuilder.getBookClient(); Book book = bookClient.findByIsbn("0151072558").getBook(); assertThat(book.getAuthor(), containsString("Orwell")); log.info("{}", book); @@ -48,7 +47,6 @@ public class BookClientTest { @Test public void givenBookClient_shouldPostBook() throws Exception { - BookClient bookClient = feignClientBuilder.getBookClient(); String isbn = UUID.randomUUID().toString(); Book book = new Book(isbn, "Me", "It's me!", null, null); bookClient.create(book); From 97e8ba7de620ada2fb4cc4299cf250cd59e0ec0e Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Thu, 15 Sep 2016 13:02:54 +0200 Subject: [PATCH 30/56] NOJIRA - removing cloud-config, hystrix and eureka project. They're now the child projects of spring-cloud --- .../config-client-development.properties | 2 - .../config-client-production.properties | 1 - spring-cloud-config/client/pom.xml | 79 ----------------- .../cloud/config/client/ConfigClient.java | 29 ------- .../src/main/resources/bootstrap.properties | 5 -- .../config/client/ConfigClientLiveTest.java | 17 ---- spring-cloud-config/docker/Dockerfile | 4 - spring-cloud-config/docker/Dockerfile.client | 6 -- spring-cloud-config/docker/Dockerfile.server | 9 -- .../docker/config-client-entrypoint.sh | 8 -- .../docker/docker-compose.scale.yml | 41 --------- spring-cloud-config/docker/docker-compose.yml | 43 --------- spring-cloud-config/pom.xml | 42 --------- spring-cloud-config/server/pom.xml | 82 ------------------ .../cloud/config/server/ConfigServer.java | 15 ---- .../src/main/resources/application.properties | 9 -- .../src/main/resources/config-server.jks | Bin 3842 -> 0 bytes .../config/server/ConfigServerListTest.java | 18 ---- spring-cloud-eureka/pom.xml | 50 ----------- .../spring-cloud-eureka-client/pom.xml | 57 ------------ .../client/EurekaClientApplication.java | 32 ------- .../eureka/client/GreetingController.java | 8 -- .../src/main/resources/application.yml | 13 --- .../spring-cloud-eureka-feign-client/pom.xml | 67 -------------- .../feign/client/FeignClientApplication.java | 29 ------- .../cloud/feign/client/GreetingClient.java | 8 -- .../src/main/resources/application.yml | 11 --- .../resources/templates/greeting-view.html | 9 -- .../spring-cloud-eureka-server/pom.xml | 52 ----------- .../server/EurekaServerApplication.java | 13 --- .../src/main/resources/application.yml | 7 -- spring-cloud-hystrix/pom.xml | 50 ----------- .../pom.xml | 82 ------------------ .../hystrix/rest/consumer/GreetingClient.java | 21 ----- .../RestConsumerFeignApplication.java | 32 ------- .../src/main/resources/application.properties | 1 - .../resources/templates/greeting-view.html | 9 -- .../pom.xml | 72 --------------- .../rest/consumer/GreetingService.java | 18 ---- .../consumer/RestConsumerApplication.java | 31 ------- .../src/main/resources/application.properties | 1 - .../resources/templates/greeting-view.html | 9 -- .../pom.xml | 40 --------- .../rest/producer/GreetingController.java | 10 --- .../producer/RestProducerApplication.java | 20 ----- .../src/main/resources/application.properties | 2 - 46 files changed, 1164 deletions(-) delete mode 100644 spring-cloud-config/client-config/config-client-development.properties delete mode 100644 spring-cloud-config/client-config/config-client-production.properties delete mode 100644 spring-cloud-config/client/pom.xml delete mode 100644 spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java delete mode 100644 spring-cloud-config/client/src/main/resources/bootstrap.properties delete mode 100644 spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/ConfigClientLiveTest.java delete mode 100644 spring-cloud-config/docker/Dockerfile delete mode 100644 spring-cloud-config/docker/Dockerfile.client delete mode 100644 spring-cloud-config/docker/Dockerfile.server delete mode 100644 spring-cloud-config/docker/config-client-entrypoint.sh delete mode 100644 spring-cloud-config/docker/docker-compose.scale.yml delete mode 100644 spring-cloud-config/docker/docker-compose.yml delete mode 100644 spring-cloud-config/pom.xml delete mode 100644 spring-cloud-config/server/pom.xml delete mode 100644 spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java delete mode 100644 spring-cloud-config/server/src/main/resources/application.properties delete mode 100644 spring-cloud-config/server/src/main/resources/config-server.jks delete mode 100644 spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/ConfigServerListTest.java delete mode 100644 spring-cloud-eureka/pom.xml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-client/pom.xml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-server/pom.xml delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java delete mode 100644 spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml delete mode 100644 spring-cloud-hystrix/pom.xml delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java delete mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties diff --git a/spring-cloud-config/client-config/config-client-development.properties b/spring-cloud-config/client-config/config-client-development.properties deleted file mode 100644 index 6401d1be7f..0000000000 --- a/spring-cloud-config/client-config/config-client-development.properties +++ /dev/null @@ -1,2 +0,0 @@ -user.role=Developer -user.password=pass diff --git a/spring-cloud-config/client-config/config-client-production.properties b/spring-cloud-config/client-config/config-client-production.properties deleted file mode 100644 index cd2e14fcc3..0000000000 --- a/spring-cloud-config/client-config/config-client-production.properties +++ /dev/null @@ -1 +0,0 @@ -user.role=User diff --git a/spring-cloud-config/client/pom.xml b/spring-cloud-config/client/pom.xml deleted file mode 100644 index 0ef4b35581..0000000000 --- a/spring-cloud-config/client/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - 4.0.0 - - - com.baeldung.spring.cloud - spring-cloud-config - 0.0.1-SNAPSHOT - - client - jar - - client - Demo project for Spring Cloud Config Client - - - UTF-8 - UTF-8 - 1.8 - - - - - org.springframework.cloud - spring-cloud-starter-config - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Brixton.BUILD-SNAPSHOT - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - diff --git a/spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java b/spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java deleted file mode 100644 index 1dd3bbdab0..0000000000 --- a/spring-cloud-config/client/src/main/java/com/baeldung/spring/cloud/config/client/ConfigClient.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.spring.cloud.config.client; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@RestController -public class ConfigClient { - @Value("${user.role}") - private String role; - - @Value("${user.password}") - private String password; - - public static void main(String[] args) { - SpringApplication.run(ConfigClient.class, args); - } - - @RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) - public String whoami(@PathVariable("username") String username) { - return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password); - } -} diff --git a/spring-cloud-config/client/src/main/resources/bootstrap.properties b/spring-cloud-config/client/src/main/resources/bootstrap.properties deleted file mode 100644 index 18982a93b5..0000000000 --- a/spring-cloud-config/client/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,5 +0,0 @@ -spring.application.name=config-client -spring.profiles.active=development -spring.cloud.config.uri=http://localhost:8888 -spring.cloud.config.username=root -spring.cloud.config.password=s3cr3t diff --git a/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/ConfigClientLiveTest.java b/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/ConfigClientLiveTest.java deleted file mode 100644 index 058fd45f35..0000000000 --- a/spring-cloud-config/client/src/test/java/com/baeldung/spring/cloud/config/client/ConfigClientLiveTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.spring.cloud.config.client; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = ConfigClient.class) -@WebAppConfiguration -public class ConfigClientLiveTest { - @Test - public void contextLoads() { - } -} diff --git a/spring-cloud-config/docker/Dockerfile b/spring-cloud-config/docker/Dockerfile deleted file mode 100644 index bdb37abf80..0000000000 --- a/spring-cloud-config/docker/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM alpine:edge -MAINTAINER baeldung.com -RUN apk add --no-cache openjdk8 -COPY files/UnlimitedJCEPolicyJDK8/* /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/ diff --git a/spring-cloud-config/docker/Dockerfile.client b/spring-cloud-config/docker/Dockerfile.client deleted file mode 100644 index 5fbc0b98c0..0000000000 --- a/spring-cloud-config/docker/Dockerfile.client +++ /dev/null @@ -1,6 +0,0 @@ -FROM alpine-java:base -MAINTAINER baeldung.com -RUN apk --no-cache add netcat-openbsd -COPY files/config-client.jar /opt/spring-cloud/lib/ -COPY files/config-client-entrypoint.sh /opt/spring-cloud/bin/ -RUN chmod 755 /opt/spring-cloud/bin/config-client-entrypoint.sh diff --git a/spring-cloud-config/docker/Dockerfile.server b/spring-cloud-config/docker/Dockerfile.server deleted file mode 100644 index 4f7bd751e8..0000000000 --- a/spring-cloud-config/docker/Dockerfile.server +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine-java:base -MAINTAINER baeldung.com -COPY files/config-server.jar /opt/spring-cloud/lib/ -ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": \ - {"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}' -ENTRYPOINT ["/usr/bin/java"] -CMD ["-jar", "/opt/spring-cloud/lib/config-server.jar"] -VOLUME /var/lib/spring-cloud/config-repo -EXPOSE 8888 diff --git a/spring-cloud-config/docker/config-client-entrypoint.sh b/spring-cloud-config/docker/config-client-entrypoint.sh deleted file mode 100644 index 12352119fa..0000000000 --- a/spring-cloud-config/docker/config-client-entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -while ! nc -z config-server 8888 ; do - echo "Waiting for upcoming Config Server" - sleep 2 -done - -java -jar /opt/spring-cloud/lib/config-client.jar diff --git a/spring-cloud-config/docker/docker-compose.scale.yml b/spring-cloud-config/docker/docker-compose.scale.yml deleted file mode 100644 index f74153bea3..0000000000 --- a/spring-cloud-config/docker/docker-compose.scale.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '2' -services: - config-server: - build: - context: . - dockerfile: Dockerfile.server - image: config-server:latest - expose: - - 8888 - networks: - - spring-cloud-network - volumes: - - spring-cloud-config-repo:/var/lib/spring-cloud/config-repo - logging: - driver: json-file - config-client: - build: - context: . - dockerfile: Dockerfile.client - image: config-client:latest - entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh - environment: - SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}' - expose: - - 8080 - ports: - - 8080 - networks: - - spring-cloud-network - links: - - config-server:config-server - depends_on: - - config-server - logging: - driver: json-file -networks: - spring-cloud-network: - driver: bridge -volumes: - spring-cloud-config-repo: - external: true diff --git a/spring-cloud-config/docker/docker-compose.yml b/spring-cloud-config/docker/docker-compose.yml deleted file mode 100644 index 74c71b651c..0000000000 --- a/spring-cloud-config/docker/docker-compose.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: '2' -services: - config-server: - container_name: config-server - build: - context: . - dockerfile: Dockerfile.server - image: config-server:latest - expose: - - 8888 - networks: - - spring-cloud-network - volumes: - - spring-cloud-config-repo:/var/lib/spring-cloud/config-repo - logging: - driver: json-file - config-client: - container_name: config-client - build: - context: . - dockerfile: Dockerfile.client - image: config-client:latest - entrypoint: /opt/spring-cloud/bin/config-client-entrypoint.sh - environment: - SPRING_APPLICATION_JSON: '{"spring": {"cloud": {"config": {"uri": "http://config-server:8888"}}}}' - expose: - - 8080 - ports: - - 8080:8080 - networks: - - spring-cloud-network - links: - - config-server:config-server - depends_on: - - config-server - logging: - driver: json-file -networks: - spring-cloud-network: - driver: bridge -volumes: - spring-cloud-config-repo: - external: true diff --git a/spring-cloud-config/pom.xml b/spring-cloud-config/pom.xml deleted file mode 100644 index 8e0e4b8706..0000000000 --- a/spring-cloud-config/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - com.baeldung.spring.cloud - spring-cloud-config - 0.0.1-SNAPSHOT - pom - - - server - client - - - - org.springframework.boot - spring-boot-starter-parent - 1.3.5.RELEASE - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*LiveTest.java - - - - - - - - - 1.3.5.RELEASE - 2.19.1 - - diff --git a/spring-cloud-config/server/pom.xml b/spring-cloud-config/server/pom.xml deleted file mode 100644 index c3f68854bb..0000000000 --- a/spring-cloud-config/server/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 4.0.0 - - - com.baeldung.spring.cloud - spring-cloud-config - 0.0.1-SNAPSHOT - - server - - server - Demo project for Spring Cloud Config Server - - - UTF-8 - UTF-8 - 1.8 - - - - - org.springframework.cloud - spring-cloud-config-server - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Brixton.BUILD-SNAPSHOT - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - diff --git a/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java b/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java deleted file mode 100644 index 4dd34ae3ff..0000000000 --- a/spring-cloud-config/server/src/main/java/com/baeldung/spring/cloud/config/server/ConfigServer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.spring.cloud.config.server; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.config.server.EnableConfigServer; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; - -@SpringBootApplication -@EnableConfigServer -@EnableWebSecurity -public class ConfigServer { - public static void main(String[] args) { - SpringApplication.run(ConfigServer.class, args); - } -} diff --git a/spring-cloud-config/server/src/main/resources/application.properties b/spring-cloud-config/server/src/main/resources/application.properties deleted file mode 100644 index 2131f3b249..0000000000 --- a/spring-cloud-config/server/src/main/resources/application.properties +++ /dev/null @@ -1,9 +0,0 @@ -server.port=8888 -spring.cloud.config.server.git.uri=https://github.com/eugenp/tutorials/tree/master/spring-cloud-config/client-config -spring.cloud.config.server.git.clone-on-start=false -security.user.name=root -security.user.password=s3cr3t -encrypt.key-store.location=classpath:/config-server.jks -encrypt.key-store.password=my-s70r3-s3cr3t -encrypt.key-store.alias=config-server-key -encrypt.key-store.secret=my-k34-s3cr3t diff --git a/spring-cloud-config/server/src/main/resources/config-server.jks b/spring-cloud-config/server/src/main/resources/config-server.jks deleted file mode 100644 index f3dddb4a8f4c4773a8feae4d8534b129e5e67f45..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3842 zcmb`J_dgVlAII;`nHgD^y*J0XlgM_m649w_GLFmMduE3tS=os@F0wC0=Ao=Y644nM zq0}jt_3iU{e1G`<0pB0qKfGS=AKvdDo`e_)M=p}sx8ff5rWc`WL! zlMKec4B0W8#OkH3wkO*R*PO+B?J3;+oxX+Zi{__PlXm^u!<}^TN5uTWzI7T0#>wUq zMxVvh3F~4M@D;1dYFMSzn6xR@Wzn!^jfQ>ZJ;&pU>AO0*mxHz=OkyZg>_R^E%=}4# zN2^wybgtyPuU8x2!<&*?d|rP~{z@;EHI~!GA#>8&m_S(N%zWF)4RP=1VfyfP=0h2!w=}j4o3&4K22hmATUkg!|R6F)MDV?coO$ z{XN4(Sy#^=hzo#?Zf6M>Fo>@D?gslm$N24N6#yYn`Q!ZT`Z*S8!JH^P!SAzUex@ z#=*LwB6kjLoXpFfuxNJa`cwQSvPkXLp~4{8qsS{K0qd@71T#**EXmqXivNo=!4NRv_EAq~G9#yhI*-@yrH@wQPr9)0 zm__NHKlQeYJtI{XnC02_KJd}kYfq|%#`ipLthJ2XCg;17Xm0|}i(a@+5veL8{HCfm zytu0AE7zl^K0Y>zIJf)&{NB*&cftU|MD0hzT`p(eP|#cob2*DB`&AYBcopyzurXwS8^wn1%LPms zEBg8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ka-client - spring-cloud-eureka-feign-client - - pom - - Spring Cloud Eureka - Spring Cloud Eureka Server and Sample Clients - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - .. - - - - UTF-8 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.springframework.boot - spring-boot-maven-plugin - 1.4.0.RELEASE - - - - - diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml b/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml deleted file mode 100644 index 720b49ddc2..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - spring-cloud-eureka-client - 1.0.0-SNAPSHOT - jar - - Spring Cloud Eureka Client - Spring Cloud Eureka Sample Client - - - com.baeldung.spring.cloud - spring-cloud-eureka - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.cloud - spring-cloud-starter-eureka - 1.1.5.RELEASE - - - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Brixton.SR4 - pom - import - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java deleted file mode 100644 index 48099eeaa2..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/EurekaClientApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.spring.cloud.eureka.client; - -import com.netflix.discovery.EurekaClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; -import org.springframework.context.annotation.Lazy; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@EnableEurekaClient -@RestController -public class EurekaClientApplication implements GreetingController { - @Autowired - @Lazy - private EurekaClient eurekaClient; - - @Value("${spring.application.name}") - private String appName; - - public static void main(String[] args) { - SpringApplication.run(EurekaClientApplication.class, args); - } - - @Override - public String greeting() { - return String.format("Hello from '%s'!", eurekaClient.getApplication(appName).getName()); - } -} diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java deleted file mode 100644 index 33ee2574b7..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/java/com/baeldung/spring/cloud/eureka/client/GreetingController.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.spring.cloud.eureka.client; - -import org.springframework.web.bind.annotation.RequestMapping; - -public interface GreetingController { - @RequestMapping("/greeting") - String greeting(); -} diff --git a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml deleted file mode 100644 index 08624aa159..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-client/src/main/resources/application.yml +++ /dev/null @@ -1,13 +0,0 @@ -spring: - application: - name: spring-cloud-eureka-client - -server: - port: 0 - -eureka: - client: - serviceUrl: - defaultZone: ${EUREKA_URI:http://localhost:8761/eureka} - instance: - preferIpAddress: true \ No newline at end of file diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml b/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml deleted file mode 100644 index 9e639c666a..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - - spring-cloud-eureka-feign-client - 1.0.0-SNAPSHOT - jar - - Spring Cloud Eureka Feign Client - Spring Cloud Eureka - Sample Feign Client - - - com.baeldung.spring.cloud - spring-cloud-eureka - 1.0.0-SNAPSHOT - .. - - - - - com.baeldung.spring.cloud - spring-cloud-eureka-client - 1.0.0-SNAPSHOT - - - org.springframework.cloud - spring-cloud-starter-feign - 1.1.5.RELEASE - - - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-thymeleaf - 1.4.0.RELEASE - - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Brixton.SR4 - pom - import - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java deleted file mode 100644 index 7beb51d1ac..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/FeignClientApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.spring.cloud.feign.client; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; - -@SpringBootApplication -@EnableEurekaClient -@EnableFeignClients -@Controller -public class FeignClientApplication { - @Autowired - private GreetingClient greetingClient; - - public static void main(String[] args) { - SpringApplication.run(FeignClientApplication.class, args); - } - - @RequestMapping("/get-greeting") - public String greeting(Model model) { - model.addAttribute("greeting", greetingClient.greeting()); - return "greeting-view"; - } -} diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java deleted file mode 100644 index 6bd444b347..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/java/com/baeldung/spring/cloud/feign/client/GreetingClient.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.spring.cloud.feign.client; - -import com.baeldung.spring.cloud.eureka.client.GreetingController; -import org.springframework.cloud.netflix.feign.FeignClient; - -@FeignClient("spring-cloud-eureka-client") -public interface GreetingClient extends GreetingController { -} diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml deleted file mode 100644 index d053ef7a7e..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/application.yml +++ /dev/null @@ -1,11 +0,0 @@ -spring: - application: - name: spring-cloud-eureka-feign-client - -server: - port: 8080 - -eureka: - client: - serviceUrl: - defaultZone: ${EUREKA_URI:http://localhost:8761/eureka} \ No newline at end of file diff --git a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html b/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html deleted file mode 100644 index 42cdadb487..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/main/resources/templates/greeting-view.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Greeting Page - - -

- - \ No newline at end of file diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml b/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml deleted file mode 100644 index f4d655f708..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - 4.0.0 - - spring-cloud-eureka-server - 1.0.0-SNAPSHOT - jar - - Spring Cloud Eureka Server - Spring Cloud Eureka Server Demo - - - com.baeldung.spring.cloud - spring-cloud-eureka - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.cloud - spring-cloud-starter-eureka-server - 1.1.5.RELEASE - - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Brixton.SR4 - pom - import - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java b/spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java deleted file mode 100644 index d55145448d..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/java/com/baeldung/spring/cloud/eureka/server/EurekaServerApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.spring.cloud.eureka.server; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; - -@SpringBootApplication -@EnableEurekaServer -public class EurekaServerApplication { - public static void main(String[] args) { - SpringApplication.run(EurekaServerApplication.class, args); - } -} diff --git a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml b/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml deleted file mode 100644 index 49c3179bb5..0000000000 --- a/spring-cloud-eureka/spring-cloud-eureka-server/src/main/resources/application.yml +++ /dev/null @@ -1,7 +0,0 @@ -server: - port: 8761 - -eureka: - client: - registerWithEureka: false - fetchRegistry: false \ No newline at end of file diff --git a/spring-cloud-hystrix/pom.xml b/spring-cloud-hystrix/pom.xml deleted file mode 100644 index 2768a4f05b..0000000000 --- a/spring-cloud-hystrix/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - - com.baeldung.spring.cloud - spring-cloud-hystrix - 1.0.0-SNAPSHOT - - spring-cloud-hystrix-rest-producer - spring-cloud-hystrix-rest-consumer - spring-cloud-hystrix-feign-rest-consumer - - pom - - Spring Cloud Hystrix - Spring Cloud Hystrix Demo - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - .. - - - - UTF-8 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - org.springframework.boot - spring-boot-maven-plugin - 1.4.0.RELEASE - - - - - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml deleted file mode 100644 index d2716e897e..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 4.0.0 - - spring-cloud-hystrix-feign-rest-consumer - 1.0.0-SNAPSHOT - jar - - Spring Cloud Hystrix Feign REST Consumer - Spring Cloud Hystrix Feign Sample Implementation - - - com.baeldung.spring.cloud - spring-cloud-hystrix - 1.0.0-SNAPSHOT - .. - - - - - com.baeldung.spring.cloud - spring-cloud-hystrix-rest-producer - 1.0.0-SNAPSHOT - - - org.springframework.cloud - spring-cloud-starter-hystrix - 1.1.5.RELEASE - - - org.springframework.cloud - spring-cloud-starter-hystrix-dashboard - 1.1.5.RELEASE - - - org.springframework.cloud - spring-cloud-starter-feign - 1.1.5.RELEASE - - - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-thymeleaf - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-actuator - 1.4.0.RELEASE - - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Brixton.SR4 - pom - import - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java deleted file mode 100644 index b715e8c052..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.consumer; - -import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController; -import org.springframework.cloud.netflix.feign.FeignClient; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PathVariable; - -@FeignClient( - name = "rest-producer", - url = "http://localhost:9090", - fallback = GreetingClient.GreetingClientFallback.class -) -public interface GreetingClient extends GreetingController { - @Component - public static class GreetingClientFallback implements GreetingClient { - @Override - public String greeting(@PathVariable("username") String username) { - return "Hello User!"; - } - } -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java deleted file mode 100644 index b97d84eaf2..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.consumer; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; - -@SpringBootApplication -@EnableCircuitBreaker -@EnableHystrixDashboard -@EnableFeignClients -@Controller -public class RestConsumerFeignApplication { - @Autowired - private GreetingClient greetingClient; - - public static void main(String[] args) { - SpringApplication.run(RestConsumerFeignApplication.class, args); - } - - @RequestMapping("/get-greeting/{username}") - public String getGreeting(Model model, @PathVariable("username") String username) { - model.addAttribute("greeting", greetingClient.greeting(username)); - return "greeting-view"; - } -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties deleted file mode 100644 index 3cf12afeb9..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8082 diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html deleted file mode 100644 index 302390fde0..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Greetings from Hystrix - - -

- - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml deleted file mode 100644 index c9be67c302..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - spring-cloud-hystrix-rest-consumer - 1.0.0-SNAPSHOT - jar - - Spring Cloud Hystrix REST Consumer - Spring Cloud Hystrix Sample Implementation - - - com.baeldung.spring.cloud - spring-cloud-hystrix - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.cloud - spring-cloud-starter-hystrix - 1.1.5.RELEASE - - - org.springframework.cloud - spring-cloud-starter-hystrix-dashboard - 1.1.5.RELEASE - - - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-thymeleaf - 1.4.0.RELEASE - - - org.springframework.boot - spring-boot-starter-actuator - 1.4.0.RELEASE - - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Brixton.SR4 - pom - import - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java deleted file mode 100644 index d3d5e6e047..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.consumer; - -import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class GreetingService { - @HystrixCommand(fallbackMethod = "defaultGreeting") - public String getGreeting(String username) { - return new RestTemplate().getForObject("http://localhost:9090/greeting/{username}", String.class, username); - } - - private String defaultGreeting(String username) { - return "Hello User!"; - } -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java deleted file mode 100644 index 9df745b1c6..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.consumer; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; -import org.springframework.cloud.netflix.hystrix.EnableHystrix; -import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; - -@SpringBootApplication -@EnableCircuitBreaker -@EnableHystrixDashboard -@Controller -public class RestConsumerApplication { - @Autowired - private GreetingService greetingService; - - public static void main(String[] args) { - SpringApplication.run(RestConsumerApplication.class, args); - } - - @RequestMapping("/get-greeting/{username}") - public String getGreeting(Model model, @PathVariable("username") String username) { - model.addAttribute("greeting", greetingService.getGreeting(username)); - return "greeting-view"; - } -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties deleted file mode 100644 index 4c00e40deb..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8080 diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html deleted file mode 100644 index 302390fde0..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - Greetings from Hystrix - - -

- - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml deleted file mode 100644 index 44e373c8ac..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - spring-cloud-hystrix-rest-producer - 1.0.0-SNAPSHOT - jar - - Spring Cloud Hystrix REST Producer - Spring Cloud Hystrix Sample REST Producer Implementation - - - com.baeldung.spring.cloud - spring-cloud-hystrix - 1.0.0-SNAPSHOT - .. - - - - - org.springframework.boot - spring-boot-starter-web - 1.4.0.RELEASE - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java deleted file mode 100644 index 81541b4f8f..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.producer; - -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -public interface GreetingController { - @RequestMapping("/greeting/{username}") - String greeting(@PathVariable("username") String username); -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java deleted file mode 100644 index 9496d4760d..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.spring.cloud.hystrix.rest.producer; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@RestController -public class RestProducerApplication implements GreetingController { - public static void main(String[] args) { - SpringApplication.run(RestProducerApplication.class, args); - } - - @Override - public String greeting(@PathVariable("username") String username) { - return String.format("Hello %s!\n", username); - } -} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties deleted file mode 100644 index 9ce9d88ffb..0000000000 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.application.name=rest-producer -server.port=9090 From 41a12d4bca7bd06d506ae23ab89874e0d5f3b546 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Fri, 2 Sep 2016 07:33:43 +0200 Subject: [PATCH 31/56] BAEL-312 Adding the config clients' properties files so that they are accessible in git. This is currently on my git account and will need to be switched to eugen's after the pull request has completed. --- spring-cloud/pom.xml | 1 + .../application-config/discovery.properties | 13 ++++ .../application-config/gateway.properties | 15 +++++ spring-cloud/spring-cloud-integration/pom.xml | 61 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 spring-cloud/spring-cloud-integration/application-config/discovery.properties create mode 100644 spring-cloud/spring-cloud-integration/application-config/gateway.properties create mode 100644 spring-cloud/spring-cloud-integration/pom.xml diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index 4f6b37a76f..340923cbdf 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -10,6 +10,7 @@ spring-cloud-config spring-cloud-eureka spring-cloud-hystrix + spring-cloud-integration pom diff --git a/spring-cloud/spring-cloud-integration/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/application-config/discovery.properties new file mode 100644 index 0000000000..40764d0ddb --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/discovery.properties @@ -0,0 +1,13 @@ +spring.application.name=discovery +server.port=8082 + +eureka.instance.hostname=localhost + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ +eureka.client.register-with-eureka=false +eureka.client.fetch-registry=false + +#management.context-path=/manage +#eureka.instance.status-page-url-path=${management.context-path}/info +#eureka.instance.health-check-url-path=${management.context-path}/health + diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/application-config/gateway.properties new file mode 100644 index 0000000000..308f6ace6c --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/gateway.properties @@ -0,0 +1,15 @@ +spring.application.name=gateway +server.port=8084 + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ + +#management.context-path=/manage +#eureka.instance.status-page-url-path=${management.context-path}/info +#eureka.instance.health-check-url-path=${management.context-path}/health + +zuul.routes.ui.path=/resource/** + +logging.level.org.springframework.cloud.netflix.zuul=debug + diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml new file mode 100644 index 0000000000..5417e83cbf --- /dev/null +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + pom + + + config + discovery + gateway + resource + + + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + org.springframework.data + spring-data-releasetrain + Hopper-SR2 + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file From ac421c8bac4997897e03a98f2fdd45c2c4dbea96 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Fri, 2 Sep 2016 08:30:14 +0200 Subject: [PATCH 32/56] BAEL-312 Committing the 4 projects for the first article. --- .../spring-cloud-integration/config/pom.xml | 27 ++++++++++++++++ .../integration/config/ConfigApplication.java | 15 +++++++++ .../src/main/resources/application.properties | 8 +++++ .../discovery/pom.xml | 28 ++++++++++++++++ .../discovery/DiscoveryApplication.java | 13 ++++++++ .../src/main/resources/bootstrap.properties | 2 ++ .../spring-cloud-integration/gateway/pom.xml | 32 +++++++++++++++++++ .../resource/GatewayApplication.java | 15 +++++++++ .../src/main/resources/bootstrap.properties | 5 +++ .../spring-cloud-integration/resource/pom.xml | 31 ++++++++++++++++++ .../resource/ResourceApplication.java | 25 +++++++++++++++ .../src/main/resources/bootstrap.properties | 5 +++ 12 files changed, 206 insertions(+) create mode 100644 spring-cloud/spring-cloud-integration/config/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java create mode 100644 spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties create mode 100644 spring-cloud/spring-cloud-integration/discovery/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java create mode 100644 spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties create mode 100644 spring-cloud/spring-cloud-integration/gateway/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java create mode 100644 spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties create mode 100644 spring-cloud/spring-cloud-integration/resource/pom.xml create mode 100644 spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java create mode 100644 spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/config/pom.xml b/spring-cloud/spring-cloud-integration/config/pom.xml new file mode 100644 index 0000000000..b186a1d5ca --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + config + 1.0.0-SNAPSHOT + + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-eureka + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java b/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java new file mode 100644 index 0000000000..ff6c093b8b --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud.integration.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; + +@SpringBootApplication +@EnableConfigServer +@EnableEurekaClient +public class ConfigApplication { + public static void main(String[] args) { + SpringApplication.run(ConfigApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties new file mode 100644 index 0000000000..e3dd94c386 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties @@ -0,0 +1,8 @@ +server.port=8081 +spring.application.name=config + +spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/application-config + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/discovery/pom.xml b/spring-cloud/spring-cloud-integration/discovery/pom.xml new file mode 100644 index 0000000000..c827895547 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + discovery + 1.0.0-SNAPSHOT + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka-server + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java b/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java new file mode 100644 index 0000000000..a21c65312f --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.spring.cloud.integration.discovery; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@SpringBootApplication +@EnableEurekaServer +public class DiscoveryApplication { + public static void main(String[] args) { + SpringApplication.run(DiscoveryApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..ca9d59c9ed --- /dev/null +++ b/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties @@ -0,0 +1,2 @@ +spring.cloud.config.name=discovery +spring.cloud.config.uri=http://localhost:8081 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/gateway/pom.xml b/spring-cloud/spring-cloud-integration/gateway/pom.xml new file mode 100644 index 0000000000..5e2db3a7af --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + gateway + 1.0.0-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.cloud + spring-cloud-starter-zuul + + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java b/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java new file mode 100644 index 0000000000..66e7c36f2a --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud.integration.resource; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +@SpringBootApplication +@EnableZuulProxy +@EnableEurekaClient +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..9610d72675 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties @@ -0,0 +1,5 @@ +spring.cloud.config.name=gateway +spring.cloud.config.discovery.service-id=config +spring.cloud.config.discovery.enabled=true + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/pom.xml b/spring-cloud/spring-cloud-integration/resource/pom.xml new file mode 100644 index 0000000000..1b109022f4 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + resource + 1.0.0-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-eureka + + + org.springframework.boot + spring-boot-starter-web + + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java b/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java new file mode 100644 index 0000000000..107a9d199f --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.cloud.integration.resource; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@EnableEurekaClient +@RestController +public class ResourceApplication { + public static void main(String[] args) { + SpringApplication.run(ResourceApplication.class, args); + } + + @Value("${resource.returnString}") + private String returnString; + + @RequestMapping("/hello/cloud") + public String getString() { + return returnString; + } +} diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties new file mode 100644 index 0000000000..3c88a0b520 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties @@ -0,0 +1,5 @@ +spring.cloud.config.name=resource +spring.cloud.config.discovery.service-id=config +spring.cloud.config.discovery.enabled=true + +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ \ No newline at end of file From 1df12fbb97cc4131c8a515239711654507e5e488 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Fri, 2 Sep 2016 08:32:12 +0200 Subject: [PATCH 33/56] BAEL-312 Adding the resource files that will need to be in a separate git repository. --- .../application-config/gateway.properties | 9 +++------ .../application-config/resource.properties | 8 ++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 spring-cloud/spring-cloud-integration/application-config/resource.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/application-config/gateway.properties index 308f6ace6c..8385c2c395 100644 --- a/spring-cloud/spring-cloud-integration/application-config/gateway.properties +++ b/spring-cloud/spring-cloud-integration/application-config/gateway.properties @@ -1,15 +1,12 @@ spring.application.name=gateway -server.port=8084 +server.port=8080 eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ -#management.context-path=/manage -#eureka.instance.status-page-url-path=${management.context-path}/info -#eureka.instance.health-check-url-path=${management.context-path}/health - -zuul.routes.ui.path=/resource/** +zuul.routes.resource.path=/resource/** +hystrix.command.resource.execution.isolation.thread.timeoutInMilliseconds: 5000 logging.level.org.springframework.cloud.netflix.zuul=debug diff --git a/spring-cloud/spring-cloud-integration/application-config/resource.properties b/spring-cloud/spring-cloud-integration/application-config/resource.properties new file mode 100644 index 0000000000..4e6cf3817c --- /dev/null +++ b/spring-cloud/spring-cloud-integration/application-config/resource.properties @@ -0,0 +1,8 @@ +spring.application.name=resource +server.port=8083 + +resource.returnString=hello cloud + +eureka.client.region = default +eureka.client.registryFetchIntervalSeconds = 5 +eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ From 4d2b5f0aa2d64aa1e01da7892d2766d3cd7331a6 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Sun, 4 Sep 2016 06:10:22 +0200 Subject: [PATCH 34/56] BAEL-314 moving the project into a sub module to better organizae the article projects. --- .../application-config/discovery.properties | 0 .../application-config/gateway.properties | 0 .../application-config/resource.properties | 0 .../{ => part-1}/config/pom.xml | 2 +- .../integration/config/ConfigApplication.java | 0 .../src/main/resources/application.properties | 2 +- .../{ => part-1}/discovery/pom.xml | 2 +- .../discovery/DiscoveryApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 .../{ => part-1}/gateway/pom.xml | 2 +- .../resource/GatewayApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 .../spring-cloud-integration/part-1/pom.xml | 25 +++++++++++++++++++ .../{ => part-1}/resource/pom.xml | 2 +- .../resource/ResourceApplication.java | 0 .../src/main/resources/bootstrap.properties | 0 spring-cloud/spring-cloud-integration/pom.xml | 12 +-------- 17 files changed, 31 insertions(+), 16 deletions(-) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/discovery.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/gateway.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/application-config/resource.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/pom.xml (92%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/config/src/main/resources/application.properties (78%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/discovery/src/main/resources/bootstrap.properties (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/gateway/src/main/resources/bootstrap.properties (100%) create mode 100644 spring-cloud/spring-cloud-integration/part-1/pom.xml rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/pom.xml (93%) rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java (100%) rename spring-cloud/spring-cloud-integration/{ => part-1}/resource/src/main/resources/bootstrap.properties (100%) diff --git a/spring-cloud/spring-cloud-integration/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/discovery.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/gateway.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties diff --git a/spring-cloud/spring-cloud-integration/application-config/resource.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/application-config/resource.properties rename to spring-cloud/spring-cloud-integration/part-1/application-config/resource.properties diff --git a/spring-cloud/spring-cloud-integration/config/pom.xml b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml similarity index 92% rename from spring-cloud/spring-cloud-integration/config/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/config/pom.xml index b186a1d5ca..c64b3626b1 100644 --- a/spring-cloud/spring-cloud-integration/config/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/config/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java b/spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java rename to spring-cloud/spring-cloud-integration/part-1/config/src/main/java/com/baeldung/spring/cloud/integration/config/ConfigApplication.java diff --git a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties similarity index 78% rename from spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties rename to spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties index e3dd94c386..249ee471a6 100644 --- a/spring-cloud/spring-cloud-integration/config/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties @@ -1,7 +1,7 @@ server.port=8081 spring.application.name=config -spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/application-config +spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/part-1/application-config eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 diff --git a/spring-cloud/spring-cloud-integration/discovery/pom.xml b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/discovery/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml index c827895547..6fe5d807f8 100644 --- a/spring-cloud/spring-cloud-integration/discovery/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java rename to spring-cloud/spring-cloud-integration/part-1/discovery/src/main/java/com/baeldung/spring/cloud/integration/discovery/DiscoveryApplication.java diff --git a/spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/discovery/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/discovery/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/gateway/pom.xml b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/gateway/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml index 5e2db3a7af..40f1884004 100644 --- a/spring-cloud/spring-cloud-integration/gateway/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java rename to spring-cloud/spring-cloud-integration/part-1/gateway/src/main/java/com/baeldung/spring/cloud/integration/resource/GatewayApplication.java diff --git a/spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/gateway/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/gateway/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/part-1/pom.xml b/spring-cloud/spring-cloud-integration/part-1/pom.xml new file mode 100644 index 0000000000..770e26bca2 --- /dev/null +++ b/spring-cloud/spring-cloud-integration/part-1/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + + com.baeldung.spring.cloud + spring-cloud-integration + 1.0.0-SNAPSHOT + + + + config + discovery + gateway + resource + + + part-1 + 1.0.0-SNAPSHOT + pom + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/resource/pom.xml b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml similarity index 93% rename from spring-cloud/spring-cloud-integration/resource/pom.xml rename to spring-cloud/spring-cloud-integration/part-1/resource/pom.xml index 1b109022f4..f1a17918ef 100644 --- a/spring-cloud/spring-cloud-integration/resource/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml @@ -6,7 +6,7 @@ com.baeldung.spring.cloud - spring-cloud-integration + part-1 1.0.0-SNAPSHOT diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java similarity index 100% rename from spring-cloud/spring-cloud-integration/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java rename to spring-cloud/spring-cloud-integration/part-1/resource/src/main/java/com/baeldung/spring/cloud/integration/resource/ResourceApplication.java diff --git a/spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties b/spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties similarity index 100% rename from spring-cloud/spring-cloud-integration/resource/src/main/resources/bootstrap.properties rename to spring-cloud/spring-cloud-integration/part-1/resource/src/main/resources/bootstrap.properties diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml index 5417e83cbf..922875df14 100644 --- a/spring-cloud/spring-cloud-integration/pom.xml +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -10,10 +10,7 @@ pom - config - discovery - gateway - resource + part-1 @@ -40,13 +37,6 @@ pom import - - org.springframework.data - spring-data-releasetrain - Hopper-SR2 - pom - import - From 38e5047e28e6c1ed01cf892f5f10890f62888498 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Sun, 4 Sep 2016 06:55:42 +0200 Subject: [PATCH 35/56] BAEL-314 modifying the config application properties so that it points to a generic file location. --- .../part-1/config/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties index 249ee471a6..6f614d0690 100644 --- a/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-integration/part-1/config/src/main/resources/application.properties @@ -1,7 +1,7 @@ server.port=8081 spring.application.name=config -spring.cloud.config.server.git.uri=file:///C:/src/cms-git/tutorials/spring-cloud/spring-cloud-integration/part-1/application-config +spring.cloud.config.server.git.uri=file:///${user.home}/application-config eureka.client.region = default eureka.client.registryFetchIntervalSeconds = 5 From 0b1ad872fcd93f83286aacdc4ed9f11ba689f0b2 Mon Sep 17 00:00:00 2001 From: Tim Schimandle Date: Tue, 6 Sep 2016 01:40:29 +0200 Subject: [PATCH 36/56] BAEL-314 adding changes to the POM structure so that each project can run in isolation --- .../application-config/discovery.properties | 5 --- .../application-config/gateway.properties | 2 - .../part-1/discovery/pom.xml | 41 +++++++++++++++---- .../part-1/gateway/pom.xml | 39 ++++++++++++++---- .../part-1/resource/pom.xml | 40 ++++++++++++++---- spring-cloud/spring-cloud-integration/pom.xml | 36 ---------------- 6 files changed, 98 insertions(+), 65 deletions(-) diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties index 40764d0ddb..7f3df86c7e 100644 --- a/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties +++ b/spring-cloud/spring-cloud-integration/part-1/application-config/discovery.properties @@ -6,8 +6,3 @@ eureka.instance.hostname=localhost eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ eureka.client.register-with-eureka=false eureka.client.fetch-registry=false - -#management.context-path=/manage -#eureka.instance.status-page-url-path=${management.context-path}/info -#eureka.instance.health-check-url-path=${management.context-path}/health - diff --git a/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties index 8385c2c395..77faec8421 100644 --- a/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties +++ b/spring-cloud/spring-cloud-integration/part-1/application-config/gateway.properties @@ -8,5 +8,3 @@ eureka.client.serviceUrl.defaultZone=http://localhost:8082/eureka/ zuul.routes.resource.path=/resource/** hystrix.command.resource.execution.isolation.thread.timeoutInMilliseconds: 5000 -logging.level.org.springframework.cloud.netflix.zuul=debug - diff --git a/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml index 6fe5d807f8..ee7c589549 100644 --- a/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/discovery/pom.xml @@ -4,17 +4,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - discovery 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + - org.springframework.cloud spring-cloud-starter-config @@ -23,6 +23,31 @@ org.springframework.cloud spring-cloud-starter-eureka-server + + org.springframework.boot + spring-boot-starter-test + test + - + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml index 40f1884004..8e56d0fd35 100644 --- a/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/gateway/pom.xml @@ -4,15 +4,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - gateway 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + org.springframework.cloud @@ -26,7 +27,31 @@ org.springframework.cloud spring-cloud-starter-zuul + + org.springframework.boot + spring-boot-starter-test + test + - + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml index f1a17918ef..78112fa3e0 100644 --- a/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml +++ b/spring-cloud/spring-cloud-integration/part-1/resource/pom.xml @@ -4,15 +4,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.baeldung.spring.cloud - part-1 - 1.0.0-SNAPSHOT - - resource 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.4.0.RELEASE + + + org.springframework.cloud @@ -26,6 +27,31 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-test + test + - + + + + + org.springframework.cloud + spring-cloud-dependencies + Brixton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-integration/pom.xml b/spring-cloud/spring-cloud-integration/pom.xml index 922875df14..1d56995009 100644 --- a/spring-cloud/spring-cloud-integration/pom.xml +++ b/spring-cloud/spring-cloud-integration/pom.xml @@ -12,40 +12,4 @@ part-1 - - - org.springframework.boot - spring-boot-starter-parent - 1.4.0.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Brixton.RELEASE - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - \ No newline at end of file From 035ea531b6c755955f7c2d2d2d191d400baca4fd Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Thu, 15 Sep 2016 14:20:31 +0200 Subject: [PATCH 37/56] NOJIRA - temporarily excluding spring-cloud-integration from the build --- spring-cloud/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index 340923cbdf..e2a676dfe8 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -10,7 +10,7 @@ spring-cloud-config spring-cloud-eureka spring-cloud-hystrix - spring-cloud-integration + pom From 443f43e488fe1b71bc66727e9a138c32602220ad Mon Sep 17 00:00:00 2001 From: gatmeister Date: Fri, 16 Sep 2016 00:02:45 +0800 Subject: [PATCH 38/56] added serialUID to fix warning --- .../org/baeldung/web/controller/status/ForbiddenException.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java index 1d4aff2ebf..348ee6d596 100644 --- a/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java +++ b/spring-rest/src/main/java/org/baeldung/web/controller/status/ForbiddenException.java @@ -5,5 +5,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.FORBIDDEN, reason="To show an example of a custom message") public class ForbiddenException extends RuntimeException { + private static final long serialVersionUID = 6826605655586311552L; } From 6ecf4f6e78888562a35539577c879dd579d0febf Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Fri, 16 Sep 2016 00:25:27 +0100 Subject: [PATCH 39/56] Add new QueryBuilder cases, factorize node client initialisation --- .../elasticsearch/ElasticSearchUnitTests.java | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java index 9a6bfb19a2..7121495e5a 100644 --- a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java +++ b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java @@ -26,6 +26,8 @@ import com.alibaba.fastjson.JSON; public class ElasticSearchUnitTests { private List listOfPersons = new ArrayList(); String jsonString = null; + + Client client = null; @Before public void setUp() { @@ -34,15 +36,13 @@ public class ElasticSearchUnitTests { listOfPersons.add(person1); listOfPersons.add(person2); jsonString = JSON.toJSONString(listOfPersons); - System.out.println(jsonString); + Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); + client = node.client(); } @Test public void givenJsonString_whenJavaObject_thenIndexDocument() { String jsonObject = "{\"age\":20,\"dateOfBirth\":1471466076564,\"fullName\":\"John Doe\"}"; - - Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); - Client client = node.client(); IndexResponse response = client.prepareIndex("people", "Doe") .setSource(jsonObject).get(); String id = response.getId(); @@ -56,9 +56,6 @@ public class ElasticSearchUnitTests { @Test public void givenDocumentId_whenJavaObject_thenDeleteDocument() { String jsonObject = "{\"age\":10,\"dateOfBirth\":1471455886564,\"fullName\":\"Johan Doe\"}"; - - Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); - Client client = node.client(); IndexResponse response = client.prepareIndex("people", "Doe") .setSource(jsonObject).get(); String id = response.getId(); @@ -68,8 +65,6 @@ public class ElasticSearchUnitTests { @Test public void givenSearchRequest_whenMatchAll_thenReturnAllResults() { - Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); - Client client = node.client(); SearchResponse response = client.prepareSearch().execute().actionGet(); SearchHit[] searchHits = response.getHits().getHits(); List results = new ArrayList(); @@ -82,8 +77,7 @@ public class ElasticSearchUnitTests { @Test public void givenSearchParamters_thenReturnResults() { - Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); - Client client = node.client(); + boolean isExecutedSuccessfully = true; SearchResponse response = client.prepareSearch() .setTypes() .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) @@ -91,19 +85,42 @@ public class ElasticSearchUnitTests { .setFrom(0).setSize(60).setExplain(true) .execute() .actionGet(); - SearchHit[] searchHits = response.getHits().getHits(); - List results = new ArrayList(); - for(SearchHit hit : searchHits){ - String sourceAsString = hit.getSourceAsString(); - Person person = JSON.parseObject(sourceAsString, Person.class); - results.add(person); + + SearchResponse response2 = client.prepareSearch() + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders + .simpleQueryStringQuery("+John -Doe OR Janette")) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); + + SearchResponse response3 = client.prepareSearch() + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders.matchQuery( + "John", "Name*")) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); + try { + response2.getHits(); + response3.getHits(); + SearchHit[] searchHits = response.getHits().getHits(); + List results = new ArrayList(); + for(SearchHit hit : searchHits){ + String sourceAsString = hit.getSourceAsString(); + Person person = JSON.parseObject(sourceAsString, Person.class); + results.add(person); + } + } catch (Exception e) { + isExecutedSuccessfully = false; } + assertTrue(isExecutedSuccessfully); } @Test public void givenContentBuilder_whenHelpers_thanIndexJson() throws IOException { - Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); - Client client = node.client(); XContentBuilder builder = XContentFactory.jsonBuilder() .startObject() .field("fullName", "Test") From 7a0deaceb4ff23be418be0870b16a5d682b5b18b Mon Sep 17 00:00:00 2001 From: Slavisa Baeldung Date: Fri, 16 Sep 2016 15:47:46 +0200 Subject: [PATCH 40/56] BAEL-53 - minor formatting changes --- .../elasticsearch/ElasticSearchUnitTests.java | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java index 7121495e5a..a5f103c005 100644 --- a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java +++ b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java @@ -26,7 +26,6 @@ import com.alibaba.fastjson.JSON; public class ElasticSearchUnitTests { private List listOfPersons = new ArrayList(); String jsonString = null; - Client client = null; @Before @@ -44,71 +43,68 @@ public class ElasticSearchUnitTests { public void givenJsonString_whenJavaObject_thenIndexDocument() { String jsonObject = "{\"age\":20,\"dateOfBirth\":1471466076564,\"fullName\":\"John Doe\"}"; IndexResponse response = client.prepareIndex("people", "Doe") - .setSource(jsonObject).get(); - String id = response.getId(); + .setSource(jsonObject).get(); String index = response.getIndex(); String type = response.getType(); assertTrue(response.isCreated()); assertEquals(index, "people"); assertEquals(type, "Doe"); } - + @Test public void givenDocumentId_whenJavaObject_thenDeleteDocument() { String jsonObject = "{\"age\":10,\"dateOfBirth\":1471455886564,\"fullName\":\"Johan Doe\"}"; IndexResponse response = client.prepareIndex("people", "Doe") - .setSource(jsonObject).get(); + .setSource(jsonObject).get(); String id = response.getId(); DeleteResponse deleteResponse = client.prepareDelete("people", "Doe", id).get(); assertTrue(deleteResponse.isFound()); } - + @Test public void givenSearchRequest_whenMatchAll_thenReturnAllResults() { SearchResponse response = client.prepareSearch().execute().actionGet(); SearchHit[] searchHits = response.getHits().getHits(); List results = new ArrayList(); - for(SearchHit hit : searchHits){ + for (SearchHit hit : searchHits) { String sourceAsString = hit.getSourceAsString(); Person person = JSON.parseObject(sourceAsString, Person.class); results.add(person); } } - + @Test public void givenSearchParamters_thenReturnResults() { boolean isExecutedSuccessfully = true; SearchResponse response = client.prepareSearch() - .setTypes() - .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) - .setPostFilter(QueryBuilders.rangeQuery("age").from(5).to(15)) - .setFrom(0).setSize(60).setExplain(true) - .execute() - .actionGet(); - + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders.rangeQuery("age").from(5).to(15)) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); + SearchResponse response2 = client.prepareSearch() - .setTypes() - .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) - .setPostFilter(QueryBuilders - .simpleQueryStringQuery("+John -Doe OR Janette")) - .setFrom(0).setSize(60).setExplain(true) - .execute() - .actionGet(); - + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders.simpleQueryStringQuery("+John -Doe OR Janette")) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); + SearchResponse response3 = client.prepareSearch() - .setTypes() - .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) - .setPostFilter(QueryBuilders.matchQuery( - "John", "Name*")) - .setFrom(0).setSize(60).setExplain(true) - .execute() - .actionGet(); + .setTypes() + .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) + .setPostFilter(QueryBuilders.matchQuery("John", "Name*")) + .setFrom(0).setSize(60).setExplain(true) + .execute() + .actionGet(); try { response2.getHits(); response3.getHits(); SearchHit[] searchHits = response.getHits().getHits(); List results = new ArrayList(); - for(SearchHit hit : searchHits){ + for (SearchHit hit : searchHits) { String sourceAsString = hit.getSourceAsString(); Person person = JSON.parseObject(sourceAsString, Person.class); results.add(person); @@ -118,17 +114,17 @@ public class ElasticSearchUnitTests { } assertTrue(isExecutedSuccessfully); } - + @Test public void givenContentBuilder_whenHelpers_thanIndexJson() throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder() - .startObject() - .field("fullName", "Test") - .field("salary", "11500") - .field("age", "10") - .endObject(); + .startObject() + .field("fullName", "Test") + .field("salary", "11500") + .field("age", "10") + .endObject(); IndexResponse response = client.prepareIndex("people", "Doe") - .setSource(builder).get(); + .setSource(builder).get(); assertTrue(response.isCreated()); } } From cf53bc6585fa2f2f439de060cacf5643ed3a6064 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 17 Sep 2016 13:07:39 +0200 Subject: [PATCH 41/56] BAEL-226 - Source code for wicket --- pom.xml | 2 +- .../examples/ApplicationConfiguration.java | 10 ---- .../wicket/examples/WebAppInitializer.java | 26 --------- {wicket-intro => wicket}/README.md | 0 {wicket-intro/WicketIntro => wicket}/pom.xml | 54 ++++++------------- .../baeldung/wicket/examples/Examples.html | 0 .../baeldung/wicket/examples/Examples.java | 0 .../wicket/examples/ExamplesApplication.java | 0 .../examples/cafeaddress/CafeAddress.html | 0 .../examples/cafeaddress/CafeAddress.java | 0 .../examples/helloworld/HelloWorld.html | 0 .../examples/helloworld/HelloWorld.java | 0 .../wicket/examples/TestHomePage.java | 23 ++++++++ wicket/src/main/webapp/WEB-INF/web.xml | 32 +++++++++++ 14 files changed, 73 insertions(+), 74 deletions(-) delete mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java delete mode 100644 wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java rename {wicket-intro => wicket}/README.md (100%) rename {wicket-intro/WicketIntro => wicket}/pom.xml (70%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/Examples.html (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/Examples.java (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html (100%) rename {wicket-intro/WicketIntro => wicket}/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java (100%) create mode 100644 wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java create mode 100644 wicket/src/main/webapp/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml index 8533a0d976..97a164b5b2 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ lombok redis webjars - wicket-intro + wicket mutation-testing spring-mvc-velocity diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java deleted file mode 100644 index 2b42af9065..0000000000 --- a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ApplicationConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.wicket.examples; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan -public class ApplicationConfiguration { - -} diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java b/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java deleted file mode 100644 index 1b2d06d2dc..0000000000 --- a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/WebAppInitializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.wicket.examples; - -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import org.apache.wicket.protocol.http.WicketFilter; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - -public class WebAppInitializer implements WebApplicationInitializer { - - @Override - public void onStartup(ServletContext container) throws ServletException { - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - container.addListener(new ContextLoaderListener(context)); - context.register(ApplicationConfiguration.class); - - FilterRegistration filter = container.addFilter("ExamplesApplication", WicketFilter.class); - filter.setInitParameter("applicationClassName", ExamplesApplication.class.getName()); - filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*"); - filter.addMappingForUrlPatterns(null, false, "/*"); - } - -} \ No newline at end of file diff --git a/wicket-intro/README.md b/wicket/README.md similarity index 100% rename from wicket-intro/README.md rename to wicket/README.md diff --git a/wicket-intro/WicketIntro/pom.xml b/wicket/pom.xml similarity index 70% rename from wicket-intro/WicketIntro/pom.xml rename to wicket/pom.xml index f4b1d0e11c..929f723c2c 100644 --- a/wicket-intro/WicketIntro/pom.xml +++ b/wicket/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.wicket.examples @@ -13,13 +13,9 @@ 9.2.13.v20150730 2.5 4.12 - 4.1.1.RELEASE - 3.1.0 - 8.0.0-M1 3.5.1 2.6 UTF-8 - none @@ -29,24 +25,6 @@ ${wicket.version} - - - - org.springframework - spring-web - ${spring-web.version} - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - - - org.apache.wicket - wicket-spring - ${wicket-spring.version} - - junit @@ -64,7 +42,6 @@ - WicketIntro false @@ -81,6 +58,22 @@ + + + false + src/test/resources + + + false + src/test/java + + ** + + + **/*.java + + + true @@ -110,17 +103,4 @@ - - - - Apache Nexus - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.html similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.html rename to wicket/src/main/java/com/baeldung/wicket/examples/Examples.html diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java b/wicket/src/main/java/com/baeldung/wicket/examples/Examples.java similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/Examples.java rename to wicket/src/main/java/com/baeldung/wicket/examples/Examples.java diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java b/wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java rename to wicket/src/main/java/com/baeldung/wicket/examples/ExamplesApplication.java diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html rename to wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.html diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java b/wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java rename to wicket/src/main/java/com/baeldung/wicket/examples/cafeaddress/CafeAddress.java diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html rename to wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.html diff --git a/wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java b/wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java similarity index 100% rename from wicket-intro/WicketIntro/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java rename to wicket/src/main/java/com/baeldung/wicket/examples/helloworld/HelloWorld.java diff --git a/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java new file mode 100644 index 0000000000..a393f1d178 --- /dev/null +++ b/wicket/src/main/test/java/com/baeldung/wicket/examples/TestHomePage.java @@ -0,0 +1,23 @@ +package com.baeldung.wicket.examples; + +import org.apache.wicket.util.tester.WicketTester; +import org.junit.Before; +import org.junit.Test; + +public class TestHomePage { + private WicketTester tester; + + @Before + public void setUp() { + tester = new WicketTester(new ExamplesApplication()); + } + + @Test + public void whenPageInvoked_thanRenderedOK() { + //start and render the test page + tester.startPage(Examples.class); + + //assert rendered page class + tester.assertRenderedPage(Examples.class); + } +} diff --git a/wicket/src/main/webapp/WEB-INF/web.xml b/wicket/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..8a4451c80e --- /dev/null +++ b/wicket/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + CafeAddress + + + + + wicket.examples + org.apache.wicket.protocol.http.WicketFilter + + applicationClassName + com.baeldung.wicket.examples.ExamplesApplication + + + + + wicket.examples + /* + + \ No newline at end of file From 4101ebd609f570003aeda5af48829142bcbc9dcc Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 17 Sep 2016 13:10:29 +0200 Subject: [PATCH 42/56] BAEL-226 - adding to main build --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 41b348c893..8115c1e902 100644 --- a/pom.xml +++ b/pom.xml @@ -130,6 +130,7 @@ lombok redis + wicket xstream java-cassandra From 2310cf87173f27d1a6e97735b7f8c012614f9ad3 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 30 Aug 2016 22:04:37 +0530 Subject: [PATCH 43/56] BAEL 298 | Intro to Selenium with JUnit / TestNg --- selenium-junit-testng/pom.xml | 36 +++++++++++++++++++ .../baeldung/selenium/SeleniumExample.java | 29 +++++++++++++++ .../selenium/junit/TestSeleniumWithJUnit.java | 30 ++++++++++++++++ .../testng/TestSeleniumWithTestNG.java | 30 ++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 selenium-junit-testng/pom.xml create mode 100644 selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java create mode 100644 selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java create mode 100644 selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml new file mode 100644 index 0000000000..c6bd2b042c --- /dev/null +++ b/selenium-junit-testng/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + com.baeldung + selenium-junit-testng + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + + org.seleniumhq.selenium + selenium-java + 2.53.1 + + + junit + junit + 4.8.1 + + + org.testng + testng + 6.9.10 + + + \ No newline at end of file diff --git a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java new file mode 100644 index 0000000000..6020b6bd2c --- /dev/null +++ b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java @@ -0,0 +1,29 @@ +package main.java.com.baeldung.selenium; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public class SeleniumExample { + + private WebDriver webDriver; + private final String url = "http://www.baeldung.com/"; + private final String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials"; + + public SeleniumExample() { + webDriver = new FirefoxDriver(); + webDriver.get(url); + } + + public void closeWindow() { + webDriver.close(); + } + + public String getActualTitle() { + return webDriver.getTitle(); + } + + public String getExpectedTitle() { + return expectedTitle; + } + +} diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java new file mode 100644 index 0000000000..371f730eb9 --- /dev/null +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java @@ -0,0 +1,30 @@ +package test.java.com.baeldung.selenium.junit; + +import static org.testng.Assert.assertEquals; +import main.java.com.baeldung.selenium.SeleniumExample; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TestSeleniumWithJUnit { + + private SeleniumExample seleniumExample; + + @Before + public void setUp() { + seleniumExample = new SeleniumExample(); + } + + @After + public void tearDown() { + seleniumExample.closeWindow(); + } + + @Test + public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { + String expectedTitle = seleniumExample.getExpectedTitle(); + String actualTitle = seleniumExample.getActualTitle(); + assertEquals(actualTitle, expectedTitle); + } +} diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java new file mode 100644 index 0000000000..ec10f9ca82 --- /dev/null +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java @@ -0,0 +1,30 @@ +package test.java.com.baeldung.selenium.testng; + +import static org.testng.Assert.assertEquals; +import main.java.com.baeldung.selenium.SeleniumExample; + +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +public class TestSeleniumWithTestNG { + + private SeleniumExample seleniumExample; + + @BeforeSuite + public void setUp() { + seleniumExample = new SeleniumExample(); + } + + @AfterSuite + public void tearDown() { + seleniumExample.closeWindow(); + } + + @Test + public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { + String expectedTitle = seleniumExample.getExpectedTitle(); + String actualTitle = seleniumExample.getActualTitle(); + assertEquals(actualTitle, expectedTitle); + } +} From bc8fd9a260249a5ac38244c503f97835c233a3ca Mon Sep 17 00:00:00 2001 From: Slavisa Baeldung Date: Tue, 20 Sep 2016 16:00:07 +0200 Subject: [PATCH 44/56] BAEL-53 - moved to java8 foreach --- elasticsearch/pom.xml | 72 +++++++++++-------- .../elasticsearch/ElasticSearchUnitTests.java | 11 ++- pom.xml | 1 + 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml index c12f258b98..1c580529e6 100644 --- a/elasticsearch/pom.xml +++ b/elasticsearch/pom.xml @@ -1,35 +1,49 @@ - 4.0.0 + 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 - elasticsearch - 0.0.1-SNAPSHOT - jar + com.baeldung + elasticsearch + 0.0.1-SNAPSHOT + jar - elasticsearch - http://maven.apache.org + elasticsearch + http://maven.apache.org - - UTF-8 - + + UTF-8 + - - - org.elasticsearch - elasticsearch - 2.3.5 - - - com.alibaba - fastjson - 1.2.13 - - - junit - junit - 4.12 - test - - + + + org.elasticsearch + elasticsearch + 2.3.5 + + + com.alibaba + fastjson + 1.2.13 + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + diff --git a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java index a5f103c005..db304ee78d 100644 --- a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java +++ b/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java @@ -5,6 +5,7 @@ import static org.junit.Assert.*; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -102,13 +103,9 @@ public class ElasticSearchUnitTests { try { response2.getHits(); response3.getHits(); - SearchHit[] searchHits = response.getHits().getHits(); - List results = new ArrayList(); - for (SearchHit hit : searchHits) { - String sourceAsString = hit.getSourceAsString(); - Person person = JSON.parseObject(sourceAsString, Person.class); - results.add(person); - } + List searchHits = Arrays.asList(response.getHits().getHits()); + final List results = new ArrayList(); + searchHits.forEach(hit -> results.add(JSON.parseObject(hit.getSourceAsString(), Person.class))); } catch (Exception e) { isExecutedSuccessfully = false; } diff --git a/pom.xml b/pom.xml index 8115c1e902..a1d3e05302 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ dozer dependency-injection deltaspike + elasticsearch enterprise-patterns feign-client From 19798c4bd600d05178a58391dd9aa4e6c84d78e8 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 22 Sep 2016 18:16:22 +0200 Subject: [PATCH 45/56] Refactor ArrayListTest --- .../java/collections/ArrayListTest.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java b/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java index 9cafa179ab..30b0111555 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/ArrayListTest.java @@ -18,18 +18,18 @@ public class ArrayListTest { @Before public void setUp() { - List xs = LongStream.range(0, 16) + List list = LongStream.range(0, 16) .boxed() .map(Long::toHexString) .collect(toCollection(ArrayList::new)); - stringsToSearch = new ArrayList<>(xs); - stringsToSearch.addAll(xs); + stringsToSearch = new ArrayList<>(list); + stringsToSearch.addAll(list); } @Test public void givenNewArrayList_whenCheckCapacity_thenDefaultValue() { - List xs = new ArrayList<>(); - assertTrue(xs.isEmpty()); + List list = new ArrayList<>(); + assertTrue(list.isEmpty()); } @Test @@ -37,29 +37,29 @@ public class ArrayListTest { Collection numbers = IntStream.range(0, 10).boxed().collect(toSet()); - List xs = new ArrayList<>(numbers); - assertEquals(10, xs.size()); - assertTrue(numbers.containsAll(xs)); + List list = new ArrayList<>(numbers); + assertEquals(10, list.size()); + assertTrue(numbers.containsAll(list)); } @Test public void givenElement_whenAddToArrayList_thenIsAdded() { - List xs = new ArrayList<>(); + List list = new ArrayList<>(); - xs.add(1L); - xs.add(2L); - xs.add(1, 3L); + list.add(1L); + list.add(2L); + list.add(1, 3L); - assertThat(Arrays.asList(1L, 3L, 2L), equalTo(xs)); + assertThat(Arrays.asList(1L, 3L, 2L), equalTo(list)); } @Test public void givenCollection_whenAddToArrayList_thenIsAdded() { - List xs = new ArrayList<>(Arrays.asList(1L, 2L, 3L)); + List list = new ArrayList<>(Arrays.asList(1L, 2L, 3L)); LongStream.range(4, 10).boxed() - .collect(collectingAndThen(toCollection(ArrayList::new), ys -> xs.addAll(0, ys))); + .collect(collectingAndThen(toCollection(ArrayList::new), ys -> list.addAll(0, ys))); - assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(xs)); + assertThat(Arrays.asList(4L, 5L, 6L, 7L, 8L, 9L, 1L, 2L, 3L), equalTo(list)); } @Test @@ -106,27 +106,27 @@ public class ArrayListTest { @Test public void givenIndex_whenRemove_thenCorrectElementRemoved() { - List xs = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new)); - Collections.reverse(xs); + List list = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new)); + Collections.reverse(list); - xs.remove(0); - assertThat(xs.get(0), equalTo(8)); + list.remove(0); + assertThat(list.get(0), equalTo(8)); - xs.remove(Integer.valueOf(0)); - assertFalse(xs.contains(0)); + list.remove(Integer.valueOf(0)); + assertFalse(list.contains(0)); } @Test public void givenListIterator_whenReverseTraversal_thenRetrieveElementsInOppositeOrder() { - List xs = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new)); - ListIterator it = xs.listIterator(xs.size()); - List result = new ArrayList<>(xs.size()); + List list = IntStream.range(0, 10).boxed().collect(toCollection(ArrayList::new)); + ListIterator it = list.listIterator(list.size()); + List result = new ArrayList<>(list.size()); while (it.hasPrevious()) { result.add(it.previous()); } - Collections.reverse(xs); - assertThat(result, equalTo(xs)); + Collections.reverse(list); + assertThat(result, equalTo(list)); } @Test From 6243fa31e13199d016981225d3ecb8d9b88a882e Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 22 Sep 2016 19:42:47 +0200 Subject: [PATCH 46/56] Move Elasticsearch module into Spring-Data-Elasticsearch --- elasticsearch/README.md | 6 - elasticsearch/pom.xml | 49 --------- pom.xml | 1 - spring-data-elasticsearch/pom.xml | 11 ++ .../com/baeldung/elasticsearch/Person.java | 104 +++++++++--------- .../elasticsearch/ElasticSearchUnitTests.java | 0 6 files changed, 63 insertions(+), 108 deletions(-) delete mode 100644 elasticsearch/README.md delete mode 100644 elasticsearch/pom.xml rename {elasticsearch => spring-data-elasticsearch}/src/main/java/com/baeldung/elasticsearch/Person.java (94%) rename {elasticsearch => spring-data-elasticsearch}/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java (100%) diff --git a/elasticsearch/README.md b/elasticsearch/README.md deleted file mode 100644 index e21070dbee..0000000000 --- a/elasticsearch/README.md +++ /dev/null @@ -1,6 +0,0 @@ -========= - -## ElasticSearch - -### Relevant Articles: -- [A Guide to ElasticSearch](http://www.baeldung.com/????????) diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml deleted file mode 100644 index 1c580529e6..0000000000 --- a/elasticsearch/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - 4.0.0 - - com.baeldung - elasticsearch - 0.0.1-SNAPSHOT - jar - - elasticsearch - http://maven.apache.org - - - UTF-8 - - - - - org.elasticsearch - elasticsearch - 2.3.5 - - - com.alibaba - fastjson - 1.2.13 - - - junit - junit - 4.12 - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - - diff --git a/pom.xml b/pom.xml index a1d3e05302..8115c1e902 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,6 @@ dozer dependency-injection deltaspike - elasticsearch enterprise-patterns feign-client diff --git a/spring-data-elasticsearch/pom.xml b/spring-data-elasticsearch/pom.xml index 3a6e330564..084695c2f3 100644 --- a/spring-data-elasticsearch/pom.xml +++ b/spring-data-elasticsearch/pom.xml @@ -69,6 +69,17 @@ log4j-over-slf4j ${org.slf4j.version} + + + org.elasticsearch + elasticsearch + 2.3.5 + + + com.alibaba + fastjson + 1.2.13 + diff --git a/elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java b/spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java similarity index 94% rename from elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java rename to spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java index 8f0b19a186..b8ad59e2e2 100644 --- a/elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java +++ b/spring-data-elasticsearch/src/main/java/com/baeldung/elasticsearch/Person.java @@ -1,52 +1,52 @@ -package com.baeldung.elasticsearch; - -import java.util.Date; - -public class Person { - - private int age; - - private String fullName; - - private Date dateOfBirth; - - public Person() { - - } - - public Person(int age, String fullName, Date dateOfBirth) { - super(); - this.age = age; - this.fullName = fullName; - this.dateOfBirth = dateOfBirth; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public Date getDateOfBirth() { - return dateOfBirth; - } - - public void setDateOfBirth(Date dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } - - @Override - public String toString() { - return "Person [age=" + age + ", fullName=" + fullName + ", dateOfBirth=" + dateOfBirth + "]"; - } -} +package com.baeldung.elasticsearch; + +import java.util.Date; + +public class Person { + + private int age; + + private String fullName; + + private Date dateOfBirth; + + public Person() { + + } + + public Person(int age, String fullName, Date dateOfBirth) { + super(); + this.age = age; + this.fullName = fullName; + this.dateOfBirth = dateOfBirth; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public Date getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Date dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + @Override + public String toString() { + return "Person [age=" + age + ", fullName=" + fullName + ", dateOfBirth=" + dateOfBirth + "]"; + } +} diff --git a/elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java b/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java similarity index 100% rename from elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java rename to spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchUnitTests.java From eaa04c6c7f84d4aca94ea0699bc4619aab7be37a Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 23 Sep 2016 12:26:48 +0200 Subject: [PATCH 47/56] add live profile --- spring-rest/pom.xml | 58 ++++++++++++++++++- .../web/test/RequestMappingLiveTest.java | 2 +- ... SpringHttpMessageConvertersLiveTest.java} | 4 +- 3 files changed, 58 insertions(+), 6 deletions(-) rename spring-rest/src/test/java/org/baeldung/web/test/{SpringHttpMessageConvertersIntegrationTestsCase.java => SpringHttpMessageConvertersLiveTest.java} (97%) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 0c0d6219dd..5340f8b437 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -182,7 +182,6 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} 1.8 1.8 @@ -192,13 +191,11 @@ org.apache.maven.plugins maven-war-plugin - ${maven-war-plugin.version} org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} @@ -234,6 +231,61 @@ + + + live + + + + org.codehaus.cargo + cargo-maven2-plugin + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + none + + + **/*LiveTest.java + + + cargo + + + + + + + + + + + diff --git a/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java b/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java index fd349f1e44..3155b5cda9 100644 --- a/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java +++ b/spring-rest/src/test/java/org/baeldung/web/test/RequestMappingLiveTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import com.jayway.restassured.RestAssured; public class RequestMappingLiveTest { - private static String BASE_URI = "http://localhost:8080/spring-rest/ex/"; + private static String BASE_URI = "http://localhost:8082/spring-rest/ex/"; @Test public void givenSimplePath_whenGetFoos_thenOk() { diff --git a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java similarity index 97% rename from spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java rename to spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java index 1dfe509c09..7f250653ab 100644 --- a/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersIntegrationTestsCase.java +++ b/spring-rest/src/test/java/org/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java @@ -21,9 +21,9 @@ import org.springframework.web.client.RestTemplate; /** * Integration Test class. Tests methods hits the server's rest services. */ -public class SpringHttpMessageConvertersIntegrationTestsCase { +public class SpringHttpMessageConvertersLiveTest { - private static String BASE_URI = "http://localhost:8080/spring-rest/"; + private static String BASE_URI = "http://localhost:8082/spring-rest/"; /** * Without specifying Accept Header, uses the default response from the From 043a6bddc8424bcf869500a42c06b52402adfc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Gonz=C3=A1lez?= Date: Fri, 23 Sep 2016 14:25:09 +0200 Subject: [PATCH 48/56] Code for Optional stream filtering document (#696) * Add new module for mocks comparison. * Add sources for testing. * Changes on testCase. * Enter some tests for mockito. * More tests for Mockito. * Even more tests. * Add the rest of the mocking libraries. * Javadoc on test. * Test bare bones for EasyMock. * Fist kind of test and setup. * Add tests using EasyMock with a change on LoginService. * Create LoginControllerTest.java * Test setup * [JMockit] No method called test. * [JMockit] Two methods called test. * [JMockit] One method called test. * [JMockit] Exception mock test * [JMockit] Mocked object to pass around test. * [JMockit] Custom matcher test. * [JMockit] Partial mocking test. * [JMockit] Fix with IDE. * Not stubs. Mocks. MOCKS!!! * Remove unnecesary import. * Use correct encoding. Was having problems with buildings. * Remove failing module. * Create new module mocks and move mock-comparisons there. * Add jmockit module. * Add model class. * Add collaborator class. * Add performer class. * Add performer test. * Fix * Add interface for tests. * Test for any. * Test for with. * Test for null. * Test for times. * Test for arg that. * Test for result and returns. * Test for delegate. * Add verifications to any tests. * Add verifications to with test. * Add verification examples to methods using null. * Add verifications to methods using times. * Formatting. * Compress tests and fix one test. * Adding new article to readme. * [BAEL-178] Add collaborator for advanced article. * [BAEL-178] Add link to readme. * [BAEL-178] Add test for mockUp. * [BAEL-178] Add test for invoke method. * [BAEL-178] Add constructors and tests for mockup for constructors. * [BAEL-178] Add private fields and more test for deencapsulation. * [BAEL-178] Add inner class and test for instantiating inner classes. * [BAEL-178] Multimocks. * [BAEL-178] Add test for expectation reusing. * [BAEL-178] Move test class to tests folders. * Add postgresql dependency. * Add test and config with properties. * [BAEL-114] Add new project for JPA with JNDI. * [BAEL-114] Config without xml. * [BAEL-114] Bring part of Foo, FooServie and FooDao. * [BAEL-114] Show all foos. * [BAEL-114] Readme. * [BAEL-114] Undo changes on main jpa project. * [BAEL-114] Remove unnecesary dependencies. * [BAEL-114] Add tomcat config. * [BAEL-114] Fixes. * Add tests for Optional streams. * Add Java 9 version of the test. * Rename and move to new core-java-9 module. --- .../java9/Java9OptionalsStreamTest.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java new file mode 100644 index 0000000000..336e803985 --- /dev/null +++ b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java @@ -0,0 +1,63 @@ +package com.baeldung.java8; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Before; +import org.junit.Test; + +public class Java9OptionalsStreamTest { + + private List> listOfOptionals; + + @Before + public void populateStream() { + listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar")); + } + + @Test + public void filterOutPresentOptionalsWithFilter() { + assertEquals(4, listOfOptionals.size()); + //@format:off + List filteredList = listOfOptionals.stream() + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); + //@format:on + assertEquals(2, filteredList.size()); + assertEquals("foo", filteredList.get(0)); + assertEquals("bar", filteredList.get(1)); + } + + @Test + public void filterOutPresentOptionalsWithFlatMap() { + assertEquals(4, listOfOptionals.size()); + //@format:off + List filteredList = listOfOptionals.stream() + .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()) + .collect(Collectors.toList()); + //@format:on + assertEquals(2, filteredList.size()); + assertEquals("foo", filteredList.get(0)); + assertEquals("bar", filteredList.get(1)); + } + + @Test + public void filterOutPresentOptionalsWithJava9() { + assertEquals(4, listOfOptionals.size()); + //@format:off + List filteredList = listOfOptionals.stream() + .flatMap(Optional::stream) + .collect(Collectors.toList()); + //@format:on + assertEquals(2, filteredList.size()); + assertEquals("foo", filteredList.get(0)); + assertEquals("bar", filteredList.get(1)); + } + +} From b0a1959cf46d7fe515d2d78107d36ff6f3837531 Mon Sep 17 00:00:00 2001 From: maibin Date: Fri, 23 Sep 2016 14:37:53 +0200 Subject: [PATCH 49/56] Spring Security + Thymeleaf (CSRF) (#695) * Expression-Based Access Control PermitAll, hasRole, hasAnyRole etc. I modified classes regards to Security * Added test cases for Spring Security Expressions * Handler Interceptor - logging example * Test for logger interceptor * Removed conflicted part * UserInterceptor (adding user information to model) * Spring Handler Interceptor - session timers * Spring Security CSRF attack protection with Thymeleaf --- .../csrf/CsrfAbstractIntegrationTest.java | 2 + spring-thymeleaf/pom.xml | 130 +++++++++++------- .../thymeleaf/config/InitSecurity.java | 11 ++ .../com/baeldung/thymeleaf/config/WebApp.java | 2 +- .../thymeleaf/config/WebMVCConfig.java | 3 +- .../thymeleaf/config/WebMVCSecurity.java | 50 +++++++ .../main/webapp/WEB-INF/views/csrfAttack.html | 12 ++ .../csrf/CsrfEnabledIntegrationTest.java | 63 +++++++++ 8 files changed, 224 insertions(+), 49 deletions(-) create mode 100644 spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java create mode 100644 spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java create mode 100644 spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html create mode 100644 spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java index 1b5f7cd894..13cb92a745 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java @@ -14,6 +14,7 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.RequestPostProcessor; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; import com.fasterxml.jackson.core.JsonProcessingException; @@ -21,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration +@Transactional public class CsrfAbstractIntegrationTest { @Autowired diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index 51e26fdfdd..35d8c37176 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -8,24 +8,24 @@ 1.7 - 4.1.8.RELEASE + 4.3.3.RELEASE 3.0.1 - 1.7.12 - 1.1.3 + 1.7.12 + 1.1.3 2.1.4.RELEASE 1.1.0.Final 5.1.2.Final - + 3.5.1 2.6 2.19.1 1.4.18 - + @@ -45,6 +45,17 @@ spring-webmvc ${org.springframework-version} + + + org.springframework.security + spring-security-web + 4.1.3.RELEASE + + + org.springframework.security + spring-security-config + 4.1.3.RELEASE + org.thymeleaf @@ -57,29 +68,29 @@ ${org.thymeleaf-version} - - - org.slf4j - slf4j-api - ${org.slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - - org.slf4j - jcl-over-slf4j - ${org.slf4j.version} - - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + + org.slf4j + jcl-over-slf4j + ${org.slf4j.version} + + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + javax.servlet @@ -98,6 +109,31 @@ hibernate-validator ${org.hibernate-version} + + + + org.springframework + spring-test + 4.1.3.RELEASE + test + + + + + org.springframework.security + spring-security-test + 4.1.3.RELEASE + test + + + + + junit + junit + 4.12 + test + + @@ -129,25 +165,25 @@ - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - 8082 - - - - + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + 8082 + + + + diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java new file mode 100644 index 0000000000..956db4a0e5 --- /dev/null +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java @@ -0,0 +1,11 @@ +package com.baeldung.thymeleaf.config; + +import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; + +public class InitSecurity extends AbstractSecurityWebApplicationInitializer { + + public InitSecurity() { + super(WebMVCSecurity.class); + + } +} diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java index 89ad7e601e..c7d5e33cb8 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java @@ -20,7 +20,7 @@ public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer @Override protected Class[] getServletConfigClasses() { - return new Class[] { WebMVCConfig.class }; + return new Class[] { WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class }; } @Override diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java index 51c60247a1..50c9cf06fe 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java @@ -1,6 +1,5 @@ package com.baeldung.thymeleaf.config; -import com.baeldung.thymeleaf.formatter.NameFormatter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -14,6 +13,8 @@ import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.view.ThymeleafViewResolver; import org.thymeleaf.templateresolver.ServletContextTemplateResolver; +import com.baeldung.thymeleaf.formatter.NameFormatter; + @Configuration @EnableWebMvc @ComponentScan({ "com.baeldung.thymeleaf" }) diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java new file mode 100644 index 0000000000..4cc1c26403 --- /dev/null +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java @@ -0,0 +1,50 @@ +package com.baeldung.thymeleaf.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) +public class WebMVCSecurity extends WebSecurityConfigurerAdapter { + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + public WebMVCSecurity() { + super(); + } + + @Override + protected void configure(final AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication().withUser("user1").password("user1Pass").authorities("ROLE_USER"); + } + + @Override + public void configure(final WebSecurity web) throws Exception { + web.ignoring().antMatchers("/resources/**"); + } + + @Override + protected void configure(final HttpSecurity http) throws Exception { + http + .authorizeRequests() + .anyRequest() + .authenticated() + .and() + .httpBasic() + .and() + ; + } + +} diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html new file mode 100644 index 0000000000..7674caa854 --- /dev/null +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html @@ -0,0 +1,12 @@ + + + + + + +
+ + +
+ + \ No newline at end of file diff --git a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java new file mode 100644 index 0000000000..bd70881dd8 --- /dev/null +++ b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java @@ -0,0 +1,63 @@ +package org.baeldung.security.csrf; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import javax.servlet.Filter; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpSession; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.RequestPostProcessor; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import com.baeldung.thymeleaf.config.InitSecurity; +import com.baeldung.thymeleaf.config.WebApp; +import com.baeldung.thymeleaf.config.WebMVCConfig; +import com.baeldung.thymeleaf.config.WebMVCSecurity; + +@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration +@ContextConfiguration(classes = { WebApp.class, WebMVCConfig.class, WebMVCSecurity.class, InitSecurity.class }) +public class CsrfEnabledIntegrationTest { + + @Autowired + WebApplicationContext wac; + @Autowired + MockHttpSession session; + + private MockMvc mockMvc; + + @Autowired + private Filter springSecurityFilterChain; + + protected RequestPostProcessor testUser() { + return user("user1").password("user1Pass").roles("USER"); + } + + @Before + public void setup() { + mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build(); + } + + @Test + public void addStudentWithoutCSRF() throws Exception { + mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser())).andExpect(status().isForbidden()); + } + + @Test + public void addStudentWithCSRF() throws Exception { + mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser()).with(csrf())).andExpect(status().isOk()); + } + +} From 53cb5767313450551c9fd95937394ce44d9045f8 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 23 Sep 2016 19:59:35 +0200 Subject: [PATCH 50/56] exclude live test --- spring-rest/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 5340f8b437..54a8b08cc6 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -198,7 +198,7 @@ maven-surefire-plugin - + **/*LiveTest.java From 3adfc4faaa9a7a5411ab351487f12b590ea96a45 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 23 Sep 2016 21:40:28 +0200 Subject: [PATCH 51/56] minor fix --- spring-rest/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index 54a8b08cc6..18cb1dc72a 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -213,7 +213,7 @@ true - jetty8x + tomcat8x embedded @@ -318,7 +318,7 @@ 3.5.1 2.6 2.19.1 - 1.4.18 + 1.6.0
From 03ebc0255644c181da7bd56525185ea59f41d04f Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sat, 24 Sep 2016 11:33:47 +0200 Subject: [PATCH 52/56] Refactor Stream> example --- .../java9/Java9OptionalsStreamTest.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java index 336e803985..102ceda18f 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java +++ b/core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java @@ -13,36 +13,31 @@ import org.junit.Test; public class Java9OptionalsStreamTest { - private List> listOfOptionals; + private static List> listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar")); - @Before - public void populateStream() { - listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar")); - } - @Test public void filterOutPresentOptionalsWithFilter() { assertEquals(4, listOfOptionals.size()); - //@format:off + List filteredList = listOfOptionals.stream() - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); - //@format:on + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); + assertEquals(2, filteredList.size()); assertEquals("foo", filteredList.get(0)); assertEquals("bar", filteredList.get(1)); } - + @Test public void filterOutPresentOptionalsWithFlatMap() { assertEquals(4, listOfOptionals.size()); - //@format:off + List filteredList = listOfOptionals.stream() - .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()) - .collect(Collectors.toList()); - //@format:on + .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()) + .collect(Collectors.toList()); assertEquals(2, filteredList.size()); + assertEquals("foo", filteredList.get(0)); assertEquals("bar", filteredList.get(1)); } @@ -50,11 +45,11 @@ public class Java9OptionalsStreamTest { @Test public void filterOutPresentOptionalsWithJava9() { assertEquals(4, listOfOptionals.size()); - //@format:off + List filteredList = listOfOptionals.stream() - .flatMap(Optional::stream) - .collect(Collectors.toList()); - //@format:on + .flatMap(Optional::stream) + .collect(Collectors.toList()); + assertEquals(2, filteredList.size()); assertEquals("foo", filteredList.get(0)); assertEquals("bar", filteredList.get(1)); From 7bfa860df9490baef2f70b67f06e230270db5afb Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 24 Sep 2016 11:52:42 +0200 Subject: [PATCH 53/56] BAEL-39 - adding SLF4J examples --- log4j/pom.xml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/log4j/pom.xml b/log4j/pom.xml index 76c05b36c1..586769aa71 100644 --- a/log4j/pom.xml +++ b/log4j/pom.xml @@ -15,7 +15,13 @@ log4j 1.2.17 - + @@ -28,22 +34,34 @@ log4j-core 2.6 - - + com.lmax disruptor 3.3.4 - + - ch.qos.logback logback-classic 1.1.7 + + From 5a10df3396bd03d895dc0c73f5956edc25a60edd Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 24 Sep 2016 12:01:23 +0200 Subject: [PATCH 54/56] BAEL-39 - adding SLF4J examples --- .../java/com/baeldung/slf4j/Slf4jExample.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java diff --git a/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java new file mode 100644 index 0000000000..dea5f22a15 --- /dev/null +++ b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java @@ -0,0 +1,20 @@ +package com.baeldung.slf4j; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * To switch between logging frameworks you need only to uncomment needed framework dependencies in pom.xml + */ +public class SLF4JExample { + private static Logger logger = LoggerFactory.getLogger(SLF4JExample.class); + + public static void main(String[] args) { + logger.debug("Debug log message"); + logger.info("Info log message"); + logger.error("Error log message"); + + String variable = "Hello John"; + logger.debug("Printing variable value {} ", variable); + } +} From 94355ee7b8fabc08fb8fd8b624f335ed9a1579a4 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 24 Sep 2016 13:14:13 +0200 Subject: [PATCH 55/56] BAEL-39 - renaming class --- log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java index dea5f22a15..6ecc7b887a 100644 --- a/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java +++ b/log4j/src/main/java/com/baeldung/slf4j/Slf4jExample.java @@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory; /** * To switch between logging frameworks you need only to uncomment needed framework dependencies in pom.xml */ -public class SLF4JExample { - private static Logger logger = LoggerFactory.getLogger(SLF4JExample.class); +public class Slf4jExample { + private static Logger logger = LoggerFactory.getLogger(Slf4jExample.class); public static void main(String[] args) { logger.debug("Debug log message"); From 5b29f1bc8119c2e66e015f32d4f7e762d7edabef Mon Sep 17 00:00:00 2001 From: maibin Date: Sat, 24 Sep 2016 22:34:15 +0200 Subject: [PATCH 56/56] New pull for Thymeleaf (#697) * Expression-Based Access Control PermitAll, hasRole, hasAnyRole etc. I modified classes regards to Security * Added test cases for Spring Security Expressions * Handler Interceptor - logging example * Test for logger interceptor * Removed conflicted part * UserInterceptor (adding user information to model) * Spring Handler Interceptor - session timers * Spring Security CSRF attack protection with Thymeleaf * Fix and(); --- .../main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java index 4cc1c26403..00c42831de 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java @@ -43,7 +43,6 @@ public class WebMVCSecurity extends WebSecurityConfigurerAdapter { .authenticated() .and() .httpBasic() - .and() ; }