public Document runAtServer ( String containerUrl , String testClassName , String testDisplayName ) { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder ; try { String url = containerUrl + String . format ( "?%s=%s&%s=%s" , TEST_CLASS_NAME_PARAM , testClassName , TEST_NAME_PARAM , URLEncoder . encode ( testDisplayName , ENCODING ) ) ; builder = factory . newDocumentBuilder ( ) ; Document document = builder . parse ( url ) ; return document ; } catch ( FileNotFoundException fe ) { throw new RuntimeException ( "Could not find the test WAR at the server. Make sure jicunit.url points to the correct context root." , fe ) ; } catch ( ConnectException ce ) { throw new RuntimeException ( "Could not connect to the server. Make sure jicunit.url points to the correct host and port." , ce ) ; } catch ( ParserConfigurationException | SAXException | IOException e ) { throw new RuntimeException ( "Could not run the test. Check the jicunit.url so it is correct." , e ) ; } }
Execute the test at the server