Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit c9c57ea

Browse files
committed
Adding tests for boostApplication using dev and release projects
1 parent a3e5365 commit c9c57ea

File tree

8 files changed

+94
-4
lines changed

8 files changed

+94
-4
lines changed

boost-gradle/src/main/groovy/io/openliberty/boost/gradle/utils/GradleProjectUtil.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ public class GradleProjectUtil {
4949

5050
try {
5151
//Projects without the war/java plugin won't have this configuration
52-
dependencies.putAll(project.configurations.getByName('compileClasspath'), logger)
52+
//compileClasspath is not a regular Configuration object so we have to go through without using getAllDependenciesFromConfiguration()
53+
project.configurations.getByName('compileClasspath').resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id }.each { ModuleVersionIdentifier id ->
54+
logger.debug("Found dependency while processing project: " + id.group.toString() + ":"
55+
+ id.name.toString() + ":" + id.version.toString())
56+
57+
dependencies.put(id.group.toString() + ":" + id.name.toString(), id.version.toString())
58+
}
5359
} catch (UnknownConfigurationException ue) {
5460
logger.debug("The compileClasspath configuration was not found.")
5561
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2019 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
import org.apache.commons.io.FileUtils
12+
13+
import org.gradle.testkit.runner.BuildResult
14+
import org.gradle.testkit.runner.GradleRunner
15+
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
16+
17+
import org.junit.After
18+
import org.junit.BeforeClass
19+
import org.junit.Test
20+
import static org.junit.Assert.assertEquals
21+
import static org.junit.Assert.assertTrue
22+
23+
24+
public class BoostPackageDevReleaseTest extends AbstractBoostTest {
25+
static File resourceDir = new File("build/resources/test/devReleaseApp")
26+
static File testProjectDir = new File(integTestDir, "BoostPackageDevReleaseTest")
27+
28+
static File devDir = new File(testProjectDir, 'dev')
29+
static File releaseDir = new File(testProjectDir, 'release')
30+
31+
private static String URL = "http://localhost:9080/"
32+
33+
private static String SERVLET_RESPONSE = "</font><font color=red>myHomeCounty</font></h1>"
34+
35+
@BeforeClass
36+
public static void setup() {
37+
createDir(testProjectDir)
38+
FileUtils.copyDirectory(resourceDir, testProjectDir)
39+
copyFile(new File("build/gradle.properties"), new File(devDir, 'gradle.properties'))
40+
copyFile(new File("build/gradle.properties"), new File(releaseDir, 'gradle.properties'))
41+
42+
//Build the dev project
43+
BuildResult result = GradleRunner.create()
44+
.withProjectDir(devDir)
45+
.forwardOutput()
46+
.withArguments("install", "-i", "-s")
47+
.build()
48+
49+
assertEquals(SUCCESS, result.task(":boostPackage").getOutcome())
50+
51+
//Build the release project
52+
result = GradleRunner.create()
53+
.withProjectDir(releaseDir)
54+
.forwardOutput()
55+
.withArguments("boostPackage", "boostStart", "-i", "-s")
56+
.build()
57+
58+
assertEquals(SUCCESS, result.task(":boostPackage").getOutcome())
59+
assertEquals(SUCCESS, result.task(":boostStart").getOutcome())
60+
}
61+
62+
@After
63+
public void teardown() {
64+
65+
BuildResult result = GradleRunner.create()
66+
.withProjectDir(releaseDir)
67+
.forwardOutput()
68+
.withArguments("boostStop", "-i", "-s")
69+
.build()
70+
71+
assertEquals(SUCCESS, result.task(":boostStop").getOutcome())
72+
73+
}
74+
75+
@Test
76+
public void checkForApplication() {
77+
assertTrue(new File(releaseDir, 'build/wlp/usr/servers/BoostServer/apps/app-1.0.war').exists())
78+
}
79+
80+
@Test
81+
public void testServletResponse() throws Exception {
82+
testServlet(URL, SERVLET_RESPONSE)
83+
}
84+
}

boost-gradle/src/test/resources/devProdApp/dev/build.gradle renamed to boost-gradle/src/test/resources/devReleaseApp/dev/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
maven { url 'https://repo.spring.io/plugins-snapshot' }
99
}
1010
dependencies {
11-
classpath("io.openliberty.boost:boost-gradle-plugin:0.1.1-SNAPSHOT")
11+
classpath("io.openliberty.boost:boost-gradle-plugin:${boostVersion}")
1212
classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE'
1313
}
1414
}
@@ -35,7 +35,7 @@ targetCompatibility = 1.8
3535

3636
dependencyManagement {
3737
imports {
38-
mavenBom "io.openliberty.boosters:ee8-bom:0.1.3-SNAPSHOT"
38+
mavenBom "io.openliberty.boosters:ee8-bom:${boosterVersion}"
3939
}
4040
}
4141

boost-gradle/src/test/resources/devProdApp/prod/build.gradle renamed to boost-gradle/src/test/resources/devReleaseApp/release/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
maven { url 'https://repo.spring.io/plugins-snapshot' }
99
}
1010
dependencies {
11-
classpath("io.openliberty.boost:boost-gradle-plugin:0.1.1-SNAPSHOT")
11+
classpath("io.openliberty.boost:boost-gradle-plugin:${boostVersion}")
1212
}
1313
}
1414

0 commit comments

Comments
 (0)