Exemplo n.º 1
0
  @Test
  public void validationSucceeds() {
    Frame frame = new Frame(Command.BEGIN);

    FrameDecorator decorator =
        new FrameDecorator() {
          @Override
          public void decorateFrame(Frame frame) {
            frame.transaction("tx-2");
          }
        };

    FramePreprocessor processor = new FrameValidator();
    processor.decorate(frame, decorator);
  }
Exemplo n.º 2
0
 public void commit(String transactionId, FrameDecorator frameDecorator) {
   checkNotNull(transactionId, "transactionId cannot be null");
   Frame frame = new Frame(Command.COMMIT);
   frame.transaction(transactionId);
   preprocessor.decorate(frame, frameDecorator);
   send(frame);
 }
Exemplo n.º 3
0
  @Test(expected = StompInvalidHeaderException.class)
  public void validationFails() {
    Frame frame = new Frame(Command.BEGIN);
    frame.transaction("tx-1");

    FrameDecorator decorator =
        new FrameDecorator() {
          @Override
          public void decorateFrame(Frame frame) {
            frame.transaction("tx-2");
          }
        };

    FramePreprocessor processor = new FrameValidator();
    processor.decorate(frame, decorator);
  }
Exemplo n.º 4
0
 @Override
 public void ack(String messageId, FrameDecorator frameDecorator) {
   checkNotNull(messageId, "messageId cannot be null");
   Frame frame = new Frame(Command.ACK);
   frame.messageId(messageId);
   preprocessor.decorate(frame, frameDecorator);
   send(frame);
 }
Exemplo n.º 5
0
 @Override
 public void unsubscribe(String id, FrameDecorator frameDecorator) {
   checkNotNull(id, "id cannot be null");
   Frame frame = new Frame(Command.UNSUBSCRIBE);
   frame.subscriptionId(id);
   preprocessor.decorate(frame, frameDecorator);
   send(frame);
 }
Exemplo n.º 6
0
 @Override
 public void send(String destination, FrameDecorator frameDecorator) {
   checkNotNull(destination, "destination cannot be null");
   Frame frame = new Frame(Command.SEND);
   frame.destination(destination);
   preprocessor.decorate(frame, frameDecorator);
   send(frame);
 }
Exemplo n.º 7
0
 @Override
 public String subscribe(String id, String destination, FrameDecorator frameDecorator)
     throws StompException {
   checkNotNull(id, "id cannot be null");
   checkNotNull(destination, "destination cannot be null");
   Frame frame = new Frame(Command.SUBSCRIBE);
   frame.destination(destination);
   frame.subscriptionId(id);
   preprocessor.decorate(frame, frameDecorator);
   send(frame);
   return id;
 }
Exemplo n.º 8
0
 @Override
 public String subscribe(String destination, FrameDecorator frameDecorator) {
   checkNotNull(destination, "destination cannot be null");
   Frame frame = new Frame(Command.SUBSCRIBE);
   frame.destination(destination);
   preprocessor.decorate(frame, frameDecorator);
   String subscriptionId = frame.subscriptionId();
   if (subscriptionId == null) {
     subscriptionId = UUID.randomUUID().toString();
   }
   frame.subscriptionId(subscriptionId);
   send(frame);
   return subscriptionId;
 }