testWebServer.php 6.47 KB
<?php 

require_once("../Client/WSClientSOAP.php");
//require_once("../Client/WSClientREST.php");

function runSuiteTests($client)
{
	//Test isAlive function
	$res = $client->isAlive();
	if (!isset($res) || ($res != true))
		echo "[ERROR] - Error during call of isAlive function".PHP_EOL;
	else
		echo "[OK] - isAlive".PHP_EOL;
 
	//Test getTimeTablesList function without userID & password
// 	$res = $client->getTimeTablesList();
// 	if (!isset($res) || !$res->success)
// 		echo "[ERROR] - Error during call of getTimeTablesList function - Test 1".PHP_EOL;
// 	else
// 		echo "[OK] - getTimeTablesList - Test 1 - ".$res->TimeTablesList.PHP_EOL;
		 
	//Test getTimeTablesList function with userID & password
	$res = $client->getTimeTablesList("budnik", "Sacre-Cour");
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getTimeTablesList function - Test 2".PHP_EOL;
	else
		echo "[OK] - getTimeTablesList - Test 2 - ".$res->TimeTablesList.PHP_EOL;
 
	//Test getTimeTable function without userID & password
// 	$res = $client->getTimeTable("sharedtt_0");
// 	if (!isset($res) || !$res->success)
// 		echo "[ERROR] - Error during call of getTimeTable function - Test 1".PHP_EOL;
// 	else
// 		echo "[OK] - getTimeTable - Test 1 - ".$res->ttFileURL.PHP_EOL;
		 
	//Test getTimeTable function with userID & password
	$res = $client->getTimeTable("tt_0", "budnik", "Sacre-Cour");
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getTimeTable function - Test 2".PHP_EOL;
	else
		echo "[OK] - getTimeTable - Test 2 - ".$res->ttFileURL.PHP_EOL;
	 
	//Test getParameterList function for impex user
// 	$res = $client->getParameterList("impex");
// 	if (!isset($res) || !$res->success)
// 		echo "[ERROR] - Error during call of getParameterList function - Test 1".PHP_EOL;
// 	else
// 		echo "[OK] - getParameterList - Test 1 - ".$res->ParameterList->LocalDataBaseParameters.PHP_EOL;
	 
	//Test getParameterList function with userID & password
	$res = $client->getParameterList("budnik", "Sacre-Cour");
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameterList function - Test 2".PHP_EOL;
	else
	{
		echo "[OK] - getParameterList - Test 2 :".PHP_EOL;
		echo "		- UserDefinedParameters : ".$res->ParameterList->UserDefinedParameters.PHP_EOL;
		echo "		- LocalDataBaseParameters : ".$res->ParameterList->LocalDataBaseParameters.PHP_EOL;
	}
	 
	//Test getObsDataTree function
	$res = $client->getObsDataTree();
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getObsDataTree function".PHP_EOL;
	else
		echo "[OK] - getObsDataTree - Test 1 - ".$res->WorkSpace->LocalDataBaseParameters.PHP_EOL;
	
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::ASCII);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 1".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 1 - ".$res->dataFileURLs.PHP_EOL;
		
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 3600, "", "", WSOutputFileFormat::ASCII);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 2".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 2 - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::VOTABLE);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 3".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 3 - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 3600, "", "", WSOutputFileFormat::VOTABLE);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 4".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 4 - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::ASCII, WSOutputTimeFormat::TIMESTAMP);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 5".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 5 - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getParameter function
	$res = $client->getParameter("2008-01-01T00:00:00", "2008-01-02T00:00:00", "imf", 0, "", "", WSOutputFileFormat::VOTABLE, WSOutputTimeFormat::ISO, 1);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getParameter function - Test 6".PHP_EOL;
	else
		echo "[OK] - getParameter - Test 6 - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getDataset function
	$res = $client->getDataset("2008-01-01T00:00:00", "2008-01-02T00:00:00", "ground:based:asy", 0, "", "", WSOutputFileFormat::ASCII);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getDataset function".PHP_EOL;
	else
		echo "[OK] - getDataset - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getOrbites function
	$res = $client->getOrbites("2008-01-01T00:00:00", "2008-01-02T00:00:00", WSSpacecraft::VEX, WSCoordinatesSytem::VSO, WSOrbitUnit::RV,
			0, "", "", WSOutputFileFormat::ASCII);
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getOrbites function".PHP_EOL;
	else
		echo "[OK] - getOrbites - ".$res->dataFileURLs.PHP_EOL;
	
	//Test getPlot function
	$res = $client->getPlot("2008-01-01T00:00:00", "2009-01-01T00:00:00", "ACE");
	if (!isset($res) || !$res->success)
		echo "[ERROR] - Error during call of getPlot function".PHP_EOL;
	else
	{
		$plotDirectoryURL = $res->plotDirectoryURL;
		echo "[OK] - getPlot".PHP_EOL;
		while (true)
		{
			echo "    -> getResultPlot".PHP_EOL;
			$res = $client->getResultPlot($plotDirectoryURL);
			if (!isset($res))
			{
				echo "[ERROR] - Error during call of getResultPlot function".PHP_EOL;
				break;
			}
			else if ($res->success)
			{
				echo "    -> plotFileURL : ".$res->plotFileURL.PHP_EOL;
				break;
			}
			echo "    -> Result not ready => Wait 5s".PHP_EOL;
			sleep(5);
		}
	}
}

$clientSOAP = new WSClientSOAP("http://apus.irap.omp.eu/NEWAMDA/public/wsdl/Methods_AMDA.wsdl");

echo "==> Suite tests for SOAP client".PHP_EOL;
runSuiteTests($clientSOAP);

//REST client is obsolete
/*$clientREST = new WSClientREST("http://localhost/NEWAMDA-BENJAMIN/php/rest/");

echo "==> Suite tests for REST client".PHP_EOL;
runSuiteTests($clientREST);*/


?>