Package wpn.hdri.ss.client

Examples of wpn.hdri.ss.client.Client


        });
    }

    @Test
    public void testTolerateExceptionsDuringWork() throws Exception {
        final Client client = mock(Client.class);

        doReturn(true).when(client).checkAttribute(anyString());
        doThrow(new RuntimeException("Holy mother of God!")).when(client).readAttribute(anyString());
        doReturn(String.class).when(client).getAttributeClass(anyString());
View Full Code Here


* @since 04.05.12
*/
public class ReadAttributeTaskTest {
    @Test
    public void testCancellation() throws Exception {
        Client mockClient = mock(Client.class);
        stub(mockClient.readAttribute(null)).toReturn(new AbstractMap.SimpleEntry<java.lang.Object, wpn.hdri.ss.data.Timestamp>(null, new Timestamp(System.currentTimeMillis())));
        Attribute mockAttribute = mock(Attribute.class);
        Logger mockLogger = mock(Logger.class);

        ScheduledExecutorService singleThreadExecutor = Executors.newScheduledThreadPool(1);

View Full Code Here

*/
public class ITTineClientFactoryTest {
    @Test
    public void testCreateClient() throws Exception {
        TineClientFactory instance = new TineClientFactory();
        Client result = instance.createClient("/TEST/SineServer/#SineGen3");

        result.readAttribute("Amplitude");
    }
View Full Code Here

    private final String name = "Test.Device";

    @Test(expected = ClientException.class)
    public void testReadAttr_Failed() throws Exception {
        ClientFactory factory = new ClientFactory();
        Client client = factory.createClient("sys/tg_test/1");

        client.readAttribute("throw_exception");
    }
View Full Code Here

    }

    //@Test
    public void testReadAttr_Position() throws Exception {
        ClientFactory factory = new ClientFactory();
        Client client = factory.createClient("tango://hasgksspp07oh1.desy.de:10000/p07/dcmmotor/dcm_2nd_yaw");
        for (int i = 0; i < 1000; i++) {
            Map.Entry<Double, Timestamp> result = client.<Double>readAttribute("Position");
            System.out.println(result.getKey());
        }
    }
View Full Code Here

    }

    @Test
    public void testCheckAttribute_Success() {
        ClientFactory factory = new ClientFactory();
        Client client = factory.createClient("sys/tg_test/1");

        boolean result = client.checkAttribute("double_scalar_w");

        assertTrue(result);
    }
View Full Code Here

    }

    @Test
    public void testCheckAttribute_Failure() {
        ClientFactory factory = new ClientFactory();
        Client client = factory.createClient("sys/tg_test/1");

        boolean result = client.checkAttribute("double_scalar_wXXX");

        assertFalse(result);
    }
View Full Code Here

        AttributesManager attributesManager = new AttributesManager(new AttributeFactory());
        for (Device dev : configuration.getDevices()) {
            String devName = dev.getName();

            final Client devClient = clientsManager.getClient(devName);

            for (DeviceAttribute attr : dev.getAttributes()) {
                final String fullName = devName + "/" + attr.getName();
                LOGGER.info("Initializing attribute " + fullName);
                boolean isAttrOk = devClient.checkAttribute(attr.getName());
                if (!isAttrOk) {
                    LOGGER.warn("DevClient reports bad attribute: " + fullName);
                    attributesManager.reportBadAttribute(fullName, "Attribute initialization failed.");
                    continue;
                }
                devClient.printAttributeInfo(attr.getName(), LOGGER);
                try {
                    Class<?> attributeClass = devClient.getAttributeClass(attr.getName());
                    boolean isArray = devClient.isArrayAttribute(attr.getName());
                    attributesManager.initializeAttribute(attr, dev.getName(), devClient, attributeClass, isArray);
                    LOGGER.info("Initialization succeed.");
                } catch (ClientException e) {
                    LOGGER.warn("Attribute initialization failed.", e);
                    attributesManager.reportBadAttribute(fullName, e.getMessage());
View Full Code Here

    }

    public List<EventReadAttributeTask> initializeEventTasks(ClientsManager clientsManager, AttributesManager attributesManager) {
        List<EventReadAttributeTask> result = new ArrayList<EventReadAttributeTask>();
        for (Attribute<?> attribute : attributesManager.getAttributesByMethod(Method.EVENT)) {
            final Client devClient = clientsManager.getClient(attribute.getName().getDeviceName());
            result.add(new EventReadAttributeTask(attribute, devClient, true, LOGGER));
        }
        return result;
    }
View Full Code Here

    public List<PollingReadAttributeTask> initializePollTasks(ClientsManager clientsManager, AttributesManager attributesManager) {
        List<PollingReadAttributeTask> result = new ArrayList<PollingReadAttributeTask>();
        for (final Attribute<?> attribute : attributesManager.getAttributesByMethod(Method.POLL)) {
            DeviceAttribute attr = configuration.getDeviceAttribute(attribute.getName().getDeviceName(), attribute.getName().getName());
            final Client devClient = clientsManager.getClient(attribute.getName().getDeviceName());
            result.add(new PollingReadAttributeTask(attribute, devClient, attr.getDelay(), true, LOGGER));
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of wpn.hdri.ss.client.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.