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


Java Assert.assertTrue方法代码示例

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


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

示例1: runFtpScanner

import org.testng.Assert; //导入方法依赖的package包/类
@Test (groups="slow")
public void runFtpScanner() throws InterruptedException
{
   ScannerFactory sf = new ScannerFactory ();
   Scanner scanner = sf.getScanner ("ftp://localhost:8089/data", 
         "user", "password", null);
   
   // scanner.setSupportedClasses(classes);
   // Scan all the items...
   scanner.setSupportedClasses(ImmutableList.of (DrbCortexItemClass
         .getCortexItemClassByName ("http://www.gael.fr/drb#item")));
   
   scanner.getScanList().simulate(false);
   
   scanner.scan();
   
   Assert.assertTrue (scanner.getScanList().size()>0, "No item found.");
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:ScannerFactoryTest.java

示例2: folderNonRecursiveMultipleFoundTest

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void folderNonRecursiveMultipleFoundTest() {
    FindFiles findFiles =  new FindFiles().setRecursive(false).setIncludeFolders(true).setIncludeFiles(false);
    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(), 2);

    Assert.assertTrue(files.contains(new File(transformedAppFolder, "src")));
    Assert.assertTrue(files.contains(new File(transformedAppFolder, "blah")));

    Assert.assertNull(findFiles.getNameRegex());
    Assert.assertNull(findFiles.getPathRegex());
    Assert.assertFalse(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 only (not including sub-folders)");
    Assert.assertNull(executionResult.getException());
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:22,代码来源:FindFilesTest.java

示例3: verifyIssuerClaim

import org.testng.Assert; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
    description = "Verify that the injected token issuer claim is as expected")
public void verifyIssuerClaim() throws Exception {
    Reporter.log("Begin verifyIssuerClaim");
    String uri = baseURL.toExternalForm() + "/endp/verifyInjectedIssuer";
    WebTarget echoEndpointTarget = ClientBuilder.newClient()
        .target(uri)
        .queryParam(Claims.iss.name(), TCKConstants.TEST_ISSUER)
        .queryParam(Claims.auth_time.name(), authTimeClaim);
    Response response = echoEndpointTarget.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
    Assert.assertEquals(response.getStatus(), HttpURLConnection.HTTP_OK);
    String replyString = response.readEntity(String.class);
    JsonReader jsonReader = Json.createReader(new StringReader(replyString));
    JsonObject reply = jsonReader.readObject();
    Reporter.log(reply.toString());
    Assert.assertTrue(reply.getBoolean("pass"), reply.getString("msg"));
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:19,代码来源:ProviderInjectionTest.java

示例4: testBulkheadMethodAsynchFutureDoneWithoutGet

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * Tests that the Future that is returned from a asynchronous bulkhead
 * method can be queried for Done OK even if the user never calls get() to
 * drive the backend (i.e. the method is called non-lazily)
 */
@Test()
public void testBulkheadMethodAsynchFutureDoneWithoutGet() {

    Checker fc = new FutureChecker(SHORT_TIME);
    Future<String> result = null;
    try {
        result = bhBeanMethodAsynchronousDefault.test(fc);
    }
    catch (InterruptedException e1) {
        Assert.fail("Unexpected interruption", e1);
    }

    Assert.assertFalse(result.isDone(), "Future reporting Done when not");
    try {
        Thread.sleep(SHORT_TIME + SHORT_TIME);
    }
    catch (Throwable t) {
        Assert.assertNull(t);
    }
    Assert.assertTrue(result.isDone(), "Future done not reporting true");
}
 
开发者ID:eclipse,项目名称:microprofile-fault-tolerance,代码行数:27,代码来源:BulkheadFutureTest.java

示例5: verifyHeapDump

import org.testng.Assert; //导入方法依赖的package包/类
private void verifyHeapDump(File dump) {
    Assert.assertTrue(dump.exists() && dump.isFile(), "Could not create dump file " + dump.getAbsolutePath());
    try {
        File out = HprofParser.parse(dump);

        Assert.assertTrue(out != null && out.exists() && out.isFile(), "Could not find hprof parser output file");
        List<String> lines = Files.readAllLines(out.toPath());
        Assert.assertTrue(lines.size() > 0, "hprof parser output file is empty");
        for (String line : lines) {
            Assert.assertFalse(line.matches(".*WARNING(?!.*Failed to resolve object.*constantPoolOop.*).*"));
        }

        out.delete();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Could not parse dump file " + dump.getAbsolutePath());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:HeapDumpTest.java

示例6: validateClaimNames

import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = TEST_GROUP_JWT,
    description = "validate the claim names")
public void validateClaimNames() {
    String[] expected = {"iss", "jti", "sub", "upn", "preferred_username",
        "aud","exp","iat", "roles","groups", "customString","customInteger",
        "customStringArray", "customIntegerArray", "customDoubleArray",
        "customObject"};
    Set<String> claimNames = jwt.getClaimNames();
    HashSet<String> missingNames = new HashSet<>();
    for (String name : expected) {
        if(!claimNames.contains(name)) {
            missingNames.add(name);
        }
    }
    Assert.assertTrue(missingNames.size() == 0, "There should be no missing claim names");
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:17,代码来源:TestTokenClaimTypesTest.java

示例7: testDownloadDirectory

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testDownloadDirectory() {
    ExecResults results = ssh.downloadDirectory(new File(LocalServer.TARGET), "~/src/test/resources/download");
    Assert.assertEquals(results.getReturnCode(), 0, "Validating the return code.");
    File downloadedDir = new File(LocalServer.TARGET + File.separator + "download");
    Assert.assertTrue(downloadedDir.exists(), "Validating the existence of downloaded artifact");
    Assert.assertTrue(downloadedDir.isDirectory(), "Validating the downloaded artifact.");
    File[] files = downloadedDir.listFiles();
    Assert.assertNotNull(files, "Validating the items in the downloaded folder.");
    Assert.assertEquals(files.length, 1, "Validating the contents of the downloaded folder.");
}
 
开发者ID:RationaleEmotions,项目名称:SimpleSSH,代码行数:12,代码来源:SshKnowHowTest.java

示例8: update

import org.testng.Assert; //导入方法依赖的package包/类
@Override
public void update ()
{
   Long id = 4L;
   NetworkUsage nu = dao.read (id);
   boolean bool = true;

   Assert.assertNotNull (nu);
   Assert.assertNotEquals (nu.getIsDownload (), bool);
   nu.setIsDownload (bool);
   dao.update (nu);

   nu = dao.read (id);
   Assert.assertTrue (nu.getIsDownload ());
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:16,代码来源:TestNetworkUsageDao.java

示例9: testNameChange

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * @bug 8161454
 * Verifies that the new / correct name is supported, as is the old / incorrect
 * one for compatibility
 */
@Test
public void testNameChange() {

    boolean feature;
    TransformerFactory tf = TransformerFactory.newInstance();
    feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
    System.out.println("Default setting: " + feature);
    // The default: true if no SecurityManager, false otherwise
    Assert.assertTrue(feature == getDefault());

    setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION, getDefaultOpposite());
    tf = TransformerFactory.newInstance();
    feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
    System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION + ": " + feature);
    clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION);
    // old/incorrect name is still supported
    Assert.assertTrue(feature != getDefault());

    setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC, getDefaultOpposite());
    tf = TransformerFactory.newInstance();
    feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
    System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION_SPEC + ": " + feature);
    clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC);
    // new/correct name is effective
    Assert.assertTrue(feature != getDefault());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:XSLTFunctionsTest.java

示例10: testDuplicatesAreRemoved

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testDuplicatesAreRemoved(){
	SomeType[] expected = {SomeType.LARGE, SomeType.CONDO};
	List<SomeType> actual = DatarouterEnumTool.uniqueListFromCsvNames(SomeType.values(),
			"large, funky, condo, large, condo, condo", false).get();
	Assert.assertTrue(CollectionTool.equalsAllElementsInIteratorOrder(Arrays.asList(expected), actual));
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:8,代码来源:DatarouterEnumToolTests.java

示例11: testRoundTrips

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testRoundTrips(){
	Random random = new Random();
	long value = Long.MIN_VALUE;
	byte[] lastBytes = getComparableBytes(value);
	long lastValue = value;
	++value;
	int counter = 0;
	long stopAt = Long.MAX_VALUE - 2 * (long)Integer.MAX_VALUE;
	Assert.assertTrue(stopAt > Integer.MAX_VALUE);
	do{
		if(counter < 1000){
			Assert.assertTrue(value < 0);
		}
		byte[] bytes = getComparableBytes(value);
		long roundTripped = fromComparableByteArray(bytes)[0];
		try{
			Assert.assertTrue(value > lastValue);
			Assert.assertTrue(ByteTool.bitwiseCompare(lastBytes, bytes) < 0);
			Assert.assertEquals(roundTripped, value);
		}catch(AssertionError e){
			throw e;
		}
		lastBytes = bytes;
		++counter;
		lastValue = value;
		long incrementor = random.nextLong() >>> 18;
		value = value + incrementor;
	}while(value < stopAt && value > lastValue);// watch out for overflowing and going back negative
	Assert.assertTrue(counter > 1000);//make sure we did a lot of tests
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:32,代码来源:LongByteTool.java

示例12: testAdd

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testAdd ()
{
   Assert.assertEquals (queue.size (), 0);
   Assert.assertTrue (queue.add (new FairQueueTestString ("key1", "item1")));
   Assert.assertEquals (queue.size (), 1);
   Assert.assertTrue (queue.add (new FairQueueTestString ("key2", "item2")));
   Assert.assertEquals (queue.size (), 2);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:10,代码来源:FairQueueTest.java

示例13: testPersistPolicy

import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testPersistPolicy() {

    ZoneEntity zone = createZone();
    this.zoneRepository.save(zone);

    PolicySetEntity policySetEntity = new PolicySetEntity(zone, "policy-set-2", "{}");
    PolicySetEntity savedPolicySet = this.policySetRepository.save(policySetEntity);
    Assert.assertEquals(this.policySetRepository.count(), 1);
    Assert.assertTrue(savedPolicySet.getId() > 0);
}
 
开发者ID:eclipse,项目名称:keti,代码行数:12,代码来源:PolicySetRepositoryTest.java

示例14: testEmptyDefaultEmptyPrefixSpecifiedNamespaceURIWriteAttribute

import org.testng.Assert; //导入方法依赖的package包/类
/**
 * Current default namespace is "".
 *
 * writeAttribute("", "http://example.org/myURI", "attrName", "value")
 *
 * XMLOutputFactory (Javadoc) : "If a writer isRepairingNamespaces it will
 * create a namespace declaration on the current StartElement for any
 * attribute that does not currently have a namespace declaration in scope.
 * If the StartElement has a uri but no prefix specified a prefix will be
 * assigned, if the prefix has not been declared in a parent of the current
 * StartElement it will be declared on the current StartElement. If the
 * defaultNamespace is bound and in scope and the default namespace matches
 * the URI of the attribute or StartElement QName no prefix will be
 * assigned."
 *
 * prefix needs to be assigned for this test case.
 */
@Test
public void testEmptyDefaultEmptyPrefixSpecifiedNamespaceURIWriteAttribute() throws Exception {

    final String EXPECTED_OUTPUT = "<?xml version=\"1.0\" ?>"
            + "<root xmlns=\"\" xmlns:{generated prefix}=\"http://example.org/myURI\" {generated prefix}:attrName=\"value\">"
            + "generate xmlns declaration {generated prefix}=\"http://example.org/myURI\"" + "</root>";

    startDocumentEmptyDefaultNamespace(xmlStreamWriter);

    xmlStreamWriter.writeAttribute("", "http://example.org/myURI", "attrName", "value");
    xmlStreamWriter.writeCharacters("generate xmlns declaration {generated prefix}=\"http://example.org/myURI\"");

    String actualOutput = endDocumentEmptyDefaultNamespace(xmlStreamWriter);

    if (DEBUG) {
        System.out.println("testEmptyDefaultUnspecifiedPrefixWriteAttribute(): expectedOutput: " + EXPECTED_OUTPUT);
        System.out.println("testEmptyDefaultUnspecifiedPrefixWriteAttribute():   actualOutput: " + actualOutput);
    }

    // there must be one xmlns=
    Assert.assertTrue(actualOutput.split("xmlns=").length == 2, "Expected 1 xmlns=, actual output: " + actualOutput);

    // there must be one xmlns:{generated prefix}="..."
    Assert.assertTrue(actualOutput.split("xmlns:").length == 2, "Expected 1 xmlns:{generated prefix}=\"\", actual output: " + actualOutput);

    // there must be one {generated prefix}:attrName="value"
    Assert.assertTrue(actualOutput.split(":attrName=\"value\"").length == 2, "Expected 1 {generated prefix}:attrName=\"value\", actual output: "
            + actualOutput);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:NamespaceTest.java

示例15: testIteratorOfDoublesWithPredicate

import org.testng.Assert; //导入方法依赖的package包/类
@Test()
public void testIteratorOfDoublesWithPredicate() {
    final Random random = new Random();
    final AtomicInteger counter = new AtomicInteger();
    final DataFrame<String,String> frame = TestDataFrames.random(double.class, 100, 100);
    frame.applyDoubles(v -> random.nextDouble() * 5);
    frame.iterator(v -> v.getDouble() > 3).forEachRemaining(v -> {
        final double v1 = v.getDouble();
        counter.incrementAndGet();
        Assert.assertTrue(v1 > 3d, "Values match at " + v.rowOrdinal() + "," + v.colOrdinal());
    });
    Assert.assertTrue(counter.get() > 0, "There was at least one match");
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:14,代码来源:IteratorTests.java


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