Package org.apache.calcite.util
Class UtilTest
- java.lang.Object
-
- org.apache.calcite.util.UtilTest
-
public class UtilTest extends java.lang.Object
Unit test forUtil
and other classes in this package.
-
-
Constructor Summary
Constructors Constructor Description UtilTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
assertByteArray(java.lang.String expected, java.lang.String bits, int bitCount)
private void
assertPrintEquals(java.lang.String expect, java.lang.String in, boolean nullMeansNull)
private static void
assertReversible(java.lang.String s)
private void
checkCase0(java.lang.String s)
private void
checkCase1(java.lang.String s)
private void
checkCompositeMap(java.lang.String[] beatles, java.util.Map<java.lang.String,java.lang.Integer> map)
private void
checkFlatList(int n)
void
checkHash(double v)
private java.util.List<java.lang.Integer>
checkIntegerIntervalSet(java.lang.String s, int... ints)
private void
checkListToString(java.lang.String... strings)
private boolean
checkLitmus(int i, org.apache.calcite.util.Litmus litmus)
private void
checkNameMap(java.lang.String s, org.apache.calcite.util.NameMap<java.lang.Integer> map)
private void
checkNameMultimap(java.lang.String s, org.apache.calcite.util.NameMultimap<java.lang.Integer> map)
private void
checkNameSet(java.lang.String s, org.apache.calcite.util.NameSet set)
private java.util.NavigableSet<java.lang.String>
checkNav(java.util.NavigableSet<java.lang.String> set, java.lang.String s)
private void
checkOrdReverse(java.lang.Iterable<org.apache.calcite.linq4j.Ord<java.lang.String>> reverse1)
private void
checkResourceMethodNames(java.lang.Object resource)
(package private) static java.lang.String
describe(org.hamcrest.Matcher m)
static void
foo(int i, int j)
Dummy method fortestParameterName()
to inspect.private static <E> org.hamcrest.Matcher<java.lang.Iterable<E>>
isIterable(java.lang.Iterable<E> iterable)
private <E> java.util.List<E>
l1(E e)
private <E> java.util.List<E>
l2(E e0, E e1)
private <E> java.util.List<E>
l3(E e0, E e1, E e2)
java.util.List<java.lang.String>
list(java.lang.String... xs)
private java.util.List<java.lang.Integer>
makeConsList(int start, int end)
(package private) static java.lang.String
mismatchDescription(org.hamcrest.Matcher m, java.lang.Object item)
static void
setUSLocale()
void
testAsIndexView()
void
testBitString()
Unit-test forBitString
.void
testCamelToUpper()
Unit test forAvaticaUtils.camelToUpper(String)
.void
testCastingList()
TestsCastingList
andUtil.cast(java.util.List<? super E>, java.lang.Class<E>)
.void
testCommaList()
TestsUtil.commaList(java.util.List)
.void
testComposeMatcher()
void
testCompositeList()
Unit test forCompositeList
.void
testCompositeMap()
void
testCons()
void
testConsPerformance()
void
testDiffLines()
Tests the difference engine,DiffTestCase.diff(java.io.File, java.io.File)
.void
testDistinct()
Unit test forUtil.isDistinct(java.util.List)
.void
testDistinctList()
Unit test forUtil.distinctList(List)
andUtil.distinctList(Iterable)
.void
testEnumConstants()
Tests the methodsUtil.enumConstants(Class)
andUtil.enumVal(Class, String)
.void
testEquivalenceSet()
void
testFilter()
TestsUtil.filter(Iterable, java.util.function.Predicate)
.void
testFirstDuplicate()
Unit test forUtil.firstDuplicate(java.util.List)
.void
testFlat34Equals()
Test case for [CALCITE-2287] FlatList.equals throws StackOverflowError.void
testFlatList()
Tests that flat lists behave like regular lists in terms of equals and hashCode.void
testFlatList2()
void
testFlatListN()
void
testFlatListProduct()
void
testHash()
Unit test forUtilities.hashCode(double)
.void
testHuman()
void
testImmutableCopy()
TestsUtil.immutableCopy(Iterable)
.void
testImmutableIntList()
void
testImmutableNullableList()
Test forImmutableNullableList
.void
testImmutableNullableListBuilder()
Test forImmutableNullableList.Builder
.void
testIntegerIntervalSet()
Unit test forIntegerIntervalSet
.void
testIntersects()
Unit test forUtil.intersects(java.util.Collection, java.util.Collection)
.void
testIsDistinctBenchmark()
Benchmark forUtil.isDistinct(java.util.List<E>)
.void
testIsLinux()
Unit test forMatchers.isLinux(java.lang.String)
.void
testIterableProperties()
void
testJsonBuilder()
Unit test forJsonBuilder
.void
testListToString()
void
testLitmus()
Test case for [CALCITE-1264] Litmus argument interpolation.void
testNameMap()
Unit test forNameMap
.void
testNameMultimap()
Unit test forNameMultimap
.void
testNameSet()
Unit test forNameSet
.void
testNlsStringClone()
void
testOrdReverse()
void
testPairAdjacents()
Unit test forPair.adjacents(Iterable)
.void
testPairFirstAnd()
Unit test forPair.firstAnd(Iterable)
.void
testPairZip()
Unit test forPair.zip(java.util.List, java.util.List)
.void
testParameterName()
TestsReflectUtil.getParameterName(java.lang.reflect.Method, int)
.void
testParseLocale()
Unit test forUtil.parseLocale(String)
method.void
testPosixTimeZone()
Tests theUtil.toPosix(TimeZone, boolean)
method.void
testPrintEquals()
void
testPrintEquals2()
void
testPrintEquals3()
void
testPrintEquals4()
void
testPrintEquals5()
void
testQuotientList()
Unit test forUtil.quotientList(java.util.List, int, int)
andUtil.pairs(List)
.void
testRelBuilderExample()
void
testResources()
void
testScientificNotation()
void
testSortedSet()
Tests that sorted sets behave the way we expect.void
testSpaces()
void
testSpaceString()
void
testSqlBuilder()
Tests SQL builders.void
testStartsWithList()
Unit test forUtil.startsWith(java.util.List<E>, java.util.List<E>)
.void
testTemplate()
Unit test forTemplate
.void
testToCamelCase()
Unit test forAvaticaUtils.toCamelCase(String)
.void
testToJavaId()
void
testTokenize()
Unit-test forUtil.tokenize(String, String)
.void
testTransform()
TestsUtil.transform(List, java.util.function.Function)
.void
testTryThreadLocal()
TestsTryThreadLocal
.void
testUnmodifiableArrayList()
Test forUnmodifiableArrayList
.void
testXmlOutput()
private static <E> java.util.List<E>
toList(java.lang.Iterable<E> iterable)
private java.lang.String
toString(byte[] bytes)
Converts a byte array to a hex string like "AB, CD".
-
-
-
Method Detail
-
setUSLocale
public static void setUSLocale()
-
testPrintEquals
public void testPrintEquals()
-
testPrintEquals2
public void testPrintEquals2()
-
testPrintEquals3
public void testPrintEquals3()
-
testPrintEquals4
public void testPrintEquals4()
-
testPrintEquals5
public void testPrintEquals5()
-
testScientificNotation
public void testScientificNotation()
-
testToJavaId
public void testToJavaId() throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
assertPrintEquals
private void assertPrintEquals(java.lang.String expect, java.lang.String in, boolean nullMeansNull)
-
testTokenize
public void testTokenize()
Unit-test forUtil.tokenize(String, String)
.
-
testBitString
public void testBitString()
Unit-test forBitString
.
-
assertReversible
private static void assertReversible(java.lang.String s)
-
assertByteArray
private void assertByteArray(java.lang.String expected, java.lang.String bits, int bitCount)
-
toString
private java.lang.String toString(byte[] bytes)
Converts a byte array to a hex string like "AB, CD".
-
testCastingList
public void testCastingList()
TestsCastingList
andUtil.cast(java.util.List<? super E>, java.lang.Class<E>)
.
-
testCons
public void testCons()
-
testConsPerformance
public void testConsPerformance()
-
makeConsList
private java.util.List<java.lang.Integer> makeConsList(int start, int end)
-
testIterableProperties
public void testIterableProperties()
-
testDiffLines
public void testDiffLines()
Tests the difference engine,DiffTestCase.diff(java.io.File, java.io.File)
.
-
testPosixTimeZone
public void testPosixTimeZone()
Tests theUtil.toPosix(TimeZone, boolean)
method.
-
testEnumConstants
public void testEnumConstants()
Tests the methodsUtil.enumConstants(Class)
andUtil.enumVal(Class, String)
.
-
testSqlBuilder
public void testSqlBuilder()
Tests SQL builders.
-
testCompositeList
public void testCompositeList()
Unit test forCompositeList
.
-
testTemplate
public void testTemplate()
Unit test forTemplate
.
-
testParseLocale
public void testParseLocale()
Unit test forUtil.parseLocale(String)
method.
-
testSpaces
public void testSpaces()
-
testSpaceString
public void testSpaceString()
-
testPairZip
public void testPairZip()
Unit test forPair.zip(java.util.List, java.util.List)
.
-
testPairAdjacents
public void testPairAdjacents()
Unit test forPair.adjacents(Iterable)
.
-
testPairFirstAnd
public void testPairFirstAnd()
Unit test forPair.firstAnd(Iterable)
.
-
testQuotientList
public void testQuotientList()
Unit test forUtil.quotientList(java.util.List, int, int)
andUtil.pairs(List)
.
-
testImmutableIntList
public void testImmutableIntList()
-
testIntegerIntervalSet
public void testIntegerIntervalSet()
Unit test forIntegerIntervalSet
.
-
checkIntegerIntervalSet
private java.util.List<java.lang.Integer> checkIntegerIntervalSet(java.lang.String s, int... ints)
-
testFlatList
public void testFlatList()
Tests that flat lists behave like regular lists in terms of equals and hashCode.
-
testFlatList2
public void testFlatList2()
-
checkFlatList
private void checkFlatList(int n)
-
l1
private <E> java.util.List<E> l1(E e)
-
l2
private <E> java.util.List<E> l2(E e0, E e1)
-
l3
private <E> java.util.List<E> l3(E e0, E e1, E e2)
-
testFlat34Equals
public void testFlat34Equals()
Test case for [CALCITE-2287] FlatList.equals throws StackOverflowError.
-
testFlatListN
public void testFlatListN()
-
testFlatListProduct
public void testFlatListProduct()
-
testToCamelCase
public void testToCamelCase()
Unit test forAvaticaUtils.toCamelCase(String)
.
-
testCamelToUpper
public void testCamelToUpper()
Unit test forAvaticaUtils.camelToUpper(String)
.
-
testDistinct
public void testDistinct()
Unit test forUtil.isDistinct(java.util.List)
.
-
testIntersects
public void testIntersects()
Unit test forUtil.intersects(java.util.Collection, java.util.Collection)
.
-
testJsonBuilder
public void testJsonBuilder()
Unit test forJsonBuilder
.
-
testCompositeMap
public void testCompositeMap()
-
checkCompositeMap
private void checkCompositeMap(java.lang.String[] beatles, java.util.Map<java.lang.String,java.lang.Integer> map)
-
testCommaList
public void testCommaList()
TestsUtil.commaList(java.util.List)
.
-
testFirstDuplicate
public void testFirstDuplicate()
Unit test forUtil.firstDuplicate(java.util.List)
.
-
testIsDistinctBenchmark
public void testIsDistinctBenchmark()
Benchmark forUtil.isDistinct(java.util.List<E>)
. Has determined that map-based implementation is better than nested loops implementation if list is larger than about 15.
-
testDistinctList
public void testDistinctList()
Unit test forUtil.distinctList(List)
andUtil.distinctList(Iterable)
.
-
testHash
public void testHash()
Unit test forUtilities.hashCode(double)
.
-
checkHash
public void checkHash(double v)
-
testStartsWithList
public void testStartsWithList()
Unit test forUtil.startsWith(java.util.List<E>, java.util.List<E>)
.
-
list
public java.util.List<java.lang.String> list(java.lang.String... xs)
-
testResources
public void testResources()
-
checkResourceMethodNames
private void checkResourceMethodNames(java.lang.Object resource)
-
testSortedSet
public void testSortedSet()
Tests that sorted sets behave the way we expect.
-
checkNav
private java.util.NavigableSet<java.lang.String> checkNav(java.util.NavigableSet<java.lang.String> set, java.lang.String s)
-
testImmutableNullableList
public void testImmutableNullableList()
Test forImmutableNullableList
.
-
testUnmodifiableArrayList
public void testUnmodifiableArrayList()
Test forUnmodifiableArrayList
.
-
testImmutableNullableListBuilder
public void testImmutableNullableListBuilder()
Test forImmutableNullableList.Builder
.
-
testHuman
public void testHuman()
-
testImmutableCopy
public void testImmutableCopy()
TestsUtil.immutableCopy(Iterable)
.
-
testAsIndexView
public void testAsIndexView()
-
testRelBuilderExample
public void testRelBuilderExample()
-
testOrdReverse
public void testOrdReverse()
-
checkOrdReverse
private void checkOrdReverse(java.lang.Iterable<org.apache.calcite.linq4j.Ord<java.lang.String>> reverse1)
-
testParameterName
public void testParameterName() throws java.lang.NoSuchMethodException
TestsReflectUtil.getParameterName(java.lang.reflect.Method, int)
.- Throws:
java.lang.NoSuchMethodException
-
foo
public static void foo(int i, int j)
Dummy method fortestParameterName()
to inspect.
-
testListToString
public void testListToString()
-
checkListToString
private void checkListToString(java.lang.String... strings)
-
testTryThreadLocal
public void testTryThreadLocal()
TestsTryThreadLocal
.TryThreadLocal was introduced to fix [CALCITE-915] Tests do not unset ThreadLocal values on exit.
-
testLitmus
public void testLitmus()
Test case for [CALCITE-1264] Litmus argument interpolation.
-
checkLitmus
private boolean checkLitmus(int i, org.apache.calcite.util.Litmus litmus)
-
testNameSet
public void testNameSet()
Unit test forNameSet
.
-
checkCase0
private void checkCase0(java.lang.String s)
-
checkCase1
private void checkCase1(java.lang.String s)
-
checkNameSet
private void checkNameSet(java.lang.String s, org.apache.calcite.util.NameSet set)
-
checkNameMap
private void checkNameMap(java.lang.String s, org.apache.calcite.util.NameMap<java.lang.Integer> map)
-
checkNameMultimap
private void checkNameMultimap(java.lang.String s, org.apache.calcite.util.NameMultimap<java.lang.Integer> map)
-
testNameMap
public void testNameMap()
Unit test forNameMap
.
-
testNameMultimap
public void testNameMultimap()
Unit test forNameMultimap
.
-
testNlsStringClone
public void testNlsStringClone()
-
testXmlOutput
public void testXmlOutput()
-
testComposeMatcher
public void testComposeMatcher()
-
testIsLinux
public void testIsLinux()
Unit test forMatchers.isLinux(java.lang.String)
.
-
testTransform
public void testTransform()
TestsUtil.transform(List, java.util.function.Function)
.
-
testFilter
public void testFilter()
TestsUtil.filter(Iterable, java.util.function.Predicate)
.
-
testEquivalenceSet
public void testEquivalenceSet()
-
isIterable
private static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> isIterable(java.lang.Iterable<E> iterable)
-
toList
private static <E> java.util.List<E> toList(java.lang.Iterable<E> iterable)
-
mismatchDescription
static java.lang.String mismatchDescription(org.hamcrest.Matcher m, java.lang.Object item)
-
describe
static java.lang.String describe(org.hamcrest.Matcher m)
-
-