Skip to content

Commit

Permalink
moving spring boot failure test to new file
Browse files Browse the repository at this point in the history
Signed-off-by: Arun Venmany <[email protected]>
  • Loading branch information
arunvenmany-ibm committed Nov 20, 2024
1 parent ee10949 commit 29fcfcd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//Check build.log content for certain tests
boolean flag = false;
String testname = basedir.getName();
String expectedMessage = null;
switch (testname) {
case "springboot-3-appsdirectory-apps-fail-it":
expectedMessage = "Found multiple springBootApplication elements specified in the server configuration. Only one springBootApplication can be configured per Liberty server.";
break;
default:
return false;
}
File buildlog = new File(basedir,"build.log");
if (buildlog.exists()) {
try {
InputStream buildOutput = new FileInputStream(buildlog);
InputStreamReader in = new InputStreamReader(buildOutput);
java.util.Scanner s = new java.util.Scanner(in);
while (s.hasNextLine() && !flag) {
String line = s.nextLine();
if (line.contains(expectedMessage)) {
flag = true;
System.out.println("Correct error message found for test "+testname);
}
}
s.close();
in.close();
buildOutput.close();
} catch (Exception e) {
System.out.println("Error checking build.log " + e.getMessage());
}
}
if (!flag) {
System.out.println("FAILED: Expected error message ("+expectedMessage+") not found in "+buildlog.getAbsolutePath());
}
return flag;
7 changes: 6 additions & 1 deletion liberty-maven-plugin/src/test/resources/cleanTest.bsh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//If need to check build.log for error message, call script
boolean flag = true;
if (basedir.getName().contains("versionless-feature-fail-") || basedir.getName().contains("springboot-3-appsdirectory-apps-fail-")) {
if (basedir.getName().contains("versionless-feature-fail-")) {
String errorScript = new File(basedir, "checkErrorVersionlessFeature.bsh").getAbsolutePath();
System.out.println("Running post-build script: "+ errorScript);
flag = source(errorScript);
}
if (basedir.getName().contains("springboot-3-appsdirectory-apps-fail-")) {
String errorScript = new File(basedir, "checkErrorSpringBootApplicationNode.bsh").getAbsolutePath();
System.out.println("Running post-build script: "+ errorScript);
flag = source(errorScript);
}
//Runs clean in the test project directory
Runtime.getRuntime().exec("../../../../mvnw clean", null, basedir);
System.out.println("Cleaned target dir(s) for " + basedir);
Expand Down

0 comments on commit 29fcfcd

Please sign in to comment.