diff --git a/README.md b/README.md
index f4693f1..56bd07b 100644
--- a/README.md
+++ b/README.md
@@ -22,13 +22,56 @@ Inside the application project there is a application.servlet package containing
For the complete feature documentation, see the servlet-3.1 feature description in IBM Knowledge Center.
## Spring Boot with Spring MVC
-This provides you with a SpringBoot application that will run on WebSphere Liberty.
-
-Inside the application project there is a application.springboot.web package containing two classes:
-* SpringBootLibertyApplication: The entry point for the SpringBoot application.
-* LibertyHelloController: A Spring MVC endpoint which you can access at /springbootweb.
+This project demonstrate a "hello world" web site with Spring technology and run on IBM WebSphere Liberty Server
+Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
+Inside the application project containing two classes:
+* application.springboot.Application: The entry point for the SpringBoot application.
+* application.springboot.web.LibertyHelloController: A Spring MVC endpoint which you can access at /springbootweb.
Inside the wlpcfg project there is the it.springboot.web.HelloControllerTest
that will test the Spring MVC endpoint to ensure it is working.
+For the complete feature documentation, see the Serving Web Content with Spring MVC
+
+## Spring Boot with Jersey
+This project demonstrate creating a "hello world" RESTful web service with Spring technology and run on IBM WebSphere Liberty Server
+Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
+
+Inside the application project containing 3 classes:
+* application.springboot.Application: The entry point for the SpringBoot application.
+* application.springboot.jersey.Endpoint: A Jersey endpoint which you can access at /springbootjersey.
+* application.springboot.jersey.JerseyConfig: Jersey configuration class.
+
+Inside the wlpcfg project there is the it.springboot.jersey.SampleJerseyApplicationTests
that will test the Jersey endpoint to ensure it is working.
+
+For the complete feature documentation, see the Building a RESTful Web Service
+
+## Spring Boot with Security
+This project demonstrate creating a simple web application with resources that are protected by Spring Security and run on IBM WebSphere Liberty Server
+Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
+
+Inside the application project containing 3 classes:
+* application.springboot.Application: The entry point for the SpringBoot application.
+* application.springboot.securityMvcConfig: Map each uri to static html resources
+* application.springboot.security.WebSecurityConfig: Seucirty configuration for Springboot application
+
+Inside the wlpcfg project there is the it.springboot.security.HelloControllerTest
that will test the /springbootsecurity endpoint to ensure it is working.
+
+For the complete feature documentation, see the Securing a Web Application
+
+## Spring Boot with JDBC
+This project demonstrate how to accessing relational data with Spring technology and run on IBM WebSphere Liberty Server
+Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
+Inside the application project containing 3 classes:
+* application.springboot.Application: The entry point for the SpringBoot application.
+* application.springboot.jdbc.Customer: POJO class for DB table
+* application.springboot.jdbc.JDBCController: A Springboot JDBC endpoint which implements the JDBC DB access
+
+Inside the wlpcfg project there is the it.springboot.jdbc.HelloControllerTest
that will test the /springbootjdbc endpoint to ensure it is working.
+
+For the complete feature documentation, see the Accessing Relational Data using JDBC with Spring
## Websockets
This provides you with the websocket-1.1 feature.
diff --git a/build.gradle b/build.gradle
index 4b6b418..8cb5156 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,7 +25,7 @@ allprojects {
mavenCentral()
}
dependencies {
- classpath 'net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.1-SNAPSHOT'
+ classpath 'net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.0'
classpath files('gradle/wlp-anttasks.jar')
}
}
diff --git a/liberty-starter-application/build.gradle b/liberty-starter-application/build.gradle
index 7fa228a..93be9e6 100644
--- a/liberty-starter-application/build.gradle
+++ b/liberty-starter-application/build.gradle
@@ -108,7 +108,7 @@ liberty {
}
clean.dependsOn(':liberty-starter-wlpcfg:cleanServer')
-war.dependsOn(':liberty-filter-application:publishWar', ':starter-microservice-test:publishTestWar', ':starter-microservice-web:publishWar', ':starter-microservice-persistence:publishWar', ':starter-microservice-rest:publishWar', ':starter-microservice-websocket:publishWar', ':starter-microservice-springboot-web:publishWar', ':starter-microservice-watsonsdk:publishWar', 'compressSkeletonBuildImage', 'copySpecialFiles', 'createSwaggerJSON')
+war.dependsOn(':liberty-filter-application:publishWar', ':starter-microservice-test:publishTestWar', ':starter-microservice-web:publishWar', ':starter-microservice-persistence:publishWar', ':starter-microservice-rest:publishWar', ':starter-microservice-websocket:publishWar', ':starter-microservice-springboot-web:publishWar', ':starter-microservice-springboot-jersey:publishWar', ':starter-microservice-springboot-security:publishWar',':starter-microservice-springboot-jdbc:publishWar', ':starter-microservice-watsonsdk:publishWar', 'compressSkeletonBuildImage', 'copySpecialFiles', 'createSwaggerJSON')
installFeature.dependsOn('installLiberty')
libertyStart.dependsOn('installFeature', 'addServerEnv', 'publishWar')
fvt.dependsOn('libertyStart', 'testClasses')
diff --git a/liberty-starter-application/src/main/resources/services.json b/liberty-starter-application/src/main/resources/services.json
index c06aed3..a91030d 100644
--- a/liberty-starter-application/src/main/resources/services.json
+++ b/liberty-starter-application/src/main/resources/services.json
@@ -3,33 +3,51 @@
{
"id" : "rest",
"name" : "REST",
- "description" : "JAX-RS implementation",
+ "description" : "REST technology allows to create a simple JAX-RS application by using Liberty jaxrs-2.0 feature. \nNotice that REST technology cannot co-exist with Spring Boot with Jersey technology.",
"endpoint" : "/rest"
},
{
"id" : "websocket",
"name" : "Web Sockets",
- "description" : "WebSocket implementation",
+ "description" : "Web Sockets technology allows to create a simple WebSocket application by using Liberty websocket-1.1 feature.",
"endpoint" : "/websocket"
},
{
"id" : "persistence",
"name" : "Persistence",
- "description" : "JPA data persistence",
+ "description" : "Persistence technology allows to create a simple JPA data persistence application by using Liberty jpa-2.1 feature.",
"endpoint" : "/persistence"
},
{
"id": "web",
"name" : "Servlet",
- "description": "Servlet 3.1",
+ "description": "Servlet technology allows to create a simple Servlet 3.1 application by using Liberty servlet-3.1 feature.",
"endpoint" : "/web"
},
{
"id": "springbootweb",
"name": "Spring Boot with Spring MVC",
- "description": "Spring Boot with Spring MVC",
+ "description": "Spring Boot with Spring MVC technology allows to create a hello world web application with SpringBoot MVC.",
"endpoint" : "/springbootweb"
},
+ {
+ "id": "springbootjersey",
+ "name": "Spring Boot with Jersey",
+ "description": "Spring Boot with Jersey technology allows to create a JAX-RS application with SpringBoot Jersey support. \nNotice that Spring Boot with Jersey technology cannot co-exist with REST technology.",
+ "endpoint" : "/springbootjersey"
+ },
+ {
+ "id": "springbootsecurity",
+ "name": "Spring Boot with Security",
+ "description": "Spring Boot with Security technology allows to create a simple web application with resources that are protected by Spring Security.",
+ "endpoint" : "/springbootsecurity"
+ },
+ {
+ "id": "springbootjdbc",
+ "name": "Spring Boot with JDBC",
+ "description": "Spring Boot with JDBC technology allows to create a simple Derby DB and do some SQL operation on it.",
+ "endpoint" : "/springbootjdbc"
+ },
{
"id": "watsonsdk",
"name": "Watson SDK",
diff --git a/liberty-starter-application/src/main/webapp/css/style.css b/liberty-starter-application/src/main/webapp/css/style.css
index e7472e7..8060867 100644
--- a/liberty-starter-application/src/main/webapp/css/style.css
+++ b/liberty-starter-application/src/main/webapp/css/style.css
@@ -232,6 +232,21 @@ body {
padding-bottom: 8px;
}
+#step1TechnologiesContainer .step1TechnologyDisabled {
+ height: 80px;
+ width: 297px;
+ padding-left: 26px;
+ color: #CCCCCC;
+ font-size: 18px;
+ border: solid 1px #BEBEBE;
+ line-height: 80px;
+ display: inline-block;
+ margin-right: 40px;
+ text-decoration: none;
+ margin-bottom: 34px;
+ position: relative;
+}
+
#step1TechnologiesContainer .step1Technology {
height: 80px;
width: 297px;
diff --git a/liberty-starter-application/src/main/webapp/js/logic.js b/liberty-starter-application/src/main/webapp/js/logic.js
index 213d126..b38478e 100644
--- a/liberty-starter-application/src/main/webapp/js/logic.js
+++ b/liberty-starter-application/src/main/webapp/js/logic.js
@@ -26,7 +26,7 @@ $(document).ready(function() {
step1TechnologiesContainer.empty();
for(var i = 0; i < technologies.length; i++) {
var technology = technologies[i];
- var technologyTag = $("" + technology.name + " ");
+ var technologyTag = $("" + technology.name + " ");
technologyTag.append(' ');
step1TechnologiesContainer.append(technologyTag);
}
@@ -108,14 +108,48 @@ $(document).ready(function() {
var updateStep1Summary = function() {
var selectedTechnologies = $("#step1TechnologiesContainer .step1Technology.selected");
var selectedTechnologiesText = "";
+ var restSelected = false;
+ var springbootjerseySelected = false;
for(var i = 0; i < selectedTechnologies.size(); i++) {
selectedTechnologiesText += selectedTechnologies.get(i).dataset.technologyname;
if(i + 1 < selectedTechnologies.size()) {
selectedTechnologiesText += ", ";
}
+
+ if(selectedTechnologies.get(i).dataset.technologyid == "rest"){
+ restSelected = true;
+ }
+ if(selectedTechnologies.get(i).dataset.technologyid == "springbootjersey"){
+ springbootjerseySelected = true;
+ }
}
$("#navigationTop1 .variableContent").text(selectedTechnologiesText);
+
+ updateStep1Conflict(restSelected, "springbootjersey");
+ updateStep1Conflict(springbootjerseySelected, "rest");
};
+
+ var updateStep1Conflict = function(selected, id) {
+ if(selected){
+ var enabledTechnologies = $("#step1TechnologiesContainer .step1Technology");
+ for(var i = 0; i < enabledTechnologies.size(); i++) {
+ var technology = enabledTechnologies[i];
+ if(technology.dataset.technologyid == id){
+ technology.className = "step1TechnologyDisabled";
+ break;
+ }
+ }
+ } else {
+ var disabledTechnologies = $("#step1TechnologiesContainer .step1TechnologyDisabled");
+ for(var i = 0; i < disabledTechnologies.size(); i++) {
+ var technology = disabledTechnologies[i];
+ if(technology.dataset.technologyid == id){
+ technology.className = "step1Technology";
+ break;
+ }
+ }
+ }
+ };
var refreshSectionVisibility = function() {
var currentlyVisibleSections = $(".step:not(.hidden)").size();
diff --git a/liberty-starter-wlpcfg/servers/StarterServer/.gitignore b/liberty-starter-wlpcfg/servers/StarterServer/.gitignore
deleted file mode 100644
index fb6290b..0000000
--- a/liberty-starter-wlpcfg/servers/StarterServer/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/server.env
diff --git a/liberty-starter-wlpcfg/servers/StarterServer/resources/security/.gitignore b/liberty-starter-wlpcfg/servers/StarterServer/resources/security/.gitignore
index 11d60b9..14f955d 100644
--- a/liberty-starter-wlpcfg/servers/StarterServer/resources/security/.gitignore
+++ b/liberty-starter-wlpcfg/servers/StarterServer/resources/security/.gitignore
@@ -1,2 +1,2 @@
/ltpa.keys
-/key.jks
+/key.jks
\ No newline at end of file
diff --git a/liberty-starter-wlpcfg/servers/StarterServer/server.xml b/liberty-starter-wlpcfg/servers/StarterServer/server.xml
index bd3020d..d9e8149 100644
--- a/liberty-starter-wlpcfg/servers/StarterServer/server.xml
+++ b/liberty-starter-wlpcfg/servers/StarterServer/server.xml
@@ -39,4 +39,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 5af1dad..9835b3f 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -22,4 +22,4 @@ include 'services:webservice'
*/
rootProject.name = 'LibertyUserExperience'
-include 'liberty-starter-wlpcfg', 'liberty-filter-application', 'liberty-starter-application', 'starter-microservice-test', 'starter-microservice-web', 'starter-microservice-persistence', 'starter-microservice-rest', 'starter-microservice-websocket', 'starter-microservice-watsonsdk', 'starter-microservice-springboot-web', 'liberty-starter-model', 'liberty-starter-common'
+include 'liberty-starter-wlpcfg', 'liberty-filter-application', 'liberty-starter-application', 'starter-microservice-test', 'starter-microservice-web', 'starter-microservice-persistence', 'starter-microservice-rest', 'starter-microservice-websocket', 'starter-microservice-watsonsdk', 'starter-microservice-springboot-web', 'starter-microservice-springboot-jersey', 'starter-microservice-springboot-security','starter-microservice-springboot-jdbc', 'liberty-starter-model', 'liberty-starter-common'
diff --git a/starter-microservice-springboot-jdbc/.gitignore b/starter-microservice-springboot-jdbc/.gitignore
new file mode 100644
index 0000000..5854a45
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/.gitignore
@@ -0,0 +1,6 @@
+/target
+/build
+/.settings
+/.classpath
+/.project
+/bin
diff --git a/starter-microservice-springboot-jdbc/build.gradle b/starter-microservice-springboot-jdbc/build.gradle
new file mode 100644
index 0000000..6a48f5e
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/build.gradle
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+apply from: '../common-java.gradle'
+apply from: '../common-war.gradle'
+
+import com.ibm.liberty.starter.gradle.MavenTask
+import com.ibm.liberty.starter.gradle.FvtTask
+
+dependencies {
+ providedCompile group:'javax.ws.rs', name:'javax.ws.rs-api', version: '2.0'
+ providedCompile group:'javax.json', name:'javax.json-api', version:'1.0'
+}
+
+buildutils {
+ contextRoot = '/springbootjdbc'
+}
+
+task installAllPOMs(type: MavenTask) {
+ id 'springbootjdbc'
+ hasProvided true
+ hasRuntime true
+ hasCompile true
+}
+
+task fvt(type: FvtTask) {
+ id 'starter-microservice-springboot-jdbc'
+ finalizedBy libertyStop
+}
+
+apply from: '../tech-type-task-graph.gradle'
diff --git a/starter-microservice-springboot-jdbc/repository/0.0.1/compile-pom.xml b/starter-microservice-springboot-jdbc/repository/0.0.1/compile-pom.xml
new file mode 100644
index 0000000..5ec8134
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/repository/0.0.1/compile-pom.xml
@@ -0,0 +1,49 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootjdbc
+ compile-pom
+ 0.0.1
+
+ compile-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 1.3.5.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+
+
+
+ org.springframework
+ spring-jdbc
+ 4.2.6.RELEASE
+
+
+ org.apache.derby
+ derby
+ 10.12.1.1
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jdbc/repository/0.0.1/provided-pom.xml b/starter-microservice-springboot-jdbc/repository/0.0.1/provided-pom.xml
new file mode 100644
index 0000000..ab69f6f
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/repository/0.0.1/provided-pom.xml
@@ -0,0 +1,46 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootjdbc
+ provided-pom
+ 0.0.1
+
+ provided-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ ibm-maven-repo
+ ibm-maven-repo
+ https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/
+
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+ com.ibm.websphere.appserver.api
+ com.ibm.websphere.appserver.api.servlet
+ 1.0.10
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jdbc/repository/0.0.1/runtime-pom.xml b/starter-microservice-springboot-jdbc/repository/0.0.1/runtime-pom.xml
new file mode 100644
index 0000000..675245d
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/repository/0.0.1/runtime-pom.xml
@@ -0,0 +1,34 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootjdbc
+ runtime-pom
+ 0.0.1
+
+ runtime-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ net.wasdev.wlp.starters.web
+ server-snippet
+ xml
+ 0.0.1
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/TechnologyAPI.java b/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/TechnologyAPI.java
new file mode 100644
index 0000000..082b598
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/TechnologyAPI.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.api;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("api")
+public class TechnologyAPI extends Application {
+
+
+}
diff --git a/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java b/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java
new file mode 100644
index 0000000..f501f79
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.api.v1;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope;
+import com.ibm.liberty.starter.api.v1.model.provider.Location;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+import com.ibm.liberty.starter.api.v1.model.provider.Tag;
+
+@Path("v1/provider")
+public class ProviderEndpoint {
+
+ private static final String DEPENDENCY_URL = "http://localhost:9082/springboot/artifacts/net/wasdev/wlp/starters/springboot/jdbc";
+
+ @GET
+ @Path("/")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Provider details(@Context UriInfo info) {
+ Provider details = new Provider();
+ String description = getStringResource("/description.html");
+ details.setDescription(description);
+
+ Location repoLocation = new Location();
+ String url = info.getBaseUri().resolve("../artifacts").toString();
+ repoLocation.setUrl(url);
+ details.setRepoUrl(repoLocation);
+ Dependency providedDependency = new Dependency();
+ providedDependency.setScope(Scope.PROVIDED);
+ providedDependency.setGroupId("net.wasdev.wlp.starters.springbootjdbc");
+ providedDependency.setArtifactId("provided-pom");
+ providedDependency.setVersion("0.0.1");
+
+ Dependency runtimeDependency = new Dependency();
+ runtimeDependency.setScope(Scope.RUNTIME);
+ runtimeDependency.setGroupId("net.wasdev.wlp.starters.springbootjdbc");
+ runtimeDependency.setArtifactId("runtime-pom");
+ runtimeDependency.setVersion("0.0.1");
+
+ Dependency compileDependency = new Dependency();
+ compileDependency.setScope(Scope.COMPILE);
+ compileDependency.setGroupId("net.wasdev.wlp.starters.springbootjdbc");
+ compileDependency.setArtifactId("compile-pom");
+ compileDependency.setVersion("0.0.1");
+
+ Dependency[] dependencies = {providedDependency, runtimeDependency, compileDependency};
+ details.setDependencies(dependencies);
+ return details;
+ }
+
+ //read the description contained in the index.html file
+ private String getStringResource(String path) {
+ InputStream in = getClass().getResourceAsStream(path);
+
+ StringBuilder index = new StringBuilder();
+ char[] buffer = new char[1024];
+ int read = 0;
+ try(InputStreamReader reader = new InputStreamReader(in)){
+ while((read = reader.read(buffer)) != -1) {
+ index.append(buffer, 0, read);
+ }
+ } catch (IOException e) {
+ //just return what we've got
+ return index.toString();
+ }
+ return index.toString();
+ }
+
+ @GET
+ @Path("samples")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response constructSample(@Context UriInfo info) {
+ StringBuilder json = new StringBuilder("{\n");
+ String base = info.getBaseUri().resolve("../sample").toString();
+ json.append("\"base\" : \"" + base + "\",\n");
+ json.append(getStringResource("/locations.json"));
+ json.append("}\n");
+ return Response.ok(json.toString()).build();
+ }
+
+ @GET
+ @Path("config")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ServerConfig getServerConfig() throws Exception {
+ ServerConfig config = new ServerConfig();
+ Tag[] tags = new Tag[]{new Tag("featureManager")};
+ tags[0].setTags(new Tag[]{new Tag("feature", "websocket-1.1")});
+ config.setTags(tags);
+ return config;
+ }
+}
\ No newline at end of file
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/.gitignore b/starter-microservice-springboot-jdbc/src/main/webapp/.gitignore
new file mode 100644
index 0000000..5d43caf
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/.gitignore
@@ -0,0 +1 @@
+/artifacts
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/META-INF/.gitignore b/starter-microservice-springboot-jdbc/src/main/webapp/META-INF/.gitignore
new file mode 100644
index 0000000..f67faf7
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/META-INF/.gitignore
@@ -0,0 +1 @@
+/swagger.json
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/.gitignore b/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/.gitignore
new file mode 100644
index 0000000..5342fdc
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/.gitignore
@@ -0,0 +1 @@
+/locations.json
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/description.html b/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/description.html
new file mode 100644
index 0000000..0a54d62
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/WEB-INF/classes/description.html
@@ -0,0 +1,27 @@
+
+
+
Spring Boot with JDBC
+
This project demonstrate how to accessing relational data with Spring technology and run on IBM WebSphere Liberty Server
+
Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
Inside the application project contains three classes:
+
+ application.springboot.Application
: The entry point for the SpringBoot application
+ application.springboot.jdbc.JDBCController
: A Springboot JDBC endpoint which you can access at /springbootjdbc
+ application.springboot.jdbc.Customer
: POJO class for DB table
+
+
Inside the wlpcfg project there is the it.springboot.jdbc.HelloControllerTest
that will test the Springboot jdbc endpoint to ensure it is working.
+
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
new file mode 100644
index 0000000..4c77aa6
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
@@ -0,0 +1,19 @@
+package application.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer{
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/Customer.java b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/Customer.java
new file mode 100644
index 0000000..5003274
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/Customer.java
@@ -0,0 +1,22 @@
+package application.springboot.jdbc;
+
+public class Customer {
+ private long id;
+ private String firstName, lastName;
+
+ public Customer(long id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "Customer[id=%d, firstName='%s', lastName='%s']",
+ id, firstName, lastName);
+ }
+
+ // getters & setters omitted for brevity
+}
+
diff --git a/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/JDBCController.java b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/JDBCController.java
new file mode 100644
index 0000000..e663126
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jdbc/JDBCController.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package application.springboot.jdbc;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.core.RowMapperResultSetExtractor;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class JDBCController {
+ @Autowired
+ JdbcTemplate jdbcTemplate;
+
+ @RequestMapping("/springbootjdbc")
+ public String executeJDBC() {
+ try {
+ String result = "Welcome to Springboot JDBC running on Liberty! Creating tables: ";
+
+ jdbcTemplate.execute("CREATE SCHEMA sa");
+
+ jdbcTemplate.execute("CREATE TABLE customers(id INT, first_name VARCHAR(255), last_name VARCHAR(255))");
+
+ List splitUpNames = new ArrayList();
+ String[] names = new String[] { "John Woo", "Jeff Dean", "Josh Bloch", "Josh Long" };
+
+ for (String name : names) {
+ splitUpNames.add(name.split(" "));
+ }
+
+ for (Object[] obj : splitUpNames) {
+ result += String.format("Inserting customer record for %s %s ", obj[0], obj[1]);
+ }
+
+ // Uses JdbcTemplate's batchUpdate operation to bulk load data
+ jdbcTemplate.batchUpdate("INSERT INTO customers(first_name, last_name) VALUES (?,?)", splitUpNames);
+
+ result += "Querying for customer records where first_name = 'Josh': ";
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ List cusList = (List) jdbcTemplate.query(
+ "SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[] { "Josh" },
+ new RowMapperResultSetExtractor(new RowMapper() {
+ public Object mapRow(ResultSet rs, int index) throws SQLException {
+ Customer c = new Customer(rs.getLong("id"), rs.getString("first_name"),
+ rs.getString("last_name"));
+
+ return c;
+ }
+ }));
+
+ for (Customer cus : cusList) {
+ result += cus.toString() + " ";
+ }
+
+ // Clear environment for next execution
+ jdbcTemplate.execute("DROP TABLE customers");
+ jdbcTemplate.execute("DROP SCHEMA sa RESTRICT");
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "Error happened during JDBC execution";
+ }
+ }
+}
\ No newline at end of file
diff --git a/starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/web/SpringBootLibertyApplication.java b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jdbc/HelloControllerTest.java
similarity index 54%
rename from starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/web/SpringBootLibertyApplication.java
rename to starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jdbc/HelloControllerTest.java
index 9d6ca91..9b1953e 100644
--- a/starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/web/SpringBootLibertyApplication.java
+++ b/starter-microservice-springboot-jdbc/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jdbc/HelloControllerTest.java
@@ -13,19 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
-package application.springboot.web;
+package it.springboot.jdbc;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration;
-import org.springframework.boot.context.web.SpringBootServletInitializer;
+import static org.junit.Assert.assertTrue;
-@SpringBootApplication(exclude = MessageSourceAutoConfiguration.class)
-public class SpringBootLibertyApplication extends SpringBootServletInitializer {
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import it.EndpointTest;
- @Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
- return application.sources(SpringBootLibertyApplication.class);
- }
+import org.junit.Test;
+
+public class HelloControllerTest extends EndpointTest {
+
+ @Test
+ public void testDeployment() {
+ testEndpoint("/springbootjdbc", "Welcome to Springboot JDBC running on Liberty!");
+ }
}
\ No newline at end of file
diff --git a/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/EndpointTest.java b/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/EndpointTest.java
new file mode 100644
index 0000000..02f80bd
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/EndpointTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.api.v1.it;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class EndpointTest {
+
+ //use this to give the REST endpoint a chance to come up after the server has reported it's started
+ public void checkAvailability(String endpoint) {
+ String ep = getEndPoint(endpoint);
+ for(int x = 0; x < 3; x++) {
+ Response response = null;
+ try {
+ response = sendRequest(ep, "GET");
+ if(response.getStatus() == 200) {
+ return;
+ }
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ //just exit
+ }
+ }
+ }
+
+ private String getEndPoint(String endpoint) {
+ String port = System.getProperty("liberty.test.port");
+ String war = System.getProperty("war.name");
+ return "http://localhost:" + port + "/" + war + endpoint;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T testEndpoint(String endpoint, Class> entity) throws Exception {
+ String url = getEndPoint(endpoint);
+ System.out.println("Testing " + url);
+ Response response = null;
+ try {
+ response = sendRequest(url, "GET");
+ int responseCode = response.getStatus();
+ assertTrue("Incorrect response code for " + url + ": " + responseCode,
+ responseCode == 200);
+ String json = response.readEntity(String.class);
+ ObjectMapper mapper = new ObjectMapper();
+ return (T) mapper.readValue(json, entity);
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ }
+
+ public Response sendRequest(String url, String requestType) {
+ Client client = ClientBuilder.newClient();
+ System.out.println("Testing " + url);
+ WebTarget target = client.target(url);
+ Invocation.Builder invoBuild = target.request();
+ Response response = invoBuild.build(requestType).invoke();
+ return response;
+ }
+}
diff --git a/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java b/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
new file mode 100644
index 0000000..e20a8fd
--- /dev/null
+++ b/starter-microservice-springboot-jdbc/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.api.v1.it;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.Sample;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+
+/**
+ * Test the deployed service responds as expected
+ *
+ */
+public class TestApplication extends EndpointTest {
+
+ @Before
+ public void checkSetup() {
+ checkAvailability("/api/v1/provider/");
+ }
+
+ @Test
+ public void testProvider() throws Exception {
+ Provider provider = testEndpoint("/api/v1/provider/", Provider.class);
+ assertNotNull("No response from API for provider", provider);
+ assertTrue("Description was not found.", provider.getDescription().contains("Spring Boot with JDBC "));
+ Dependency[] dependencies = provider.getDependencies();
+ boolean providedDependency = false;
+ boolean runtimeDependency = false;
+ boolean compileDependency = false;
+ for (Dependency dependency : dependencies) {
+ if (Dependency.Scope.PROVIDED.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootjdbc".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "provided-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ providedDependency = true;
+ }
+ if (Dependency.Scope.RUNTIME.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootjdbc".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "runtime-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ runtimeDependency = true;
+ }
+ if (Dependency.Scope.COMPILE.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootjdbc".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "compile-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ compileDependency = true;
+ }
+ }
+ assertTrue("Provided dependencies weren't specified.", providedDependency);
+ assertTrue("Runtime dependencies weren't specified.", runtimeDependency);
+ assertTrue("Compile dependencies weren't specified.", compileDependency);
+ }
+
+ @Test
+ public void testConfig() throws Exception {
+ ServerConfig config = testEndpoint("/api/v1/provider/config", ServerConfig.class);
+ assertNotNull("No response from API for configuration", config);
+ String actual = config.getTags()[0].getTags()[0].getValue();
+ String expected = "websocket-1.1";
+ assertEquals("Incorrect feature specified", expected , actual);
+ }
+
+ @Test
+ public void testSamples() throws Exception {
+ Sample sample = testEndpoint("/api/v1/provider/samples", Sample.class);
+ assertNotNull("No response from API for sample", sample);
+ assertNotNull("Expected locations", sample.getLocations());
+ assertEquals("No files were expected for sample", 4, sample.getLocations().length);
+ }
+
+}
diff --git a/starter-microservice-springboot-jersey/.gitignore b/starter-microservice-springboot-jersey/.gitignore
new file mode 100644
index 0000000..5854a45
--- /dev/null
+++ b/starter-microservice-springboot-jersey/.gitignore
@@ -0,0 +1,6 @@
+/target
+/build
+/.settings
+/.classpath
+/.project
+/bin
diff --git a/starter-microservice-springboot-jersey/build.gradle b/starter-microservice-springboot-jersey/build.gradle
new file mode 100644
index 0000000..7bc8c8d
--- /dev/null
+++ b/starter-microservice-springboot-jersey/build.gradle
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+apply from: '../common-java.gradle'
+apply from: '../common-war.gradle'
+
+import com.ibm.liberty.starter.gradle.MavenTask
+import com.ibm.liberty.starter.gradle.FvtTask
+
+dependencies {
+ providedCompile group:'javax.ws.rs', name:'javax.ws.rs-api', version: '2.0'
+ providedCompile group:'javax.json', name:'javax.json-api', version:'1.0'
+}
+
+buildutils {
+ contextRoot = '/springbootjersey'
+}
+
+task installAllPOMs(type: MavenTask) {
+ id 'springbootjersey'
+ hasProvided true
+ hasRuntime true
+ hasCompile true
+}
+
+task fvt(type: FvtTask) {
+ id 'starter-microservice-springboot-jersey'
+ finalizedBy libertyStop
+}
+
+apply from: '../tech-type-task-graph.gradle'
diff --git a/starter-microservice-springboot-jersey/repository/0.0.1/compile-pom.xml b/starter-microservice-springboot-jersey/repository/0.0.1/compile-pom.xml
new file mode 100644
index 0000000..554810d
--- /dev/null
+++ b/starter-microservice-springboot-jersey/repository/0.0.1/compile-pom.xml
@@ -0,0 +1,39 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springboot.jersey
+ compile-pom
+ 0.0.1
+
+ compile-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jersey
+ 1.3.5.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jersey/repository/0.0.1/provided-pom.xml b/starter-microservice-springboot-jersey/repository/0.0.1/provided-pom.xml
new file mode 100644
index 0000000..e924198
--- /dev/null
+++ b/starter-microservice-springboot-jersey/repository/0.0.1/provided-pom.xml
@@ -0,0 +1,46 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springboot.jersey
+ provided-pom
+ 0.0.1
+
+ provided-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ ibm-maven-repo
+ ibm-maven-repo
+ https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/
+
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+ com.ibm.websphere.appserver.api
+ com.ibm.websphere.appserver.api.servlet
+ 1.0.10
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jersey/repository/0.0.1/runtime-pom.xml b/starter-microservice-springboot-jersey/repository/0.0.1/runtime-pom.xml
new file mode 100644
index 0000000..d6ab4a2
--- /dev/null
+++ b/starter-microservice-springboot-jersey/repository/0.0.1/runtime-pom.xml
@@ -0,0 +1,34 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springboot.jersey
+ runtime-pom
+ 0.0.1
+
+ runtime-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ net.wasdev.wlp.starters.web
+ server-snippet
+ xml
+ 0.0.1
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/TechnologyAPI.java b/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/TechnologyAPI.java
new file mode 100644
index 0000000..b0d2a76
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/TechnologyAPI.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.jersey.api;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("api")
+public class TechnologyAPI extends Application {
+
+
+}
diff --git a/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/ProviderEndpoint.java b/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/ProviderEndpoint.java
new file mode 100644
index 0000000..4b3f2ac
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/ProviderEndpoint.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.jersey.api.v1;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope;
+import com.ibm.liberty.starter.api.v1.model.provider.Location;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+import com.ibm.liberty.starter.api.v1.model.provider.Tag;
+
+@Path("v1/provider")
+public class ProviderEndpoint {
+
+ private static final String DEPENDENCY_URL = "http://localhost:9082/springboot/artifacts/net/wasdev/wlp/starters/springboot/jersey";
+
+ @GET
+ @Path("/")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Provider details(@Context UriInfo info) {
+ Provider details = new Provider();
+ String description = getStringResource("/description.html");
+ details.setDescription(description);
+
+ Location repoLocation = new Location();
+ String url = info.getBaseUri().resolve("../artifacts").toString();
+ repoLocation.setUrl(url);
+ details.setRepoUrl(repoLocation);
+ Dependency providedDependency = new Dependency();
+ providedDependency.setScope(Scope.PROVIDED);
+ providedDependency.setGroupId("net.wasdev.wlp.starters.springboot.jersey");
+ providedDependency.setArtifactId("provided-pom");
+ providedDependency.setVersion("0.0.1");
+
+ Dependency runtimeDependency = new Dependency();
+ runtimeDependency.setScope(Scope.RUNTIME);
+ runtimeDependency.setGroupId("net.wasdev.wlp.starters.springboot.jersey");
+ runtimeDependency.setArtifactId("runtime-pom");
+ runtimeDependency.setVersion("0.0.1");
+
+ Dependency compileDependency = new Dependency();
+ compileDependency.setScope(Scope.COMPILE);
+ compileDependency.setGroupId("net.wasdev.wlp.starters.springboot.jersey");
+ compileDependency.setArtifactId("compile-pom");
+ compileDependency.setVersion("0.0.1");
+
+ Dependency[] dependencies = {providedDependency, runtimeDependency, compileDependency};
+ details.setDependencies(dependencies);
+ return details;
+ }
+
+ //read the description contained in the index.html file
+ private String getStringResource(String path) {
+ InputStream in = getClass().getResourceAsStream(path);
+
+ StringBuilder index = new StringBuilder();
+ char[] buffer = new char[1024];
+ int read = 0;
+ try(InputStreamReader reader = new InputStreamReader(in)){
+ while((read = reader.read(buffer)) != -1) {
+ index.append(buffer, 0, read);
+ }
+ } catch (IOException e) {
+ //just return what we've got
+ return index.toString();
+ }
+ return index.toString();
+ }
+
+ @GET
+ @Path("samples")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response constructSample(@Context UriInfo info) {
+ StringBuilder json = new StringBuilder("{\n");
+ String base = info.getBaseUri().resolve("../sample").toString();
+ json.append("\"base\" : \"" + base + "\",\n");
+ json.append(getStringResource("/locations.json"));
+ json.append("}\n");
+ return Response.ok(json.toString()).build();
+ }
+
+ @GET
+ @Path("config")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ServerConfig getServerConfig() throws Exception {
+ ServerConfig config = new ServerConfig();
+ Tag[] tags = new Tag[]{new Tag("featureManager")};
+ tags[0].setTags(new Tag[]{new Tag("feature", "websocket-1.1")});
+ config.setTags(tags);
+ return config;
+ }
+}
\ No newline at end of file
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/.gitignore b/starter-microservice-springboot-jersey/src/main/webapp/.gitignore
new file mode 100644
index 0000000..5d43caf
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/.gitignore
@@ -0,0 +1 @@
+/artifacts
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/META-INF/.gitignore b/starter-microservice-springboot-jersey/src/main/webapp/META-INF/.gitignore
new file mode 100644
index 0000000..f67faf7
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/META-INF/.gitignore
@@ -0,0 +1 @@
+/swagger.json
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/.gitignore b/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/.gitignore
new file mode 100644
index 0000000..5342fdc
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/.gitignore
@@ -0,0 +1 @@
+/locations.json
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/description.html b/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/description.html
new file mode 100644
index 0000000..9f17f14
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/WEB-INF/classes/description.html
@@ -0,0 +1,28 @@
+
+
+
Spring Boot with Jersey
+
This project demonstrate creating a "hello world" RESTful web service with Spring technology and run on IBM WebSphere Liberty Server
+
Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
Inside the application project contains three classes:
+
+ application.springboot.Application
: The entry point for the SpringBoot application
+ application.springboot.jersey.JerseyConfig
: Configuration for Jersey
+ application.springboot.jersey.Endpoint
: A Spring Jersey endpoint which you can access at /springbootjersey
+
+
+
Inside the wlpcfg project there is the it.springboot.jersey.SampleJerseyApplicationTests
that will test the Spring Jersey endpoint to ensure it is working.
+
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
new file mode 100644
index 0000000..4c77aa6
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
@@ -0,0 +1,19 @@
+package application.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer{
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/Endpoint.java b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/Endpoint.java
new file mode 100644
index 0000000..2ac4891
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/Endpoint.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package application.springboot.jersey;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Component
+@Path("/")
+public class Endpoint {
+ private ObjectMapper objectMapper;
+
+ @Autowired
+ public Endpoint(ObjectMapper objectMapper) {
+ this.objectMapper = objectMapper;
+ }
+
+ @GET
+ public String message() {
+ return "Hello from the SpringBoot Jersey endpoint!";
+ }
+}
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/JerseyConfig.java b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/JerseyConfig.java
new file mode 100644
index 0000000..37e4189
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/jersey/JerseyConfig.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012-2015 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package application.springboot.jersey;
+
+import javax.ws.rs.ApplicationPath;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ApplicationPath("/springbootjersey")
+public class JerseyConfig extends ResourceConfig {
+
+ public JerseyConfig() {
+ register(Endpoint.class);
+ }
+}
diff --git a/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jersey/SampleJerseyApplicationTests.java b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jersey/SampleJerseyApplicationTests.java
new file mode 100644
index 0000000..bd9f928
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/jersey/SampleJerseyApplicationTests.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2012-2015 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package it.springboot.jersey;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import it.EndpointTest;
+import org.junit.Test;
+
+
+public class SampleJerseyApplicationTests extends EndpointTest {
+ @Test
+ public void testJerseyApplication() {
+ testEndpoint("/springbootjersey", "Hello from the SpringBoot Jersey endpoint!");
+ }
+}
diff --git a/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/EndpointTest.java b/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/EndpointTest.java
new file mode 100644
index 0000000..8bcc320
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/EndpointTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.jersey.api.v1.it;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class EndpointTest {
+
+ //use this to give the REST endpoint a chance to come up after the server has reported it's started
+ public void checkAvailability(String endpoint) {
+ String ep = getEndPoint(endpoint);
+ for(int x = 0; x < 3; x++) {
+ Response response = null;
+ try {
+ response = sendRequest(ep, "GET");
+ if(response.getStatus() == 200) {
+ return;
+ }
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ //just exit
+ }
+ }
+ }
+
+ private String getEndPoint(String endpoint) {
+ String port = System.getProperty("liberty.test.port");
+ String war = System.getProperty("war.name");
+ return "http://localhost:" + port + "/" + war + endpoint;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T testEndpoint(String endpoint, Class> entity) throws Exception {
+ String url = getEndPoint(endpoint);
+ System.out.println("Testing " + url);
+ Response response = null;
+ try {
+ response = sendRequest(url, "GET");
+ int responseCode = response.getStatus();
+ assertTrue("Incorrect response code for " + url + ": " + responseCode,
+ responseCode == 200);
+ String json = response.readEntity(String.class);
+ ObjectMapper mapper = new ObjectMapper();
+ return (T) mapper.readValue(json, entity);
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ }
+
+ public Response sendRequest(String url, String requestType) {
+ Client client = ClientBuilder.newClient();
+ System.out.println("Testing " + url);
+ WebTarget target = client.target(url);
+ Invocation.Builder invoBuild = target.request();
+ Response response = invoBuild.build(requestType).invoke();
+ return response;
+ }
+}
diff --git a/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/TestApplication.java b/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/TestApplication.java
new file mode 100644
index 0000000..69c3e89
--- /dev/null
+++ b/starter-microservice-springboot-jersey/src/test/java/com/ibm/liberty/starter/service/springboot/jersey/api/v1/it/TestApplication.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.jersey.api.v1.it;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.Sample;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+
+/**
+ * Test the deployed service responds as expected
+ *
+ */
+public class TestApplication extends EndpointTest {
+
+ @Before
+ public void checkSetup() {
+ checkAvailability("/api/v1/provider/");
+ }
+
+ @Test
+ public void testProvider() throws Exception {
+ Provider provider = testEndpoint("/api/v1/provider/", Provider.class);
+ assertNotNull("No response from API for provider", provider);
+ assertTrue("Description was not found.", provider.getDescription().contains("Spring Boot with Jersey "));
+ Dependency[] dependencies = provider.getDependencies();
+ boolean providedDependency = false;
+ boolean runtimeDependency = false;
+ boolean compileDependency = false;
+ for (Dependency dependency : dependencies) {
+ if (Dependency.Scope.PROVIDED.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot.jersey".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "provided-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ providedDependency = true;
+ }
+ if (Dependency.Scope.RUNTIME.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot.jersey".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "runtime-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ runtimeDependency = true;
+ }
+ if (Dependency.Scope.COMPILE.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot.jersey".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "compile-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ compileDependency = true;
+ }
+ }
+ assertTrue("Provided dependencies weren't specified.", providedDependency);
+ assertTrue("Runtime dependencies weren't specified.", runtimeDependency);
+ assertTrue("Compile dependencies weren't specified.", compileDependency);
+ }
+
+ @Test
+ public void testConfig() throws Exception {
+ ServerConfig config = testEndpoint("/api/v1/provider/config", ServerConfig.class);
+ assertNotNull("No response from API for configuration", config);
+ String actual = config.getTags()[0].getTags()[0].getValue();
+ String expected = "websocket-1.1";
+ assertEquals("Incorrect feature specified", expected , actual);
+ }
+
+ @Test
+ public void testSamples() throws Exception {
+ Sample sample = testEndpoint("/api/v1/provider/samples", Sample.class);
+ assertNotNull("No response from API for sample", sample);
+ assertNotNull("Expected locations", sample.getLocations());
+ assertEquals("No files were expected for sample", 4, sample.getLocations().length);
+ }
+
+}
diff --git a/starter-microservice-springboot-security/.gitignore b/starter-microservice-springboot-security/.gitignore
new file mode 100644
index 0000000..5854a45
--- /dev/null
+++ b/starter-microservice-springboot-security/.gitignore
@@ -0,0 +1,6 @@
+/target
+/build
+/.settings
+/.classpath
+/.project
+/bin
diff --git a/starter-microservice-springboot-security/build.gradle b/starter-microservice-springboot-security/build.gradle
new file mode 100644
index 0000000..6a4f318
--- /dev/null
+++ b/starter-microservice-springboot-security/build.gradle
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+apply from: '../common-java.gradle'
+apply from: '../common-war.gradle'
+
+import com.ibm.liberty.starter.gradle.MavenTask
+import com.ibm.liberty.starter.gradle.FvtTask
+
+dependencies {
+ providedCompile group:'javax.ws.rs', name:'javax.ws.rs-api', version: '2.0'
+ providedCompile group:'javax.json', name:'javax.json-api', version:'1.0'
+}
+
+buildutils {
+ contextRoot = '/springbootsecurity'
+}
+
+task installAllPOMs(type: MavenTask) {
+ id 'springbootsecurity'
+ hasProvided true
+ hasRuntime true
+ hasCompile true
+}
+
+task fvt(type: FvtTask) {
+ id 'starter-microservice-springboot-security'
+ finalizedBy libertyStop
+}
+
+apply from: '../tech-type-task-graph.gradle'
diff --git a/starter-microservice-springboot-security/repository/0.0.1/compile-pom.xml b/starter-microservice-springboot-security/repository/0.0.1/compile-pom.xml
new file mode 100644
index 0000000..1132144
--- /dev/null
+++ b/starter-microservice-springboot-security/repository/0.0.1/compile-pom.xml
@@ -0,0 +1,51 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootsecurity
+ compile-pom
+ 0.0.1
+
+ compile-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+ 1.3.5.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+ 1.3.5.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/repository/0.0.1/provided-pom.xml b/starter-microservice-springboot-security/repository/0.0.1/provided-pom.xml
new file mode 100644
index 0000000..c0b7250
--- /dev/null
+++ b/starter-microservice-springboot-security/repository/0.0.1/provided-pom.xml
@@ -0,0 +1,46 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootsecurity
+ provided-pom
+ 0.0.1
+
+ provided-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ ibm-maven-repo
+ ibm-maven-repo
+ https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/
+
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+ com.ibm.websphere.appserver.api
+ com.ibm.websphere.appserver.api.servlet
+ 1.0.10
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/repository/0.0.1/runtime-pom.xml b/starter-microservice-springboot-security/repository/0.0.1/runtime-pom.xml
new file mode 100644
index 0000000..28e8b09
--- /dev/null
+++ b/starter-microservice-springboot-security/repository/0.0.1/runtime-pom.xml
@@ -0,0 +1,34 @@
+
+ 4.0.0
+
+ net.wasdev.wlp.starters.springbootsecurity
+ runtime-pom
+ 0.0.1
+
+ runtime-pom
+
+
+
+ The Apache Software License, Version 2.0
+ https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE
+ repo
+
+
+
+
+ scm:git:git@github.com:WASdev/tool.artisan.core.git
+ scm:git@github.com:WASdev/tool.artisan.core.git
+ git@github.com:WASdev/tool.artisan.core.git
+
+
+
+
+ net.wasdev.wlp.starters.web
+ server-snippet
+ xml
+ 0.0.1
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/TechnologyAPI.java b/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/TechnologyAPI.java
new file mode 100644
index 0000000..c1d5af3
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/TechnologyAPI.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.security.api;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("api")
+public class TechnologyAPI extends Application {
+
+
+}
diff --git a/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/v1/ProviderEndpoint.java b/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/v1/ProviderEndpoint.java
new file mode 100644
index 0000000..6adeca6
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/java/com/ibm/liberty/starter/service/springboot/security/api/v1/ProviderEndpoint.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.security.api.v1;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency.Scope;
+import com.ibm.liberty.starter.api.v1.model.provider.Location;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+import com.ibm.liberty.starter.api.v1.model.provider.Tag;
+
+@Path("v1/provider")
+public class ProviderEndpoint {
+
+ private static final String DEPENDENCY_URL = "http://localhost:9082/springboot/artifacts/net/wasdev/wlp/starters/springbootsecurity";
+
+ @GET
+ @Path("/")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Provider details(@Context UriInfo info) {
+ Provider details = new Provider();
+ String description = getStringResource("/description.html");
+ details.setDescription(description);
+
+ Location repoLocation = new Location();
+ String url = info.getBaseUri().resolve("../artifacts").toString();
+ repoLocation.setUrl(url);
+ details.setRepoUrl(repoLocation);
+ Dependency providedDependency = new Dependency();
+ providedDependency.setScope(Scope.PROVIDED);
+ providedDependency.setGroupId("net.wasdev.wlp.starters.springbootsecurity");
+ providedDependency.setArtifactId("provided-pom");
+ providedDependency.setVersion("0.0.1");
+
+ Dependency runtimeDependency = new Dependency();
+ runtimeDependency.setScope(Scope.RUNTIME);
+ runtimeDependency.setGroupId("net.wasdev.wlp.starters.springbootsecurity");
+ runtimeDependency.setArtifactId("runtime-pom");
+ runtimeDependency.setVersion("0.0.1");
+
+ Dependency compileDependency = new Dependency();
+ compileDependency.setScope(Scope.COMPILE);
+ compileDependency.setGroupId("net.wasdev.wlp.starters.springbootsecurity");
+ compileDependency.setArtifactId("compile-pom");
+ compileDependency.setVersion("0.0.1");
+
+ Dependency[] dependencies = {providedDependency, runtimeDependency, compileDependency};
+ details.setDependencies(dependencies);
+ return details;
+ }
+
+ //read the description contained in the index.html file
+ private String getStringResource(String path) {
+ InputStream in = getClass().getResourceAsStream(path);
+
+ StringBuilder index = new StringBuilder();
+ char[] buffer = new char[1024];
+ int read = 0;
+ try(InputStreamReader reader = new InputStreamReader(in)){
+ while((read = reader.read(buffer)) != -1) {
+ index.append(buffer, 0, read);
+ }
+ } catch (IOException e) {
+ //just return what we've got
+ return index.toString();
+ }
+ return index.toString();
+ }
+
+ @GET
+ @Path("samples")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response constructSample(@Context UriInfo info) {
+ StringBuilder json = new StringBuilder("{\n");
+ String base = info.getBaseUri().resolve("../sample").toString();
+ json.append("\"base\" : \"" + base + "\",\n");
+ json.append(getStringResource("/locations.json"));
+ json.append("}\n");
+ return Response.ok(json.toString()).build();
+ }
+
+ @GET
+ @Path("config")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ServerConfig getServerConfig() throws Exception {
+ ServerConfig config = new ServerConfig();
+ Tag[] tags = new Tag[]{new Tag("featureManager")};
+ tags[0].setTags(new Tag[]{new Tag("feature", "websocket-1.1")});
+ config.setTags(tags);
+ return config;
+ }
+}
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/webapp/.gitignore b/starter-microservice-springboot-security/src/main/webapp/.gitignore
new file mode 100644
index 0000000..5d43caf
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/.gitignore
@@ -0,0 +1 @@
+/artifacts
diff --git a/starter-microservice-springboot-security/src/main/webapp/META-INF/.gitignore b/starter-microservice-springboot-security/src/main/webapp/META-INF/.gitignore
new file mode 100644
index 0000000..f67faf7
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/META-INF/.gitignore
@@ -0,0 +1 @@
+/swagger.json
diff --git a/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/.gitignore b/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/.gitignore
new file mode 100644
index 0000000..5342fdc
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/.gitignore
@@ -0,0 +1 @@
+/locations.json
diff --git a/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/description.html b/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/description.html
new file mode 100644
index 0000000..590b679
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/WEB-INF/classes/description.html
@@ -0,0 +1,28 @@
+
+
+
Spring Boot with Security
+
This project demonstrate creating a simple web application with resources that are protected by Spring Security and run on IBM WebSphere Liberty Server
+
Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
Inside the application project contains three classes:
+
+ application.springboot.Application
: The entry point for the SpringBoot application
+ application.springboot.security.MvcConfig
: Config url mapping to static html page
+ application.springboot.security.WebSecurityConfig
: Config security setting for application
+ View how application work at:/springbootsecurity
+
+
Inside the wlpcfg project there is the it.springboot.security.HelloControllerTest
that will test the Springboot security endpoint to ensure it is working.
+
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
new file mode 100644
index 0000000..4c77aa6
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
@@ -0,0 +1,19 @@
+package application.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer{
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/MvcConfig.java b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/MvcConfig.java
new file mode 100644
index 0000000..8b47446
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/MvcConfig.java
@@ -0,0 +1,18 @@
+package application.springboot.security;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+public class MvcConfig extends WebMvcConfigurerAdapter {
+
+ @Override
+ public void addViewControllers(ViewControllerRegistry registry) {
+ registry.addViewController("/springbootsecurity/home").setViewName("security-home");
+ registry.addViewController("/springbootsecurity").setViewName("security-home");
+ registry.addViewController("/springbootsecurity/hello").setViewName("security-hello");
+ registry.addViewController("/springbootsecurity/login").setViewName("security-login");
+ }
+
+}
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/WebSecurityConfig.java b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/WebSecurityConfig.java
new file mode 100644
index 0000000..5b9c497
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/security/WebSecurityConfig.java
@@ -0,0 +1,33 @@
+package application.springboot.security;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http
+ .authorizeRequests()
+ .antMatchers("/springbootsecurity/hello").hasRole("USER")
+ .and()
+ .formLogin()
+ .loginPage("/springbootsecurity/login")
+ .permitAll()
+ .and()
+ .logout()
+ .permitAll();
+ }
+
+ @Autowired
+ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
+ auth
+ .inMemoryAuthentication()
+ .withUser("admin").password("admin").roles("USER");
+ }
+}
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/application.properties b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/application.properties
new file mode 100644
index 0000000..409b428
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.contextPath=/myLibertyApp
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-hello.html b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-hello.html
new file mode 100644
index 0000000..46feef7
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-hello.html
@@ -0,0 +1,13 @@
+
+
+
+ Hello World!
+
+
+ Hello [[${#httpServletRequest.remoteUser}]]!
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-home.html b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-home.html
new file mode 100644
index 0000000..07f2a45
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-home.html
@@ -0,0 +1,12 @@
+
+
+
+ Spring Security Example
+
+
+ Welcome!
+
+ Click here to see a greeting.
+ On the log in page, try to use username "admin" and password "admin" to log in.
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-login.html b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-login.html
new file mode 100644
index 0000000..4388a5c
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-application/src/main/resources/templates/security-login.html
@@ -0,0 +1,20 @@
+
+
+
+ Spring Security Example
+
+
+
+ Invalid username and password.
+
+
+ You have been logged out.
+
+
+
+
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/security/HelloControllerTest.java b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/security/HelloControllerTest.java
new file mode 100644
index 0000000..d666256
--- /dev/null
+++ b/starter-microservice-springboot-security/src/main/webapp/sample/myProject-wlpcfg/src/test/java/it/springboot/security/HelloControllerTest.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package it.springboot.security;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import it.EndpointTest;
+
+import org.junit.Test;
+
+public class HelloControllerTest extends EndpointTest {
+
+
+ @Test
+ public void testDeployment() {
+ testEndpoint("/springbootsecurity", "Welcome!");
+ }
+}
\ No newline at end of file
diff --git a/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/EndpointTest.java b/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/EndpointTest.java
new file mode 100644
index 0000000..aa84a85
--- /dev/null
+++ b/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/EndpointTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.security.api.v1.it;
+
+import static org.junit.Assert.assertTrue;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class EndpointTest {
+
+ //use this to give the REST endpoint a chance to come up after the server has reported it's started
+ public void checkAvailability(String endpoint) {
+ String ep = getEndPoint(endpoint);
+ for(int x = 0; x < 3; x++) {
+ Response response = null;
+ try {
+ response = sendRequest(ep, "GET");
+ if(response.getStatus() == 200) {
+ return;
+ }
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ //just exit
+ }
+ }
+ }
+
+ private String getEndPoint(String endpoint) {
+ String port = System.getProperty("liberty.test.port");
+ String war = System.getProperty("war.name");
+ return "http://localhost:" + port + "/" + war + endpoint;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T testEndpoint(String endpoint, Class> entity) throws Exception {
+ String url = getEndPoint(endpoint);
+ System.out.println("Testing " + url);
+ Response response = null;
+ try {
+ response = sendRequest(url, "GET");
+ int responseCode = response.getStatus();
+ assertTrue("Incorrect response code for " + url + ": " + responseCode,
+ responseCode == 200);
+ String json = response.readEntity(String.class);
+ ObjectMapper mapper = new ObjectMapper();
+ return (T) mapper.readValue(json, entity);
+ } finally {
+ if(response != null) {
+ response.close();
+ }
+ }
+ }
+
+ public Response sendRequest(String url, String requestType) {
+ Client client = ClientBuilder.newClient();
+ System.out.println("Testing " + url);
+ WebTarget target = client.target(url);
+ Invocation.Builder invoBuild = target.request();
+ Response response = invoBuild.build(requestType).invoke();
+ return response;
+ }
+}
diff --git a/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/TestApplication.java b/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/TestApplication.java
new file mode 100644
index 0000000..a1675fa
--- /dev/null
+++ b/starter-microservice-springboot-security/src/test/java/com/ibm/liberty/starter/service/springboot/security/api/v1/it/TestApplication.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+package com.ibm.liberty.starter.service.springboot.security.api.v1.it;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.ibm.liberty.starter.api.v1.model.provider.Dependency;
+import com.ibm.liberty.starter.api.v1.model.provider.Provider;
+import com.ibm.liberty.starter.api.v1.model.provider.Sample;
+import com.ibm.liberty.starter.api.v1.model.provider.ServerConfig;
+
+/**
+ * Test the deployed service responds as expected
+ *
+ */
+public class TestApplication extends EndpointTest {
+
+ @Before
+ public void checkSetup() {
+ checkAvailability("/api/v1/provider/");
+ }
+
+ @Test
+ public void testProvider() throws Exception {
+ Provider provider = testEndpoint("/api/v1/provider/", Provider.class);
+ assertNotNull("No response from API for provider", provider);
+ assertTrue("Description was not found.", provider.getDescription().contains("Spring Boot with Security "));
+ Dependency[] dependencies = provider.getDependencies();
+ boolean providedDependency = false;
+ boolean runtimeDependency = false;
+ boolean compileDependency = false;
+ for (Dependency dependency : dependencies) {
+ if (Dependency.Scope.PROVIDED.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootsecurity".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "provided-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ providedDependency = true;
+ }
+ if (Dependency.Scope.RUNTIME.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootsecurity".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "runtime-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ runtimeDependency = true;
+ }
+ if (Dependency.Scope.COMPILE.equals(dependency.getScope())) {
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootsecurity".equals(dependency.getGroupId()));
+ assertTrue("artifactId incorrect.", "compile-pom".equals(dependency.getArtifactId()));
+ assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
+ compileDependency = true;
+ }
+ }
+ assertTrue("Provided dependencies weren't specified.", providedDependency);
+ assertTrue("Runtime dependencies weren't specified.", runtimeDependency);
+ assertTrue("Compile dependencies weren't specified.", compileDependency);
+ }
+
+ @Test
+ public void testConfig() throws Exception {
+ ServerConfig config = testEndpoint("/api/v1/provider/config", ServerConfig.class);
+ assertNotNull("No response from API for configuration", config);
+ String actual = config.getTags()[0].getTags()[0].getValue();
+ String expected = "websocket-1.1";
+ assertEquals("Incorrect feature specified", expected , actual);
+ }
+
+ @Test
+ public void testSamples() throws Exception {
+ Sample sample = testEndpoint("/api/v1/provider/samples", Sample.class);
+ assertNotNull("No response from API for sample", sample);
+ assertNotNull("Expected locations", sample.getLocations());
+ assertEquals("No files were expected for sample", 8, sample.getLocations().length);
+ }
+
+}
diff --git a/starter-microservice-springboot-web/.gitignore b/starter-microservice-springboot-web/.gitignore
index f5d14ab..5854a45 100644
--- a/starter-microservice-springboot-web/.gitignore
+++ b/starter-microservice-springboot-web/.gitignore
@@ -1,5 +1,4 @@
/target
-/pom.xml
/build
/.settings
/.classpath
diff --git a/starter-microservice-springboot-web/repository/0.0.1/compile-pom.xml b/starter-microservice-springboot-web/repository/0.0.1/compile-pom.xml
index 34e89d8..b5316ce 100644
--- a/starter-microservice-springboot-web/repository/0.0.1/compile-pom.xml
+++ b/starter-microservice-springboot-web/repository/0.0.1/compile-pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- net.wasdev.wlp.starters.springboot
+ net.wasdev.wlp.starters.springbootweb
compile-pom
0.0.1
@@ -26,7 +26,7 @@
org.springframework.boot
spring-boot-starter-web
- 1.3.0.RELEASE
+ 1.3.5.RELEASE
org.springframework.boot
diff --git a/starter-microservice-springboot-web/repository/0.0.1/provided-pom.xml b/starter-microservice-springboot-web/repository/0.0.1/provided-pom.xml
index ea88f27..9bc42b8 100644
--- a/starter-microservice-springboot-web/repository/0.0.1/provided-pom.xml
+++ b/starter-microservice-springboot-web/repository/0.0.1/provided-pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- net.wasdev.wlp.starters.springboot
+ net.wasdev.wlp.starters.springbootweb
provided-pom
0.0.1
diff --git a/starter-microservice-springboot-web/repository/0.0.1/runtime-pom.xml b/starter-microservice-springboot-web/repository/0.0.1/runtime-pom.xml
index 52a1d99..3014b88 100644
--- a/starter-microservice-springboot-web/repository/0.0.1/runtime-pom.xml
+++ b/starter-microservice-springboot-web/repository/0.0.1/runtime-pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- net.wasdev.wlp.starters.springboot
+ net.wasdev.wlp.starters.springbootweb
runtime-pom
0.0.1
diff --git a/starter-microservice-springboot-web/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java b/starter-microservice-springboot-web/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java
index a994dcb..6bbfea2 100644
--- a/starter-microservice-springboot-web/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java
+++ b/starter-microservice-springboot-web/src/main/java/com/ibm/liberty/starter/service/springboot/api/v1/ProviderEndpoint.java
@@ -53,19 +53,19 @@ public Provider details(@Context UriInfo info) {
details.setRepoUrl(repoLocation);
Dependency providedDependency = new Dependency();
providedDependency.setScope(Scope.PROVIDED);
- providedDependency.setGroupId("net.wasdev.wlp.starters.springboot");
+ providedDependency.setGroupId("net.wasdev.wlp.starters.springbootweb");
providedDependency.setArtifactId("provided-pom");
providedDependency.setVersion("0.0.1");
Dependency runtimeDependency = new Dependency();
runtimeDependency.setScope(Scope.RUNTIME);
- runtimeDependency.setGroupId("net.wasdev.wlp.starters.springboot");
+ runtimeDependency.setGroupId("net.wasdev.wlp.starters.springbootweb");
runtimeDependency.setArtifactId("runtime-pom");
runtimeDependency.setVersion("0.0.1");
Dependency compileDependency = new Dependency();
compileDependency.setScope(Scope.COMPILE);
- compileDependency.setGroupId("net.wasdev.wlp.starters.springboot");
+ compileDependency.setGroupId("net.wasdev.wlp.starters.springbootweb");
compileDependency.setArtifactId("compile-pom");
compileDependency.setVersion("0.0.1");
diff --git a/starter-microservice-springboot-web/src/main/webapp/WEB-INF/classes/description.html b/starter-microservice-springboot-web/src/main/webapp/WEB-INF/classes/description.html
index 77dea01..25340f8 100644
--- a/starter-microservice-springboot-web/src/main/webapp/WEB-INF/classes/description.html
+++ b/starter-microservice-springboot-web/src/main/webapp/WEB-INF/classes/description.html
@@ -15,11 +15,12 @@
-->
Spring Boot with Spring MVC
-
Inside the application project there is a application.springboot.web package
- containing two classes:
+
This project demonstrate a "hello world" web site with Spring technology and run on IBM WebSphere Liberty Server
+
Learn more about IBM WebSphere Liberty, visit https://developer.ibm.com/wasdev/
+
Inside the application project contains two classes:
- SpringBootLibertyApplication
: The entry point for the SpringBoot application.
- LibertyHelloController
: A Spring MVC endpoint which you can access at /springbootweb
+ application.springboot.Application
: The entry point for the SpringBoot application
+ application.springboot.web.LibertyHelloController
: A Spring MVC endpoint which you can access at /springbootweb
Inside the wlpcfg project there is the it.springboot.web.HelloControllerTest
that will test the Spring MVC endpoint to ensure it is working.
diff --git a/starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java b/starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
new file mode 100644
index 0000000..4c77aa6
--- /dev/null
+++ b/starter-microservice-springboot-web/src/main/webapp/sample/myProject-application/src/main/java/application/springboot/Application.java
@@ -0,0 +1,19 @@
+package application.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer{
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java b/starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
index 8a8e3ce..fbc2757 100644
--- a/starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
+++ b/starter-microservice-springboot-web/src/test/java/com/ibm/liberty/starter/service/springboot/api/v1/it/TestApplication.java
@@ -47,19 +47,19 @@ public void testProvider() throws Exception {
boolean compileDependency = false;
for (Dependency dependency : dependencies) {
if (Dependency.Scope.PROVIDED.equals(dependency.getScope())) {
- assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot".equals(dependency.getGroupId()));
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootweb".equals(dependency.getGroupId()));
assertTrue("artifactId incorrect.", "provided-pom".equals(dependency.getArtifactId()));
assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
providedDependency = true;
}
if (Dependency.Scope.RUNTIME.equals(dependency.getScope())) {
- assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot".equals(dependency.getGroupId()));
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootweb".equals(dependency.getGroupId()));
assertTrue("artifactId incorrect.", "runtime-pom".equals(dependency.getArtifactId()));
assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
runtimeDependency = true;
}
if (Dependency.Scope.COMPILE.equals(dependency.getScope())) {
- assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springboot".equals(dependency.getGroupId()));
+ assertTrue("groupId incorrect.", "net.wasdev.wlp.starters.springbootweb".equals(dependency.getGroupId()));
assertTrue("artifactId incorrect.", "compile-pom".equals(dependency.getArtifactId()));
assertTrue("version incorrect.", "0.0.1".equals(dependency.getVersion()));
compileDependency = true;