本文整理了Java中org.testng.Assert.assertSame()
方法的一些代码示例,展示了Assert.assertSame()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertSame()
方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertSame
[英]Asserts that two objects refer to the same object. If they do not, an AssertionError is thrown.
[中]断言两个对象引用同一个对象。如果没有,则抛出断言错误。
代码示例来源:origin: spring-projects/spring-framework
@Test(dependsOnMethods = { "verifyContextWasDirtied" })
public void verifyContextWasNotDirtied() {
assertSame(this.applicationContext, this.dirtiedApplicationContext,
"The application context should NOT have been 'dirtied'.");
}
代码示例来源:origin: prestodb/presto
@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);
}
}
代码示例来源:origin: prestodb/presto
@Test
public void testSplit()
{
assertEquals(SPLIT.getTableHandle(), TABLE);
assertEquals(SPLIT.getAddresses(), ADDRESSES);
assertSame(SPLIT.getInfo(), SPLIT);
assertEquals(SPLIT.isRemotelyAccessible(), false);
}
代码示例来源:origin: prestodb/presto
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);
代码示例来源:origin: apache/incubator-pinot
@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);
}
}
代码示例来源:origin: java-json-tools/json-schema-validator
@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);
}
代码示例来源:origin: prestodb/presto
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);
代码示例来源:origin: java-json-tools/json-schema-validator
@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);
}
代码示例来源:origin: prestodb/presto
@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);
}
}
代码示例来源:origin: linkedin/parseq
@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());
}
}
代码示例来源:origin: linkedin/parseq
@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());
}
}
代码示例来源:origin: prestodb/presto
@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);
}
代码示例来源:origin: java-json-tools/json-schema-validator
@Test
public void defaultLibraryIsDraftV4()
{
final ValidationConfiguration defaultConfiguration
= ValidationConfiguration.byDefault();
assertSame(defaultConfiguration.getDefaultLibrary(),
DraftV4Library.get());
}
代码示例来源:origin: prestodb/presto
@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);
}
代码示例来源:origin: java-json-tools/json-schema-validator
@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));
}
代码示例来源:origin: linkedin/rest.li
@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);
}
代码示例来源:origin: prestodb/presto
@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);
}
}
代码示例来源:origin: prestodb/presto
@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")));
}
代码示例来源:origin: linkedin/parseq
@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);
}
代码示例来源:origin: linkedin/parseq
@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);
}
内容来源于网络,如有侵权,请联系作者删除!