Package org.apache.curator.test

Examples of org.apache.curator.test.TestingServer


            }
            Assert.assertTrue(timing.acquireSemaphore(semaphore));

            timing.sleepABit();

            server = new TestingServer(server.getPort(), server.getTempDirectory());
            Assert.assertTrue(timing.awaitLatch(latch));

            timing.sleepABit();

            Assert.assertNull(namespaceClient.checkExists().forPath("/test-me"));
View Full Code Here


            catch ( KeeperException.ConnectionLossException e )
            {
                // expected
            }
           
            server = new TestingServer(serverPort, serverDir);
            Assert.assertNotNull(client.checkExists().forPath(PATH));

            server.stop(); // cause the next delete to fail
            server = null;
            try
            {
                client.delete().guaranteed().forPath(PATH);
                Assert.fail();
            }
            catch ( KeeperException.ConnectionLossException e )
            {
                // expected
            }

            server = new TestingServer(serverPort, serverDir);

            final int       TRIES = 5;
            for ( int i = 0; i < TRIES; ++i )
            {
                if ( client.checkExists().forPath(PATH) != null )
View Full Code Here

            catch ( KeeperException.ConnectionLossException e )
            {
                // expected
            }

            server = new TestingServer(server.getPort(), server.getTempDirectory());
            try
            {
                client.setData().forPath("/test", "test".getBytes());
            }
            catch ( KeeperException.NoAuthException e )
View Full Code Here

    public static void main(String[] args) throws Exception
    {
        // This method is scaffolding to get the example up and running

        TestingServer                                   server = new TestingServer();
        CuratorFramework                                client = null;
        ServiceDiscovery<InstanceDetails>               serviceDiscovery = null;
        Map<String, ServiceProvider<InstanceDetails>>   providers = Maps.newHashMap();
        try
        {
            client = CuratorFrameworkFactory.newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3));
            client.start();

            JsonInstanceSerializer<InstanceDetails> serializer = new JsonInstanceSerializer<InstanceDetails>(InstanceDetails.class);
            serviceDiscovery = ServiceDiscoveryBuilder.builder(InstanceDetails.class).client(client).basePath(PATH).serializer(serializer).build();
            serviceDiscovery.start();
View Full Code Here

        // FakeLimitedResource simulates some external resource that can only be access by one process at a time
        final FakeLimitedResource   resource = new FakeLimitedResource();

        ExecutorService             service = Executors.newFixedThreadPool(QTY);
        final TestingServer         server = new TestingServer();
        try
        {
            for ( int i = 0; i < QTY; ++i )
            {
                final int       index = i;
                Callable<Void>  task = new Callable<Void>()
                {
                    @Override
                    public Void call() throws Exception
                    {
                        CuratorFramework        client = CuratorFrameworkFactory.newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3));
                        try
                        {
                            client.start();

                            ExampleClientThatLocks      example = new ExampleClientThatLocks(client, PATH, resource, "Client " + index);
View Full Code Here

                        break;
                    }

                    case 2:
                    {
                        server = new TestingServer(serverPort, tempDirectory);
                        break;
                    }

                    case 3:
                    case 4:
View Full Code Here

    }

    @Test
    public void     testChanging() throws Exception
    {
        TestingServer               secondServer = new TestingServer();
        try
        {
            String                          mainConnectionString = "count=1&port=" + server.getPort() + "&server0=localhost";
            String                          secondConnectionString = "count=1&port=" + secondServer.getPort() + "&server0=localhost";

            final Semaphore                 semaphore = new Semaphore(0);
            final AtomicReference<String>   connectionString = new AtomicReference<String>(mainConnectionString);
            Exhibitors                      exhibitors = new Exhibitors(Lists.newArrayList("foo", "bar"), 1000, dummyConnectionStringProvider);
            ExhibitorRestClient             mockRestClient = new ExhibitorRestClient()
View Full Code Here

    @BeforeMethod
    public void     setup() throws Exception
    {
        System.setProperty(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES, "true");
        server = new TestingServer();
    }
View Full Code Here

            client.getZooKeeper().create("/test", writtenData, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            Thread.sleep(1000);
            server.stop();
            Thread.sleep(1000);

            server = new TestingServer(serverPort, tempDirectory);
            Assert.assertTrue(client.blockUntilConnectedOrTimedOut());
            byte[]      readData = client.getZooKeeper().getData("/test", false, null);
            Assert.assertEquals(readData, writtenData);
        }
        finally
View Full Code Here

                                {
                                    timing.sleepABit();

                                    server.stop();
                                    Assert.assertTrue(timing.awaitLatch(latch));
                                    server = new TestingServer(server.getPort(), server.getTempDirectory());
                                }
                            }
                            finally
                            {
                                try
View Full Code Here

TOP

Related Classes of org.apache.curator.test.TestingServer

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.