Add an integration test for the generate features mojo in devmode.
/*******************************************************************************
- * (c) Copyright IBM Corporation 2019.
+ * (c) Copyright IBM Corporation 2019, 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -210,6 +210,40 @@ public class DevTest extends BaseDevTest {
assertTrue(systemHealthTarget.exists());
}
+ // TBD @Test
+ public void generateFeatureTest() throws Exception {
+
+ final String GENERATED_FEATURES_FILE_NAME = "liberty-plugin-added-features.xml";
+ final String SERVER_XML_COMMENT = "Plugin has generated Liberty features"; // the explanation added to server.xml
+ // TBD final String NEW_FILE_INFO_MESSAGE = "Some message"; // the explanation added to the generated features file
+
+ assertTrue(verifyLogMessageExists("Liberty is running in dev mode.", 10000));
+ assertFalse(verifyLogMessageExists("batch-1.0", 10000));
+
+ File newFeatureFile = new File(tempProj, "/src/main/liberty/config/configDropins/overrides/"+GENERATED_FEATURES_FILE_NAME);
+ File newTargetFeatureFile = new File(targetDir, "/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/"+GENERATED_FEATURES_FILE_NAME);
+ File serverXmlFile = new File(tempProj, "/src/main/liberty/config/server.xml");
+ assertTrue(serverXmlFile.exists());
+
+ // Copy a Java file into place to create the HelloBatch class
+ File helloBatchRes = new File("../resources/HelloBatch.java");
+ assertTrue(helloBatchRes.exists());
+ File helloBatchSrc = new File(tempProj, "/src/main/java/com/demo/HelloBatch.java");
+ FileUtils.copyFile(helloBatchRes, helloBatchSrc);
+ assertTrue(helloBatchSrc.exists());
+
+ // Dev mode should now compile the new Java file...
+ Thread.sleep(15000);
+ // ... and run the proper mojo.
+ assertTrue(verifyLogMessageExists("Running liberty:generate-features", 10000)); // mojo ran
+ assertTrue(newFeatureFile.exists()); // mojo created file
+ assertTrue(newTargetFeatureFile.exists()); // mojo copied file
+ assertTrue(verifyLogMessageExists("batch-1.0", 10000, newFeatureFile));
+ // TBD assertTrue(verifyLogMessageExists(NEW_FILE_INFO_MESSAGE, 10000, newFeatureFile));
+ assertTrue(verifyLogMessageExists(SERVER_XML_COMMENT, 10000, serverXmlFile));
+ assertTrue(verifyLogMessageExists("batch-1.0", 10000)); // should appear in the message "CWWKF0012I: The server installed the following features:"
+ }
+
@Test
public void mpVersionTest() throws Exception {
assertEquals(GenerateFeaturesMojo.getMPVersion("mpHealth-2.0"), 3);
