JML

org.multijava.mjc
Class TestParsingController

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.multijava.util.testing.TestCase
              extended byorg.multijava.mjc.TestParsingController
All Implemented Interfaces:
junit.framework.Test

public class TestParsingController
extends TestCase

Unit tests for ParsingController


Field Summary
private  JavadocLexer docLexer
           
private static String EXPECTED_SAMPLE_DOC
           
private static String EXPECTED_SAMPLE_DOC2
           
private static String EXPECTED_SAMPLE_DOC3
           
private static String IGNORE_SAMPLE_DOC_CLASS
           
private  MjcLexer mjLexer
           
private  ParsingController parsingController
           
private static String SAMPLE_CLASS
           
private static String SAMPLE_DOC
           
private static String SAMPLE_DOC2
           
private static String SAMPLE_DOC3
           
private static String SAMPLE_DOC_CLASS
           
private static TroubleReporter SIMPLE_REPORTER
           
 
Fields inherited from class org.multijava.util.testing.TestCase
NEWLINE
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
TestParsingController(String name)
           
 
Method Summary
private  antlr.Token discardAllMJTokens()
          Discards all MultiJava tokens from the input and returns the end-of-file token.
private  void establishLexers(String sourceCode)
          Establish lexers and the controller for the given source code, without adding streams to the controller.
private  void establishTest(String sourceCode)
          Establish lexers and controller for the given source code.
private  void establishTest(String sourceCode, boolean selectInitial)
          Establish lexers and controller for the given source code.
 void test_addInputStream_method1()
          Should get an exception if the first argument is null.
 void test_addInputStream_method2()
          Should get an exception if the second argument is null.
 void test_addInputStream_method3()
          Should get an exception if we try to bind two input streams to the same key.
 void test_discardAllTokensFor_method1()
          Should get an exception when requesting discarding for an undefined key.
 void test_discardAllTokensFor_method2()
          Should get an exception when requesting discarding for a key for which a token stream has already been exposed
 void test_discardAllTokensFor_method3()
          Should find no javadoc comments when discarding them, even though they are present in the source.
 void test_FilteredTokenStream_class1()
          Should successfully lex the MultiJava tokens in the input stream.
 void test_FilteredTokenStream_class2()
          Should successfully lex the javadoc tokens in the input stream, but no javadoc tokens are in the input stream.
 void test_FilteredTokenStream_class3()
          Should successfully lex just the multijava tokens in the input stream.
 void test_FilteredTokenStream_class4()
          Should successfully lex just the javadoc tokens in the input stream.
 void test_FilteredTokenStream_class5()
          Should successfully lex both the multijava and javadoc tokens in the input stream.
 void test_FilteredTokenStream_class6()
          Should successfully lex both the multijava and javadoc tokens in the input stream.
 void test_FilteredTokenStream_class7()
          Should successfully lex both the multijava and javadoc tokens in the input stream.
 void test_FilteredTokenStream_class8()
          Should successfully lex just the multijava tokens in the input stream despite the javadoc comment ending in '**' + '/'.
 void test_getColumn_method1()
          Should successfully give the column numbers of each token.
 void test_getColumn_method2()
          Should successfully give the column numbers of each token.
 void test_getLine_method1()
          Should successfully give the line numbers of each token.
 void test_getLine_method2()
          Should successfully give the line numbers of each token.
 void test_initialOutputStream_method1()
          Should get an exception if we try to get the initial output stream without setting an initial lexer.
 void test_selectInitial_method1()
          Should get an exception if we try to select based on a key that is not bound.
 void test_selectInitial_method2()
          Should get an exception if we try to select more than once.
 void test_streamForBefore_method1()
          Should get an exception when requesting a stream for an undefined key.
 void test_streamForBefore_method2()
          Should be able to request a stream twice for the same key and index, but second stream should yield end-of-file token.
 
Methods inherited from class org.multijava.util.testing.TestCase
assertDiff, assertEquals
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mjLexer

private MjcLexer mjLexer

docLexer

private JavadocLexer docLexer

parsingController

private ParsingController parsingController

SAMPLE_CLASS

private static final String SAMPLE_CLASS

SAMPLE_DOC

private static final String SAMPLE_DOC

SAMPLE_DOC2

private static final String SAMPLE_DOC2

EXPECTED_SAMPLE_DOC2

private static final String EXPECTED_SAMPLE_DOC2

SAMPLE_DOC3

private static final String SAMPLE_DOC3

EXPECTED_SAMPLE_DOC3

private static final String EXPECTED_SAMPLE_DOC3

EXPECTED_SAMPLE_DOC

private static final String EXPECTED_SAMPLE_DOC

SAMPLE_DOC_CLASS

private static final String SAMPLE_DOC_CLASS

IGNORE_SAMPLE_DOC_CLASS

private static final String IGNORE_SAMPLE_DOC_CLASS

SIMPLE_REPORTER

private static final TroubleReporter SIMPLE_REPORTER
Constructor Detail

TestParsingController

public TestParsingController(String name)
Method Detail

test_addInputStream_method1

public void test_addInputStream_method1()
Should get an exception if the first argument is null.


test_addInputStream_method2

public void test_addInputStream_method2()
Should get an exception if the second argument is null.


test_addInputStream_method3

public void test_addInputStream_method3()
Should get an exception if we try to bind two input streams to the same key.


test_selectInitial_method1

public void test_selectInitial_method1()
Should get an exception if we try to select based on a key that is not bound.


test_selectInitial_method2

public void test_selectInitial_method2()
Should get an exception if we try to select more than once.


test_initialOutputStream_method1

public void test_initialOutputStream_method1()
Should get an exception if we try to get the initial output stream without setting an initial lexer.


test_discardAllTokensFor_method1

public void test_discardAllTokensFor_method1()
Should get an exception when requesting discarding for an undefined key.


test_discardAllTokensFor_method2

public void test_discardAllTokensFor_method2()
Should get an exception when requesting discarding for a key for which a token stream has already been exposed


test_discardAllTokensFor_method3

public void test_discardAllTokensFor_method3()
                                      throws ParsingController.KeyException,
                                             antlr.TokenStreamException
Should find no javadoc comments when discarding them, even though they are present in the source.

Throws:
ParsingController.KeyException
antlr.TokenStreamException

test_streamForBefore_method1

public void test_streamForBefore_method1()
Should get an exception when requesting a stream for an undefined key.


test_streamForBefore_method2

public void test_streamForBefore_method2()
                                  throws ParsingController.KeyException,
                                         antlr.TokenStreamException
Should be able to request a stream twice for the same key and index, but second stream should yield end-of-file token.

Throws:
ParsingController.KeyException
antlr.TokenStreamException

test_FilteredTokenStream_class1

public void test_FilteredTokenStream_class1()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex the MultiJava tokens in the input stream. No javadoc tokens are in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class2

public void test_FilteredTokenStream_class2()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex the javadoc tokens in the input stream, but no javadoc tokens are in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class3

public void test_FilteredTokenStream_class3()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex just the multijava tokens in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class4

public void test_FilteredTokenStream_class4()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex just the javadoc tokens in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class5

public void test_FilteredTokenStream_class5()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex both the multijava and javadoc tokens in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class6

public void test_FilteredTokenStream_class6()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex both the multijava and javadoc tokens in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class7

public void test_FilteredTokenStream_class7()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex both the multijava and javadoc tokens in the input stream.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_FilteredTokenStream_class8

public void test_FilteredTokenStream_class8()
                                     throws ParsingController.ConfigurationException,
                                            antlr.TokenStreamException
Should successfully lex just the multijava tokens in the input stream despite the javadoc comment ending in '**' + '/'.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_getLine_method1

public void test_getLine_method1()
                          throws ParsingController.ConfigurationException,
                                 antlr.TokenStreamException
Should successfully give the line numbers of each token.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_getLine_method2

public void test_getLine_method2()
                          throws ParsingController.ConfigurationException,
                                 antlr.TokenStreamException
Should successfully give the line numbers of each token.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_getColumn_method1

public void test_getColumn_method1()
                            throws ParsingController.ConfigurationException,
                                   antlr.TokenStreamException
Should successfully give the column numbers of each token.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

test_getColumn_method2

public void test_getColumn_method2()
                            throws ParsingController.ConfigurationException,
                                   antlr.TokenStreamException
Should successfully give the column numbers of each token.

Throws:
ParsingController.ConfigurationException
antlr.TokenStreamException

establishLexers

private void establishLexers(String sourceCode)
Establish lexers and the controller for the given source code, without adding streams to the controller.


establishTest

private void establishTest(String sourceCode,
                           boolean selectInitial)
Establish lexers and controller for the given source code.

Parameters:
sourceCode - the source code to be lexed
selectInitial - indicates whether an initial stream should be selected

establishTest

private void establishTest(String sourceCode)
Establish lexers and controller for the given source code.


discardAllMJTokens

private antlr.Token discardAllMJTokens()
Discards all MultiJava tokens from the input and returns the end-of-file token.


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.