Search in sources :

Example 66 with Logger

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);
}
Also used : SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) ThreadLocalAMTokenCache(org.forgerock.openam.sts.token.ThreadLocalAMTokenCache) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 67 with Logger

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();
}
Also used : STSPublishException(org.forgerock.openam.sts.STSPublishException) Logger(org.slf4j.Logger)

Example 68 with Logger

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);
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) DockerClient(com.spotify.docker.client.DockerClient) AbstractTestEnvironment(org.opennms.test.system.api.AbstractTestEnvironment) Logger(org.slf4j.Logger)

Example 69 with Logger

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);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) Logger(org.slf4j.Logger) IllegalStateException(javax.resource.spi.IllegalStateException) SystemException(javax.transaction.SystemException)

Example 70 with Logger

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());
}
Also used : Type(java.lang.reflect.Type) Logger(org.slf4j.Logger) LinkedList(java.util.LinkedList) Test(org.testng.annotations.Test)

Aggregations

Logger (org.slf4j.Logger)1088 Test (org.junit.Test)249 IOException (java.io.IOException)127 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)110 ArrayList (java.util.ArrayList)71 InputStream (java.io.InputStream)64 List (java.util.List)59 File (java.io.File)56 Map (java.util.Map)51 LoggerFactory (org.slf4j.LoggerFactory)46 Test (org.testng.annotations.Test)43 HashMap (java.util.HashMap)39 Properties (java.util.Properties)35 HashSet (java.util.HashSet)31 FileInputStream (java.io.FileInputStream)29 Transfer (org.commonjava.maven.galley.model.Transfer)29 Set (java.util.Set)28 StoreKey (org.commonjava.indy.model.core.StoreKey)28 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)27 Date (java.util.Date)26