net.sf.farrago.test
Class FarragoRexToOJTranslatorTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.eigenbase.test.DiffTestCase
              extended by net.sf.farrago.test.ResultSetTestCase
                  extended by net.sf.farrago.test.FarragoTestCase
                      extended by net.sf.farrago.test.FarragoSqlToRelTestBase
                          extended by net.sf.farrago.test.FarragoRexToOJTranslatorTest
All Implemented Interfaces:
Test

public class FarragoRexToOJTranslatorTest
extends FarragoSqlToRelTestBase

FarragoRexToOJTranslatorTest contains unit tests for the translation code in net.sf.farrago.ojrex. Each test case takes a single SQL row expression string as input, performs code generation, and then diffs the generated Java code snippet against an expected .ref file under directory farrago/testlog/FarragoRexToOJTranslatorTest.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/test/FarragoRexToOJTranslatorTest.java#33 $
Author:
John V. Sichi

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.farrago.test.FarragoTestCase
FarragoTestCase.Cleanup, FarragoTestCase.CleanupFactory
 
Field Summary
 
Fields inherited from class net.sf.farrago.test.FarragoTestCase
allocOwner, connection, preparedStmt, repos, stmt, tracer
 
Fields inherited from class net.sf.farrago.test.ResultSetTestCase
resultSet
 
Fields inherited from class org.eigenbase.test.DiffTestCase
logFile, logOutputStream, refFile
 
Constructor Summary
FarragoRexToOJTranslatorTest(String testName)
          Creates a new FarragoRexToOJTranslatorTest object.
 
Method Summary
protected  void checkAbstract(FarragoPreparingStmt stmt, RelNode topRel)
           
private  void checkTranslation(String rowExpression)
          Tests translation of a single row expression, using the SALES.EMPS table for context.
private  void checkTranslation(String rowExpression, String tableExpression)
          Tests translation of a single row expression.
protected  void initPlanner(FarragoPreparingStmt stmt)
           
protected  boolean shouldDiff()
           
static Test suite()
           
 void testBooleanAnd()
           
 void testBooleanConjunction()
           
 void testBooleanConjunctionNotNull()
           
 void testBooleanNot()
           
 void testBooleanOr()
           
 void testBooleanOrNullable()
           
 void testCaseNotNullableCondWithElse()
           
 void testCaseNotNullableCondWithElsePrimitive()
           
 void testCaseNotNullableCondWithoutElse()
           
 void testCaseNotNullableCondWithoutElsePrimitive()
           
 void testCaseNullableCondWithElse()
           
 void testCaseNullableCondWithElsePrimitive()
           
 void testCaseNullableCondWithoutElse()
           
 void testCaseNullableCondWithoutElsePrimitive()
           
 void testCastIntToVarchar()
           
 void testCastToVarbinaryImplicitTruncate()
           
 void testCastToVarchar()
           
 void testCastToVarcharImplicitTruncate()
           
 void testCharacterLength()
           
 void testCharLength()
           
 void testConcatBothNullable()
           
 void testConcatNoNullable()
           
 void testConcatWithOneNullable()
           
 void testCurrentDate()
           
 void testCurrentPath()
           
 void testCurrentTime()
           
 void testCurrentTimestamp()
           
 void testCurrentUser()
           
 void testInitcap()
           
 void testJavaUdfInvocation()
           
 void testLikeLiteral()
           
 void testLikeLiteralWithEscape()
           
 void testLikeRuntime()
           
 void testLikeRuntimeWithEscape()
           
 void testLower()
           
 void testMod()
           
 void testNotNullIsFalse()
           
 void testNotNullIsNotNull()
           
 void testNotNullIsNull()
           
 void testNotNullIsTrue()
           
 void testNullableIsFalse()
           
 void testNullableIsNotNull()
           
 void testNullableIsNull()
           
 void testNullableIsTrue()
           
 void testOverlayAllNullable()
           
 void testOverlayNoLength()
           
 void testOverlayNoNullable()
           
 void testOverlayNullable()
           
 void testOverlayThreeNullable()
           
 void testPlusCastNullSmallint()
           
 void testPosition()
           
 void testPower()
           
 void testPrefixMinusCastNullTinyint()
           
 void testPrimitiveDivide()
           
 void testPrimitiveEquals()
           
 void testPrimitiveEqualsNotNull()
           
 void testPrimitiveGreater()
           
 void testPrimitiveGreaterBoolean()
           
 void testPrimitiveLess()
           
 void testPrimitiveMinus()
           
 void testPrimitivePlus()
           
 void testPrimitivePrefixMinus()
           
 void testPrimitiveTimes()
           
 void testSessionUser()
           
 void testSimilarLiteral()
           
 void testSimilarLiteralWithEscape()
           
 void testSimilarRuntime()
           
 void testSimilarRuntimeWithEscape()
           
 void testSqlUdfInvocation()
           
 void testSubstringNegativeLength()
           
 void testSubstringNoLength()
           
 void testSubstringNothingNullable()
           
 void testSubstringNullableLength()
           
 void testSubstringNullablePosition()
           
 void testSubstringPositionLessThanZero()
           
 void testSubstringPositionZero()
           
 void testSystemUser()
           
 void testTrimBoth()
           
 void testTrimLeading()
           
 void testTrimTrailing()
           
 void testUpper()
           
 void testUser()
           
 void testVarcharEquals()
           
 void testVarcharLess()
           
 
Methods inherited from class net.sf.farrago.test.FarragoSqlToRelTestBase
addRulesAndCheckQuery, checkQuery
 
Methods inherited from class net.sf.farrago.test.FarragoTestCase
forceShutdown, getJdbcUri, getSession, getTestlogRoot, getTestlogRootStatic, newConnection, newJdbcEngineDriver, restoreParameters, restoreParameters, runCleanup, runSqlLineTest, runSqlLineTest, saveParameters, saveParameters, setRefFileDiffMasks, setUp, staticSetUp, staticTearDown, tearDown, tearDownImpl, wrappedSuite, wrappedSuite
 
Methods inherited from class net.sf.farrago.test.ResultSetTestCase
compareResultList, compareResultLists, compareResultSet, compareResultSetWithDelta, compareResultSetWithPattern, getResultSetCount
 
Methods inherited from class org.eigenbase.test.DiffTestCase
addDiffMask, addIgnorePattern, diffFile, diffLines, diffTestLog, fileContents, openTestLog, openTestLogOutputStream, setGC, setVerbose
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FarragoRexToOJTranslatorTest

public FarragoRexToOJTranslatorTest(String testName)
                             throws Exception
Creates a new FarragoRexToOJTranslatorTest object.

Parameters:
testName - .
Throws:
Exception - .
Method Detail

suite

public static Test suite()

shouldDiff

protected boolean shouldDiff()
Overrides:
shouldDiff in class FarragoTestCase

checkTranslation

private void checkTranslation(String rowExpression,
                              String tableExpression)
                       throws Exception
Tests translation of a single row expression.

Parameters:
rowExpression - the text of the row expression to test (this is used as the single select item in a constructed EXPLAIN PLAN statement)
tableExpression - the table to use in the FROM clause (don't use anything fancy here like a nested query because the optimizer used for this test has its hands tied)
Throws:
Exception

checkAbstract

protected void checkAbstract(FarragoPreparingStmt stmt,
                             RelNode topRel)
                      throws Exception
Specified by:
checkAbstract in class FarragoSqlToRelTestBase
Throws:
Exception

initPlanner

protected void initPlanner(FarragoPreparingStmt stmt)
Specified by:
initPlanner in class FarragoSqlToRelTestBase

checkTranslation

private void checkTranslation(String rowExpression)
                       throws Exception
Tests translation of a single row expression, using the SALES.EMPS table for context.

Parameters:
rowExpression - the text of the row expression to test (this is used as the single select item in a constructed EXPLAIN PLAN statement)
Throws:
Exception

testPrimitiveEquals

public void testPrimitiveEquals()
                         throws Exception
Throws:
Exception

testPrimitiveEqualsNotNull

public void testPrimitiveEqualsNotNull()
                                throws Exception
Throws:
Exception

testPrimitiveLess

public void testPrimitiveLess()
                       throws Exception
Throws:
Exception

testPrimitiveGreater

public void testPrimitiveGreater()
                          throws Exception
Throws:
Exception

testPrimitivePlus

public void testPrimitivePlus()
                       throws Exception
Throws:
Exception

testPrimitiveMinus

public void testPrimitiveMinus()
                        throws Exception
Throws:
Exception

testPrimitiveTimes

public void testPrimitiveTimes()
                        throws Exception
Throws:
Exception

testPrimitiveDivide

public void testPrimitiveDivide()
                         throws Exception
Throws:
Exception

testPrimitivePrefixMinus

public void testPrimitivePrefixMinus()
                              throws Exception
Throws:
Exception

testPrimitiveGreaterBoolean

public void testPrimitiveGreaterBoolean()
                                 throws Exception
Throws:
Exception

testPrefixMinusCastNullTinyint

public void testPrefixMinusCastNullTinyint()
                                    throws Exception
Throws:
Exception

testPlusCastNullSmallint

public void testPlusCastNullSmallint()
                              throws Exception
Throws:
Exception

testVarcharEquals

public void testVarcharEquals()
                       throws Exception
Throws:
Exception

testVarcharLess

public void testVarcharLess()
                     throws Exception
Throws:
Exception

testBooleanNot

public void testBooleanNot()
                    throws Exception
Throws:
Exception

testBooleanOr

public void testBooleanOr()
                   throws Exception
Throws:
Exception

testBooleanOrNullable

public void testBooleanOrNullable()
                           throws Exception
Throws:
Exception

testBooleanAnd

public void testBooleanAnd()
                    throws Exception
Throws:
Exception

testBooleanConjunction

public void testBooleanConjunction()
                            throws Exception
Throws:
Exception

testBooleanConjunctionNotNull

public void testBooleanConjunctionNotNull()
                                   throws Exception
Throws:
Exception

testNullableIsTrue

public void testNullableIsTrue()
                        throws Exception
Throws:
Exception

testNullableIsFalse

public void testNullableIsFalse()
                         throws Exception
Throws:
Exception

testNotNullIsTrue

public void testNotNullIsTrue()
                       throws Exception
Throws:
Exception

testNotNullIsFalse

public void testNotNullIsFalse()
                        throws Exception
Throws:
Exception

testNullableIsNull

public void testNullableIsNull()
                        throws Exception
Throws:
Exception

testNullableIsNotNull

public void testNullableIsNotNull()
                           throws Exception
Throws:
Exception

testNotNullIsNull

public void testNotNullIsNull()
                       throws Exception
Throws:
Exception

testNotNullIsNotNull

public void testNotNullIsNotNull()
                          throws Exception
Throws:
Exception

testUser

public void testUser()
              throws Exception
Throws:
Exception

testCurrentUser

public void testCurrentUser()
                     throws Exception
Throws:
Exception

testSessionUser

public void testSessionUser()
                     throws Exception
Throws:
Exception

testSystemUser

public void testSystemUser()
                    throws Exception
Throws:
Exception

testCurrentDate

public void testCurrentDate()
                     throws Exception
Throws:
Exception

testCurrentTime

public void testCurrentTime()
                     throws Exception
Throws:
Exception

testCurrentTimestamp

public void testCurrentTimestamp()
                          throws Exception
Throws:
Exception

testCurrentPath

public void testCurrentPath()
                     throws Exception
Throws:
Exception

testJavaUdfInvocation

public void testJavaUdfInvocation()
                           throws Exception
Throws:
Exception

testSqlUdfInvocation

public void testSqlUdfInvocation()
                          throws Exception
Throws:
Exception

testCastToVarcharImplicitTruncate

public void testCastToVarcharImplicitTruncate()
                                       throws Exception
Throws:
Exception

testCastToVarchar

public void testCastToVarchar()
                       throws Exception
Throws:
Exception

testCastToVarbinaryImplicitTruncate

public void testCastToVarbinaryImplicitTruncate()
                                         throws Exception
Throws:
Exception

testCastIntToVarchar

public void testCastIntToVarchar()
                          throws Exception
Throws:
Exception

testCaseNotNullableCondWithElse

public void testCaseNotNullableCondWithElse()
                                     throws Exception
Throws:
Exception

testCaseNotNullableCondWithoutElse

public void testCaseNotNullableCondWithoutElse()
                                        throws Exception
Throws:
Exception

testCaseNullableCondWithElse

public void testCaseNullableCondWithElse()
                                  throws Exception
Throws:
Exception

testCaseNullableCondWithoutElse

public void testCaseNullableCondWithoutElse()
                                     throws Exception
Throws:
Exception

testCaseNotNullableCondWithElsePrimitive

public void testCaseNotNullableCondWithElsePrimitive()
                                              throws Exception
Throws:
Exception

testCaseNotNullableCondWithoutElsePrimitive

public void testCaseNotNullableCondWithoutElsePrimitive()
                                                 throws Exception
Throws:
Exception

testCaseNullableCondWithElsePrimitive

public void testCaseNullableCondWithElsePrimitive()
                                           throws Exception
Throws:
Exception

testCaseNullableCondWithoutElsePrimitive

public void testCaseNullableCondWithoutElsePrimitive()
                                              throws Exception
Throws:
Exception

testSubstringNullableLength

public void testSubstringNullableLength()
                                 throws Exception
Throws:
Exception

testSubstringNullablePosition

public void testSubstringNullablePosition()
                                   throws Exception
Throws:
Exception

testSubstringNoLength

public void testSubstringNoLength()
                           throws Exception
Throws:
Exception

testSubstringPositionLessThanZero

public void testSubstringPositionLessThanZero()
                                       throws Exception
Throws:
Exception

testSubstringPositionZero

public void testSubstringPositionZero()
                               throws Exception
Throws:
Exception

testSubstringNegativeLength

public void testSubstringNegativeLength()
                                 throws Exception
Throws:
Exception

testSubstringNothingNullable

public void testSubstringNothingNullable()
                                  throws Exception
Throws:
Exception

testConcatNoNullable

public void testConcatNoNullable()
                          throws Exception
Throws:
Exception

testConcatWithOneNullable

public void testConcatWithOneNullable()
                               throws Exception
Throws:
Exception

testConcatBothNullable

public void testConcatBothNullable()
                            throws Exception
Throws:
Exception

testOverlayNoLength

public void testOverlayNoLength()
                         throws Exception
Throws:
Exception

testOverlayNullable

public void testOverlayNullable()
                         throws Exception
Throws:
Exception

testOverlayNoNullable

public void testOverlayNoNullable()
                           throws Exception
Throws:
Exception

testOverlayThreeNullable

public void testOverlayThreeNullable()
                              throws Exception
Throws:
Exception

testOverlayAllNullable

public void testOverlayAllNullable()
                            throws Exception
Throws:
Exception

testPower

public void testPower()
               throws Exception
Throws:
Exception

testMod

public void testMod()
             throws Exception
Throws:
Exception

testTrimBoth

public void testTrimBoth()
                  throws Exception
Throws:
Exception

testTrimLeading

public void testTrimLeading()
                     throws Exception
Throws:
Exception

testTrimTrailing

public void testTrimTrailing()
                      throws Exception
Throws:
Exception

testUpper

public void testUpper()
               throws Exception
Throws:
Exception

testLower

public void testLower()
               throws Exception
Throws:
Exception

testInitcap

public void testInitcap()
                 throws Exception
Throws:
Exception

testCharLength

public void testCharLength()
                    throws Exception
Throws:
Exception

testCharacterLength

public void testCharacterLength()
                         throws Exception
Throws:
Exception

testPosition

public void testPosition()
                  throws Exception
Throws:
Exception

testLikeLiteral

public void testLikeLiteral()
                     throws Exception
Throws:
Exception

testLikeRuntime

public void testLikeRuntime()
                     throws Exception
Throws:
Exception

testLikeLiteralWithEscape

public void testLikeLiteralWithEscape()
                               throws Exception
Throws:
Exception

testLikeRuntimeWithEscape

public void testLikeRuntimeWithEscape()
                               throws Exception
Throws:
Exception

testSimilarLiteral

public void testSimilarLiteral()
                        throws Exception
Throws:
Exception

testSimilarRuntime

public void testSimilarRuntime()
                        throws Exception
Throws:
Exception

testSimilarLiteralWithEscape

public void testSimilarLiteralWithEscape()
                                  throws Exception
Throws:
Exception

testSimilarRuntimeWithEscape

public void testSimilarRuntimeWithEscape()
                                  throws Exception
Throws:
Exception