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
+ }
0 commit comments