Package org.talend.esb.servicelocator.client.internal.zk

Examples of org.talend.esb.servicelocator.client.internal.zk.ZKBackend$NodeMapper


    private ZKBackend backend;

    private PrintStream out;

    public ServiceLocatorMain() {
        backend = new ZKBackend();
        sl = new ServiceLocatorImpl();
        sl.setBackend(backend);
    }
View Full Code Here


        return transformer.fromEndpoint(eprProvider, lastTimeStarted, lastTimeStopped);
    }
   
    private ServiceLocatorBackend getBackend() {
        if (backend == null) {
            backend = new ZKBackend();
        }
        return backend;
    }
View Full Code Here

    @Test
    public void connect() throws Exception {
        expect(zkMock.getState()).andStubReturn(ZooKeeper.States.CONNECTED);
        replay(zkMock);

        ZKBackend zkb = createZKBackend(true);

        RootNode rootNode = zkb.connect();

        assertNotNull(rootNode);
        assertTrue(zkb.isConnected());
        verify(zkMock);
    }
View Full Code Here

        verify(zkMock);
    }

    @Test
    public void connectFailing() throws Exception {
        ZKBackend zkb = createZKBackend(false);

        replay(zkMock);

        zkb.setConnectionTimeout(5);

        try {
            zkb.connect();
            fail("A ServiceLocatorException should have been thrown.");
        } catch (ServiceLocatorException e) {
            ignore("Expected exception");
        }
View Full Code Here

    }

    @Ignore
    @Test
    public void connectWithCredentialsProvided () throws Exception {
        ZKBackend zkb = createZKBackend();

        zkMock.addAuthInfo(eq("sl"), aryEq(USER_NAME_PASSWORD_BYTES));
        replay(zkMock);

        zkb.setUserName(USER_NAME);
        zkb.setPassword(PASSWORD);
        zkb.connect();

        verify(zkMock);       
    }
View Full Code Here

    @Test
    public void nodeExistsTrue()  throws Exception {
        expect(zkMock.exists(NODE_PATH.toString(), false)).andReturn(new Stat());
        replay(zkMock);
        ZKBackend zkb = createZKBackend();

        zkb.connect();
        boolean exists = zkb.nodeExists(NODE_PATH);
       
        assertTrue(exists);
        verify(zkMock);
    }
View Full Code Here

    @Test
    public void nodeExistsFalse()  throws Exception {
        expect(zkMock.exists(NODE_PATH.toString(), false)).andReturn(null);
       
        ZKBackend zkb = createZKBackend();
        replay(zkMock);

        zkb.connect();
        boolean exists = zkb.nodeExists(NODE_PATH);
       
        assertFalse(exists);
        verify(zkMock);
    }
View Full Code Here

    @Test
    public void createNode()  throws Exception {
        expect(zkMock.create(NODE_PATH.toString(), CONTENT_ANY_1, getACLs(), PERSISTENT)).
            andReturn(NODE_PATH.toString());
       
        ZKBackend zkb = createZKBackend();
        replay(zkMock);

        zkb.connect();
        zkb.createNode(NODE_PATH, PERSISTENT, CONTENT_ANY_1);
        verify(zkMock);
    }
View Full Code Here

        return createZKBackend(true);
    }

        private ZKBackend createZKBackend(final boolean connectSuccessful)
            throws ServiceLocatorException {
        return new ZKBackend() {
            @Override
            protected ZooKeeper createZooKeeper(CountDownLatch connectionLatch)
                    throws ServiceLocatorException {
                if (connectSuccessful) {
                    connectionLatch.countDown();
View Full Code Here

TOP

Related Classes of org.talend.esb.servicelocator.client.internal.zk.ZKBackend$NodeMapper

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.