Ensure dev mode is finished processing before exiting generate features test.
@@ -74,6 +74,7 @@ public class DevTest extends BaseDevTest {
@Test
public void resourceFileChangeTest() throws Exception {
+ // CWWKZ0003I: The application xxx updated in y.yyy seconds.
int appUpdatedCount = countOccurrences("CWWKZ0003I:", logFile);
// make a resource file change
@@ -83,14 +84,16 @@ public class DevTest extends BaseDevTest {
File propertiesFile = new File(resourceDir, "microprofile-config.properties");
assertTrue(propertiesFile.createNewFile());
+ // dev mode copies file to target dir
File targetPropertiesFile = new File(targetDir, "classes/microprofile-config.properties");
assertTrue(getLogTail(), verifyFileExists(targetPropertiesFile, 30000)); // wait for dev mode
assertTrue(getLogTail(), verifyLogMessageExists("CWWKZ0003I:", 10000, logFile, ++appUpdatedCount));
// delete a resource file
assertTrue(propertiesFile.delete());
- assertTrue(verifyFileDoesNotExist(targetPropertiesFile, 5000));
+ assertTrue(getLogTail(), verifyFileDoesNotExist(targetPropertiesFile, 5000));
}
+
@Test
public void testDirectoryTest() throws Exception {
// create the test directory
@@ -109,9 +112,8 @@ public class DevTest extends BaseDevTest {
// wait for compilation
assertTrue(getLogTail(), verifyFileExists(unitTestTargetFile, 6000));
long lastModified = unitTestTargetFile.lastModified();
+ waitLongEnough();
- // The resolution of File.lastModified() is 1000 ms so wait long enough for lastModified() to register the modification.
- Thread.sleep(2000);
// modify the test file
String str = "// testing";
BufferedWriter javaWriter = new BufferedWriter(new FileWriter(unitTestSrcFile, true));
@@ -198,6 +200,9 @@ public class DevTest extends BaseDevTest {
final String SERVER_XML_COMMENT = "Plugin has generated Liberty features"; // the explanation added to server.xml
final String NEW_FILE_INFO_MESSAGE = "This file was generated by the Liberty Maven Plugin and will be overwritten"; // the explanation added to the generated features file
final String RUNNING_GENERATE_FEATURES = "Running liberty:generate-features";
+ // After generate features is toggled off and on we end up with 'No functional changes were detected'
+ final String SERVER_NOT_UPDATED = "CWWKG0018I:";
+ final String SERVER_UPDATE_COMPLETE = "CWWKF0008I:"; // Feature update completed in 0.649 seconds.
// Verify generate features runs when dev mode first starts
assertTrue(verifyLogMessageExists(RUNNING_GENERATE_FEATURES, 10000));
@@ -255,7 +260,9 @@ public class DevTest extends BaseDevTest {
// toggle on
writer.write("g\n");
writer.flush();
- assertTrue(autoGenOn, verifyLogMessageExists(autoGenOn, 10000)); // allow time to run scanner
+ assertTrue(autoGenOn, verifyLogMessageExists(autoGenOn, 10000));
+ // Check for server response to regenerated feature list.
+ assertTrue(SERVER_NOT_UPDATED, verifyLogMessageExists(SERVER_NOT_UPDATED, 10000));
// Remove a class and use 'optimize' to rebuild the generated features
assertTrue(helloBatchSrc.delete());
@@ -267,6 +274,9 @@ public class DevTest extends BaseDevTest {
writer.write("o\n");
writer.flush();
assertTrue(verifyLogMessageExists("batch-1.0", 10000, newFeatureFile, 0)); // exist 0 times
+ // Check for server response to newly generated feature list.
+ assertTrue(SERVER_UPDATE_COMPLETE, verifyLogMessageExists(SERVER_UPDATE_COMPLETE, 10000));
+ // Need to ensure server finished updating before the next test starts.
}
@Test
