use of org.slf4j.Logger in project OpenAM by OpenRock.
the class TokenDelegationHandlersProviderTest method testWrappedCustomDelegationHandler.
@Test
public void testWrappedCustomDelegationHandler() throws UnsupportedEncodingException {
Logger mockLogger = mock(Logger.class);
ThreadLocalAMTokenCache mockTokenCache = mock(ThreadLocalAMTokenCache.class);
SoapSTSInstanceConfig instanceConfig = createInstanceConfig(!DELEGATION_VALIDATORS_SPECIFIED, CUSTOM_DELEGATION_HANDLER);
assertTrue(new TokenDelegationHandlersProvider(instanceConfig, mockTokenCache, mockLogger).get().get(0) instanceof CustomDelegationHandlerWrapper);
}
use of org.slf4j.Logger in project OpenAM by OpenRock.
the class RestSTSSetupListener method setupComplete.
/**
* Republish any existing rest-sts instances obtained from the SMS, and register a ServiceListener to respond when
* new rest-sts instances are written to the SMS.
*/
@Override
public void setupComplete() {
new Thread(new Runnable() {
public void run() {
Logger logger = null;
try {
logger = STSPublishInjectorHolder.getInstance(Key.get(Logger.class));
RestSTSInstancePublisher publisher = STSPublishInjectorHolder.getInstance(Key.get(RestSTSInstancePublisher.class));
/*
Don't register the ServiceListener until after the SMS-resident rest-sts instances have been re-published
upon startup. The ServiceListener is only there to bring the rest-sts-instance CREST router in congruence
with the state of the SMS in site deployments.
*/
publisher.republishExistingInstances();
publisher.registerServiceListener();
} catch (STSPublishException e) {
if (logger != null) {
logger.error("Exception caught republishing existing Rest STS instances: ", e);
} else {
System.out.println("Exception caught republishing existing Rest STS instances: " + e);
}
}
}
}).start();
}
use of org.slf4j.Logger in project opennms by OpenNMS.
the class MinionHeartbeatOutageIT method restartContainer.
private void restartContainer(ContainerAlias alias) {
final DockerClient docker = ((AbstractTestEnvironment) testEnvironment).getDockerClient();
final String id = testEnvironment.getContainerInfo(alias).id();
final Logger logger = getLogger();
try {
logger.info("Restarting container: {} -> {}", alias, id);
docker.restartContainer(id);
logger.info("Container restarted: {} -> {}", alias, id);
} catch (DockerException | InterruptedException e) {
logger.warn("Unexpected exception while restarting container {}", id, e);
}
}
use of org.slf4j.Logger in project aries by apache.
the class TransactionControlImpl method close.
@Override
public void close() {
try {
super.close();
if (recoverableResources != null) {
recoverableResources.close();
}
} finally {
if (log != null) {
try {
log.doStop();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Note that the thread is daemon, so it won't stop shutdown
try {
Field f = HOWLLog.class.getDeclaredField("logger");
f.setAccessible(true);
org.objectweb.howl.log.Logger howlLogger = (org.objectweb.howl.log.Logger) f.get(log);
f = org.objectweb.howl.log.Logger.class.getDeclaredField("bmgr");
f.setAccessible(true);
Object logBufferManager = f.get(howlLogger);
f = logBufferManager.getClass().getDeclaredField("flushManager");
f.setAccessible(true);
Thread flushThread = (Thread) f.get(logBufferManager);
if (flushThread.isAlive()) {
// Briefly Join this thread in case it is going to stop properly.
// Pick the shorter of 250 milliseconds or twice the flush interval.
int toWait = Math.min(250, 2 * log.getFlushSleepTimeMilliseconds());
flushThread.join(toWait);
if (flushThread.isAlive()) {
// Still alive after waiting, time to pull the trigger ourselves
flushThread.interrupt();
// Let the thread react to interruption
flushThread.join(toWait);
}
}
} catch (Exception e) {
logger.error("An error ocurred while trying to close the HOWL flush thread.", e);
}
}
}
}
use of org.slf4j.Logger in project incubator-atlas by apache.
the class AbstractNotificationConsumerTest method testNext.
@Test
public void testNext() throws Exception {
Logger logger = mock(Logger.class);
TestMessage testMessage1 = new TestMessage("sValue1", 99);
TestMessage testMessage2 = new TestMessage("sValue2", 98);
TestMessage testMessage3 = new TestMessage("sValue3", 97);
TestMessage testMessage4 = new TestMessage("sValue4", 96);
List<String> jsonList = new LinkedList<>();
jsonList.add(GSON.toJson(new VersionedMessage<>(new MessageVersion("1.0.0"), testMessage1)));
jsonList.add(GSON.toJson(new VersionedMessage<>(new MessageVersion("1.0.0"), testMessage2)));
jsonList.add(GSON.toJson(new VersionedMessage<>(new MessageVersion("1.0.0"), testMessage3)));
jsonList.add(GSON.toJson(new VersionedMessage<>(new MessageVersion("1.0.0"), testMessage4)));
Type versionedMessageType = new TypeToken<VersionedMessage<TestMessage>>() {
}.getType();
NotificationConsumer<TestMessage> consumer = new TestNotificationConsumer<>(versionedMessageType, jsonList, logger);
assertTrue(consumer.hasNext());
assertEquals(testMessage1, consumer.next());
assertTrue(consumer.hasNext());
assertEquals(testMessage2, consumer.next());
assertTrue(consumer.hasNext());
assertEquals(testMessage3, consumer.next());
assertTrue(consumer.hasNext());
assertEquals(testMessage4, consumer.next());
assertFalse(consumer.hasNext());
}
Aggregations