Package org.jboss.soa.esb.addressing.eprs

Examples of org.jboss.soa.esb.addressing.eprs.FileEpr


    final String scheme = new URI(sUri).getScheme();

    if ("ftp".equals(scheme))
      return new FTPEpr(sUri);
    if ("file".equals(scheme))
      return new FileEpr(sUri);

    throw new IllegalArgumentException("Not a recognised protocol!");
  }
View Full Code Here


    throw new IllegalArgumentException("Not a recognised protocol!");
  }
 
  private final void pickup (String url) throws Exception
  {
    FileEpr epr = getEpr(url);
    epr.setInputSuffix(".esbMessage");
    epr.setPostDelete(true);
    TwoWayCourier courier = CourierFactory.getPickupCourier(epr);

    Message message = null;
    while (null != (message = courier.pickup(100)))
      System.out.println(message.getHeader().getCall().getMessageID());
View Full Code Here

  public void testMessageAttributes() throws Exception
    {
    String contents = "This is the text that travels in the Message body";

    // toEpr for files must be a directory
    FileEpr toEpr = new FileEpr(_tmpDir.toURI());
    toEpr.setInputSuffix(TEST_SUFFIX);
   
    Message msg = MessageFactory.getInstance().getMessage();
    msg.getBody().add(contents.getBytes());

    Call call = new Call(toEpr);
    String uid = UUID.randomUUID().toString();
    call.setMessageID(new URI(uid));
    msg.getHeader().setCall(call);
   
    CourierUtil.deliverMessage(msg);
   
    String timeSent = (String) msg.getProperties().getProperty(Environment.MESSAGE_ENTRY_TIME);
    String source = (String) msg.getProperties().getProperty(Environment.MESSAGE_SOURCE);
   
    File theFile = new File(_tmpDir,uid+TEST_SUFFIX);
    Assert.assertTrue(theFile.exists());
    _logger.info("Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(toEpr.getURI());
    fromEpr.setInputSuffix(TEST_SUFFIX);
    fromEpr.setPostSuffix(DONE_SUFFIX);
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
    Message retrieved = pickUp.pickup(1000);
    Assert.assertFalse("Null message retrieved",null==retrieved);
   
View Full Code Here

 
  @Test
  public void testFaultMessage () throws Exception
    {
    // toEpr for files must be a directory
    FileEpr toEpr = new FileEpr(_tmpDir.toURI());
    toEpr.setInputSuffix(TEST_SUFFIX);
   
    Message msg = MessageFactory.getInstance().getMessage();
    String errorMessage = "Some failure occurred!";
    URI code = new URI("urn:errorcode");
   
    msg.getFault().setReason(errorMessage);
    msg.getFault().setCode(code);
    msg.getFault().setCause(new IOException());

    Call call = new Call(toEpr);
    String uid = UUID.randomUUID().toString();
    call.setMessageID(new URI(uid));
    msg.getHeader().setCall(call);
   
    CourierUtil.deliverMessage(msg);
   
    File theFile = new File(_tmpDir,uid+TEST_SUFFIX);
    Assert.assertTrue(theFile.exists());
    _logger.info("Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(toEpr.getURI());
    fromEpr.setInputSuffix(TEST_SUFFIX);
    fromEpr.setPostSuffix(DONE_SUFFIX);
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);

    try
    {
View Full Code Here

  public void testStoreRetrieve() throws Exception
    {
    String contents = "This is the text that travels in the Message body";

    // toEpr for files must be a directory
    FileEpr toEpr = new FileEpr(_tmpDir.toURI());
    toEpr.setInputSuffix(TEST_SUFFIX);
   
    Message msg = MessageFactory.getInstance().getMessage();
    msg.getBody().add(contents.getBytes());

    Call call = new Call(toEpr);
    String uid = UUID.randomUUID().toString();
    call.setMessageID(new URI(uid));
    msg.getHeader().setCall(call);
   
    CourierUtil.deliverMessage(msg);
    File theFile = new File(_tmpDir,uid+TEST_SUFFIX);
    Assert.assertTrue(theFile.exists());
    _logger.info("Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(toEpr.getURI());
    fromEpr.setInputSuffix(TEST_SUFFIX);
    fromEpr.setPostSuffix(DONE_SUFFIX);
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
    Message retrieved = pickUp.pickup(1000);
    Assert.assertFalse("Null message retrieved",null==retrieved);
   
View Full Code Here

  public void testStoreAndDelete() throws Exception
    {
    String contents = "This is the text that travels in the Message body";

    // toEpr for files must be a directory
    FileEpr toEpr = new FileEpr(_tmpDir.toURI());
    toEpr.setInputSuffix(TEST_SUFFIX);
   
    Message msg = MessageFactory.getInstance().getMessage();
    msg.getBody().add(contents.getBytes());
    msg.getBody().add("exampleObj", new ExampleObject("hello", 1234));
   
    Call call = new Call(toEpr);
    final String uid = UUID.randomUUID().toString();
    call.setMessageID(new URI(uid));
    msg.getHeader().setCall(call);
   
    CourierUtil.deliverMessage(msg);
    File theFile = new File(_tmpDir,uid+TEST_SUFFIX);
    Assert.assertTrue(theFile.exists());
    _logger.info("Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(toEpr.getURI());
    fromEpr.setInputSuffix(TEST_SUFFIX);
    // setting postdelete to true will delete input Message files, if they were picked up
    fromEpr.setPostDelete(true);
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
    Message retrieved = pickUp.pickup(1000);
    Assert.assertFalse("Null message retrieved",null==retrieved);
   
View Full Code Here

    out.print("This is an invalid message");
    out.close();
    Assert.assertTrue(theFile.exists());
    _logger.info("Invalid Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(_tmpDir.toURI()) ;
    fromEpr.setInputSuffix(TEST_SUFFIX);
    fromEpr.setPostSuffix(DONE_SUFFIX);
    fromEpr.setErrorSuffix(ERROR_SUFFIX);
    // Don't delete - default is to delete files in error
    fromEpr.setErrorDelete(false);
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
    Message retrieved = pickUp.pickup(1000);
    Assert.assertTrue("Null message retrieved",null==retrieved);
   
View Full Code Here

    out.print("This is an invalid message");
    out.close();
    Assert.assertTrue(theFile.exists());
    _logger.info("Invalid Message file "+theFile.toString()+" successfully created");
       
    FileEpr fromEpr = new FileEpr(_tmpDir.toURI());
    fromEpr.setInputSuffix(TEST_SUFFIX);
    fromEpr.setPostSuffix(DONE_SUFFIX);
    fromEpr.setErrorSuffix(ERROR_SUFFIX);
    // Not using setErrorDelete(false) should delete files in error
   
    TwoWayCourier pickUp = CourierFactory.getPickupCourier(fromEpr);
    Message retrieved = pickUp.pickup(1000);
    Assert.assertTrue("Null message retrieved",null==retrieved);
View Full Code Here

        try
        {
          String initialSuffix = ".msg";
         
          //  Send a Message that will be picked up by a listener, and specify replyTo
          FileEpr toEpr = new FileEpr(WORKDIR.toURI().toString());
          toEpr.setInputSuffix(initialSuffix);
          toEpr.setPostDelete(true);
          FileEpr replyToEpr = (FileEpr)DefaultReplyTo.getReplyTo(toEpr);

          String text_1 = "Outgoing";
          Message outgoingMsg = MessageFactory.getInstance().getMessage();
          outgoingMsg.getHeader().getCall().setTo(toEpr);
          outgoingMsg.getHeader().getCall().setReplyTo(replyToEpr);
          outgoingMsg.getBody().add(text_1.getBytes());
          CourierUtil.deliverMessage(outgoingMsg);

          // Mock a service that picks up the original message and replies
          FileEpr serviceEpr = new FileEpr(toEpr.getURI());
          serviceEpr.setInputSuffix(initialSuffix);
          serviceEpr.setPostDelete(true);
          PickUpOnlyCourier listener = CourierFactory.getPickupCourier(serviceEpr);
          Message received = listener.pickup(100);
          String text_2 = new String((byte[]) received.getBody().get());
          assertTrue(text_1.equals(text_2));
          assertTrue(replyToEpr.equals(received.getHeader().getCall().getReplyTo()));
View Full Code Here

  {
    Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);

    try
    {
      FileEpr epr = new FileEpr("file://tmp/bar.txt");
     
      epr.setErrorDelete(true);
     
      msg.getHeader().getCall().setTo(epr);
     
      ByteArrayOutputStream s = new ByteArrayOutputStream();
      ObjectOutputStream o = new ObjectOutputStream(s);
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.addressing.eprs.FileEpr

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.