Package net.helipilot50.citrusleaf.sqlimport

Source Code of net.helipilot50.citrusleaf.sqlimport.SqlFileTest

package net.helipilot50.citrusleaf.sqlimport;

import java.io.File;
import java.io.IOException;

import junit.framework.Assert;
import net.helipilot50.citrusleaf.sqlimport.importWizards.grammar.NoCaseFileStream;
import net.helipilot50.citrusleaf.sqlimport.importWizards.grammar.ToolSQLLexer;
import net.helipilot50.citrusleaf.sqlimport.importWizards.grammar.ToolSQLParser;
import net.helipilot50.citrusleaf.sqlimport.importWizards.grammar.ToolSQLParser.sql_file_return;

import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenStream;
import org.junit.Before;
import org.junit.Test;

public class SqlFileTest {
  public TokenStream getStream(File file) throws IOException{
    CharStream stream =
        new NoCaseFileStream(file.getAbsolutePath());
    ToolSQLLexer lexer = new ToolSQLLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    return tokenStream;
  }
 
  public int syntaxErrors(ToolSQLParser parser){
    int errors = parser.getNumberOfSyntaxErrors();
    if (errors > 0) Assert.fail();
    return errors;
  }


  @Before
  public void setUp() throws Exception {
  }

  @Test
  public void test() throws IOException, RecognitionException {
    File file = new File("TestData/Oracledb.sql");
    ToolSQLParser parser = new ToolSQLParser(getStream(file));
    parser.connectCitrusleaf("10.1.1.16", 3000);
    sql_file_return result = parser.sql_file();
    syntaxErrors(parser);
  }

}
TOP

Related Classes of net.helipilot50.citrusleaf.sqlimport.SqlFileTest

TOP
Copyright © 2018 www.massapi.com. 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.