<commit_before><?php

use SimpleJsonRpcClient\Client;
use SimpleJsonRpcClient\Request;

/**
 * Tests for HttpPostClient
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright &copy; <NAME> 2013-
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */
class HttpPostClientTest extends \PHPUnit_Framework_TestCase
{

	/**
	 * @var Client\HttpPostClient the JSON-RPC client
	 */
	private $_client;

	/**
	 * Instantiates the JSON-RPC client
	 */
	protected function setUp()
	{
		$server = 'http://'.WEB_SERVER_HOST.':'.WEB_SERVER_PORT;
		$this->_client = new Client\HttpPostClient($server, WEB_SERVER_USER, WEB_SERVER_PASS);
	}

	public function testSendRequest()
	{
		$request = new Request\Request('add', array('x'=>1, 'y'=>2));

		try
		{
			$response = $this->_client->sendRequest($request);
			$this->assertEquals(3, $response->result);
		}
		catch (\Exception $e)
		{
			$this->fail($e->getMessage());
		}
	}

	public function testSendNotification()
	{
		$notification = new Request\Notification('start');

		try
		{
			$this->_client->sendNotification($notification);
		}
		catch (\Exception $e)
		{
			$this->fail($e->getMessage());
		}
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ClientException
	 */
	public function testInvalidServer()
	{
		// Connect to a completely invalid host
		$this->_client = new Client\HttpPostClient('test');
		$this->_client->sendRequest(new Request\Request('test'));
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ResponseErrorException
	 */
	public function testInvalidRequest()
	{
		$this->_client->sendRequest(new Request\Request('nonexisting'));
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ClientException
	 * @expectedExceptionMessage Unauthorized
	 */
	public function testInvalidCredentials()
	{
		$this->_client = new Client\HttpPostClient('http://'.WEB_SERVER_HOST.':'.WEB_SERVER_PORT);
		$this->_client->sendRequest(new Request\Request('add', array('x'=>1, 'y'=>2)));
	}

	public function testBatchRequest()
	{
		// The Zend JSON Server doesn't support batch requests
	}

}
<commit_msg>remove unnecessary try-catch blocks from HttpPostClientTest<commit_after><?php

use SimpleJsonRpcClient\Client;
use SimpleJsonRpcClient\Request;

/**
 * Tests for HttpPostClient
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright &copy; <NAME> 2013-
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */
class HttpPostClientTest extends \PHPUnit_Framework_TestCase
{

	/**
	 * @var Client\HttpPostClient the JSON-RPC client
	 */
	private $_client;

	/**
	 * Instantiates the JSON-RPC client
	 */
	protected function setUp()
	{
		$server = 'http://'.WEB_SERVER_HOST.':'.WEB_SERVER_PORT;
		$this->_client = new Client\HttpPostClient($server, WEB_SERVER_USER, WEB_SERVER_PASS);
	}

	public function testSendRequest()
	{
		$request = new Request\Request('add', array('x'=>1, 'y'=>2));
		$response = $this->_client->sendRequest($request);
		$this->assertEquals(3, $response->result);
	}

	public function testSendNotification()
	{
		$notification = new Request\Notification('start');
		$this->_client->sendNotification($notification);
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ClientException
	 */
	public function testInvalidServer()
	{
		// Connect to a completely invalid host
		$this->_client = new Client\HttpPostClient('test');
		$this->_client->sendRequest(new Request\Request('test'));
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ResponseErrorException
	 */
	public function testInvalidRequest()
	{
		$this->_client->sendRequest(new Request\Request('nonexisting'));
	}

	/**
	 * @expectedException SimpleJsonRpcClient\Exception\ClientException
	 * @expectedExceptionMessage Unauthorized
	 */
	public function testInvalidCredentials()
	{
		$this->_client = new Client\HttpPostClient('http://'.WEB_SERVER_HOST.':'.WEB_SERVER_PORT);
		$this->_client->sendRequest(new Request\Request('add', array('x'=>1, 'y'=>2)));
	}

	public function testBatchRequest()
	{
		// The Zend JSON Server doesn't support batch requests
	}

}

{'fraction_non_alphanumeric': 0.14996342355523043, 'fraction_numerical': 0.0043891733723482075, 'mean_word_length': 4.729050279329609, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1669842', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1246, 'n_words': 241}