1- /*******************************************************************************
2- * (c ) Copyright IBM Corporation 2017, 2023.
1+ /**
2+ * (C ) Copyright IBM Corporation 2022,2025
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
15- *******************************************************************************/
16- package net .wasdev .wlp .maven .test .it ;
15+ */
16+ package application ;
17+
18+ import static org .junit .Assert .*;
1719
1820import java .io .File ;
19- import java .io .FileInputStream ;
2021import java .io .FileNotFoundException ;
2122import java .util .Scanner ;
22-
23- import javax .xml .parsers .DocumentBuilder ;
24- import javax .xml .parsers .DocumentBuilderFactory ;
25- import javax .xml .xpath .XPath ;
26- import javax .xml .xpath .XPathConstants ;
27- import javax .xml .xpath .XPathFactory ;
28-
2923import org .junit .Test ;
30- import org .w3c .dom .Document ;
31- import org .w3c .dom .NodeList ;
32- import org .w3c .dom .Document ;
3324
34- import static org .junit .Assert .assertEquals ;
35- import static org .junit .Assert .assertTrue ;
36-
37- public class LooseConfigTestIT {
38- public static final String LOG_LOCATION = "liberty/wlp/usr/servers/test/logs/messages.log" ;
39- public final String LOOSE_APP = "liberty/wlp/usr/servers/test/apps/AppXmlEAR.ear.xml" ;
25+ public class InstallSpringBoot20AppIT {
26+ public static final String TOOLCHAIN_CONFIGURED_FOR_GOAL = "CWWKM4101I: The %s goal is using the configured toolchain JDK located at" ;
27+ public static final String LOG_LOCATION = "liberty/usr/servers/test/logs/messages.log" ;
4028
4129 @ Test
42- public void testLooseApplicationFileExist () throws Exception {
43- File f = new File (LOOSE_APP );
44- assertTrue (f .getCanonicalFile () + " doesn't exist" , f .exists ());
30+ public void testThinApplicationExistsInAppsDirectory () throws Exception {
31+
32+ File f = new File ("target/liberty/wlp/usr/servers/test/apps/thin-springboot-appsdirectory-apps-it-1.0.0.Final-exec.jar" );
33+ assertTrue (f .getCanonicalFile () + " doesn't exist. Plugin failed to place the file at right destination." , f .exists ());
4534 }
4635
4736 @ Test
48- public void testLooseApplicationFileContent () throws Exception {
49- File in = new File (LOOSE_APP );
50- try (FileInputStream input = new FileInputStream (in )) {
51-
52- // get input XML Document
53- DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory .newInstance ();
54- inputBuilderFactory .setIgnoringComments (true );
55- inputBuilderFactory .setCoalescing (true );
56- inputBuilderFactory .setIgnoringElementContentWhitespace (true );
57- inputBuilderFactory .setValidating (false );
58- inputBuilderFactory .setFeature ("http://apache.org/xml/features/nonvalidating/load-dtd-grammar" , false );
59- inputBuilderFactory .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false );
60- DocumentBuilder inputBuilder = inputBuilderFactory .newDocumentBuilder ();
61- Document inputDoc =inputBuilder .parse (input );
62-
63- // parse input XML Document
64- XPath xPath = XPathFactory .newInstance ().newXPath ();
65- String expression = "/archive/file" ;
66- NodeList nodes = (NodeList ) xPath .compile (expression ).evaluate (inputDoc , XPathConstants .NODESET );
67- assertEquals ("Number of <file/> element ==>" , 2 , nodes .getLength ());
68- assertEquals ("file targetInArchive attribute value" , "/META-INF/application.xml" ,
69- nodes .item (0 ).getAttributes ().getNamedItem ("targetInArchive" ).getNodeValue ());
70- File appXml = new File ("../src/main/application/META-INF/application.xml" );
71- assertEquals ("file sourceOnDisk attribute value" , appXml .getCanonicalPath (),
72- nodes .item (0 ).getAttributes ().getNamedItem ("sourceOnDisk" ).getNodeValue ());
73-
74- expression = "/archive/archive/archive" ;
75- nodes = (NodeList ) xPath .compile (expression ).evaluate (inputDoc , XPathConstants .NODESET );
76- assertEquals ("Number of <archive/> element ==>" , 1 , nodes .getLength ());
77- assertEquals ("archive targetInArchive attribute value" , "/WEB-INF/lib/SampleBundle-1.0-SNAPSHOT.jar" ,
78- nodes .item (0 ).getAttributes ().getNamedItem ("targetInArchive" ).getNodeValue ());
79-
80- expression = "/archive/archive/archive/dir" ;
81- nodes = (NodeList ) xPath .compile (expression ).evaluate (inputDoc , XPathConstants .NODESET );
82- assertEquals ("Number of <dir/> element ==>" , 1 , nodes .getLength ());
83-
84- expression = "/archive/archive/archive/file" ;
85- nodes = (NodeList ) xPath .compile (expression ).evaluate (inputDoc , XPathConstants .NODESET );
86- assertEquals ("Number of <dir/> element ==>" , 1 , nodes .getLength ());
87- }
37+ public void testLibIndexCacheExists () throws Exception {
38+ File f = new File ("target/liberty/wlp/usr/shared/resources/lib.index.cache" );
39+ assertTrue (f .getCanonicalFile ()+ " doesn't exist. Plugin failed to place the cache directory at right destination." , f .exists ());
8840 }
8941
9042 @ Test
@@ -96,15 +48,15 @@ public void testToolchainLogs() throws Exception {
9648 assertTrue ("Did not find toolchain honored message for package goal in build.log" , logContainsMessage (buildLog , String .format (TOOLCHAIN_CONFIGURED_FOR_GOAL , "package" )));
9749 assertTrue ("Did not find toolchain honored message for test-start goal in build.log" , logContainsMessage (buildLog , String .format (TOOLCHAIN_CONFIGURED_FOR_GOAL , "test-start" )));
9850 assertTrue ("Did not find toolchain honored message for test-stop goal in build.log" , logContainsMessage (buildLog , String .format (TOOLCHAIN_CONFIGURED_FOR_GOAL , "test-stop" )));
99-
51+ File logFile = new File (LOG_LOCATION );
52+ assertTrue ("Log file not found at location: " +LOG_LOCATION , logFile .exists ());
10053 // should contain java.version = 11 since <jdkToolChain> is defined as Java 11
101- assertTrue ("Did not find toolchain version in messages.log" , logContainsMessage ( "java.version = 11" ));
54+ assertTrue ("Did not find toolchain version in messages.log" , logContainsMessage (logFile , "java.version = 11" ));
10255
10356 }
10457
105- public boolean logContainsMessage (String message ) throws FileNotFoundException {
106- File logFile = new File (LOG_LOCATION );
107- assertTrue ("Log file not found at location: " +LOG_LOCATION , logFile .exists ());
58+ public boolean logContainsMessage (File logFile , String message ) throws FileNotFoundException {
59+
10860 boolean found = false ;
10961
11062 try (Scanner scanner = new Scanner (logFile );) {
0 commit comments