Refine search
@Test(dependsOnMethods = { "verifyContextWasDirtied" }) public void verifyContextWasNotDirtied() { assertSame(this.applicationContext, this.dirtiedApplicationContext, "The application context should NOT have been 'dirtied'."); }
@Test public void testZoneKeyLookup() { for (TimeZoneKey timeZoneKey : TimeZoneKey.getTimeZoneKeys()) { assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getKey()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId()), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toUpperCase(ENGLISH)), timeZoneKey); assertSame(TimeZoneKey.getTimeZoneKey(timeZoneKey.getId().toLowerCase(ENGLISH)), timeZoneKey); } }
@Test public void testSplit() { assertEquals(SPLIT.getTableHandle(), TABLE); assertEquals(SPLIT.getAddresses(), ADDRESSES); assertSame(SPLIT.getInfo(), SPLIT); assertEquals(SPLIT.isRemotelyAccessible(), false); }
assertSame(TimeZoneKey.getTimeZoneKey((short) 0), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("Z"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("Zulu"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("zulu"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("ZULU"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UCT"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("Universal"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT+00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("+00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("-00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/utc"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt+00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/gmt-00:00"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/ut"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/UT"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/UCT"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("etc/Universal"), UTC_KEY);
@Test public void testSanitizeStringValue() { assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 3), "pot"); assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 6), "pot"); assertEquals(StringUtil.sanitizeStringValue("potato", 2), "po"); assertEquals(StringUtil.sanitizeStringValue("pot\0ato", 2), "po"); String value = "potato"; assertSame(StringUtil.sanitizeStringValue(value, 6), value); assertSame(StringUtil.sanitizeStringValue(value, 7), value); } }
@Test public void onlyRelevantValidatorsAreBuilt() throws ProcessingException { final Map<String, JsonNode> digests = Maps.newTreeMap(); digests.put(K1, JacksonUtils.nodeFactory().nullNode()); final SchemaDigest digest = new SchemaDigest(null, digests); final ProcessingReport report = mock(ProcessingReport.class); final ValidatorList context = validatorBuilder.process(report, digest); final List<KeywordValidator> list = Lists.newArrayList(context); assertEquals(list.size(), 1); assertSame(list.get(0).getClass(), Keyword1.class); }
assertSame(TimeZoneKey.getTimeZoneKey("GMT0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-0"), UTC_KEY); assertTimeZoneNotSupported("GMT7"); assertSame(TimeZoneKey.getTimeZoneKey("GMT+7"), PLUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-7"), MINUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT+7"), PLUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("GMT-7"), MINUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT-0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT-0"), UTC_KEY); assertTimeZoneNotSupported("UT7"); assertSame(TimeZoneKey.getTimeZoneKey("UT+7"), PLUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT-7"), MINUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT+7"), PLUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UT-7"), MINUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC-0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC+0"), UTC_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC-0"), UTC_KEY); assertTimeZoneNotSupported("UTC7"); assertSame(TimeZoneKey.getTimeZoneKey("UTC+7"), PLUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC-7"), MINUS_7_KEY); assertSame(TimeZoneKey.getTimeZoneKey("UTC+7"), PLUS_7_KEY);
@Test public void allRelevantValidatorsAreBuilt() throws ProcessingException { final Map<String, JsonNode> digests = Maps.newTreeMap(); digests.put(K1, JacksonUtils.nodeFactory().nullNode()); digests.put(K2, JacksonUtils.nodeFactory().nullNode()); final SchemaDigest digest = new SchemaDigest(null, digests); final ProcessingReport report = mock(ProcessingReport.class); final ValidatorList context = validatorBuilder.process(report, digest); final List<KeywordValidator> list = Lists.newArrayList(context); assertEquals(list.size(), 2); assertSame(list.get(0).getClass(), Keyword1.class); assertSame(list.get(1).getClass(), Keyword2.class); }
@Test public void testJsonRoundTrip() { String json = SPLIT_CODEC.toJson(SPLIT); JmxSplit copy = SPLIT_CODEC.fromJson(json); assertEquals(copy.getTableHandle(), SPLIT.getTableHandle()); assertEquals(copy.getAddresses(), SPLIT.getAddresses()); assertSame(copy.getInfo(), copy); assertEquals(copy.isRemotelyAccessible(), false); } }
@Test public void testWithTimeoutAsMiddleOperation() { Task<String> task = delayedValue("value", 250, TimeUnit.MILLISECONDS).map("first", x -> x + 3) .withTimeout(5, TimeUnit.MILLISECONDS).map("second", x -> TASK_VALUE); try { runAndWait("TestFusionTask.testWithTimeoutAsMiddleOperation", task); fail("should have failed!"); } catch (Exception ex) { assertSame(ex.getCause().getClass(), Exceptions.TIMEOUT_EXCEPTION.getClass()); } }
@Test public void testWithTimeoutAsLastOperation() { Task<String> task = delayedValue("value", 250, TimeUnit.MILLISECONDS).map(x -> x + 1).map(x -> TASK_VALUE) .withTimeout(5, TimeUnit.MILLISECONDS); try { runAndWait("TestFusionTask.testWithTimeoutAsLastOperation", task); fail("should have failed!"); } catch (Exception ex) { assertSame(ex.getCause().getClass(), Exceptions.TIMEOUT_EXCEPTION.getClass()); } }
@Test public void testMinPageSizeThreshold() { Page page = createSequencePage(TYPES, 10); MergingPageOutput output = new MergingPageOutput(TYPES, page.getSizeInBytes(), Integer.MAX_VALUE, Integer.MAX_VALUE); assertTrue(output.needsInput()); assertNull(output.getOutput()); output.addInput(createPagesIterator(page)); assertFalse(output.needsInput()); assertSame(output.getOutput(), page); }
@Test public void defaultLibraryIsDraftV4() { final ValidationConfiguration defaultConfiguration = ValidationConfiguration.byDefault(); assertSame(defaultConfiguration.getDefaultLibrary(), DraftV4Library.get()); }
@Test public void testMinRowCountThreshold() { Page page = createSequencePage(TYPES, 10); MergingPageOutput output = new MergingPageOutput(TYPES, 1024 * 1024, page.getPositionCount(), Integer.MAX_VALUE); assertTrue(output.needsInput()); assertNull(output.getOutput()); output.addInput(createPagesIterator(page)); assertFalse(output.needsInput()); assertSame(output.getOutput(), page); }
@Test(dataProvider = "sampleData") public void onlyRelevantDigestsAreBuilt(final JsonNode node) throws ProcessingException { final NodeType type = NodeType.getNodeType(node); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema); final SchemaContext context = new SchemaContext(tree, type); final ProcessingReport report = mock(ProcessingReport.class); final SchemaDigest digest = schemaDigester.process(report, context); verify(digester1).digest(schema); verify(digester2).digest(schema); final Map<String,JsonNode> digests = digest.getDigests(); if (TYPES1.contains(type)) assertSame(digests.get(K1), digest1); else assertFalse(digests.containsKey(K1)); if (TYPES2.contains(type)) assertSame(digests.get(K2), digest2); else assertFalse(digests.containsKey(K2)); }
@Test public void testGetWithDefault() { Assert.assertTrue(MapUtil.getWithDefault(_subjectMap, "boolean", false)); Assert.assertFalse(MapUtil.getWithDefault(_subjectMap, "boolean_default", false)); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "integer", 11), (Integer) 1); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "integer_default", 11), (Integer) 11); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "long", 12L), (Long) 2L); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "long_default", 12L), (Long) 12L); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "float", 13F), 3F); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "float_default", 13F), 13F); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "double", 14D), 4D); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "double_default", 14D), 14D); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "string", "Bar"), "Foo"); Assert.assertEquals(MapUtil.getWithDefault(_subjectMap, "string_default", "Bar"), "Bar"); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "subMap", null, LinkedHashMap.class).getClass(), LinkedHashMap.class); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "subMap", _probeMap).getClass(), LinkedHashMap.class); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "subMap_default", _probeMap).getClass(), HashMap.class); Assert.assertNull(MapUtil.getWithDefault(_subjectMap, "subMap_default", null, Object.class)); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "siblingMap", null, Hashtable.class).getClass(), Hashtable.class); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "siblingMap", _probeMap, Map.class).getClass(), Hashtable.class); Assert.assertSame(MapUtil.getWithDefault(_subjectMap, "siblingMap_default", _probeMap, Map.class).getClass(), HashMap.class); }
@Test public void testSuppressedException() { RuntimeException runtimeException = new RuntimeException(); Exception exception = new Exception(); Error error = new Error(); AutoCloseableCloser closer = AutoCloseableCloser.create(); // add twice to test self suppression handling closer.register(failingCloseable(error)); closer.register(failingCloseable(error)); closer.register(failingCloseable(exception)); closer.register(failingCloseable(exception)); closer.register(failingCloseable(runtimeException)); closer.register(failingCloseable(runtimeException)); try { closer.close(); fail("expected to fail"); } catch (Throwable t) { assertSame(t, runtimeException); assertSame(t.getSuppressed()[0], exception); assertSame(t.getSuppressed()[1], exception); assertSame(t.getSuppressed()[2], error); assertSame(t.getSuppressed()[3], error); } }
@Test public void testCache() { PageFunctionCompiler cacheCompiler = new PageFunctionCompiler(createTestMetadataManager(), 100); assertSame( cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()), cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty())); assertSame( cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")), cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint"))); assertSame( cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")), cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2"))); assertSame( cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()), cacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2"))); PageFunctionCompiler noCacheCompiler = new PageFunctionCompiler(createTestMetadataManager(), 0); assertNotSame( noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()), noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty())); assertNotSame( noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")), noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint"))); assertNotSame( noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint")), noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2"))); assertNotSame( noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.empty()), noCacheCompiler.compileProjection(ADD_10_EXPRESSION, Optional.of("hint2"))); }
@Test public void testTransformFailureToFailure() { Task<String> failure = getFailureTask(); final Exception failureReason = new Exception(); Task<String> transformed = failure.transform(tryT -> Failure.of(failureReason)); try { runAndWait("AbstractTaskTest.testTransformFailureToFailure", transformed); fail("should have failed"); } catch (Exception ex) { assertTrue(transformed.isFailed()); } assertSame(transformed.getError(), failureReason); }
@Test public void testTransformSuccessToFailure() { Task<String> success = getSuccessTask(); final Exception failureReason = new Exception(); Task<String> transformed = success.transform(tryT -> Failure.of(failureReason)); try { runAndWait("AbstractTaskTest.testTransformSuccessToSuccess", transformed); fail("should have failed"); } catch (Exception ex) { assertTrue(transformed.isFailed()); } assertSame(transformed.getError(), failureReason); }