Search in sources :

Example 1 with LargeFileSubstitutionHandler

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();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) LargeFileSubstitutionHandler(com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler) Substitutable(com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream)

Example 2 with LargeFileSubstitutionHandler

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();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) LargeFileSubstitutionHandler(com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler) Substitutable(com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream)

Aggregations

Substitutable (com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable)2 LargeFileSubstitutionHandler (com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2