示例#1
0
 /**
  * Testing UUID
  *
  * @return void
  */
 public function testCreateUuid()
 {
     $uuid1 = Helper::createUuid();
     $this->assertTRUE(mb_strlen($uuid1, 'ISO-8859-1') == 36, 'The generated UUID is not the correct length ');
     $this->assertTRUE(count(str_split($uuid1, 1)) == 36, 'The generated UUID is not the correct length');
     $uuid = Helper::uuidToBin($uuid1);
     $this->assertTRUE(mb_strlen($uuid, 'ISO-8859-1') == 16, 'The conversion to bin of the UUID is not the correct length (16 bytes)');
     $this->assertTRUE(count(str_split($uuid, 1)) == 16, 'The conversion to bin of the UUID is not the correct length (16 bytes)');
     //test that the bin format is correct for rexPro
     $this->assertEquals(bin2hex($uuid), str_replace('-', '', trim($uuid1)), 'The conversion to bin of the UUID is incorrect');
     $uuid = Helper::binToUuid($uuid);
     $this->assertTRUE(mb_strlen($uuid, 'ISO-8859-1') == 36, 'The conversion of bin UUID to UUID is not the correct length');
     $this->assertTRUE(count(str_split($uuid, 1)) == 36, 'The conversion of bin UUID to UUID is not the correct length');
     $this->assertEquals($uuid, $uuid1, 'UUID before and after convertion do not match');
 }
示例#2
0
 /**
  * Retrieve the current session UUID
  *
  * @return string current UUID
  */
 public function getSession()
 {
     if (!isset($this->_sessionUuid)) {
         $this->_sessionUuid = Helper::createUuid();
     }
     return $this->_sessionUuid;
 }
示例#3
0
 /**
  * Connects to socket and starts a session on RexPro
  * 
  * @param string $host        host and port seperated by ":"
  * @param string $graph       graph to load into session. defaults to tinkergraph
  * @param string $username    username for authentification
  * @param string $password    password to use for authentification
  * @param string $graphObject Graph object name. defaults to 'g'
  * 
  * @return bool TRUE on success FALSE on error
  */
 public function open($host = 'localhost:8184', $graph = 'tinkergraph', $username = NULL, $password = NULL, $graphObject = 'g')
 {
     if ($this->_socket === NULL) {
         $this->error = NULL;
         $this->host = $host;
         $this->graph = $graph;
         $this->graphObject = $graphObject;
         $this->username = $username;
         $this->password = $password;
         if (!$this->connectSocket()) {
             return FALSE;
         }
         //lets make opening session message:
         $msg = new Messages($this->_serializer);
         $msg->buildSessionMessage(Helper::createUuid(), $this->username, $this->password, array('graphName' => $this->graph, 'graphObjName' => $this->graphObject), $this->protocolVersion);
         if (!$this->send($msg)) {
             return FALSE;
         }
         //lets get the response
         $response = $this->getResponse();
         if ($response === FALSE) {
             return FALSE;
         }
         $this->response = $response;
         $this->sessionUuid = $this->response[4][0];
         return TRUE;
     }
 }