Ejemplo n.º 1
0
 /**
  * Tests Stomp->unsubscribe()
  */
 public function testUnsubscribe()
 {
     $this->markTestIncomplete("This test doesn't use mocks, it tries to talk to a STOMP server");
     if (!$this->Stomp->isConnected()) {
         $this->Stomp->connect();
     }
     $this->Stomp->subscribe($this->queue);
     $this->assertTrue($this->Stomp->unsubscribe($this->queue));
 }
 /**
  * append messages to a buffer in chunks
  * and make sure we properly determine if there is a message in a buffer
  * and properly read messages
  */
 public function testConnectionReadChunks()
 {
     $connection = new Connection(new Stomp\ConnectionFactory\NullFactory());
     $frame1 = new Stomp\Message\Map(array("title" => "lorem ipsum \n\n test  end of line", "descripiton" => "test1\n\n"));
     $frame2 = new Stomp\Message\Map(array("title" => "lorem ipsum \n\n test  end of line", "descripiton" => "test2\n\n"));
     $this->assertFalse($connection->_bufferContainsMessage(), 'Do not expect any messages in connection');
     $connection->_appendToBuffer($frame1->__toString());
     // brake second message apart so we can insert chunks of it in to buffer
     $frame2_msg = $frame2->__toString();
     $frame2_part1 = substr($frame2_msg, 0, 50);
     $frame2_part2 = substr($frame2_msg, 50);
     // append just a chunk of a second message
     $connection->_appendToBuffer("\n\n");
     $connection->_appendToBuffer($frame2_part1);
     $this->assertTrue($connection->_bufferContainsMessage(), 'Expect a message and a half');
     //remove first message from buffer
     $message = $connection->readFrame();
     $this->assertNotNull($message, "Expected a message");
     $this->assertFalse($connection->_bufferContainsMessage(), "There is only half of message in a buffere");
     // put second chank in to a buffer
     $connection->_appendToBuffer($frame2_part2);
     $this->assertTrue($connection->_bufferContainsMessage(), "We should have got a message in a buffer");
     $message2 = $connection->readFrame();
     $this->assertNotNull($message2, "Expected second frame here");
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider read_frame_provider
  *
  * @param Stomp\Connection $stomp
  * @param array            $expected_frames
  * @param                  $message
  */
 public function testReadFrame(Stomp\Connection $stomp, array $expected_frames, $message)
 {
     foreach ($expected_frames as $frame) {
         $this->assertEquals($frame, $stomp->readFrame(), $message);
     }
 }
Ejemplo n.º 4
0
 /**
  * Tests Stomp->connect()
  */
 public function testFailoverConnect()
 {
     $this->markTestIncomplete("This test doesn't use mocks, it tries to talk to a STOMP server");
     $this->assertTrue($this->Stomp->connect());
 }
 public function flush()
 {
     $this->stomp->send($this->destination, $this->buffer, $this->properties);
     $this->buffer = "";
 }
Ejemplo n.º 6
0
 protected function consume()
 {
     $this->markTestIncomplete("This test doesn't use mocks, it tries to talk to a STOMP server");
     $consumer2 = new Stomp\Connection($this->broker);
     $consumer2->sync = false;
     $consumer2->clientId = "test";
     $consumer2->setReadTimeout(1);
     $consumer2->connect("system", "manager");
     $consumer2->subscribe($this->topic);
     $frame = $consumer2->readFrame();
     $this->assertEquals($frame->body, "test message");
     if ($frame != null) {
         $consumer2->ack($frame);
     }
     $consumer2->disconnect();
 }