Package net.windwards.dnsfrontend.client

Examples of net.windwards.dnsfrontend.client.Client


        frontend2 = new TestingFrontend();
        frontend2.setup(conf2);
        frontend2.start();

        client = new Client() {
            @Override
            protected void log(String message) {
                LoggerFactory.getLogger(TestComplexSetup.class).info(message);
            }
        };
View Full Code Here


    @Test
    public void receiveRequest() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);

        Client client = new Client();
        client.addReceiver(new Recipient() {
            @Override
            public void receive(Request request) {
                latch.countDown();
            }
        });
        client.connect();

        FakeServer server = new FakeServer();
        server.send(
                "{ \"type\": \"Request\"," +
                "  \"moniker\": \"bar\"," +
                "  \"name\": \"foo\" }");

        Assert.assertEquals(1, latch.getCount());
        Assert.assertTrue(latch.await(200, TimeUnit.MILLISECONDS));

        client.disconnect();
        server.shutdown();
    }
View Full Code Here

    @Test
    public void sendUpdate() throws Exception {
        FakeServer server = new FakeServer();

        Client client = new Client();
        client.connect();

        Update update = new Update();
        update.address = "192.168.0.1";
        update.family = "ipv4";
        update.name = "foo";
        update.moniker = "bar";

        Assert.assertEquals(0, server.received.size());

        client.send(update);

        Assert.assertEquals(0, server.received.size());

        Thread.sleep(200);

        Assert.assertEquals(1, server.received.size());

        client.disconnect();
        server.shutdown();
    }
View Full Code Here

    @Test
    public void overhearUpdate() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);

        Client client = new Client();
        client.addReceiver(new Recipient() {
            @Override
            public void receive(Request request) {
                latch.countDown();
            }
        });
        client.connect();

        FakeServer server = new FakeServer();
        server.send("{" +
                "\"type\": \"update\", " +
                "\"address\": \"192.168.0.1\", " +
                "\"family\": \"ipv4\", " +
                "\"name\": \"foo\"," +
                "\"moniker\": \"bar\" }");

        Assert.assertEquals(1, latch.getCount());
        Assert.assertFalse(latch.await(200, TimeUnit.MILLISECONDS));

        client.disconnect();
        server.shutdown();

    }
View Full Code Here

            }
        };
        frontend.setup(conf);
        frontend.start();

        client = new Client();
        client.connect();
    }
View Full Code Here

TOP

Related Classes of net.windwards.dnsfrontend.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.