Skip to content

Commit

Permalink
check each log messages individually
Browse files Browse the repository at this point in the history
  • Loading branch information
jjiwooLim committed Oct 30, 2023
1 parent 2707ed9 commit 6dc6999
Showing 1 changed file with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,53 +51,47 @@ public void testVerifyUsrFeature() throws Exception {
}
}

@Test
public void testVerifyAll() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("all") && System.getProperty("keyid").equals("0x05534365803788CE"));
String VERIFIED_MESSAGE = "All features were successfully verified.";
assertTrue(buildLogCheck(VERIFIED_MESSAGE));
}


@Test
public void buildLogCheck() throws Exception {
File buildLog = new File("build.log");
assertTrue(buildLog.exists());

InputStream buildOutput = null;
InputStreamReader in = null;
Scanner s = null;

final String VERIFIED_MESSAGE = "All features were successfully verified.";
boolean VERIFIED_MESSAGE_FOUND = false;

final String CWWKF1514E_MESSAGE = "CWWKF1514E";
boolean CWWKF1514E_MESSAGE_FOUND = false;

final String CWWKF1508E_MESSAGE = "CWWKF1508E";
boolean CWWKF1508E_MESSAGE_FOUND = false;

final String CWWKF1512E_MESSAGE = "CWWKF1512E";
boolean CWWKF1512E_MESSAGE_FOUND = false;


public void testVerifyWarnWrongKeyId() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("warn") && System.getProperty("keyid").equals("0xWRONGKEYID"));
//CWWKF1514E: The 0X05534365803788CE public key ID does not match the 0xWRONGKEYID provided key ID.
String CWWKF1514E_MESSAGE = "CWWKF1514E";
assertTrue(buildLogCheck(CWWKF1514E_MESSAGE));
}

@Test
public void testVerifyEnforceWithoutUserKeyId() throws Exception {
Assume.assumeTrue(System.getProperty("verify").equals("enforce") && System.getProperty("keyid") == null);
//CWWKF1508E: The public key ID for the src/test/resources/SimpleActivatorValidKey.asc key URL was not provided.
String CWWKF1508E_MESSAGE = "CWWKF1508E";
assertTrue(buildLogCheck(CWWKF1508E_MESSAGE));
}


try {
buildOutput = new FileInputStream(buildLog);
in = new InputStreamReader(buildOutput);
s = new Scanner(in);

public boolean buildLogCheck(String msg) throws Exception {
File buildLog = new File("build.log");
assertTrue(buildLog.exists());

try (InputStream buildOutput = new FileInputStream(buildLog); InputStreamReader in = new InputStreamReader(buildOutput); Scanner s = new Scanner(in);) {
while (s.hasNextLine()) {
String line = s.nextLine();
if (line.equals(VERIFIED_MESSAGE)) {
VERIFIED_MESSAGE_FOUND = true;
} else if (line.equals(CWWKF1514E_MESSAGE)) {
CWWKF1514E_MESSAGE_FOUND = true;
} else if (line.equals(CWWKF1508E_MESSAGE)) {
CWWKF1508E_MESSAGE_FOUND = true;
} else if (line.equals(CWWKF1512E_MESSAGE)) {
CWWKF1512E_MESSAGE_FOUND = true;
if(line.contains(msg)) {
return true;
}
}
} catch (Exception e) {

System.out.println("Error checking build.log " + e.getMessage());
}

assertTrue(VERIFIED_MESSAGE_FOUND || CWWKF1514E_MESSAGE_FOUND || CWWKF1508E_MESSAGE_FOUND || CWWKF1512E_MESSAGE_FOUND);
return false;
}

}

0 comments on commit 6dc6999

Please sign in to comment.