|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase org.eigenbase.test.SqlValidatorTestCase
public class SqlValidatorTestCase
An abstract base class for implementing tests against SqlValidator
.
A derived class can refine this test in two ways. First, it can add
testXxx()
methods, to test more functionality.
Second, it can override the getTester(org.eigenbase.sql.validate.SqlConformance)
method to return a
different implementation of the SqlValidatorTestCase.Tester
object. This encapsulates the
differences between test environments, for example, which SQL parser or
validator to use.
Nested Class Summary | |
---|---|
static interface |
SqlValidatorTestCase.Tester
Encapsulates differences between test environments, for example, which SQL parser or validator to use. |
static class |
SqlValidatorTestCase.TesterImpl
Implementation of SqlValidatorTestCase.Tester
which talks to a mock catalog. |
Field Summary | |
---|---|
private static Pattern |
lineColPattern
|
private static Pattern |
lineColTwicePattern
|
protected static String |
NL
|
protected SqlValidatorTestCase.Tester |
tester
|
Constructor Summary | |
---|---|
SqlValidatorTestCase(String name)
Creates a testcase. |
Method Summary | |
---|---|
protected void |
assertExceptionIsThrown(String sql,
String expectedMsgPattern)
|
void |
check(String sql)
|
void |
checkCharset(String sql,
Charset expectedCharset)
|
void |
checkCollation(String sql,
String expectedCollationName,
SqlCollation.Coercibility expectedCoercibility)
|
void |
checkColumnType(String sql,
String expected)
Checks that a query returns a single column, and that the column has the expected type. |
static void |
checkEx(Throwable ex,
String expectedMsgPattern,
SqlParserUtil.StringAndPos sap)
Checks whether an exception matches the expected pattern. |
void |
checkExp(String sql)
|
void |
checkExpFails(String sql,
String expected)
Checks that a SQL expression gives a particular error. |
void |
checkExpType(String sql,
String expected)
|
void |
checkFails(String sql,
String expected)
Checks that a SQL query gives a particular error, or succeeds if expected is null. |
void |
checkIntervalConv(String sql,
String expected)
Checks that the first column returned by a query has the expected type. |
void |
checkResultType(String sql,
String expected)
Checks that a query returns a row of the expected type. |
void |
checkWholeExpFails(String sql,
String expected)
Checks that a SQL expression gives a particular error, and that the location of the error is the whole expression. |
SqlValidatorTestCase.Tester |
getTester(SqlConformance conformance)
Returns a tester. |
private static SqlConformance |
splitConformance(String name)
|
private static String |
splitName(String name)
|
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, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final String NL
private static final Pattern lineColPattern
private static final Pattern lineColTwicePattern
protected final SqlValidatorTestCase.Tester tester
Constructor Detail |
---|
public SqlValidatorTestCase(String name)
If name is of the form "compatible:testCase", invokes sets the compatibility to "compatible".
name
- Name; examples "Sql2003:testGroup", "testGroup"Method Detail |
---|
private static String splitName(String name)
private static SqlConformance splitConformance(String name)
public SqlValidatorTestCase.Tester getTester(SqlConformance conformance)
conformance
- Language version tests should check compatibility withpublic void check(String sql)
public void checkExp(String sql)
public final void checkFails(String sql, String expected)
expected
is null.
public final void checkExpFails(String sql, String expected)
public final void checkWholeExpFails(String sql, String expected)
public void checkExpType(String sql, String expected)
public void checkColumnType(String sql, String expected)
checkColumnType("SELECT empno FROM Emp", "INTEGER NOT
NULL");
sql
- Queryexpected
- Expected type, including nullabilitypublic void checkResultType(String sql, String expected)
checkResultType("select empno, name from emp","{EMPNO
INTEGER NOT NULL, NAME VARCHAR(10) NOT NULL}");
sql
- Queryexpected
- Expected row typepublic void checkIntervalConv(String sql, String expected)
checkQueryType("SELECT empno FROM Emp", "INTEGER NOT
NULL");
sql
- Queryexpected
- Expected type, including nullabilityprotected final void assertExceptionIsThrown(String sql, String expectedMsgPattern)
public void checkCharset(String sql, Charset expectedCharset)
public void checkCollation(String sql, String expectedCollationName, SqlCollation.Coercibility expectedCoercibility)
public static void checkEx(Throwable ex, String expectedMsgPattern, SqlParserUtil.StringAndPos sap)
sap
contains an error location, checks this too.
ex
- Exception thrownexpectedMsgPattern
- Expected patternsap
- Query and (optional) position in query
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |