Package testCases

Source Code of testCases.ModelGen

package testCases;

import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import samples.ModelLexer;
import samples.ModelParser;

public class ModelGen {
  private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
  }

  @AfterClass
  public static void tearDownAfterClass() throws Exception {
  }

  @Before
  public void setUp() throws Exception {
    System.setErr(new PrintStream(errContent));
  }

  @After
  public void tearDown() throws Exception {
    System.setErr(null);
  }

  @Test
  public void compostieModel() throws org.antlr.runtime.RecognitionException,
      IOException {
    CharStream input = new ANTLRFileStream(
        "src/main/java/samples/CompositeModel.java");
    ModelLexer lex = new ModelLexer(input);
    CommonTokenStream tokens = new CommonTokenStream(lex);
    ModelParser p = new ModelParser(tokens);
    p.compilationUnit();
    assertTrue(errContent.toString().isEmpty());
  }

}
TOP

Related Classes of testCases.ModelGen

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.