当前位置: 首页>>代码示例>>Java>>正文


Java Assert.assertSame方法代码示例

本文整理汇总了Java中org.testng.Assert.assertSame方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertSame方法的具体用法?Java Assert.assertSame怎么用?Java Assert.assertSame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.testng.Assert的用法示例。


在下文中一共展示了Assert.assertSame方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sortedMapTest

import org.testng.Assert; //导入方法依赖的package包/类
/** Tests if maps correctly. */
@Test
public void sortedMapTest()
{
   SortedMap<Integer, String> sorted_map = new SortedMap<>(dataSet, cmp);
   Assert.assertEquals(sorted_map.size(), dataSet.size());

   for (Map.Entry<Integer, String> entry: sorted_map.entrySet())
   {
      Assert.assertSame(entry.getValue(), dataSet.get(entry.getKey()));
   }

   Assert.assertTrue(sorted_map.values().containsAll(dataSet.values()));
   Assert.assertTrue(dataSet.values().containsAll(sorted_map.values()));

   Assert.assertTrue(sorted_map.keySet().containsAll(dataSet.keySet()));
   Assert.assertTrue(dataSet.keySet().containsAll(sorted_map.keySet()));
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:SortedMapTest.java

示例2: test

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void test() throws IOException{
	String sentBody = "{ 'key': 'value' }";
	Charset charset = StandardCharsets.UTF_8;
	StringEntity sentEntity = new StringEntity(sentBody, charset);
	HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	Mockito.doAnswer(any -> new CachingServletInputStream(sentEntity.getContent()))
			.when(request).getInputStream();

	CachingHttpServletRequest cachingRequest = CachingHttpServletRequest.getOrCreate(request);
	// test repeat reads
	for(int i = 0; i < 5; i++){
		InputStreamEntity entity = new InputStreamEntity(request.getInputStream());
		String receivedBody = EntityUtils.toString(entity, charset);
		Assert.assertEquals(sentBody, receivedBody);

		receivedBody = EntityUtils.toString(new InputStreamEntity(cachingRequest.getInputStream()), charset);
		Assert.assertEquals(sentBody, receivedBody);
	}

	Assert.assertSame(CachingHttpServletRequest.getOrCreate(cachingRequest), cachingRequest);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:23,代码来源:CachingHttpServletRequestTests.java

示例3: checkLastHandler

import org.testng.Assert; //导入方法依赖的package包/类
@Test()
static void checkLastHandler() {
    if (RUNNING_WITH_Xrs) {
        return;
    }
    Signal signal = new Signal("TERM");
    Handler h1 = new Handler();
    Handler h2 = new Handler();
    SignalHandler orig = Signal.handle(signal, h1);
    if (orig == SignalHandler.SIG_IGN) {
        // SIG_IGN for TERM means it cannot be handled
        return;
    }

    try {
        SignalHandler prev = Signal.handle(signal, h2);
        Assert.assertSame(prev, h1, "prev handler mismatch");

        prev = Signal.handle(signal, h1);
        Assert.assertSame(prev, h2, "prev handler mismatch");
    } finally {
        if (orig != null && signal != null) {
            Signal.handle(signal, orig);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SunMiscSignalTest.java

示例4: test3

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void test3() throws Exception {
    SAXTransformerFactory sf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    Transformer t = sf.newTransformer();

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder parser = dbf.newDocumentBuilder();
    Document dom = parser.parse(Bug5072946.class.getResourceAsStream("Bug5072946.xml"));

    DOMResult r = new DOMResult();

    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());

    Node n = r.getNode().getFirstChild();
    r.setNode(n);
    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());
    Assert.assertSame(r.getNode(), n);

    r.setNextSibling(r.getNode().getFirstChild());
    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());
    Assert.assertSame(r.getNode(), n);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Bug5072946.java

示例5: paramSelectorShiftParam

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void paramSelectorShiftParam() {
	final List<Shift> shifts = singletonList(Shift.DEFAULT);
	final List<Param> params = singletonList(Param.DEFAULT);

	final ParamSelector selector = new ParamSelector(shifts, params);
	final byte[] seed = selector.seed();

	Assert.assertSame(selector.shift(), shifts.get(0));
	Assert.assertSame(selector.param(), params.get(0));

	for (int i = 0; i < 100; ++i) {
		selector.next();
		Assert.assertFalse(Arrays.equals(seed, selector.seed()));
		Assert.assertSame(selector.shift(), shifts.get(0));
		Assert.assertSame(selector.param(), params.get(0));
	}
}
 
开发者ID:jenetics,项目名称:prngine,代码行数:19,代码来源:XOR32ShiftRandomTest.java

示例6: noInvoiceDateFallbackUsage

import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = "fast")
public void noInvoiceDateFallbackUsage() {
    // given
    final DateTime invoiceItemCreatedDate = new DateTime();
    List<InvoiceItem> items = setupDefaultInvoice(now, invoiceItemCreatedDate,
            TEST_INVOICE_DATE, null, null);

    // when
    SimpleTaxDateResolver resolver = createResolver(
            configureFallbackToInvoiceDate(new Properties(), false));
    DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
            Collections.emptyList());

    // then
    Assert.assertSame(result, invoiceItemCreatedDate,
            "Disabling invoice date fallback resolves invoice item created date");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:18,代码来源:SimpleTaxDateResolverTests.java

示例7: noInvoiceItemCreatedDateFallbackUsage

import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = "fast")
public void noInvoiceItemCreatedDateFallbackUsage() {
    // given
    final DateTime invoiceCreatedDate = new DateTime();
    List<InvoiceItem> items = setupDefaultInvoice(invoiceCreatedDate, now, TEST_INVOICE_DATE,
            null, null);

    // when
    SimpleTaxDateResolver resolver = createResolver(configureFallbackToInvoiceItemCreatedDate(
            configureFallbackToInvoiceDate(new Properties(), false), false));
    DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
            Collections.emptyList());

    // then
    Assert.assertSame(result, invoiceCreatedDate,
            "Disabling invoice item created date fallback resolves invoice created date");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:18,代码来源:SimpleTaxDateResolverTests.java

示例8: testValidateAlreadyCached

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testValidateAlreadyCached() throws IOException{
	byte[] bytes = "{ 'key': 'value' }".getBytes(StandardCharsets.UTF_8);
	HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	Mockito.doReturn(new CachingServletInputStream(new ByteArrayInputStream(bytes))).when(request).getInputStream();
	Mockito.doReturn(toParamMap(params)).when(request).getParameterMap();
	CachingHttpServletRequest cachingRequest = CachingHttpServletRequest.getOrCreate(request);
	Assert.assertNotNull(cachingRequest.getContent());
	Mockito.reset(request);

	SecurityValidationResult result = validator.validate(cachingRequest);
	Mockito.verify(request, Mockito.never()).getInputStream();
	Assert.assertSame(result.getWrappedRequest(), cachingRequest);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:15,代码来源:DefaultSignatureValidatorTests.java

示例9: testCreateMethods

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testCreateMethods(){
	HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	Assert.assertTrue(SecurityValidationResult.success(request).isSuccess());
	Assert.assertSame(SecurityValidationResult.success(request).getWrappedRequest(), request);
	Assert.assertNull(SecurityValidationResult.success(request).getFailureMessage());
	Assert.assertFalse(SecurityValidationResult.failure(request).isSuccess());
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:9,代码来源:SecurityValidationResultTests.java

示例10: testGlobal

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public static void testGlobal() throws Exception {
    final String name = "testGlobal";
    final Symbol symbol1 = (Symbol)NativeSymbol._for(null, name);
    final Symbol symbol2 = serializeRoundTrip(symbol1);
    Assert.assertSame(symbol1, symbol2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JDK_8142924_Test.java

示例11: parseAndCheckReset

import org.testng.Assert; //导入方法依赖的package包/类
private void parseAndCheckReset(boolean setFeature, boolean value) throws Exception {
    // Expected result based on system property and feature
    boolean resetExpected = setFeature && value;
    // Indicates if system property is set
    boolean spSet = runWithAllPerm(() -> System.getProperty(RESET_FEATURE)) != null;
    // Dummy xml input for parser
    String input = "<dummy>Test</dummy>";

    // Check if system property is set only when feature setting is not requested
    // and estimate if reset of symbol table is expected
    if (!setFeature && spSet) {
        resetExpected = runWithAllPerm(() -> Boolean.getBoolean(RESET_FEATURE));
    }

    // Create SAXParser and set feature if it is requested
    SAXParserFactory spf = SAXParserFactory.newInstance();
    if (setFeature) {
        spf.setFeature(RESET_FEATURE, value);
    }
    SAXParser p = spf.newSAXParser();

    // First parse iteration
    p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
    // Get first symbol table reference
    Object symTable1 = p.getProperty(SYMBOL_TABLE_PROPERTY);

    // reset parser
    p.reset();

    // Second parse iteration
    p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
    // Get second symbol table reference
    Object symTable2 = p.getProperty(SYMBOL_TABLE_PROPERTY);

    // Check symbol table references after two subsequent parse operations
    if (resetExpected) {
        Assert.assertNotSame(symTable1, symTable2, "Symbol table references");
    } else {
        Assert.assertSame(symTable1, symTable2, "Symbol table references");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:SymbolTableResetTest.java

示例12: defaultUsageWithInvoiceItemCreatedDateFallback

import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = "fast")
public void defaultUsageWithInvoiceItemCreatedDateFallback() {
    // given
    DateTime itemCreatedDate = new DateTime();
    List<InvoiceItem> items = setupDefaultInvoice(now, itemCreatedDate, null, null, null);

    // when
    SimpleTaxDateResolver resolver = createResolver(new Properties());
    DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
            Collections.emptyList());

    // then
    Assert.assertSame(result, itemCreatedDate,
            "Default resolves item created date when start/end/invoice dates mising");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:16,代码来源:SimpleTaxDateResolverTests.java

示例13: defaultUsageWithInvoiceCreatedDateFallback

import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = "fast")
public void defaultUsageWithInvoiceCreatedDateFallback() {
    // given
    DateTime invoiceCreatedDate = new DateTime();
    List<InvoiceItem> items = setupDefaultInvoice(invoiceCreatedDate, null, null, null, null);

    // when
    SimpleTaxDateResolver resolver = createResolver(new Properties());
    DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
            Collections.emptyList());

    // then
    Assert.assertSame(result, invoiceCreatedDate,
            "Default resolves null when start/end/invoice/item created dates mising");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:16,代码来源:SimpleTaxDateResolverTests.java


注:本文中的org.testng.Assert.assertSame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。