當前位置: 首頁>>代碼示例>>Java>>正文


Java Assert類代碼示例

本文整理匯總了Java中org.testng.Assert的典型用法代碼示例。如果您正苦於以下問題:Java Assert類的具體用法?Java Assert怎麽用?Java Assert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Assert類屬於org.testng包,在下文中一共展示了Assert類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: system_size

import org.testng.Assert; //導入依賴的package包/類
@Test
public void system_size() throws IOException, CompressorException, ArchiveException
{
   ProcessingManager mgr = new ProcessingManager();
   long size = mgr.system_size(sample);
   Assert.assertEquals(size, 494928);
   
   File folder=sample.getParentFile();
   File extaction_folder=new File(folder, "unzip");
   extaction_folder.mkdirs();
   
   UnZip.unCompress(sample.getAbsolutePath(), 
      extaction_folder.getAbsolutePath());
   
   File tocheck = extaction_folder.listFiles()[0];
   size = mgr.system_size(tocheck);
   Assert.assertEquals(size, SIZE, tocheck.getAbsolutePath());
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:19,代碼來源:ProcessingManagerTest.java

示例2: testOAuthWithTokenLogin

import org.testng.Assert; //導入依賴的package包/類
@Test(enabled = false)
public void testOAuthWithTokenLogin() throws Exception
{
	HttpResponse response = defaultClientTokenRequest("token",
		TokenSecurity.createSecureToken("AutoTest", "token", "token", null));
	String string = EntityUtils.toString(response.getEntity());

	Assert.assertTrue(string.contains("oal_allowButton"), "Should be logged in");

	response = defaultClientTokenRequestPost("event__", "oal.allowAccess");
	Assert.assertTrue(hasAccessToken(response));

	// we should be able to make REST calls with this token as the AutoTest
	// user
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:16,代碼來源:OAuthTest.java

示例3: testToFromByteArray

import org.testng.Assert; //導入依賴的package包/類
@Test
public void testToFromByteArray(){
	boolean one = true;
	boolean two = false;
	boolean three = false;

	List<Boolean> booleans = new ArrayList<>();
	booleans.add(one);
	booleans.add(null);
	booleans.add(null);
	booleans.add(two);
	booleans.add(three);

	byte[] booleanBytes = getBooleanByteArray(booleans);
	List<Boolean> result = fromBooleanByteArray(booleanBytes, 0);
	Assert.assertEquals(result, booleans);

}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:19,代碼來源:BooleanByteTool.java

示例4: successAllTest

import org.testng.Assert; //導入依賴的package包/類
@Test
public void successAllTest() throws IOException {
    ReplaceText replaceText = new ReplaceText("foo").setReplacement("zoo").relative("/src/main/resources/application.properties").setFirstOnly(false);
    TOExecutionResult executionResult = replaceText.execution(transformedAppFolder, transformationContext);
    Assert.assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);

    assertChangedFile("/src/main/resources/application.properties");
    assertSameLineCount("/src/main/resources/application.properties");

    Properties properties = getProperties("/src/main/resources/application.properties");

    Assert.assertEquals(properties.size(), 3);
    Assert.assertEquals(properties.getProperty("bar"), "barv");
    Assert.assertEquals(properties.getProperty("zoo"), "zoov");
    Assert.assertEquals(properties.getProperty("zoozoo"), "zoozoov");
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:17,代碼來源:ReplaceTextTest.java

示例5: testAddElementToGlobalNs

import org.testng.Assert; //導入依賴的package包/類
@Test
public void testAddElementToGlobalNs() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    parentExplicitNS.addNamespaceDeclaration("", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", "");
    childGlobalNS.addNamespaceDeclaration("", "");
    SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child");
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertNull(grandChildGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:SaajEmptyNamespaceTest.java

示例6: testFactoryFind

import org.testng.Assert; //導入依賴的package包/類
@Test
public void testFactoryFind() throws Exception {
    TransformerFactory factory = TransformerFactory.newInstance();
    Assert.assertTrue(factory.getClass().getClassLoader() == null);

    runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
    factory = TransformerFactory.newInstance();
    Assert.assertTrue(factory.getClass().getClassLoader() == null);

    runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(new MyClassLoader()));
    factory = TransformerFactory.newInstance();
    if (System.getSecurityManager() == null)
        Assert.assertTrue(myClassLoaderUsed);
    else
        Assert.assertFalse(myClassLoaderUsed);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:FactoryFindTest.java

示例7: 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

示例8: testSAX

import org.testng.Assert; //導入依賴的package包/類
public void testSAX(boolean setUseCatalog, boolean useCatalog, String catalog,
        String xml, MyHandler handler, String expected) throws Exception {
    SAXParser parser = getSAXParser(setUseCatalog, useCatalog, catalog);

    parser.parse(xml, handler);
    Assert.assertEquals(handler.getResult().trim(), expected);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:CatalogSupportBase.java

示例9: nonStemmedAnalyzeTest

import org.testng.Assert; //導入依賴的package包/類
@Test
public void nonStemmedAnalyzeTest() {
    ModelMetadata metadata = ModelMetadata.createDefault().applyStemmer(0);
    IndraAnalyzer analyzer = new IndraAnalyzer(LANG, metadata);
    String loveString = "love";
    List<String> res = analyzer.analyze(loveString);

    Assert.assertEquals(res.size(), 1);
    Assert.assertEquals(res.get(0), loveString);

    loveString = "LOVE";
    res = analyzer.analyze(loveString);

    Assert.assertEquals(res.size(), 1);
    Assert.assertEquals(res.get(0), loveString.toLowerCase());
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:17,代碼來源:IndraAnalyzerEnglishTest.java

示例10: assertEqualTrees

import org.testng.Assert; //導入依賴的package包/類
/**
 * This wrapper method allows for potential post-processing, such as
 * removing tags that we don't care to compare in {@code returnedTree}.
 * 
 * @param returnedTree The returned tree from the web service.
 * @param expectedTree The simulated tree that we expect.
 */
private void assertEqualTrees(ConsumableTree<TestSpan> returnedTree,
        ConsumableTree<TestSpan> expectedTree) {
    
    // It's okay if the returnedTree has tags other than the ones we
    // want to compare, so just remove those
    returnedTree.visitTree(span -> span.getTags().keySet()
            .removeIf(key -> !key.equals(Tags.SPAN_KIND.getKey())
                    && !key.equals(Tags.HTTP_METHOD.getKey())
                    && !key.equals(Tags.HTTP_URL.getKey())
                    && !key.equals(Tags.HTTP_STATUS.getKey())
                    && !key.equals(TestServerWebServices.LOCAL_SPAN_TAG_KEY)));
    
    // It's okay if the returnedTree has log entries other than the ones we
    // want to compare, so just remove those
    returnedTree.visitTree(span -> span.getLogEntries()
            .removeIf(logEntry -> true));
    
    Assert.assertEquals(returnedTree, expectedTree);
}
 
開發者ID:eclipse,項目名稱:microprofile-opentracing,代碼行數:27,代碼來源:OpentracingClientTests.java

示例11: testBoolean

import org.testng.Assert; //導入依賴的package包/類
@Test
public void testBoolean(){
	ManyFieldBean bean = new ManyFieldBean();

	//test true value
	bean.setBooleanField(true);
	mapNode.put(bean, null);
	ManyFieldBean roundTripped = mapNode.get(bean.getKey(), null);
	Assert.assertNotSame(roundTripped, bean);
	Assert.assertEquals(roundTripped.getBooleanField(), bean.getBooleanField());

	//test false value
	bean.setBooleanField(false);
	mapNode.put(bean, null);
	ManyFieldBean roundTrippedFalse = mapNode.get(bean.getKey(), null);
	Assert.assertNotSame(roundTrippedFalse, bean);
	Assert.assertEquals(roundTrippedFalse.getBooleanField(), bean.getBooleanField());

}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:20,代碼來源:BaseManyFieldIntegrationTests.java

示例12: testCreateByIterable4

import org.testng.Assert; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test(dataProvider = "arrays")
public <T> void testCreateByIterable4(Array<T> array) {
    final List<T> list = array.stream().values().collect(Collectors.toList());
    final Index<T> index1 = Index.of((Iterable)list);
    final Index<T> index2 = Index.of((Collection)list);
    Assert.assertEquals(index1.size(), list.size(), "Size matches array length");
    Assert.assertEquals(index2.size(), list.size(), "Size matches array length");
    for (int i=0; i<index1.size(); ++i) {
        final T key = index1.getKey(i);
        Assert.assertEquals(key, list.get(i), "Key matches array value at " + i);
        Assert.assertEquals(index1.getIndexForKey(key), i, "Index matches for ordinal " + i);
        Assert.assertEquals(index1.getOrdinalForKey(key), i, "Ordinals match");
        Assert.assertEquals(index1.getIndexForOrdinal(i), i, "Ordinal and index match");
        Assert.assertEquals(index2.getIndexForKey(key), index1.getIndexForKey(key), "Index matches for ordinal " + i);
        Assert.assertEquals(index2.getOrdinalForKey(key), index1.getOrdinalForKey(key), "Ordinals match");
        Assert.assertEquals(index2.getIndexForOrdinal(i), index1.getIndexForOrdinal(i), "Ordinal and index match");
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:20,代碼來源:IndexCreateTests.java

示例13: testPOSTResourcesMissingIdentifier

import org.testng.Assert; //導入依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void testPOSTResourcesMissingIdentifier() throws Exception {
    List<BaseResource> resources = JSON_UTILS
            .deserializeFromFile("controller-test/missing-identifier-resources-collection.json", List.class);

    Assert.assertNotNull(resources);

    // Append a list of resources
    MockMvcContext postContext =
        TEST_UTILS.createWACWithCustomPOSTRequestBuilder(this.wac, this.testZone.getSubdomain(), RESOURCE_BASE_URL);
    postContext.getMockMvc()
            .perform(postContext.getBuilder().contentType(MediaType.APPLICATION_JSON)
                    .content(OBJECT_MAPPER.writeValueAsString(resources)))
            .andExpect(status().isUnprocessableEntity());

}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:18,代碼來源:ResourcePrivilegeManagementControllerIT.java

示例14: testRepairNotification

import org.testng.Assert; //導入依賴的package包/類
@Test
   public void testRepairNotification(){
	Notifications noti = new Notifications();
	noti.setAntennaClient(antennaClientMock);
	noti.setCmProcessor(cmProcessorMock);
	noti.setEnvProcessor(envProcessorMock);
	EventUtil eventUtil = new EventUtil();
	eventUtil.setGson(new Gson());
	noti.setEventUtil(eventUtil);
	CiChangeStateEvent event = getCiChangeEvent(UNHEALTHY, NOTIFY, OPEN, NEW);
	OpsBaseEvent opsEvent = eventUtil.getOpsEvent(event);
	NotificationMessage message = noti.sendRepairNotification(event, null);
	String subject = message.getSubject();
	String text = message.getText();
	Assert.assertEquals(subject, getSubjPrefix()+opsEvent.getName()+SUBJECT_SUFFIX_OPEN_EVENT);
	Assert.assertEquals(text, CI_NAME +" is in "+event.getNewState()+" state"+TEXT_NOTE_SEPERATOR+Notifications.REPAIR_IN_PROGRESS);
	Assert.assertEquals(message.getSource(),"ops");
	Assert.assertEquals(message.getPayload().get(Notifications.CLASS_NAME),MOCK_CI_CLASS_NAME);
	Assert.assertEquals(message.getPayload().get(Notifications.OLD_STATE),NOTIFY);
	Assert.assertEquals(message.getPayload().get(Notifications.NEW_STATE),UNHEALTHY);
	Assert.assertEquals(message.getPayload().get(Notifications.STATUS),NEW);
	Assert.assertEquals(message.getPayload().get(Notifications.STATE),OPEN);
	Assert.assertEquals(message.getSeverity(), NotificationSeverity.warning);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:25,代碼來源:NotificationsTest.java

示例15: testLowerAndHigherValueOnSortedStringArray

import org.testng.Assert; //導入依賴的package包/類
@Test()
public void testLowerAndHigherValueOnSortedStringArray() {
    final Array<String> array = Array.of("a", "c", "e", "g", "i", "k", "m", "o", "q", "s", "u", "w", "y");

    Assert.assertEquals(array.previous("e").map(ArrayValue::getValue).get(), "c", "Lower value than e");
    Assert.assertEquals(array.previous("g").map(ArrayValue::getValue).get(), "e", "Lower value than g");
    Assert.assertEquals(array.previous("i").map(ArrayValue::getValue).get(), "g", "Lower value than i");
    Assert.assertEquals(array.previous("q").map(ArrayValue::getValue).get(), "o", "Lower value than q");
    Assert.assertEquals(array.previous("b").map(ArrayValue::getValue).get(), "a", "Lower value than e");
    Assert.assertEquals(array.previous("f").map(ArrayValue::getValue).get(), "e", "Lower value than g");
    Assert.assertEquals(array.previous("h").map(ArrayValue::getValue).get(), "g", "Lower value than i");
    Assert.assertEquals(array.previous("p").map(ArrayValue::getValue).get(), "o", "Lower value than q");

    Assert.assertEquals(array.next("e").map(ArrayValue::getValue).get(), "g", "Lower value than e");
    Assert.assertEquals(array.next("g").map(ArrayValue::getValue).get(), "i", "Lower value than g");
    Assert.assertEquals(array.next("i").map(ArrayValue::getValue).get(), "k", "Lower value than i");
    Assert.assertEquals(array.next("q").map(ArrayValue::getValue).get(), "s", "Lower value than q");
    Assert.assertEquals(array.next("b").map(ArrayValue::getValue).get(), "c", "Lower value than e");
    Assert.assertEquals(array.next("f").map(ArrayValue::getValue).get(), "g", "Lower value than g");
    Assert.assertEquals(array.next("h").map(ArrayValue::getValue).get(), "i", "Lower value than i");
    Assert.assertEquals(array.next("p").map(ArrayValue::getValue).get(), "q", "Lower value than q");
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:23,代碼來源:ArraysBasicTests.java


注:本文中的org.testng.Assert類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。