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


Java Assert.assertNull方法代碼示例

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


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

示例1: testSerializationNullData

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testSerializationNullData() {
    GroupDataSummary summary = new GroupDataSummary();
    summary.setData(null);

    byte[] serialized = summary.toByteArray();
    Assert.assertNotNull(serialized);

    Memory memory = new NativeMemory(serialized);

    byte initializedByte = memory.getByte(GroupDataSummary.INITIALIZED_POSITION);
    int length = memory.getInt(GroupDataSummary.SIZE_POSITION);
    byte[] dataSerialized = new byte[length];
    memory.getByteArray(GroupDataSummary.DATA_POSITION, dataSerialized, 0, length);
    CachingGroupData data = SerializerDeserializer.fromBytes(dataSerialized);

    Assert.assertTrue(initializedByte == 0);
    Assert.assertTrue(length > 0);
    Assert.assertNull(data);
}
 
開發者ID:yahoo,項目名稱:bullet-core,代碼行數:21,代碼來源:GroupDataSummaryTest.java

示例2: testRequestNoneActiveIntermediate

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testRequestNoneActiveIntermediate() {
    final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
    authCtx.getIntermediateFlows().put("test2", authCtx.getPotentialFlows().get("test2"));
    final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
            "test2"));
    final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
    rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
            new ExactPrincipalEvalPredicateFactory());
    rpc.setOperator("exact");
    rpc.setRequestedPrincipals(principals);
    authCtx.addSubcontext(rpc, true);
    authCtx.getPotentialFlows().get("test2").setSupportedPrincipals(principals);
    authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(principals);

    action.execute(src);

    Assert.assertNull(authCtx.getAuthenticationResult());
    Assert.assertEquals(authCtx.getAttemptedFlow().getId(), "test3");
}
 
開發者ID:CSCfi,項目名稱:shibboleth-idp-oidc-extension,代碼行數:21,代碼來源:SelectAuthenticationFlowTest.java

示例3: folderRecursiveOneFoundTest

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void folderRecursiveOneFoundTest() {
    FindFiles findFiles =  new FindFiles("resources", true).setIncludeFiles(false).setIncludeFolders(true);
    TUExecutionResult executionResult = findFiles.execution(transformedAppFolder, transformationContext);
    Assert.assertEquals(executionResult.getType(), TUExecutionResult.Type.VALUE);
    Assert.assertNotNull(executionResult.getValue());

    List<File> files = (List<File>) executionResult.getValue();
    Assert.assertEquals(files.size(), 1);

    Assert.assertTrue(files.contains(new File(transformedAppFolder, "/src/main/resources")));
    Assert.assertEquals(findFiles.getNameRegex(), "resources");
    Assert.assertNull(findFiles.getPathRegex());
    Assert.assertTrue(findFiles.isRecursive());
    Assert.assertFalse(findFiles.isIncludeFiles());
    Assert.assertTrue(findFiles.isIncludeFolders());
    Assert.assertEquals(findFiles.getDescription(), "Find files whose name and/or path match regular expression and are under the root folder and sub-folders");
    Assert.assertNull(executionResult.getException());
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:20,代碼來源:FindFilesTest.java

示例4: testMatchPolicyWithNoTargetAction

import org.testng.Assert; //導入方法依賴的package包/類
/**
 * Tests matching a blanket policy to a request.
 *
 * @throws IOException
 *             on failure to load policy required for test.
 */
public void testMatchPolicyWithNoTargetAction() throws IOException {
    File file = getPolicyFileForTest(getMethodName());
    PolicySet policySet = PolicySets.loadFromFile(file);
    List<Policy> policies = policySet.getPolicies();

    PolicyMatchCandidate candidate = new PolicyMatchCandidate();
    candidate.setAction("GET");
    candidate.setResourceURI("/this/does/not/exist");
    candidate.setSubjectIdentifier("Edward R. Murrow");
    candidate.setSupplementalResourceAttributes(Collections.emptySet());
    candidate.setSupplementalSubjectAttributes(Collections.emptySet());
    List<MatchedPolicy> matchedPolicies = this.policyMatcher.match(candidate, policies);
    Assert.assertEquals(matchedPolicies.size(), 1);
    Assert.assertEquals(matchedPolicies.get(0).getPolicy(), policies.get(policies.size() - 1));
    Assert.assertNull(matchedPolicies.get(0).getPolicy().getTarget());
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:23,代碼來源:PolicyMatcherImplTest.java

示例5: listTest

import org.testng.Assert; //導入方法依賴的package包/類
@Test(dependsOnMethods = "createTest")
public void listTest()
{
	ArrayNode all = institutions.list();

	boolean scratchyFound = false;
	boolean newFound = false;

	for( JsonNode inst : all )
	{
		if( "AutoTest".equals(inst.get("name").asText()) )
		{
			scratchyFound = true;
			Assert.assertEquals(inst.get("filestoreId").asText(), "autotest");
			Assert.assertTrue(inst.get("enabled").asBoolean());
			Assert.assertTrue(inst.get("url").asText().endsWith("/autotest/"));
			Assert.assertNull(inst.get("password"));
		}
		else if( INST_NAME.equals(inst.get("name").asText()) )
		{
			newFound = true;
			Assert.assertEquals(inst.get("filestoreId").asText(), INST_NAME);
			Assert.assertTrue(inst.get("enabled").asBoolean());
			Assert.assertTrue(inst.get("url").asText().endsWith("/" + INST_NAME + "/"));
			Assert.assertNull(inst.get("password"));
		}
		if( scratchyFound && newFound )
		{
			break;
		}
	}
	Assert.assertTrue(scratchyFound, "Scratchy not found");
	Assert.assertTrue(newFound, "New institution not found");
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:InstitutionApiTest.java

示例6: evalInvalidRegexTest

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void evalInvalidRegexTest() {
    RegexMatch regexMatch;
    TUExecutionResult executionResult;

    regexMatch = new RegexMatch().relative("/src/main/resources/dogs.yaml");
    regexMatch.setRegex("*Mustache*");
    executionResult = regexMatch.execution(transformedAppFolder, transformationContext);
    Assert.assertEquals(executionResult.getType(), TUExecutionResult.Type.ERROR);
    Assert.assertNull(executionResult.getValue());
    Assert.assertEquals(executionResult.getException().getClass(), PatternSyntaxException.class);
    Assert.assertEquals(executionResult.getException().getMessage(), "Dangling meta character '*' near index 0\n*Mustache*\n^");
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:14,代碼來源:RegexMatchTest.java

示例7: testMaxUnackedMessages

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testMaxUnackedMessages() throws PubSubException {
    String randomMessage = UUID.randomUUID().toString();
    String randomID = UUID.randomUUID().toString();

    KafkaConsumer<String, byte[]> consumer = makeMockConsumer(randomID, randomMessage);
    KafkaSubscriber subscriber = new KafkaSubscriber(consumer, 1);
    // Multiple receives without a commit.
    Assert.assertNotNull(subscriber.receive());
    Assert.assertNull(subscriber.receive());
}
 
開發者ID:yahoo,項目名稱:bullet-kafka,代碼行數:12,代碼來源:KafkaSubscriberTest.java

示例8: testWeb

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testWeb() throws ComponentInitializationException {
    OIDCClientMetadata input = new OIDCClientMetadata();
    input.setApplicationType(ApplicationType.WEB);
    OIDCClientMetadata result = new OIDCClientMetadata();
    setUpContext(input, result);
    Assert.assertNull(action.execute(requestCtx));
    Assert.assertEquals(result.getApplicationType(), ApplicationType.WEB);
}
 
開發者ID:CSCfi,項目名稱:shibboleth-idp-oidc-extension,代碼行數:10,代碼來源:AddApplicationTypeToClientMetadataTest.java

示例9: testUnimplementedStrategies

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testUnimplementedStrategies() {
    Aggregation aggregation = new Aggregation();
    aggregation.setType(null);
    aggregation.configure(new BulletConfig());

    Assert.assertNull(aggregation.getStrategy());
}
 
開發者ID:yahoo,項目名稱:bullet-core,代碼行數:9,代碼來源:AggregationTest.java

示例10: testAddElementToNullNsNoDeclarations

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

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

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

示例11: getProduct_should_return_null_if_product_is_not_set

import org.testng.Assert; //導入方法依賴的package包/類
@Test(groups = "StockConfig.getProduct")
public void getProduct_should_return_null_if_product_is_not_set()
        throws StockException {
    StockConfig config = new StockConfig();

    Assert.assertNull(config.getProduct());
}
 
開發者ID:adobe,項目名稱:stock-api-sdk,代碼行數:8,代碼來源:StockConfigTest.java

示例12: getProductByDownloadableFilename

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void getProductByDownloadableFilename ()
{
   fr.gael.dhus.database.object.Collection validCollection;
   fr.gael.dhus.database.object.Collection invalidCollection;
   Product product;

   validCollection = new Collection ();
   validCollection.setUUID ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3");
   validCollection.setName ("Japan");

   invalidCollection = new Collection ();
   invalidCollection.setUUID ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4");
   invalidCollection.setName ("China");

   product = dao.getProductByDownloadableFilename("prod0",validCollection);
   Assert.assertNotNull(product);
   Assert.assertEquals(product.getId ().intValue(), 0);

   product = dao.getProductByDownloadableFilename("prod6",validCollection);
   Assert.assertNull(product);

   product = dao.getProductByDownloadableFilename("prod0",invalidCollection);
   Assert.assertNull (product);

   product = dao.getProductByDownloadableFilename("prod6",null);
   Assert.assertNotNull(product);
   Assert.assertEquals(product.getId ().intValue (), 6);

   product = dao.getProductByDownloadableFilename (null, null);
   Assert.assertNull (product);
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:33,代碼來源:TestProductDao.java

示例13: assertViewerAndPreview

import org.testng.Assert; //導入方法依賴的package包/類
public void assertViewerAndPreview(JsonNode attachment, String viewer, boolean preview)
{
	JsonNode viewerNode = attachment.get("viewer");
	if( viewer == null )
	{
		Assert.assertNull(viewerNode);
	}
	else
	{
		Assert.assertEquals(viewerNode.asText(), viewer);
	}
	Assert.assertEquals(attachment.get("preview").asBoolean(), preview);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:ApiAssertions.java

示例14: defaultUsageWithNullFallback

import org.testng.Assert; //導入方法依賴的package包/類
@Test(groups = "fast")
public void defaultUsageWithNullFallback() {
    // given
    List<InvoiceItem> items = setupDefaultInvoice(null, null, null, null, null);

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

    // then
    Assert.assertNull(result,
            "Default resolves null when start/end/invoice/item created/invoice created dates mising");
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:15,代碼來源:SimpleTaxDateResolverTests.java

示例15: delete

import org.testng.Assert; //導入方法依賴的package包/類
@Override
public void delete ()
{
   long id = 5;
   dao.delete (dao.read (id));
   Assert.assertEquals (dao.count (), (howMany () - 1));
   Assert.assertNull (dao.read (id));
   Assert.assertNotNull (udao.read ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3"));
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:10,代碼來源:TestNetworkUsageDao.java


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