Esempio n. 1
0
 /**
  * Tests Stomp->connect(), send(), and subscribe() - out of order. the messages should be received in FIFO order.
  */
 public function testAsyncSub()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->assertTrue($this->Stomp->send('/queue/test', 'test 1'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test 2'));
     $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid'));
     $frame = $this->Stomp->readFrame();
     $this->assertEquals($frame->body, 'test 1', 'test 1 was not received!');
     $frame = $this->Stomp->readFrame();
     $this->assertEquals($frame->body, 'test 2', 'test 2 was not received!');
 }
Esempio n. 2
0
 public function testAbortTransaction()
 {
     $this->assertTrue($this->Stomp->connect());
     $this->assertTrue($this->simpleStomp->begin('my-id'));
     $this->assertTrue($this->Stomp->send('/queue/test', 'test t-id', ['transaction' => 'my-id']));
     $this->assertTrue($this->simpleStomp->abort('my-id'));
     $this->assertTrue($this->simpleStomp->subscribe('/queue/test', 'mysubid'));
     $this->Stomp->getConnection()->setReadTimeout(0, 500000);
     $frame = $this->Stomp->readFrame();
     $this->assertFalse($frame);
 }
Esempio n. 3
0
 /**
  * Tests Stomp->unsubscribe()
  */
 public function testUnsubscribe()
 {
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect();
     }
     $this->simpleStomp->subscribe($this->queue, 'mysubid');
     $this->assertTrue($this->simpleStomp->unsubscribe($this->queue, 'mysubid'));
 }
Esempio n. 4
0
 /**
  * Tests Stomp->unsubscribe()
  */
 public function testUnsubscribe()
 {
     if (!$this->stomp->isConnected()) {
         $this->stomp->connect();
     }
     $simpleStomp = new SimpleStomp($this->stomp);
     $simpleStomp->subscribe('/queue/unsub');
     $this->assertTrue($simpleStomp->unsubscribe('/queue/unsub'));
 }
Esempio n. 5
0
 /**
  * Tests Stomp->connect()
  */
 public function testFailoverConnect()
 {
     $this->assertTrue($this->Stomp->connect());
 }
Esempio n. 6
0
 public function testDisconnectWillCallConnectionDisconnectEvenWhenWriteFails()
 {
     $connection = $this->getMockBuilder(Connection::class)->setConstructorArgs(['tcp://127.0.0.1:'])->setMethods(['disconnect', 'readFrame', 'writeFrame', 'isConnected'])->getMock();
     $connection->expects($this->any())->method('isConnected')->willReturn(true);
     $connection->expects($this->once())->method('readFrame')->will($this->returnValue(new Frame('CONNECTED', ['session' => 'id', 'server' => 'activemq'])));
     $connection->expects($this->once())->method('disconnect');
     $stomp = new Client($connection);
     $stomp->connect();
     $connection->expects($this->once())->method('writeFrame')->will($this->throwException(new StompException('Test: Writing frame failed.')));
     $stomp->disconnect();
     // ensure that instance is not destroyed before mock assertions are done
     // (calling destruct would invoke disconnect outside current test)
     self::$stomp = $stomp;
 }
Esempio n. 7
0
 public function testConnectOnApollo()
 {
     $this->assertTrue($this->client->connect(), 'Expected reachable broker.');
     $this->assertInstanceOf(Apollo::class, $this->client->getProtocol(), 'Expected a Apollo broker.');
 }