コード例 #1
0
ファイル: ClientTest.php プロジェクト: stomp-php/stomp-php
 /**
  * Tests Stomp byte messages
  */
 public function testByteMessages()
 {
     if (!$this->stomp->isConnected()) {
         $this->stomp->connect();
     }
     $body = 'test';
     $mapMessage = new Bytes($body);
     $this->stomp->send('/queue/bytes', $mapMessage);
     $simpleStomp = new SimpleStomp($this->stomp);
     $simpleStomp->subscribe('/queue/bytes');
     $msg = $this->stomp->readFrame();
     $this->assertEquals($msg->body, $body);
     $this->stomp->disconnect();
 }
コード例 #2
0
ファイル: ClientTest.php プロジェクト: stomp-php/stomp-php
 /**
  * Tests Stomp byte messages
  */
 public function testByteMessages()
 {
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect();
     }
     $body = 'test';
     $mapMessage = new Bytes($body);
     $this->Stomp->send($this->queue, $mapMessage);
     $this->Stomp->disconnect(true);
     $this->simpleStomp->subscribe($this->queue, 'mysubid');
     $msg = $this->Stomp->readFrame();
     $this->assertEquals($msg->body, $body);
     $this->simpleStomp->ack($msg);
     $this->Stomp->disconnect();
 }
コード例 #3
0
 /**
  * Cleans up the environment after running a test.
  */
 protected function tearDown()
 {
     $this->Stomp->disconnect();
     $this->Stomp = null;
     parent::tearDown();
 }
コード例 #4
0
ファイル: ClientTest.php プロジェクト: stomp-php/stomp-php
 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;
 }