/**
  * Checks if the resource identifier will be initialized
  * propertly from the data of a passed URL.
  *
  * @return void
  */
 public function testPopulateFromUrl()
 {
     // populate the identifier with the data of the passed URL
     $this->resourceIdentifier->populateFromUrl(ResourceIdentifierTest::TEST_URL);
     // check the data from the resource identifier
     $this->assertSame($this->resourceIdentifier->getScheme(), 'php');
     $this->assertSame($this->resourceIdentifier->getUser(), 'user');
     $this->assertSame($this->resourceIdentifier->getPass(), 'password');
     $this->assertSame($this->resourceIdentifier->getHost(), '127.0.0.1');
     $this->assertSame($this->resourceIdentifier->getPort(), 9080);
     $this->assertSame($this->resourceIdentifier->getPath(), '/example/index.pc/TechDivision/Example/Services/UserProcessor');
     $this->assertSame($this->resourceIdentifier->getQuery(), 'SESSID=sadf8dafs879sdfsad');
     $this->assertSame($this->resourceIdentifier->getFilename(), '/example/index.pc');
     $this->assertSame($this->resourceIdentifier->getContextName(), 'example');
     $this->assertSame($this->resourceIdentifier->getPathInfo(), '/TechDivision/Example/Services/UserProcessor');
 }
Esempio n. 2
0
 /**
  * Makes a remote lookup for the URL containing the information of the requested bean.
  *
  * @param \AppserverIo\Psr\Naming\ResourceIdentifier $resourceIdentifier The resource identifier with the requested bean information
  * @param string                                     $sessionId          The session-ID, necessary for lookup stateful session beans
  *
  * @return object The been proxy instance
  */
 protected function doRemoteLookup(ResourceIdentifier $resourceIdentifier, $sessionId = null)
 {
     // initialize the connection
     $connection = RemoteConnectionFactory::createContextConnection();
     $connection->injectPort($resourceIdentifier->getPort());
     $connection->injectAddress($resourceIdentifier->getHost());
     $connection->injectTransport($resourceIdentifier->getTransport());
     // query if we've a context name defined in the resource identifier
     if ($contextName = $resourceIdentifier->getContextName()) {
         // if yes, use it as application name
         $connection->injectAppName($contextName);
     } else {
         // use the application context from the servlet request
         if ($this->getServletRequest() && $this->getServletRequest()->getContext()) {
             $application = $this->getServletRequest()->getContext();
         } else {
             $application = $this->getApplication();
         }
         // use the application name
         $connection->injectAppName($application->getName());
     }
     // finally try to lookup the bean
     return $this->doLookup($resourceIdentifier, $connection, $sessionId);
 }