Package fr.imag.adele.apam.pax.test.msg.m1.producer.impl

Examples of fr.imag.adele.apam.pax.test.msg.m1.producer.impl.M1ConsumerImpl02


    Instance producerApam1 = producer01Impl.createInstance(null, null);
    Instance producerApam2 = producer02Impl.createInstance(null, null);

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();
    M1ProducerImpl producer2 = (M1ProducerImpl) producerApam2
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();

    List<EletronicMsg> messages1 = new ArrayList<EletronicMsg>();
    List<EletronicMsg> messages2 = new ArrayList<EletronicMsg>();
    ;

    for (int i = 1; i <= 20; i++) {
      messages1.add(new EletronicMsg(Integer.toString(i)));
    }

    for (int i = 21; i <= 50; i++) {
      messages2.add(new EletronicMsg(Integer.toString(i)));
    }

    List<EletronicMsg> allMessages = new ArrayList<EletronicMsg>();
    allMessages.addAll(messages1);
    allMessages.addAll(messages2);

    AsynchronousSender sender1 = new AsynchronousSender(producer1,
        messages1);
    AsynchronousSender sender2 = new AsynchronousSender(producer2,
        messages2);

    sender1.execute();
    sender2.execute();

    sender1.join();
    sender2.join();

    final String message = "Given multiple producers and one consumer, the method that produces the message, from the different producers, are called by different threads. It is expected that all messages are received, but some messages got lost therefore not seem by the consumer";

    Assert.assertTrue(message, consumer.getQueue().containsAll(allMessages));

  }
View Full Code Here


    Instance producerApam1 = producer01Impl.createInstance(null, null);

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();
    consumer.getList();
    consumer.getSet();

    producer1.pushMessage("message 1");
    producer1.pushMessage("message 2");
    producer1.pushMessage("message 3");

    // ensure queue is inject
    Assert.assertTrue(String.format(usecase,
        "but the queue was not injected (has null value assigned)"),
        consumer.getQueue() != null);
    Assert.assertTrue(
        String.format(
            usecase,
            "but the queue was not injected (has size different than the number of messages sent)"),
        consumer.getQueue().size() == 3);
    Assert.assertTrue(
        String.format(usecase,
            "but the queue was not injected (the message is different than the one sent)"),
        consumer.getQueue().poll()
            .equals(new EletronicMsg("message 1")));

    // ensure that list and set type are not injected
    Assert.assertTrue(
        String.format(usecase, "the type List received the messages"),
        consumer.getList() == null);
    Assert.assertTrue(
        String.format(usecase, "the type Set received the messages"),
        consumer.getSet() == null);

  }
View Full Code Here

    Instance producerApam2 = producer02Impl.createInstance(null, null);
    Instance producerApam3 = producer03Impl.createInstance(null, null);

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();
    M1ProducerImpl producer2 = (M1ProducerImpl) producerApam2
        .getServiceObject();
    M1ProducerImpl producer3 = (M1ProducerImpl) producerApam3
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();

    final String message1producer1 = "message 1 produce 1";
    final String message1producer2 = "message 2 produce 2";
    final String message1producer3 = "message 3 produce 3";

    producer1.pushMessage(message1producer1);
    producer2.pushMessage(message1producer2);
    producer3.pushMessage(message1producer3);

    Assert.assertTrue(consumer.getQueue().size() == 3);

    Assert.assertTrue(consumer.getQueue().poll()
        .equals(new EletronicMsg(message1producer1)));
    Assert.assertTrue(consumer.getQueue().poll()
        .equals(new EletronicMsg(message1producer2)));
    Assert.assertTrue(consumer.getQueue().poll()
        .equals(new EletronicMsg(message1producer3)));

  }
View Full Code Here

    Instance producer = producerImpl.createInstance(null, null);

    Instance consumer = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 m1ConsumerImpl = (M1ConsumerImpl01) consumer
        .getServiceObject();

    M1ProducerImpl m1ProdImpl = (M1ProducerImpl) producer
        .getServiceObject();

    // TODO message: forcewire in message test
    m1ConsumerImpl.getQueue();

    for (int x = 0; x < POOL_SIZE; x++) {
      m1ProdImpl.pushMessage(String.format("message %d", x));
    }

    Assert.assertTrue(String.format(
        "Producer sent %d messages but the consumer received %d",
        POOL_SIZE, m1ConsumerImpl.getQueue().size()), m1ConsumerImpl
        .getQueue().size() == 10);

    for (int x = 0; x < POOL_SIZE; x++) {
      EletronicMsg message = m1ConsumerImpl.getQueue().poll();
      Assert.assertTrue(
          String.format(
              "The producer sent %d messages in ascending order, the consumer should receive in the same order but the message %d arrived in wrong order",
              POOL_SIZE, x), message.equals(new EletronicMsg(
              String.format("message %d", x))));
View Full Code Here

    Instance producer = producerImpl.createInstance(null, null);

    Instance consumer = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 m1ConsumerImpl = (M1ConsumerImpl01) consumer
        .getServiceObject();

    M1ProducerImpl m1ProdImpl = (M1ProducerImpl) producer
        .getServiceObject();

    // TODO message: forcewire in message test
    m1ConsumerImpl.getQueue();

    m1ProdImpl.pushMessage("message 1");

    Assert.assertTrue(
        String.format(
            "After producer sends 1 message, the consumer received %d messages instead of 1",
            m1ConsumerImpl.getQueue().size()), m1ConsumerImpl
            .getQueue().size() == 1);

    EletronicMsg message = m1ConsumerImpl.getQueue().poll();

    Assert.assertTrue(
        String.format("After producer sends 1 message, the consumer received the right number of messages but not the expected message (not the same message sent)"),
        message.equals(new EletronicMsg("message 1")));
View Full Code Here

    Implementation consumerImpl = waitForImplByName(null,
        "MessageConsumeImpl01");

    Instance consumer = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 m1ConsumerImpl = (M1ConsumerImpl01) consumer
        .getServiceObject();

    // TODO message: forcewire in message test
    m1ConsumerImpl.getQueue();

    Instance producer = producerImpl.createInstance(null, null);

    M1ProducerImpl m1ProdImpl = (M1ProducerImpl) producer
        .getServiceObject();

    m1ProdImpl.pushMessage("message 1");

    Assert.assertTrue(
        String.format(
            "In this use case where the consumer was started before the producer, after producer sends 1 message, the consumer received %d messages instead of 1 ",
            m1ConsumerImpl.getQueue().size()), m1ConsumerImpl
            .getQueue().size() == 1);

    EletronicMsg message = m1ConsumerImpl.getQueue().poll();

    Assert.assertTrue(
        String.format("In this use case where the consumer was started before the producer, after producer sends 1 message, the consumer received the right number of messages but not the expected message (not the same message sent)"),
        message.equals(new EletronicMsg("message 1")));
View Full Code Here

    Instance producerApam1 = producer01Impl.createInstance(null, null);

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();

    List<EletronicMsg> messages1 = new ArrayList<EletronicMsg>();
    List<EletronicMsg> messages2 = new ArrayList<EletronicMsg>();
    ;

    for (int i = 1; i <= 20; i++) {
      messages1.add(new EletronicMsg(Integer.toString(i)));
    }

    for (int i = 21; i <= 50; i++) {
      messages2.add(new EletronicMsg(Integer.toString(i)));
    }

    List<EletronicMsg> allMessages = new ArrayList<EletronicMsg>();
    allMessages.addAll(messages1);
    allMessages.addAll(messages2);

    AsynchronousSender sender = new AsynchronousSender(producer1,
        messages1, messages2);

    sender.execute();
    sender.join();

    final String message = "Given one producer and one consumer, the method that produces the message is called by different threads expecting that all messages are received, but some messages got lost therefore not seem by the consumer";

    Assert.assertTrue(message, consumer.getQueue().containsAll(allMessages));

  }
View Full Code Here

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();
    M1ProducerImpl producer2 = (M1ProducerImpl) producerApam2
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();
View Full Code Here

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();
    consumer.getList();
    consumer.getSet();

    producer1.pushMessage("message 1");
    producer1.pushMessage("message 2");
    producer1.pushMessage("message 3");

    // ensure queue is inject
    Assert.assertTrue(String.format(usecase,
        "but the queue was not injected (has null value assigned)"),
        consumer.getQueue() != null);
View Full Code Here

    Instance consumerApam = consumerImpl.createInstance(null, null);

    M1ConsumerImpl01 consumer = (M1ConsumerImpl01) consumerApam
        .getServiceObject();

    M1ProducerImpl producer1 = (M1ProducerImpl) producerApam1
        .getServiceObject();
    M1ProducerImpl producer2 = (M1ProducerImpl) producerApam2
        .getServiceObject();
    M1ProducerImpl producer3 = (M1ProducerImpl) producerApam3
        .getServiceObject();

    // TODO message: force wire in message test
    consumer.getQueue();

    final String message1producer1 = "message 1 produce 1";
    final String message1producer2 = "message 2 produce 2";
    final String message1producer3 = "message 3 produce 3";

    producer1.pushMessage(message1producer1);
    producer2.pushMessage(message1producer2);
    producer3.pushMessage(message1producer3);

    Assert.assertTrue(consumer.getQueue().size() == 3);

    Assert.assertTrue(consumer.getQueue().poll()
        .equals(new EletronicMsg(message1producer1)));
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.pax.test.msg.m1.producer.impl.M1ConsumerImpl02

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.