Class TemplateEngineTests


  • public final class TemplateEngineTests
    extends Object
    TemplateEngine tests.
    • Constructor Detail

      • TemplateEngineTests

        public TemplateEngineTests()
        Default constructor.
    • Method Detail

      • defaultConstructor

        @Test
        public void defaultConstructor()
        Test default constructor.
      • setFile

        @Test
        public void setFile()
        Test set template file.
      • setFileMaxLength

        @Test
        public void setFileMaxLength()
        Test set template file with max length.
      • setFileEmpty

        @Test
        public void setFileEmpty()
        Test set template file.
      • setFileToLong

        @Test
        public void setFileToLong()
        Test set template file with to long filename.
      • setFileWrongname

        @Test
        public void setFileWrongname()
        Test set template file with wrong filename.
      • setFileToLarge

        @Test
        public void setFileToLarge()
        Test set template file with to large file.
      • subst

        @Test
        public void subst()
                   throws IOException
        Test read template file.
        Throws:
        IOException - IO exception
      • substEmpty

        @Test
        public void substEmpty()
        Test read empty template file.
      • substToLong

        @Test
        public void substToLong()
        Test subst with to long varname.
      • substWrongName

        @Test
        public void substWrongName()
        Test subst with wrong varname.
      • substMaxLength

        @Test
        public void substMaxLength()
                            throws IOException
        Test subst with max varname length varname.
        Throws:
        IOException - IO exception
      • getUndefined

        @Test
        public void getUndefined()
                          throws IOException
        Get undefined variables from template.
        Throws:
        IOException - IO exception
      • getUndefinedFromEmptyFile

        @Test
        public void getUndefinedFromEmptyFile()
                                       throws IOException
        Get undefined variables from empty template.
        Throws:
        IOException - IO exception
      • getUndefinedEmpty

        @Test
        public void getUndefinedEmpty()
        Get empty undefined variables.
      • getUndefinedToLong

        @Test
        public void getUndefinedToLong()
        Get undefined variables with to long varname.
      • getUndefinedWrongName

        @Test
        public void getUndefinedWrongName()
        Get undefined variables with wrong varname.
      • getUndefinedMaxLength

        @Test
        public void getUndefinedMaxLength()
                                   throws IOException
        Get undefined variables with maximum varname length.
        Throws:
        IOException - IO exception
      • setVarEmpty

        @Test
        public void setVarEmpty()
                         throws IOException
        Test set variable as empty.
        Throws:
        IOException - IO exception
      • setVar

        @Test
        public void setVar()
                    throws IOException
        Test set variable with value.
        Throws:
        IOException - IO exception
      • setEmptyVar

        @Test
        public void setEmptyVar()
        Test set empty variable with value.
      • setVarMaxLong

        @Test
        public void setVarMaxLong()
        Test set variable with maximum long name.
      • setVarToLong

        @Test
        public void setVarToLong()
        Test set variable with to long name.
      • setVarWrongName

        @Test
        public void setVarWrongName()
        Test set variable with wrong name.
      • setVarToLarge

        @Test
        public void setVarToLarge()
        Test set variable with to large value.
      • setVarMaxLarge

        @Test
        public void setVarMaxLarge()
                            throws IOException
        Test set variable with maximum value size.
        Throws:
        IOException - IO exception
      • getRemoved

        @Test
        public void getRemoved()
                        throws IOException
        Test get removed variable parsing.
        Throws:
        IOException - IO exception
      • getKeep

        @Test
        public void getKeep()
                     throws IOException
        Test get keep variable parsing.
        Throws:
        IOException - IO exception
      • getComment

        @Test
        public void getComment()
                        throws IOException
        Test get replace with comment variable parsing.
        Throws:
        IOException - IO exception
      • setBlockFailure

        @Test
        public void setBlockFailure()
        Test set non existing block.
      • setBlockEmpty

        @Test
        public void setBlockEmpty()
        Test set empty block name.
      • setBlock

        @Test
        public void setBlock()
                      throws IOException
        Test set existing block.
        Throws:
        IOException - IO exception
      • setBlockParentToLong

        @Test
        public void setBlockParentToLong()
        Test set block with to long parent name.
      • setBlockVarnameToLong

        @Test
        public void setBlockVarnameToLong()
        Test set block with to long varname.
      • setBlockNameToLong

        @Test
        public void setBlockNameToLong()
        Test set block with to long name.
      • setBlockParentWrong

        @Test
        public void setBlockParentWrong()
        Test set block with to wrong parent name.
      • setBlockVarnameWrong

        @Test
        public void setBlockVarnameWrong()
        Test set block with wrong varname.
      • setBlockNameWrong

        @Test
        public void setBlockNameWrong()
        Test set block with wrong name.
      • setBlockParentMaxLength

        @Test
        public void setBlockParentMaxLength()
                                     throws IOException
        Test set block with to max length parent name.
        Throws:
        IOException - IO exception
      • setBlockParentMaxLength2

        @Test
        public void setBlockParentMaxLength2()
                                      throws IOException
        Test set block with to max length parent name.
        Throws:
        IOException - IO exception
      • setBlockVarnameMaxLength

        @Test
        public void setBlockVarnameMaxLength()
                                      throws IOException
        Test set block with max length varname.
        Throws:
        IOException - IO exception
      • setBlockNameMaxLength

        @Test
        public void setBlockNameMaxLength()
                                   throws IOException
        Test set block with max length name.
        Throws:
        IOException - IO exception
      • parseNonAppend

        @Test
        public void parseNonAppend()
                            throws IOException
        Test parsing without append.
        Throws:
        IOException - IO exception
      • parseEmpty

        @Test
        public void parseEmpty()
        Test empty parsing.
      • parseAppend

        @Test
        public void parseAppend()
                         throws IOException
        Test parsing with append.
        Throws:
        IOException - IO exception
      • parseProblem

        @Test
        public void parseProblem()
                          throws IOException
        Test a specific parsing problem. Problem description for original phplib template engine: When using the same template-variable within a page and a block thats contained by the page, then the behavior during parsing the page might be different. Thats because inside the subst() method a loop runs over the list of known template variables. When a variable has been replaced before a block (that contains the same variable) will be replaced, then the variable will not be replaced within the block. When the block will be parsed first, then the variable will also be replaced within the block.
        Throws:
        IOException - IO exception
      • parseTargetToLong

        @Test
        public void parseTargetToLong()
        Test parsing with to long target name.
      • parseVarnameToLong

        @Test
        public void parseVarnameToLong()
        Test parsing with to long varname.
      • parseTargetWrong

        @Test
        public void parseTargetWrong()
        Test parsing with wrong target name.
      • parseVarnameWrong

        @Test
        public void parseVarnameWrong()
        Test parsing with wrong varname.
      • parseTargetMaxLength

        @Test
        public void parseTargetMaxLength()
                                  throws IOException
        Test parsing with maximum target name length.
        Throws:
        IOException - IO exception
      • parseVarnameMaxLength

        @Test
        public void parseVarnameMaxLength()
                                   throws IOException
        Test parsing with maximum varname length.
        Throws:
        IOException - IO exception
      • getVarsEmpty

        @Test
        public void getVarsEmpty()
        Test empty variable list.
      • getVars

        @Test
        public void getVars()
        Test variable list.
      • getVarMaxLong

        @Test
        public void getVarMaxLong()
        Test get variable with maximum long name.
      • getVarToLong

        @Test
        public void getVarToLong()
        Test get variable with to long name.
      • getVarWrongName

        @Test
        public void getVarWrongName()
        Test get variable with wrong name.
      • substEmptyFile

        @Test
        public void substEmptyFile()
                            throws IOException
        Test subst empty file.
        Throws:
        IOException - IO exception
      • setBlockEmptyFile

        @Test
        public void setBlockEmptyFile()
                               throws IOException
        Test set existing block.
        Throws:
        IOException - IO exception
      • setUnknowns

        @Test
        public void setUnknowns()
                         throws IOException
        Test get keep variable parsing.
        Throws:
        IOException - IO exception
      • readFromClasspath

        @Test
        public void readFromClasspath()
                               throws IOException
        Test read template file from classpath.
        Throws:
        IOException - IO exception
      • readNonExisting

        @Test
        public void readNonExisting()
                             throws IOException
        Test read template file from classpath.
        Throws:
        IOException - IO exception
      • unsetVar

        @Test
        public void unsetVar()
                      throws IOException
        Test unset variable.
        Throws:
        IOException - IO exception
      • unsetVarEmpty

        @Test
        public void unsetVarEmpty()
        Test unset empty variable.
      • unsetVarMaxLength

        @Test
        public void unsetVarMaxLength()
                               throws IOException
        Test unset variable with maximum name length.
        Throws:
        IOException - IO exception
      • unsetVarToLong

        @Test
        public void unsetVarToLong()
        Test unset variable with to long name.
      • unsetVarWrongName

        @Test
        public void unsetVarWrongName()
        Test unset variable with wrong name.
      • testToString

        @Test
        public void testToString()
        Test toString.
      • newInstanceFile1

        @Test
        public void newInstanceFile1()
                              throws IOException
        Test newInstance from file.
        Throws:
        IOException - IO exception
      • newInstanceFileNonExisting

        @Test
        public void newInstanceFileNonExisting()
        Test newInstance from non existing file.
      • newInstanceFileFromDirectory

        @Test
        public void newInstanceFileFromDirectory()
        Test newInstance from directory.
      • newInstanceFileNull

        @Test
        public void newInstanceFileNull()
        Test newInstance from File with null.
      • newInstanceFileToLarge

        @Test
        public void newInstanceFileToLarge()
        Test newInstance with a to large file.
      • newInstanceFileMaxSize

        @Test
        public void newInstanceFileMaxSize()
                                    throws IOException
        Test newInstance with maximum size file.
        Throws:
        IOException - IO exception
      • newInstanceInputStreamNull

        @Test
        public void newInstanceInputStreamNull()
        Test newInstance from InputStream with null.
      • newInstanceInputStream

        @Test
        public void newInstanceInputStream()
                                    throws IOException
        Test newInstance from InputStream.
        Throws:
        IOException - IO exception
      • newInstanceInputStreamEmpty

        @Test
        public void newInstanceInputStreamEmpty()
        Test newInstance from empty InputStream.
      • newInstanceStringNull

        @Test
        public void newInstanceStringNull()
        Test newInstance from String with null.
      • newInstanceStringEmpty

        @Test
        public void newInstanceStringEmpty()
        Test newInstance from String with empty string.
      • newInstanceString

        @Test
        public void newInstanceString()
        Test newInstance from String.
      • readStringFromFile

        private static String readStringFromFile​(File file)
                                          throws IOException
        Read String from File.
        Parameters:
        file - File to read from
        Returns:
        File content as String
        Throws:
        IOException - IO exception
      • newInstanceStringToLarge

        @Test
        public void newInstanceStringToLarge()
        Test newInstance from String with to large string.
      • newInstanceStringMaxSize

        @Test
        public void newInstanceStringMaxSize()
                                      throws IOException
        Test newInstance from String with max size string.
        Throws:
        IOException - IO exception
      • newInstanceCopy

        @Test
        public void newInstanceCopy()
                             throws IOException
        Test newInstance from TemplateEngine copy.
        Throws:
        IOException - IO exception
      • copyConstructor

        @Test
        public void copyConstructor()
        Test copy constructor.
      • getVarEmpty

        @Test
        public void getVarEmpty()
        Test get empty variable with value.
      • finishEmpty

        @Test
        public void finishEmpty()
        Test empty finish.
      • finishToLarge

        @Test
        public void finishToLarge()
        Test finish with to large template.
      • finishMaxSize

        @Test
        public void finishMaxSize()
                           throws IOException
        Test finish with maximum template size.
        Throws:
        IOException - IO exception
      • doubleOpenCurlyBrace

        @Test
        public void doubleOpenCurlyBrace()
                                  throws IOException
        Test two { after each other within template.
        Throws:
        IOException - IO exception
      • testHashCode

        @Test
        public void testHashCode()
        Test hash code.
      • testEquals

        @Test
        public void testEquals()
        Test equals.
      • undefined

        @Test
        public void undefined()
        Test HandleUndefined.