Package org.drools.core.reteoo.test.dsl

Examples of org.drools.core.reteoo.test.dsl.NodeTestCase


    private NodeTestDef test;
    private DslStep step;
    private Context current;
   
    public NodeTestCase createTestCase( String name ) {
        testCase = new NodeTestCase( cleanString( name ) );
        return testCase;
    }
View Full Code Here


    private static NodeTestCase compile(final NodeTestDSLParser parser) {
        try {
            compilation_unit_return cur = parser.compilation_unit();
            if ( parser.hasErrors() ) {
                NodeTestCase result = new NodeTestCase();
                result.setErrors( parser.getErrorMessages() );
                return result;
            }
            NodeTestCase testCase = walk( parser.getTokenStream(),
                                          (CommonTree) cur.getTree() );
            return testCase;
        } catch ( RecognitionException e ) {
            NodeTestCase result = new NodeTestCase();
            result.setErrors( Collections.singletonList( e.getMessage() ) );
            return result;
        }
    }
View Full Code Here

                return arg1.endsWith( NodeTestCase.SUFFIX );
                //return arg1.endsWith("NotNodeAssertRetractTest.nodeTestCase");
            }
        } ) ) {
            InputStream is = new FileInputStream( file );
            NodeTestCase tcase = ReteDslTestEngine.compile( is );
            tcase.setFileName(file.getName());
            if ( tcase.hasErrors() ) {
                throw new IllegalArgumentException( "Error parsing and loading testcase: " + file.getAbsolutePath() + "\n" + tcase.getErrors().toString() );
            }
            result.add( tcase );
            is.close();
        }
View Full Code Here

    public List<NodeTestCase> getTestCases() throws Exception {
        String testName = System.getProperty( "nodeTestName" );
        if( testName == null || testName.trim().length() == 0 ) {
            throw new IllegalArgumentException("No test defined. Please set the system property 'nodeTestName' with the appropriate test name.");
        }
        NodeTestCase result = new NodeTestCase();
        File base = new File( this.getClass().getResource( "." ).toURI() );
        for ( File file : base.listFiles( new FilenameFilter() {
            public boolean accept(File arg0,
                                  String arg1) {
                return arg1.endsWith( ".nodeTestCase" );
            }
        } ) ) {
            InputStream is = null;
            try {
                is = new FileInputStream( file );
                NodeTestCase tcase = ReteDslTestEngine.compile( is );
                if ( tcase.hasErrors() ) {
                    throw new IllegalArgumentException( "Error parsing and loading testcase: " + file.getAbsolutePath() + "\n" + tcase.getErrors().toString() );
                }
                for( NodeTestDef test : tcase.getTests() ) {
                    if( test.getName().equals( testName ) ) {
                        result.setFileName(file.getName());
                        result.setName( tcase.getName() );
                        result.setImports( tcase.getImports() );
                        result.setSetup( tcase.getSetup() );
                        result.addTest( test );
                        result.setTearDown( tcase.getTearDown() );
                        return Collections.singletonList( result );
                    }
                }
            } finally {
                is.close();
View Full Code Here

    }

    public static void executeDsl( String fileName, InputStream inputStream) {
        assertNotNull( inputStream );
        try {
            NodeTestCase testCase = ReteDslTestEngine.compile( inputStream );
            ReteDslTestEngine tester = new ReteDslTestEngine();
            NodeTestCaseResult result = tester.run( testCase, null );
            if( result.getTotalTests()-result.getSuccesses() > 0 ) {
                fail("Error executing "+fileName+" : \n    "+ result );
            }
View Full Code Here

    @Test
    public void testDslCommandBuilder() {
        InputStream stream = getClass().getResourceAsStream( "DslTestBuilder.testCase" );
        assertNotNull( stream );
        NodeTestCase test = null;
        try {
            test = ReteDslTestEngine.compile( stream );
        } catch ( Exception e ) {
            e.printStackTrace();
            fail( "Unexpected Exception: " + e.getMessage() );
        }
        assertEquals( "Test Case Name",
                      test.getName() );

        checkSetup( test );

        assertEquals( 0,
                      test.getTearDown().size() );

        List<NodeTestDef> tests = test.getTests();
        assertEquals( 2,
                      tests.size() );

        NodeTestDef test1 = tests.get( 0 );
        assertEquals( "test 1",
View Full Code Here

            System.out.println( command );
        }
    }

    private NodeTestResult executeTest(String str) throws IOException {
        NodeTestCase testCase = ReteDslTestEngine.compile( str );
        if( testCase.hasErrors() ) {
            fail( testCase.getErrors().toString() );
        }

        ReteDslTestEngine tester = new ReteDslTestEngine();
        NodeTestCaseResult testCaseResult = tester.run( testCase, null );
       
View Full Code Here

    private static NodeTestCase compile(final NodeTestDSLParser parser) {
        try {
            compilation_unit_return cur = parser.compilation_unit();
            if ( parser.hasErrors() ) {
                NodeTestCase result = new NodeTestCase();
                result.setErrors( parser.getErrorMessages() );
                return result;
            }
            NodeTestCase testCase = walk( parser.getTokenStream(),
                                          (CommonTree) cur.getTree() );
            return testCase;
        } catch ( RecognitionException e ) {
            NodeTestCase result = new NodeTestCase();
            result.setErrors( Collections.singletonList( e.getMessage() ) );
            return result;
        }
    }
View Full Code Here

    @Test
    public void testDslCommandBuilder() {
        InputStream stream = getClass().getResourceAsStream( "DslTestBuilder.testCase" );
        assertNotNull( stream );
        NodeTestCase test = null;
        try {
            test = ReteDslTestEngine.compile( stream );
        } catch ( Exception e ) {
            e.printStackTrace();
            fail( "Unexpected Exception: " + e.getMessage() );
        }
        assertEquals( "Test Case Name",
                      test.getName() );

        checkSetup( test );

        assertEquals( 0,
                      test.getTearDown().size() );

        List<NodeTestDef> tests = test.getTests();
        assertEquals( 2,
                      tests.size() );

        NodeTestDef test1 = tests.get( 0 );
        assertEquals( "test 1",
View Full Code Here

            System.out.println( command );
        }
    }

    private NodeTestResult executeTest(String str) throws IOException {
        NodeTestCase testCase = ReteDslTestEngine.compile( str );
        if( testCase.hasErrors() ) {
            fail( testCase.getErrors().toString() );
        }

        ReteDslTestEngine tester = new ReteDslTestEngine();
        NodeTestCaseResult testCaseResult = tester.run( testCase, null );
       
View Full Code Here

TOP

Related Classes of org.drools.core.reteoo.test.dsl.NodeTestCase

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.