use of com.github.valfirst.slf4jtest.TestLogger in project mule by mulesoft.
the class AbstractDeploymentTestCase method beforeClass.
@BeforeClass
public static void beforeClass() throws URISyntaxException, IllegalAccessException {
// Reduces unnecessary logging
TestLogger compilerUtilsTestLogger = getTestLogger(CompilerUtils.class);
compilerUtilsTestLogger.setEnabledLevelsForAllThreads(Level.ERROR);
TestLogger pollingProberTestLogger = getTestLogger(PollingProber.class);
pollingProberTestLogger.setEnabledLevelsForAllThreads(Level.ERROR);
TestLogger testLogger = getTestLogger(LoggerMessageProcessor.class);
testLogger.setEnabledLevelsForAllThreads(Level.ERROR);
// Initialises logging plugins with correct classloader
LogManager.getContext(false);
barUtils1ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar1/BarUtils.java"));
barUtils1_0JarFile = new JarFileBuilder("barUtils1", new JarCompiler().compiling(getResourceFile("/org/bar1/BarUtils.java")).compile("bar-1.0.jar")).getArtifactFile();
barUtils2ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar2/BarUtils.java"));
barUtils2_0JarFile = new JarFileBuilder("barUtils2", new JarCompiler().compiling(getResourceFile("/org/bar2/BarUtils.java")).compile("bar-2.0.jar")).getArtifactFile();
barUtilsJavaxClassFile = new SingleClassCompiler().compile(getResourceFile("/javax/annotation/BarUtils.java"));
barUtilsJavaxJarFile = new JarCompiler().compiling(getResourceFile("/javax/annotation/BarUtils.java")).compile("bar-javax.jar");
barUtilsForbiddenJavaClassFile = new SingleClassCompiler().compile(getResourceFile("/java/lang/BarUtils.java"));
barUtilsForbiddenJavaJarFile = new JarCompiler().compiling(getResourceFile("/java/lang/BarUtils.java")).compile("bar-javaForbidden.jar");
barUtilsForbiddenMuleContainerClassFile = new SingleClassCompiler().compile(getResourceFile("/org/mule/runtime/api/util/BarUtils.java"));
barUtilsForbiddenMuleContainerJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/runtime/api/util/BarUtils.java")).compile("bar-muleContainerForbidden.jar");
barUtilsForbiddenMuleThirdPartyClassFile = new SingleClassCompiler().compile(getResourceFile("/org/slf4j/BarUtils.java"));
barUtilsForbiddenMuleThirdPartyJarFile = new JarCompiler().compiling(getResourceFile("/org/slf4j/BarUtils.java")).compile("bar-muleThirdPartyForbidden.jar");
echoTestClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/EchoTest.java"));
echoTestJarFile = new JarCompiler().compiling(getResourceFile("/org/foo/EchoTest.java")).compile("echo.jar");
defaulServiceEchoJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/echo/DefaultEchoService.java"), getResourceFile("/org/mule/echo/EchoServiceProvider.java")).compile("mule-module-service-echo-default-4.0-SNAPSHOT.jar");
defaultFooServiceJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/service/foo/DefaultFooService.java"), getResourceFile("/org/mule/service/foo/FooServiceProvider.java")).dependingOn(defaulServiceEchoJarFile.getAbsoluteFile()).compile("mule-module-service-foo-default-4.0-SNAPSHOT.jar");
helloExtensionV1JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).including(getResourceFile("/org/foo/hello/registry-bootstrap.properties"), "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties").compile("mule-module-hello-1.0.0.jar", "1.0.0");
loadClassExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/classloading/LoadClassExtension.java"), getResourceFile("/org/foo/classloading/LoadClassOperation.java")).including(getResourceFile("/org/foo/classloading/registry-bootstrap.properties"), "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties").compile("mule-module-classloading-1.0.0.jar", "1.0.0");
callbackExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/callback/CallbackExtension.java"), getResourceFile("/org/foo/callback/CallbackOperation.java")).compile("mule-module-callback-1.0.0.jar", "1.0.0");
callbackExtensionPomFile = new JarFileBuilder("callbackExtension", callbackExtensionJarFile).getArtifactPomFile();
customExceptionClassFile = new CompilerUtils.SingleClassCompiler().compile(getResourceFile("/org/exception/CustomException.java"));
oracleExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/oracle/OracleExtension.java"), getResourceFile("/org/foo/oracle/OracleOperation.java")).compile("mule-module-oracle-1.0.0.jar", "1.0.0");
classloaderConnectionExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/connection/operation/ClassloaderConnectExtension.java"), getResourceFile("/org/foo/connection/operation/ClassloaderOperation.java")).including(getResourceFile("/org/foo/connection/extension/file.txt"), "file.txt").compile("mule-module-connect-1.0.0.jar", "1.0.0");
classloaderConfigConnectionExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/connection/config/ClassloaderConfigConnectExtension.java"), getResourceFile("/org/foo/connection/config/ClassloaderConfigOperation.java")).including(getResourceFile("/org/foo/connection/extension/file.txt"), "file.txt").compile("mule-module-classloader-config-1.0.0.jar", "1.0.0");
usingObjectStoreJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/os/UsingObjectStoreExtension.java")).compile("mule-module-using-object-store-1.0.0.jar", "1.0.0");
goodbyeExtensionV1JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/goodbye/GoodByeConfiguration.java"), getResourceFile("/org/foo/goodbye/GoodByeExtension.java")).compile("mule-module-goodbye-1.0.0.jar", "1.0.0");
helloExtensionV2JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).compile("mule-module-hello-2.0.0.jar", "2.0.0");
policyDependencyInjectionExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/policyIsolation/PolicyDependencyInjectionExtension.java"), getResourceFile("/org/foo/policyIsolation/PolicyDependencyInjectionOperations.java"), getResourceFile("/org/foo/policyIsolation/internal/InternalRegistryBean.java"), getResourceFile("/org/foo/policyIsolation/internal/PolicyDependencyInjectionFunctions.java")).including(getResourceFile("/org/foo/policyIsolation/registry-bootstrap.properties"), "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties").compile("mule-module-with-internal-dependency-4.0-SNAPSHOT.jar", "1.0.0");
policyConfigurationExtensionJarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/policyIsolation/PolicyConfigurationExtension.java"), getResourceFile("/org/foo/policyIsolation/PolicyConfigurationOperations.java")).compile("mule-module-with-internal-dependency-4.0-SNAPSHOT.jar", "1.0.0");
loadsAppResourceCallbackClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceCallback.java"));
loadsAppResourceCallbackJarFile = new JarCompiler().compiling(getResourceFile("/org/foo/LoadsAppResourceCallback.java")).compile("loadsAppResourceCallback.jar");
pluginEcho1TestClassFile = new SingleClassCompiler().dependingOn(barUtils1_0JarFile).compile(getResourceFile("/org/foo/Plugin1Echo.java"));
internalIsRunningTests = (Boolean) readDeclaredStaticField(TestComponentBuildingDefinitionProvider.class, "internalIsRunningTests", true);
writeDeclaredStaticField(TestComponentBuildingDefinitionProvider.class, "internalIsRunningTests", true, true);
}
use of com.github.valfirst.slf4jtest.TestLogger in project mule by mulesoft.
the class ClassloadingTroubleshootingTestCase method assertExpectedContentInLog.
private void assertExpectedContentInLog(String fileLocation, TestLogger logger) throws Exception {
File logContent = new File(getResourceAsUrl(fileLocation, ClassloadingTroubleshootingTestCase.class).toURI());
final String expectedErrorLog = readFileToString(logContent);
new PollingProber(EXPECTED_CONTENT_IN_LOG_SECS, DEFAULT_POLLING_INTERVAL).check(new Probe() {
@Override
public boolean isSatisfied() {
try {
assertThat(toMessages(logger.getAllLoggingEvents()), hasItem(expectedErrorLog));
return true;
} catch (Exception e) {
return false;
}
}
@Override
public String describeFailure() {
final StringJoiner joiner = new StringJoiner(lineSeparator());
logger.getAllLoggingEvents().forEach(e -> joiner.add(e.getMessage()));
return "expected content ('" + expectedErrorLog + "') not found. Full log is:" + lineSeparator() + joiner.toString();
}
});
}
Aggregations