本文整理汇总了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!");
}
}
示例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());
}
示例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");
}
示例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:");
}
示例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);
}
示例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");
}
示例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));
}
示例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");
}
示例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");
}
示例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);
}
示例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());
}
示例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());
}
示例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]");
}
示例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");
}
示例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);
}