This repository was archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Dev/Release project support for Gradle #282
Open
mattbsox
wants to merge
5
commits into
MicroShed:master
Choose a base branch
from
mattbsox:boostAppConfiguration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
67a3115
adding boostApp configuration
mattbsox 3351532
adding demo/test project
mattbsox b58bd35
Adding tests for boostApplication using dev and release projects
mattbsox 010443b
addressing review comments
mattbsox 253a794
Fixing missed test failures in the Gradle tests
mattbsox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
export testExitCode=0 | ||
|
||
./gradlew clean install check -Ptest.exclude="**/*15*" -Druntime=$RUNTIME -DruntimeVersion=$RUNTIME_VERSION --stacktrace --info --no-daemon | ||
if [ $? ]; then | ||
testExitCode=1 | ||
fi | ||
|
||
ls build/test-results/test/ >> out.txt | ||
./gradlew wrapper --gradle-version 4.10 | ||
|
||
./gradlew clean install check -Ptest.include="**/*15*" -Druntime=$RUNTIME -DruntimeVersion=$RUNTIME_VERSION --stacktrace --info --no-daemon | ||
if [ $? ]; then | ||
testExitCode=1 | ||
fi | ||
|
||
ls build/test-results/test/ >> out.txt | ||
cat out.txt | ||
|
||
exit $testExitCode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
boost-gradle/src/test/groovy/BoostPackageDevReleaseTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
import org.apache.commons.io.FileUtils | ||
|
||
import org.gradle.testkit.runner.BuildResult | ||
import org.gradle.testkit.runner.GradleRunner | ||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||
|
||
import org.junit.After | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
import static org.junit.Assert.assertEquals | ||
import static org.junit.Assert.assertTrue | ||
|
||
|
||
public class BoostPackageDevReleaseTest extends AbstractBoostTest { | ||
static File resourceDir = new File("build/resources/test/devReleaseApp") | ||
static File testProjectDir = new File(integTestDir, "BoostPackageDevReleaseTest") | ||
|
||
static File devDir = new File(testProjectDir, 'dev') | ||
static File releaseDir = new File(testProjectDir, 'release') | ||
|
||
private static String URL = "http://localhost:9080/" | ||
|
||
private static String SERVLET_RESPONSE = "</font><font color=red>myHomeCounty</font></h1>" | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
createDir(testProjectDir) | ||
FileUtils.copyDirectory(resourceDir, testProjectDir) | ||
copyFile(new File("build/gradle.properties"), new File(devDir, 'gradle.properties')) | ||
copyFile(new File("build/gradle.properties"), new File(releaseDir, 'gradle.properties')) | ||
|
||
//Build the dev project | ||
BuildResult result = GradleRunner.create() | ||
.withProjectDir(devDir) | ||
.forwardOutput() | ||
.withArguments("install", "-i", "-s") | ||
.build() | ||
|
||
assertEquals(SUCCESS, result.task(":boostPackage").getOutcome()) | ||
|
||
//Build the release project | ||
result = GradleRunner.create() | ||
.withProjectDir(releaseDir) | ||
.forwardOutput() | ||
.withArguments("boostPackage", "boostStart", "-i", "-s") | ||
.build() | ||
|
||
assertEquals(SUCCESS, result.task(":boostPackage").getOutcome()) | ||
assertEquals(SUCCESS, result.task(":boostStart").getOutcome()) | ||
} | ||
|
||
@After | ||
public void teardown() { | ||
|
||
BuildResult result = GradleRunner.create() | ||
.withProjectDir(releaseDir) | ||
.forwardOutput() | ||
.withArguments("boostStop", "-i", "-s") | ||
.build() | ||
|
||
assertEquals(SUCCESS, result.task(":boostStop").getOutcome()) | ||
|
||
} | ||
|
||
@Test | ||
public void checkForApplication() { | ||
assertTrue(new File(releaseDir, 'build/wlp/usr/servers/BoostServer/apps/app-1.0.war').exists()) | ||
} | ||
|
||
@Test | ||
public void testServletResponse() throws Exception { | ||
testServlet(URL, SERVLET_RESPONSE) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
boost-gradle/src/test/resources/devReleaseApp/dev/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
maven { | ||
url 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
maven { url 'https://repo.spring.io/plugins-snapshot' } | ||
} | ||
dependencies { | ||
classpath("io.openliberty.boost:boost-gradle-plugin:${boostVersion}") | ||
classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE' | ||
} | ||
} | ||
|
||
apply plugin: 'war' | ||
apply plugin: 'maven' | ||
apply plugin: 'boost' | ||
apply plugin: 'io.spring.dependency-management' | ||
|
||
group = "test" | ||
version = "1.0" | ||
|
||
war { | ||
baseName = 'app' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
dependencyManagement { | ||
imports { | ||
mavenBom "io.openliberty.boosters:ee8-bom:${boosterVersion}" | ||
} | ||
} | ||
|
||
dependencies { | ||
compile "io.openliberty.boosters:jaxrs" | ||
compile "io.openliberty.boosters:jdbc" | ||
compile("org.apache.httpcomponents:httpclient:4.5.6") | ||
compile("org.apache.httpcomponents:httpcore:4.4.10") | ||
compile "javax.servlet:javax.servlet-api:4.0.0" | ||
|
||
libertyRuntime "$runtimeGroup:$runtimeArtifactId:$runtimeVersion" | ||
} |
72 changes: 72 additions & 0 deletions
72
...e/src/test/resources/devReleaseApp/dev/src/main/java/application/servlet/JdbcServlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package application.servlet; | ||
|
||
import java.io.IOException; | ||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import javax.annotation.Resource; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.sql.DataSource; | ||
|
||
/** | ||
* Servlet implementation class JdbcServlet | ||
*/ | ||
@WebServlet("/*") | ||
public class JdbcServlet extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse | ||
* response) | ||
*/ | ||
@Resource | ||
DataSource ds1; | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
Statement stmt = null; | ||
Connection con = null; | ||
|
||
try { | ||
con = ds1.getConnection(); | ||
|
||
stmt = con.createStatement(); | ||
// create a table | ||
stmt.executeUpdate( | ||
"create table cities (name varchar(50) not null primary key, population int, county varchar(30))"); | ||
// insert a test record | ||
stmt.executeUpdate("insert into cities values ('myHomeCity', 106769, 'myHomeCounty')"); | ||
// select a record | ||
ResultSet result = stmt.executeQuery("select county from cities where name='myHomeCity'"); | ||
result.next(); | ||
// display the county information for the city. | ||
response.getWriter().print("<h1><font color=green>Text retrieved from database is: </font>" | ||
+ "<font color=red>" + result.getString(1) + "</font></h1>"); | ||
// System.out.println("The county for myHomeCity is " + | ||
// result.getString(1)); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} finally { | ||
try { | ||
// drop the table to clean up and to be able to rerun the test. | ||
stmt.executeUpdate("drop table cities"); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
try { | ||
con.close(); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
boost-gradle/src/test/resources/devReleaseApp/dev/src/main/webapp/WEB-INF/web.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | ||
<display-name>Java REST Sample</display-name> | ||
<welcome-file-list> | ||
<welcome-file>index.html</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
Binary file added
BIN
+196 KB
boost-gradle/src/test/resources/devReleaseApp/dev/src/main/webapp/index.html
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
boost-gradle/src/test/resources/devReleaseApp/release/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
maven { | ||
url 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
maven { url 'https://repo.spring.io/plugins-snapshot' } | ||
} | ||
dependencies { | ||
classpath("io.openliberty.boost:boost-gradle-plugin:${boostVersion}") | ||
} | ||
} | ||
|
||
apply plugin: 'boost' | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
boostApp "test:app:1.0" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indent