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


Java Assert.assertNotNull方法代碼示例

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


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

示例1: initialize_should_return_httpClient_object

import org.testng.Assert; //導入方法依賴的package包/類
@Test(groups = "HttpsUtils.initialize")
public void initialize_should_return_httpClient_object() {
    Method method = null;
    try {
        method = HttpUtils.class.getDeclaredMethod("initialize");
        method.setAccessible(true);

        HttpClient httpClient = (HttpClient) method.invoke(null);

        method.setAccessible(false);
        Assert.assertNotNull(httpClient);
        Assert.assertTrue(httpClient instanceof CloseableHttpClient);
    } catch (Exception e) {
        try {
            if (method != null)
                method.setAccessible(false);
        } catch (Exception e1) {
            Assert.fail("Unable to make initialize method private again!");
        }
        Assert.fail("initialize method invocation failed with reflection!");
    }
}
 
開發者ID:adobe,項目名稱:stock-api-sdk,代碼行數:23,代碼來源:HttpUtilsTest.java

示例2: bothNonRecursiveOneFoundTest

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void bothNonRecursiveOneFoundTest() {
    FindFiles findFiles =  new FindFiles("(bla.)", false).relative(".").setIncludeFolders(true).setIncludeFiles(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, "./blah")));

    Assert.assertEquals(findFiles.getNameRegex(), "(bla.)");
    Assert.assertNull(findFiles.getPathRegex());
    Assert.assertFalse(findFiles.isRecursive());
    Assert.assertTrue(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 only (not including sub-folders)");
    Assert.assertNull(executionResult.getException());
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:21,代碼來源:FindFilesTest.java

示例3: testBindResourceEmptyJson

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testBindResourceEmptyJson() {
    BindResource bindResource = JsonUtil.readValue(BIND_RESOURCE_EMPTY_JSON, BindResource.class);

    Assert.assertNotNull(bindResource, "BindResource deserialized object should not be null");
    Assert.assertFalse(bindResource.getAppGuid().isPresent(), "BindResource appGuid should not be present");
    Assert.assertFalse(bindResource.getRoute().isPresent(), "BindResource route should not be present");
}
 
開發者ID:blackducksoftware,項目名稱:hub-cf,代碼行數:9,代碼來源:BindResourceTest.java

示例4: testForObject

import org.testng.Assert; //導入方法依賴的package包/類
@Test(dataProvider = "forObjectDataProvider", dataProviderClass = ForObjectDataProvider.class)
public void testForObject(Object obj, String expected) {
    JavaConstant jConst = TestHelper.CONSTANT_REFLECTION_PROVIDER.forObject(obj);
    Assert.assertNotNull(jConst,
                    "An instance of JavaConstant returned by" + " \"forObject\" method should not be null");
    Assert.assertEquals(jConst.toString(), expected, "Unexpected result:");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:HotSpotConstantReflectionProviderTest.java

示例5: testCreatePolicySetPositive

import org.testng.Assert; //導入方法依賴的package包/類
public void testCreatePolicySetPositive() {
    PolicySet policySet = this.jsonUtils.deserializeFromFile("set-with-1-policy.json", PolicySet.class);
    String policyName = policySet.getName();
    this.policyService.upsertPolicySet(policySet);
    PolicySet savedPolicySet = this.policyService.getPolicySet(policyName);
    Assert.assertNotNull(savedPolicySet);
    Assert.assertEquals(savedPolicySet.getPolicies().size(), 1);
    Assert.assertEquals(savedPolicySet.getPolicies().get(0).getTarget().getResource().getUriTemplate(),
            "/secured-by-value/sites/sanramon");
    this.policyService.deletePolicySet(policyName);
    Assert.assertEquals(this.policyService.getAllPolicySets().size(), 0);
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:13,代碼來源:PolicyManagementServiceTest.java

示例6: testThenComposeAsync

import org.testng.Assert; //導入方法依賴的package包/類
public void testThenComposeAsync() throws Exception {
    // Composing CompletableFuture is complete
    CompletableFuture<String> cf1 = CompletableFuture.completedFuture("one");

    // Composing function returns a CompletableFuture executed asynchronously
    CountDownLatch cdl = new CountDownLatch(1);
    CompletableFuture<String> cf2 = cf1.thenCompose(str -> CompletableFuture.supplyAsync(() -> {
        while (true) {
            try {
                cdl.await();
                break;
            }
            catch (InterruptedException e) {
            }
        }
        return str + ", two";
    }));

    // Ensure returned CompletableFuture completes after call to thenCompose
    // This guarantees that any premature internal completion will be
    // detected
    cdl.countDown();

    String val = cf2.get();
    Assert.assertNotNull(val);
    Assert.assertEquals(val, "one, two");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:ThenComposeAsyncTest.java

示例7: testWithMetadataAndSequenceCreation

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testWithMetadataAndSequenceCreation() {
    String messageID = getRandomString();
    String messageContent = getRandomString();
    String metadataContent = getRandomString();
    Signal signal = Signal.ACKNOWLEDGE;
    //Test creation with a sequence number.
    PubSubMessage message = new PubSubMessage(messageID, messageContent, new Metadata(signal, metadataContent), 0);
    Assert.assertTrue(messageID.equals(message.getId()));
    Assert.assertTrue(messageContent.equals(message.getContent()));
    Assert.assertEquals(message.getSequence(), 0);
    Assert.assertNotNull(message.getMetadata());
    Assert.assertEquals(message.getMetadata().getSignal(), signal);
    Assert.assertTrue(message.getMetadata().getContent().toString().equals(metadataContent));
}
 
開發者ID:yahoo,項目名稱:bullet-core,代碼行數:16,代碼來源:PubSubMessageTest.java

示例8: testRemove

import org.testng.Assert; //導入方法依賴的package包/類
@Override
public void testRemove() throws Exception {
    List<String> insertedIds = testCreateUser();
    Assert.assertNotNull(insertedIds);
    long countRemovedEntries = dao.remove(insertedIds);
    Assert.assertTrue(countRemovedEntries > 0, "Failed to delete any service");

}
 
開發者ID:sjsucohort6,項目名稱:amigo-chatbot,代碼行數:9,代碼來源:UserDAOTest.java

示例9: testBindResourceJsonAllPresent

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testBindResourceJsonAllPresent() {
    BindResource bindResource = JsonUtil.readValue(bindResourceJsonAllPresent, BindResource.class);

    Assert.assertNotNull(bindResource, "BindResource deserialized object should not be null");
    Assert.assertTrue(bindResource.getAppGuid().isPresent(), "BindResource appGuid should be present");
    Assert.assertTrue(bindResource.getRoute().isPresent(), "BindResource route should be present");

    Assert.assertEquals(bindResource.getAppGuid().get(), TEST_APPGUID, "BindResource appGuid incorrect");
    Assert.assertEquals(bindResource.getRoute().get(), TEST_ROUTE, "BindResource route incorrect");
}
 
開發者ID:blackducksoftware,項目名稱:hub-cf,代碼行數:12,代碼來源:BindResourceTest.java

示例10: testFloatLookupProgrammatically

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testFloatLookupProgrammatically() {
    Float[] value = config.getValue("tck.config.test.javaconfig.converter.floatvalues",
        Float[].class);
    Assert.assertNotNull(value);
    Assert.assertEquals(value.length, 2);

    Assert.assertEquals( value[0].floatValue(), 12.34f);
    Assert.assertEquals( value[1].floatValue(), 99.99f);

}
 
開發者ID:eclipse,項目名稱:ConfigJSR,代碼行數:12,代碼來源:ArrayConverterTest.java

示例11: testCreateResourceConnectorWithEmptyAdapters

import org.testng.Assert; //導入方法依賴的package包/類
@Test(dataProvider = "requestUrlProvider")
public void testCreateResourceConnectorWithEmptyAdapters(final String endpointUrl) throws Exception {
    createZone1AndAssert();
    AttributeConnector connector = this.jsonUtils.deserializeFromFile(
            "controller-test/createAttributeConnectorWithEmptyAdapters.json", AttributeConnector.class);
    Assert.assertNotNull(connector, "createAttributeConnectorWithEmptyAdapters.json file not found or invalid");
    String connectorContent = this.objectWriter.writeValueAsString(connector);

    this.mockMvc.perform(
            put(endpointUrl).contentType(MediaType.APPLICATION_JSON).content(connectorContent))
            .andExpect(status().isUnprocessableEntity());
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:13,代碼來源:AttributeConnectorControllerIT.java

示例12: testPUTResourceNoResourceId

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testPUTResourceNoResourceId() throws Exception {

    BaseResource resource = JSON_UTILS
            .deserializeFromFile("controller-test/no-resourceIdentifier-resource.json", BaseResource.class);
    Assert.assertNotNull(resource);

    String thisUri = RESOURCE_BASE_URL + "/%2Fservices%2Fsecured-api%2Fsubresource";
    // Update a given resource
    MockMvcContext putContext =
        TEST_UTILS.createWACWithCustomPUTRequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    putContext.getMockMvc().perform(putContext.getBuilder().contentType(MediaType.APPLICATION_JSON)
            .content(OBJECT_MAPPER.writeValueAsString(resource))).andExpect(status().is2xxSuccessful());

    // Get a given resource
    MockMvcContext getContext =
        TEST_UTILS.createWACWithCustomGETRequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    getContext.getMockMvc().perform(getContext.getBuilder()).andExpect(status().isOk())
            .andExpect(jsonPath("resourceIdentifier", is("/services/secured-api/subresource")))
            .andExpect(jsonPath("attributes[0].value", isIn(new String[] { "supervisor", "it" })))
            .andExpect(jsonPath("attributes[0].issuer", is("https://acs.attributes.int")));

    // Delete a given resource
    MockMvcContext deleteContext =
        TEST_UTILS.createWACWithCustomDELETERequestBuilder(this.wac, this.testZone.getSubdomain(), thisUri);
    deleteContext.getMockMvc().perform(deleteContext.getBuilder()).andExpect(status().isNoContent());
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:28,代碼來源:ResourcePrivilegeManagementControllerIT.java

示例13: testgetSendLogsCronConfiguration

import org.testng.Assert; //導入方法依賴的package包/類
@Test
public void testgetSendLogsCronConfiguration ()
{
   Assert.assertNotNull (configurationManager.getSendLogsCronConfiguration ());
   Assert.assertEquals (configurationManager.getSendLogsCronConfiguration ().getSchedule (), "0 0 0 ? * *");
   Assert.assertEquals (configurationManager.getSendLogsCronConfiguration ().getAddresses (), "[email protected]");
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:8,代碼來源:TestConfigurationManager.java

示例14: assertStudentJsonNode

import org.testng.Assert; //導入方法依賴的package包/類
private void assertStudentJsonNode(final JsonNode studentJsonNode) {
    Assert.assertNotNull(studentJsonNode);
    Assert.assertEquals(studentJsonNode.findValuesAsText("id").get(0), "S00001");
    Assert.assertEquals(studentJsonNode.findValuesAsText("name").get(0), "Joe");
    Assert.assertEquals(studentJsonNode.findValuesAsText("age").get(0), "15");
    Assert.assertEquals(studentJsonNode.findValue("courses").get(0).asText(), "Math");
    Assert.assertEquals(studentJsonNode.findValue("courses").get(1).asText(), "Arts");
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:9,代碼來源:JsonUtilsTest.java

示例15: testScriptExecutionUsingAssignment

import org.testng.Assert; //導入方法依賴的package包/類
/**
 * Test the execution of a policy condition, which tries to assign null, to a variable.
 *
 * @throws ConditionParsingException
 */
@Test
public void testScriptExecutionUsingAssignment() throws ConditionParsingException {
    String script = "resource = null; resource == null;";
    ConditionScript parsedScript = this.shell.parse(script);
    Map<String, Object> parameter = new HashMap<>();
    final ResourceHandler resourceHandler = new ResourceHandler(new HashSet<Attribute>(), "", "");
    parameter.put("resource", resourceHandler);
    Assert.assertEquals(parsedScript.execute(parameter), true);
    Assert.assertNotNull(resourceHandler);
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:16,代碼來源:GroovyConditionScriptTest.java


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