Esempio n. 1
0
 public function testSetDefaultEndpointWithObject()
 {
     $endpoint1 = $this->client->createEndpoint('s1');
     $endpoint2 = $this->client->createEndpoint('s2');
     $this->client->setEndpoints(array($endpoint1, $endpoint2));
     $this->assertEquals($endpoint1, $this->client->getEndpoint());
     $this->client->setDefaultEndpoint($endpoint2);
     $this->assertEquals($endpoint2, $this->client->getEndpoint());
 }
Esempio n. 2
0
 public function testConstructorAndGetters()
 {
     $client = new Client();
     $endpoint = $client->getEndpoint();
     $httpException = new HttpException('test exception');
     $event = new EndpointFailure($endpoint, $httpException);
     $this->assertEquals($endpoint, $event->getEndpoint());
     $this->assertEquals($httpException, $event->getException());
 }
 public function testConstructorAndGetters()
 {
     $client = new Client();
     $request = new Request();
     $request->addParam('testparam', 'test value');
     $endpoint = $client->getEndpoint();
     $event = new PreExecuteRequest($request, $endpoint);
     $this->assertEquals($request, $event->getRequest());
     $this->assertEquals($endpoint, $event->getEndpoint());
     return $event;
 }
 public function testConstructorAndGetters()
 {
     $client = new Client();
     $request = new Request();
     $request->addParam('testparam', 'test value');
     $endpoint = $client->getEndpoint();
     $response = new Response('', array('HTTP 1.0 200 OK'));
     $event = new PostExecuteRequest($request, $endpoint, $response);
     $this->assertEquals($request, $event->getRequest());
     $this->assertEquals($endpoint, $event->getEndpoint());
     $this->assertEquals($response, $event->getResponse());
 }
 public function testBlockedQueryTypeNotLoadbalanced()
 {
     $originalHost = $this->client->getEndpoint()->getHost();
     $endpoints = array('server1' => 100, 'server2' => 1);
     $this->plugin->setEndpoints($endpoints);
     $request = new Request();
     $query = new UpdateQuery();
     // this is a blocked querytype that should not be loadbalanced
     $event = new PreCreateRequestEvent($query);
     $this->plugin->preCreateRequest($event);
     $event = new PreExecuteRequestEvent($request, new Endpoint());
     $this->plugin->preExecuteRequest($event);
     $this->assertEquals($originalHost, $this->client->getEndpoint()->getHost());
     $this->assertEquals(null, $this->plugin->getLastEndpoint());
 }