-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Kornel <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...st-examples/src/test/java/io/skodjob/testframe/test/integration/GlobalLogCollectorIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Skodjob authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.skodjob.testframe.test.integration; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class GlobalLogCollectorIT extends AbstractIT { | ||
@Test | ||
void testGlobalLogCollector() { | ||
fail("Expected issue"); | ||
} | ||
|
||
@AfterEach | ||
void clean() throws IOException { | ||
FileUtils.deleteDirectory(LOG_DIR.toFile()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...est/java/io/skodjob/testframe/test/integration/helpers/GlobalLogCollectorTestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Skodjob authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
package io.skodjob.testframe.test.integration.helpers; | ||
|
||
import io.skodjob.testframe.test.integration.AbstractIT; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* Override test failure for expected test issue in GlobalLogCollectorIT test | ||
*/ | ||
public class GlobalLogCollectorTestHandler implements TestExecutionExceptionHandler { | ||
|
||
/** | ||
* Check cause message and if it is from GlobalLogCollectorIT check if logs | ||
* are collected and do not mark test as failure | ||
* | ||
* @param context extension context | ||
* @param cause throwable object | ||
* @throws Throwable throwable object | ||
*/ | ||
@Override | ||
public void handleTestExecutionException(ExtensionContext context, Throwable cause) throws Throwable { | ||
if (cause.getMessage().contains("Expected issue")) { | ||
assertTrue(AbstractIT.LOG_DIR.toFile().exists()); | ||
assertTrue(AbstractIT.LOG_DIR.resolve("default").toFile().exists()); | ||
assertTrue(AbstractIT.LOG_DIR.resolve("cluster-wide-resources").toFile().exists()); | ||
} else { | ||
throw cause; | ||
} | ||
} | ||
} |