Skip to content

Commit

Permalink
[CALCITE-3892] Make junit test classes and methods non-public where p…
Browse files Browse the repository at this point in the history
…ossible

Prior to junit 5, classes and methods had to be public. This is no
longer the case.

Some classes need to remain public because they are referenced from
elsewhere, or if they use reflection somehow. The remaining 'public'
keyword will be informative to maintainers.
  • Loading branch information
julianhyde committed Apr 5, 2020
1 parent f1b2d3c commit 9492dd4
Show file tree
Hide file tree
Showing 196 changed files with 5,908 additions and 5,925 deletions.
26 changes: 13 additions & 13 deletions babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
/**
* Tests the "Babel" SQL parser, that understands all dialects of SQL.
*/
public class BabelParserTest extends SqlParserTest {
class BabelParserTest extends SqlParserTest {

@Override protected SqlParserImplFactory parserImplFactory() {
return SqlBabelParserImpl.FACTORY;
}

@Test public void testReservedWords() {
@Test void testReservedWords() {
assertThat(isReserved("escape"), is(false));
}

/** {@inheritDoc}
*
* <p>Copy-pasted from base method, but with some key differences.
*/
@Override @Test public void testMetadata() {
@Override @Test protected void testMetadata() {
SqlAbstractParserImpl.Metadata metadata = getSqlParser("").getMetadata();
assertThat(metadata.isReservedFunctionName("ABS"), is(true));
assertThat(metadata.isReservedFunctionName("FOO"), is(false));
Expand Down Expand Up @@ -88,14 +88,14 @@ public class BabelParserTest extends SqlParserTest {
assertThat(!jdbcKeywords.contains(",SELECT,"), is(true));
}

@Test public void testSelect() {
@Test void testSelect() {
final String sql = "select 1 from t";
final String expected = "SELECT 1\n"
+ "FROM `T`";
sql(sql).ok(expected);
}

@Test public void testYearIsNotReserved() {
@Test void testYearIsNotReserved() {
final String sql = "select 1 as year from t";
final String expected = "SELECT 1 AS `YEAR`\n"
+ "FROM `T`";
Expand All @@ -104,7 +104,7 @@ public class BabelParserTest extends SqlParserTest {

/** Tests that there are no reserved keywords. */
@Disabled
@Test public void testKeywords() {
@Test void testKeywords() {
final String[] reserved = {"AND", "ANY", "END-EXEC"};
final StringBuilder sql = new StringBuilder("select ");
final StringBuilder expected = new StringBuilder("SELECT ");
Expand All @@ -124,14 +124,14 @@ public class BabelParserTest extends SqlParserTest {
}

/** In Babel, AS is not reserved. */
@Test public void testAs() {
@Test void testAs() {
final String expected = "SELECT `AS`\n"
+ "FROM `T`";
sql("select as from t").ok(expected);
}

/** In Babel, DESC is not reserved. */
@Test public void testDesc() {
@Test void testDesc() {
final String sql = "select desc\n"
+ "from t\n"
+ "order by desc asc, desc desc";
Expand All @@ -149,15 +149,15 @@ public class BabelParserTest extends SqlParserTest {
* @see <a href="https://issues.apache.org/jira/browse/CALCITE-2847">[CALCITE-2847]
* Optimize global LOOKAHEAD for SQL parsers</a>
*/
@Test public void testCaseExpressionBabel() {
@Test void testCaseExpressionBabel() {
sql("case x when 2, 4 then 3 ^when^ then 5 else 4 end")
.fails("(?s)Encountered \"when then\" at .*");
}

/** In Redshift, DATE is a function. It requires special treatment in the
* parser because it is a reserved keyword.
* (Curiously, TIMESTAMP and TIME are not functions.) */
@Test public void testDateFunction() {
@Test void testDateFunction() {
final String expected = "SELECT `DATE`(`X`)\n"
+ "FROM `T`";
sql("select date(x) from t").ok(expected);
Expand All @@ -166,7 +166,7 @@ public class BabelParserTest extends SqlParserTest {
/** In Redshift, PostgreSQL the DATEADD, DATEDIFF and DATE_PART functions have
* ordinary function syntax except that its first argument is a time unit
* (e.g. DAY). We must not parse that first argument as an identifier. */
@Test public void testRedshiftFunctionsWithDateParts() {
@Test void testRedshiftFunctionsWithDateParts() {
final String sql = "SELECT DATEADD(day, 1, t),\n"
+ " DATEDIFF(week, 2, t),\n"
+ " DATE_PART(year, t) FROM mytable";
Expand All @@ -179,7 +179,7 @@ public class BabelParserTest extends SqlParserTest {

/** PostgreSQL and Redshift allow TIMESTAMP literals that contain only a
* date part. */
@Test public void testShortTimestampLiteral() {
@Test void testShortTimestampLiteral() {
sql("select timestamp '1969-07-20'")
.ok("SELECT TIMESTAMP '1969-07-20 00:00:00'");
// PostgreSQL allows the following. We should too.
Expand Down Expand Up @@ -234,7 +234,7 @@ private void checkExNotNull(SqlParserUtil.StringAndPos sap, Throwable thrown) {
}

/** Tests parsing PostgreSQL-style "::" cast operator. */
@Test public void testParseInfixCast() {
@Test void testParseInfixCast() {
checkParseInfixCast("integer");
checkParseInfixCast("varchar");
checkParseInfixCast("boolean");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/**
* Unit tests for the Babel SQL parser.
*/
public class BabelQuidemTest extends QuidemTest {
class BabelQuidemTest extends QuidemTest {
/** Runs a test from the command line.
*
* <p>For example:
Expand Down
4 changes: 2 additions & 2 deletions babel/src/test/java/org/apache/calcite/test/BabelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
* Unit tests for Babel framework.
*/
public class BabelTest {
class BabelTest {

static final String URL = "jdbc:calcite:";

Expand Down Expand Up @@ -75,7 +75,7 @@ static Connection connect(UnaryOperator<CalciteAssert.PropBuilder> propBuild)
return DriverManager.getConnection(URL, info);
}

@Test public void testInfixCast() throws SQLException {
@Test void testInfixCast() throws SQLException {
try (Connection connection = connect(useLibraryList("standard,postgresql"));
Statement statement = connection.createStatement()) {
checkInfixCast(statement, "integer", Types.INTEGER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
@Execution(ExecutionMode.SAME_THREAD)
@ExtendWith(CassandraExtension.class)
public class CassandraAdapterDataTypesTest {
class CassandraAdapterDataTypesTest {

/** Connection factory based on the "mongo-zips" model. */
private static final ImmutableMap<String, String> DTCASSANDRA =
Expand All @@ -53,7 +53,7 @@ static void load(Session session) {
.load(new ClassPathCQLDataSet("datatypes.cql"));
}

@Test public void testSimpleTypesRowType() {
@Test void testSimpleTypesRowType() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_simple\"")
Expand All @@ -79,7 +79,7 @@ static void load(Session session) {
+ ", f_varint INTEGER]");
}

@Test public void testSimpleTypesValues() {
@Test void testSimpleTypesValues() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_simple\"")
Expand All @@ -105,21 +105,21 @@ static void load(Session session) {
+ "; f_varint=10\n");
}

@Test public void testCounterRowType() {
@Test void testCounterRowType() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_counter\"")
.typeIs("[f_int INTEGER, f_counter BIGINT]");
}

@Test public void testCounterValues() {
@Test void testCounterValues() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_counter\"")
.returns("f_int=1; f_counter=1\n");
}

@Test public void testCollectionsRowType() {
@Test void testCollectionsRowType() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_collections\"")
Expand All @@ -130,7 +130,7 @@ static void load(Session session) {
+ ", f_tuple STRUCT]");
}

@Test public void testCollectionsValues() {
@Test void testCollectionsValues() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_collections\"")
Expand All @@ -142,7 +142,7 @@ static void load(Session session) {
+ "\n");
}

@Test public void testCollectionsInnerRowType() {
@Test void testCollectionsInnerRowType() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select \"f_list\"[1], "
Expand All @@ -160,7 +160,7 @@ static void load(Session session) {

// ignored as tuple elements returns 'null' when accessed in the select statement
@Disabled
@Test public void testCollectionsInnerValues() {
@Test void testCollectionsInnerValues() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select \"f_list\"[1], "
Expand All @@ -177,7 +177,7 @@ static void load(Session session) {
}

// frozen collections should not affect the row type
@Test public void testFrozenCollectionsRowType() {
@Test void testFrozenCollectionsRowType() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_frozen_collections\"")
Expand All @@ -190,7 +190,7 @@ static void load(Session session) {
}

// frozen collections should not affect the result set
@Test public void testFrozenCollectionsValues() {
@Test void testFrozenCollectionsValues() {
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select * from \"test_frozen_collections\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
@Execution(ExecutionMode.SAME_THREAD)
@ExtendWith(CassandraExtension.class)
public class CassandraAdapterTest {
class CassandraAdapterTest {

/** Connection factory based on the "mongo-zips" model. */
private static final ImmutableMap<String, String> TWISSANDRA =
Expand All @@ -52,14 +52,14 @@ static void load(Session session) {
.load(new ClassPathCQLDataSet("twissandra.cql"));
}

@Test public void testSelect() {
@Test void testSelect() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select * from \"users\"")
.returnsCount(10);
}

@Test public void testFilter() {
@Test void testFilter() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select * from \"userline\" where \"username\"='!PUBLIC!'")
Expand All @@ -71,7 +71,7 @@ static void load(Session session) {
+ " CassandraTableScan(table=[[twissandra, userline]]");
}

@Test public void testFilterUUID() {
@Test void testFilterUUID() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select * from \"tweets\" where \"tweet_id\"='f3cd759c-d05b-11e5-b58b-90e2ba530b12'")
Expand All @@ -83,7 +83,7 @@ static void load(Session session) {
+ " CassandraTableScan(table=[[twissandra, tweets]]");
}

@Test public void testSort() {
@Test void testSort() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select * from \"userline\" where \"username\" = '!PUBLIC!' order by \"time\" desc")
Expand All @@ -93,7 +93,7 @@ static void load(Session session) {
+ " CassandraFilter(condition=[=($0, '!PUBLIC!')])\n");
}

@Test public void testProject() {
@Test void testProject() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select \"tweet_id\" from \"userline\" where \"username\" = '!PUBLIC!' limit 2")
Expand All @@ -105,29 +105,29 @@ static void load(Session session) {
+ " CassandraFilter(condition=[=($0, '!PUBLIC!')])\n");
}

@Test public void testProjectAlias() {
@Test void testProjectAlias() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select \"tweet_id\" as \"foo\" from \"userline\" "
+ "where \"username\" = '!PUBLIC!' limit 1")
.returns("foo=f3c329de-d05b-11e5-b58b-90e2ba530b12\n");
}

@Test public void testProjectConstant() {
@Test void testProjectConstant() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select 'foo' as \"bar\" from \"userline\" limit 1")
.returns("bar=foo\n");
}

@Test public void testLimit() {
@Test void testLimit() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select \"tweet_id\" from \"userline\" where \"username\" = '!PUBLIC!' limit 8")
.explainContains("CassandraLimit(fetch=[8])\n");
}

@Test public void testSortLimit() {
@Test void testSortLimit() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select * from \"userline\" where \"username\"='!PUBLIC!' "
Expand All @@ -136,7 +136,7 @@ static void load(Session session) {
+ " CassandraSort(sort0=[$1], dir0=[DESC])");
}

@Test public void testSortOffset() {
@Test void testSortOffset() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select \"tweet_id\" from \"userline\" where "
Expand All @@ -146,7 +146,7 @@ static void load(Session session) {
+ "tweet_id=f3e4182e-d05b-11e5-b58b-90e2ba530b12\n");
}

@Test public void testMaterializedView() {
@Test void testMaterializedView() {
CalciteAssert.that()
.with(TWISSANDRA)
.query("select \"tweet_id\" from \"tweets\" where \"username\"='JmuhsAaMdw'")
Expand Down
Loading

0 comments on commit 9492dd4

Please sign in to comment.