Package org.apache.avro.test

Examples of org.apache.avro.test.Mail


    System.out.println("server port : " + serverPort);

    // client
    Transceiver transceiver = new NettyTransceiver(new InetSocketAddress(
        serverPort));
    Mail proxy = (Mail) SpecificRequestor.getClient(Mail.class, transceiver);

    Message msg = new Message();
    msg.to = new Utf8("wife");
    msg.from = new Utf8("husband");
    msg.body = new Utf8("I love you!");

    try {
      CharSequence result = proxy.send(msg);
      System.out.println("Result: " + result);
      Assert.assertEquals(
          "Sent message to [wife] from [husband] with body [I love you!]",
          result.toString());
    } finally {
View Full Code Here


  @Test
  public void testConnectionsCount() throws Exception {
    Transceiver transceiver2 = new NettyTransceiver(new InetSocketAddress(
            server.getPort()), CONNECT_TIMEOUT_MILLIS);
    Mail proxy2 = SpecificRequestor.getClient(Mail.class, transceiver2);
    proxy.fireandforget(createMessage());
    proxy2.fireandforget(createMessage());
    Assert.assertEquals(2, ((NettyServer) server).getNumActiveConnections());
    transceiver2.close();
    Assert.assertEquals(1, ((NettyServer) server).getNumActiveConnections());
  }
View Full Code Here

import static org.junit.Assert.fail;

public class TestNettyTransceiverWhenServerStops {
  @Test
    public void testNettyTransceiverWhenServerStops() throws Exception {
    Mail mailService = new TestNettyServer.MailImpl();
    Responder responder = new SpecificResponder(Mail.class, mailService);
    NettyServer server = new NettyServer(responder, new InetSocketAddress(0));
    server.start();

    int serverPort = server.getPort();

    final NettyTransceiver transceiver = new NettyTransceiver(new InetSocketAddress(serverPort), 60000L);
    final Mail mail = SpecificRequestor.getClient(Mail.class, transceiver);

    final AtomicInteger successes = new AtomicInteger();
    final AtomicInteger failures = new AtomicInteger();
    final AtomicBoolean quitOnFailure = new AtomicBoolean();
    List<Thread> threads = new ArrayList<Thread>();

    // Start a bunch of client threads that use the transceiver to send messages
    for (int i = 0; i < 100; i++) {
      Thread thread = new Thread(new Runnable() {
          @Override
            public void run() {
            while (true) {
              try {
                mail.send(createMessage());
                successes.incrementAndGet();
              } catch (Exception e) {
                failures.incrementAndGet();
                if (quitOnFailure.get()) {
                  return;
View Full Code Here

  @Test
  public void testConnectionsCount() throws Exception {
    Transceiver transceiver2 = new NettyTransceiver(new InetSocketAddress(
            server.getPort()), CONNECT_TIMEOUT_MILLIS);
    Mail proxy2 = SpecificRequestor.getClient(Mail.class, transceiver2);
    proxy.fireandforget(createMessage());
    proxy2.fireandforget(createMessage());
    Assert.assertEquals(2, ((NettyServer) server).getNumActiveConnections());
    transceiver2.close();
    Assert.assertEquals(1, ((NettyServer) server).getNumActiveConnections());
  }
View Full Code Here

    System.out.println("server port : " + serverPort);

    // client
    Transceiver transceiver = new NettyTransceiver(new InetSocketAddress(
        serverPort));
    Mail proxy = SpecificRequestor.getClient(Mail.class, transceiver);

    Message msg = new Message();
    msg.to = new Utf8("wife");
    msg.from = new Utf8("husband");
    msg.body = new Utf8("I love you!");

    try {
      for(int x = 0; x < 5; x++) {
        CharSequence result = proxy.send(msg);
        System.out.println("Result: " + result);
        Assert.assertEquals(
            "Sent message to [wife] from [husband] with body [I love you!]",
            result.toString());
      }
View Full Code Here

    SpecificResponder responder = new SpecificResponder(Mail.class, new TestMailImpl());
    SpecificRequestor requestor = new SpecificRequestor(Mail.class, new LocalTransceiver(responder));
    responder.addRPCPlugin(plugin);
    requestor.addRPCPlugin(plugin);
   
    Mail client = SpecificRequestor.getClient(Mail.class, requestor);
    Message message = createTestMessage();
    client.send(message);
  }
View Full Code Here

    SpecificResponder responder = new SpecificResponder(Mail.class, new TestMailImpl());
    SpecificRequestor requestor = new SpecificRequestor(Mail.class, new LocalTransceiver(responder));
    responder.addRPCPlugin(plugin);
    requestor.addRPCPlugin(plugin);
   
    Mail client = SpecificRequestor.getClient(Mail.class, requestor);
    Message message = createTestMessage();
    client.send(message);
  }
View Full Code Here

    SpecificResponder responder = new SpecificResponder(Mail.class, new TestMailImpl());
    SpecificRequestor requestor = new SpecificRequestor(Mail.class, new LocalTransceiver(responder));
    responder.addRPCPlugin(plugin);
    requestor.addRPCPlugin(plugin);
   
    Mail client = SpecificRequestor.getClient(Mail.class, requestor);
    Message message = createTestMessage();
    client.send(message);
  }
View Full Code Here

import static org.junit.Assert.fail;

public class TestNettyTransceiverWhenServerStops {
//  @Test                                           // disable flakey test!
    public void testNettyTransceiverWhenServerStops() throws Exception {
    Mail mailService = new TestNettyServer.MailImpl();
    Responder responder = new SpecificResponder(Mail.class, mailService);
    NettyServer server = new NettyServer(responder, new InetSocketAddress(0));
    server.start();

    int serverPort = server.getPort();

    final NettyTransceiver transceiver = new NettyTransceiver(new InetSocketAddress(serverPort), 60000L);
    final Mail mail = SpecificRequestor.getClient(Mail.class, transceiver);

    final AtomicInteger successes = new AtomicInteger();
    final AtomicInteger failures = new AtomicInteger();
    final AtomicBoolean quitOnFailure = new AtomicBoolean();
    List<Thread> threads = new ArrayList<Thread>();

    // Start a bunch of client threads that use the transceiver to send messages
    for (int i = 0; i < 100; i++) {
      Thread thread = new Thread(new Runnable() {
          @Override
            public void run() {
            while (true) {
              try {
                mail.send(createMessage());
                successes.incrementAndGet();
              } catch (Exception e) {
                failures.incrementAndGet();
                if (quitOnFailure.get()) {
                  return;
View Full Code Here

TOP

Related Classes of org.apache.avro.test.Mail

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.