use of com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler in project Payara by payara.
the class AbstractSubstitutionAlgo method testLargeXMLFileSubstitution.
/**
* Test substitution for large XML file.
*/
// @Test
// TODO: Test case failing on hudson, Test case execution create temporary file
// to perform substitution.
public void testLargeXMLFileSubstitution() {
String fileName = _testFileName.replace(".txt", ".xml");
createXMLFile(fileName);
Substitutable resolver = null;
try {
resolver = new LargeFileSubstitutionHandler(_testFile);
_algorithm.substitute(resolver);
resolver.finish();
} catch (Exception e) {
Assert.fail("Test case failed : " + e.getMessage());
}
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName))));
} catch (FileNotFoundException e) {
Assert.fail("Test case failed : " + e.getMessage());
}
String afterSubstitutionLine = null;
try {
int i = 0;
while ((afterSubstitutionLine = reader.readLine()) != null) {
switch(i++) {
case 1:
Assert.assertEquals(afterSubstitutionLine, "<port name=\"http\" value=\"8080\"></port>");
break;
case 2:
Assert.assertEquals(afterSubstitutionLine, "<port name=\"https\" value=\"8443\"></port>");
break;
default:
break;
}
}
reader.close();
} catch (IOException e) {
Assert.fail("Not able to read test file");
} finally {
_testFile.delete();
}
}
use of com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler in project Payara by payara.
the class AbstractSubstitutionAlgo method testLargeTextFileSubstitution.
/**
* Test substitution for large text file.
*/
// @Test
// TODO: Test case failing on hudson, Test case execution create temporary file
// to perform substitution.
public void testLargeTextFileSubstitution() {
createTextFile();
Substitutable resolver = null;
try {
resolver = new LargeFileSubstitutionHandler(_testFile);
_algorithm.substitute(resolver);
resolver.finish();
} catch (Exception e) {
Assert.fail("Test case failed : " + e.getMessage());
}
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(_testFileName))));
} catch (FileNotFoundException e) {
Assert.fail("Not able to locate test file : " + _testFileName, e);
}
String afterSubstitutionLine = null;
try {
int i = 0;
while ((afterSubstitutionLine = reader.readLine()) != null) {
switch(i++) {
case 0:
Assert.assertEquals(afterSubstitutionLine, "First replacedLine in testFile repeat First replacedLine in testFile");
break;
case 1:
Assert.assertEquals(afterSubstitutionLine, "Second replacedLine in testFile");
break;
default:
break;
}
}
reader.close();
} catch (IOException e) {
Assert.fail("Not able to read test file");
} finally {
_testFile.delete();
}
}
Aggregations