Search in sources :

Example 61 with Logger

use of org.slf4j.Logger in project openhab1-addons by openhab.

the class MStepperPositionImpl method setLogger.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
public void setLogger(Logger newLogger) {
    Logger oldLogger = logger;
    logger = newLogger;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MSTEPPER_POSITION__LOGGER, oldLogger, logger));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Logger(org.slf4j.Logger)

Example 62 with Logger

use of org.slf4j.Logger in project openhab1-addons by openhab.

the class MStepperVelocityImpl method setLogger.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
public void setLogger(Logger newLogger) {
    Logger oldLogger = logger;
    logger = newLogger;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MSTEPPER_VELOCITY__LOGGER, oldLogger, logger));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Logger(org.slf4j.Logger)

Example 63 with Logger

use of org.slf4j.Logger in project openhab1-addons by openhab.

the class MaxCubeDiscover method discoverIp.

/**
     * Automatic UDP discovery of a MAX!Cube
     * 
     * @return if the cube is found, returns the IP address as a string. Otherwise returns null
     */
public static final String discoverIp() {
    String maxCubeIP = null;
    String maxCubeName = null;
    String rfAddress = null;
    Logger logger = LoggerFactory.getLogger(MaxCubeDiscover.class);
    DatagramSocket bcReceipt = null;
    DatagramSocket bcSend = null;
    // Find the MaxCube using UDP broadcast
    try {
        bcSend = new DatagramSocket();
        bcSend.setBroadcast(true);
        byte[] sendData = "eQ3Max*\0**********I".getBytes();
        // Broadcast the message over all the network interfaces
        Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
        while (interfaces.hasMoreElements()) {
            NetworkInterface networkInterface = interfaces.nextElement();
            if (networkInterface.isLoopback() || !networkInterface.isUp()) {
                continue;
            }
            for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) {
                InetAddress[] broadcast = new InetAddress[2];
                broadcast[0] = InetAddress.getByName("224.0.0.1");
                broadcast[1] = interfaceAddress.getBroadcast();
                for (InetAddress bc : broadcast) {
                    // Send the broadcast package!
                    if (bc != null) {
                        try {
                            DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, bc, 23272);
                            bcSend.send(sendPacket);
                        } catch (IOException e) {
                            logger.debug("IO error during MAX! Cube discovery: {}", e.getMessage());
                        } catch (Exception e) {
                            logger.debug(e.getMessage());
                            logger.debug(Utils.getStackTrace(e));
                        }
                        logger.trace("Request packet sent to: {} Interface: {}", bc.getHostAddress(), networkInterface.getDisplayName());
                    }
                }
            }
        }
        logger.trace("Done looping over all network interfaces. Now waiting for a reply!");
        bcSend.close();
        bcReceipt = new DatagramSocket(23272);
        bcReceipt.setReuseAddress(true);
        // Wait for a response
        byte[] recvBuf = new byte[15000];
        DatagramPacket receivePacket = new DatagramPacket(recvBuf, recvBuf.length);
        bcReceipt.receive(receivePacket);
        // We have a response
        logger.trace("Broadcast response from server: {}", receivePacket.getAddress());
        // Check if the message is correct
        String message = new String(receivePacket.getData()).trim();
        if (message.startsWith("eQ3Max")) {
            maxCubeIP = receivePacket.getAddress().getHostAddress();
            maxCubeName = message.substring(0, 8);
            rfAddress = message.substring(8, 18);
            logger.debug("Found at: {}", maxCubeIP);
            logger.debug("Name    : {}", maxCubeName);
            logger.debug("Serial  : {}", rfAddress);
            logger.trace("Message : {}", message);
        } else {
            logger.info("No Max!Cube gateway found on network");
        }
    } catch (IOException e) {
        logger.debug("IO error during MAX! Cube discovery: {}", e.getMessage());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        logger.debug(Utils.getStackTrace(e));
    } finally {
        try {
            if (bcReceipt != null) {
                bcReceipt.close();
            }
        } catch (Exception e) {
            logger.debug(e.toString());
        }
        try {
            if (bcSend != null) {
                bcSend.close();
            }
        } catch (Exception e) {
            logger.debug(e.toString());
        }
    }
    return maxCubeIP;
}
Also used : DatagramSocket(java.net.DatagramSocket) InterfaceAddress(java.net.InterfaceAddress) DatagramPacket(java.net.DatagramPacket) NetworkInterface(java.net.NetworkInterface) IOException(java.io.IOException) Logger(org.slf4j.Logger) InetAddress(java.net.InetAddress) IOException(java.io.IOException)

Example 64 with Logger

use of org.slf4j.Logger in project OpenAM by OpenRock.

the class ScriptConfigurationServiceTest method setUp.

@BeforeMethod
public void setUp() throws ResourceException {
    Logger logger = mock(Logger.class);
    Subject subject = new Subject();
    subject.getPrincipals().add(testUserPrinciple);
    dataStore = mock(ScriptingDataStore.class);
    ScriptingDataStoreFactory dataStoreFactory = mock(ScriptingDataStoreFactory.class);
    when(dataStoreFactory.create(any(Subject.class), anyString())).thenReturn(dataStore);
    service = new ScriptConfigurationService(logger, subject, "/", dataStoreFactory);
}
Also used : ScriptingDataStoreFactory(org.forgerock.openam.scripting.datastore.ScriptingDataStoreFactory) ScriptingDataStore(org.forgerock.openam.scripting.datastore.ScriptingDataStore) Logger(org.slf4j.Logger) Subject(javax.security.auth.Subject) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 65 with Logger

use of org.slf4j.Logger in project OpenAM by OpenRock.

the class TokenDelegationHandlersProviderTest method testDefaultDelegationHandler.

@Test
public void testDefaultDelegationHandler() 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 DefaultTokenDelegationHandler);
}
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)

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