Package net.mindengine.galen.parser

Examples of net.mindengine.galen.parser.FileSyntaxException


    }
   
   
    @Test
    public void givesError_ifThereAreSpecs_withNoObjectSpecified_inSection() throws IOException {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/no-object-in-section.spec");
       
        String fullSpecPath = getClass().getResource("/negative-specs/no-object-in-section.spec").getFile();
       
        assertThat(exception.getMessage(), is("There is no object defined in section\n    in " + fullSpecPath + ":8"));
        assertThat(exception.getFilePath(), endsWith("/no-object-in-section.spec"));
        assertThat(exception.getLine(), is(8));
    }
View Full Code Here


        assertThat(exception.getLine(), is(8));
    }
   
    @Test
    public void givesError_ifThereAre_invalidSpecs() throws IOException {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/invalid-spec.spec");
        String fullSpecPath = getClass().getResource("/negative-specs/invalid-spec.spec").getFile();
       
        assertThat(exception.getMessage(), is("There is no location defined\n    in " + fullSpecPath + ":10"));
        assertThat(exception.getFilePath(), endsWith("/invalid-spec.spec"));
        assertThat(exception.getLine(), is(10));
    }
View Full Code Here

        assertThat(exception.getLine(), is(10));
    }
   
    @Test
    public void givesError_ifThereAre_invalidObjectLocators() throws Exception {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/invalid-object-locator.spec");
       
        String fullSpecPath = getClass().getResource("/negative-specs/invalid-object-locator.spec").getFile();
       
        assertThat(exception.getMessage(), is("Missing locator for object \"bad-object\"\n    in " + fullSpecPath +":7"));
        assertThat(exception.getFilePath(), endsWith("/invalid-object-locator.spec"));
        assertThat(exception.getLine(), is(7));
    }
View Full Code Here

        assertThat(exception.getLine(), is(7));
    }
   
    @Test
    public void givesError_ifThereAre_tooManySpacesInIndentation() throws Exception {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/incorrect-indentation-1.spec");
       
        String fullSpecPath = getClass().getResource("/negative-specs/incorrect-indentation-1.spec").getFile();
       
        assertThat(exception.getMessage(), is("Incorrect indentation. Use from 1 to 8 spaces for indentation\n    in " + fullSpecPath +":9"));
        assertThat(exception.getFilePath(), endsWith("/incorrect-indentation-1.spec"));
        assertThat(exception.getLine(), is(9));
    }
View Full Code Here

        assertThat(exception.getLine(), is(9));
    }
   
    @Test
    public void givesError_ifThereAre_differentIndentation() throws Exception {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/incorrect-indentation-2.spec");
       
        String fullSpecPath = getClass().getResource("/negative-specs/incorrect-indentation-2.spec").getFile();
       
        assertThat(exception.getMessage(), is("Incorrect indentation. You should use same indentation within one spec\n    in " + fullSpecPath + ":10"));
        assertThat(exception.getFilePath(), endsWith("/incorrect-indentation-2.spec"));
        assertThat(exception.getLine(), is(10));
    }
View Full Code Here

        assertThat(exception.getLine(), is(10));
    }
   
    @Test
    public void givesError_ifThereAre_tabsIndentations() throws Exception {
        FileSyntaxException exception = expectExceptionFromReading("/negative-specs/incorrect-indentation-3.spec");
       
        String fullSpecPath = getClass().getResource("/negative-specs/incorrect-indentation-3.spec").getFile();
       
        assertThat(exception.getMessage(), is("Incorrect indentation. Should not use tabs. Use spaces\n    in " + fullSpecPath + ":9"));
        assertThat(exception.getFilePath(), endsWith("/incorrect-indentation-3.spec"));
        assertThat(exception.getLine(), is(9));
    }
View Full Code Here

           
            int lineNumber = -1;
            if (e.getLine() != null) {
                lineNumber = e.getLine().getNumber();
            }
            throw new FileSyntaxException(e, filePath, lineNumber);
        }
    }
View Full Code Here

                line = bufferedReader.readLine();
                lineNumber++;
            }
        }
        catch (Exception exception) {
            throw new FileSyntaxException(exception, fileLocation, lineNumber);
        }

        return lineProcessor.buildPageSpec();
    }
View Full Code Here

   
   
   
   
    @Test(dataProvider="provideBadSamples") public void shouldGiveError_withLineNumberInformation_whenParsingIncorrectSuite(String filePath, int expectedLine, String expectedMessage) throws IOException {
        FileSyntaxException exception = null;
        try {
            new GalenSuiteReader().read(new File(getClass().getResource(filePath).getFile()));
        }
        catch (FileSyntaxException e) {
            exception = e;
            System.out.println("***************");
            e.printStackTrace();
        }
       
       
        String fullPath = getClass().getResource(filePath).getFile();
        assertThat("Exception should be thrown", exception, notNullValue());
        assertThat("Message should be", exception.getMessage(), is(expectedMessage + "\n    in " + fullPath + ":" + expectedLine));
        assertThat("Line should be", exception.getLine(), is(expectedLine));
       
    }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.parser.FileSyntaxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.