use of org.apache.qpid.server.SystemLauncherListener in project qpid-broker-j by apache.
the class EmbeddedBrokerPerClassAdminImpl method beforeTestClass.
@Override
public void beforeTestClass(final Class testClass) {
setClassQualifiedTestName(testClass.getName());
LOGGER.info("========================= starting broker for test class : " + testClass.getSimpleName());
try {
String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
_currentWorkDirectory = Files.createTempDirectory(String.format("qpid-work-%s-%s-", timestamp, testClass.getSimpleName())).toString();
Map<String, String> context = new HashMap<>();
context.put("qpid.work_dir", _currentWorkDirectory);
context.put("qpid.port.protocol_handshake_timeout", "1000000");
context.putAll(Arrays.stream((ConfigItem[]) testClass.getAnnotationsByType(ConfigItem.class)).collect(Collectors.toMap(ConfigItem::name, ConfigItem::value, (name, value) -> value)));
Map<String, Object> systemConfigAttributes = new HashMap<>();
// systemConfigAttributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, "classpath:config-protocol-tests.json");
systemConfigAttributes.put(ConfiguredObject.CONTEXT, context);
systemConfigAttributes.put(ConfiguredObject.TYPE, System.getProperty("broker.config-store-type", "JSON"));
systemConfigAttributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, Boolean.FALSE);
if (Thread.getDefaultUncaughtExceptionHandler() == null) {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
}
LOGGER.info("Starting internal broker (same JVM)");
List<SystemLauncherListener> systemLauncherListeners = new ArrayList<>();
systemLauncherListeners.add(new LogbackLoggingSystemLauncherListener());
systemLauncherListeners.add(new ShutdownLoggingSystemLauncherListener());
systemLauncherListeners.add(new PortExtractingLauncherListener());
_systemLauncher = new SystemLauncher(systemLauncherListeners.toArray(new SystemLauncherListener[systemLauncherListeners.size()]));
_systemLauncher.startup(systemConfigAttributes);
} catch (Exception e) {
throw new RuntimeException("Failed to start broker for test class", e);
}
}
Aggregations