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


Java Test类代码示例

本文整理汇总了Java中org.testng.annotations.Test的典型用法代码示例。如果您正苦于以下问题:Java Test类的具体用法?Java Test怎么用?Java Test使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testTransformer

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void testTransformer() throws TransformerException {
    String xml = "<?xml version='1.0'?><root/>";
    ReaderStub.used = false;

    TransformerFactory transFactory = TransformerFactory.newInstance();
    Transformer transformer = transFactory.newTransformer();
    InputSource in = new InputSource(new StringReader(xml));
    SAXSource source = new SAXSource(in);
    StreamResult result = new StreamResult(new StringWriter());

    transformer.transform(source, result);

    assertTrue(ReaderStub.used);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Bug4515660.java

示例2: testEntityExpansionDOMNeg

import org.testng.annotations.Test; //导入依赖的package包/类
/**
 * Use a DocumentBuilder to create a DOM object and see how does the Secure
 * Processing feature and entityExpansionLimit value affects output.
 * Negative test that when entityExpansionLimit is too small.
 *
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = SAXParseException.class)
public void testEntityExpansionDOMNeg() throws Exception {
    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
    dfactory.setFeature(FEATURE_SECURE_PROCESSING, true);
    setSystemProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2));
    DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
    MyErrorHandler eh = new MyErrorHandler();
    dBuilder.setErrorHandler(eh);
    dBuilder.parse(ENTITY_XML);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AuctionItemRepository.java

示例3: shouldSynchronizeConcurrentAddsOfSameElement

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void shouldSynchronizeConcurrentAddsOfSameElement() {
    // given:
    final String element = "Hello World";
    replica2.disconnect(replica3);

    // when:
    orSet1.add(element);
    orSet3.add(element);

    // then:
    assertThat(orSet1, contains(element));
    assertThat(orSet2, equalTo(orSet1));
    assertThat(orSet3, equalTo(orSet1));

    // when:
    replica2.connect(replica3);

    // then:
    assertThat(orSet1, contains(element));
    assertThat(orSet2, equalTo(orSet1));
    assertThat(orSet3, equalTo(orSet1));
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:24,代码来源:LocalORSetTest.java

示例4: test_badMinusTemporalUnitChrono

import org.testng.annotations.Test; //导入依赖的package包/类
@Test(dataProvider="calendars")
public void test_badMinusTemporalUnitChrono(Chronology chrono) {
    LocalDate refDate = LocalDate.of(2013, 1, 1);
    ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
    for (Chronology[] clist : data_of_calendars()) {
        Chronology chrono2 = clist[0];
        ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
        TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
        if (chrono != chrono2) {
            try {
                cdt.minus(1, adjuster);
                Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + cdt.getClass()
                        + ", can not be cast to " + cdt2.getClass());
            } catch (ClassCastException cce) {
                // Expected exception; not an error
            }
        } else {
            // Same chronology,
            ChronoLocalDateTime<?> result = cdt.minus(1, adjuster);
            assertEquals(result, cdt2, "WithAdjuster failed to replace date");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:TCKChronoLocalDateTime.java

示例5: testWithTrueTrue

import org.testng.annotations.Test; //导入依赖的package包/类
/**
 * namespace processing is enabled. namespace-prefix is also is enabled.
 * So it is a True-True combination.
 * The test is to test SAXParser with these conditions.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testWithTrueTrue() throws Exception {
    String outputFile = USER_DIR + "SPNSTableTT.out";
    String goldFile = GOLDEN_DIR + "NSTableTTGF.out";
    String xmlFile = XML_DIR + "namespace1.xml";
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    spf.setFeature("http://xml.org/sax/features/namespace-prefixes",
                                true);
    try (MyNSContentHandler handler = new MyNSContentHandler(outputFile)) {
        spf.newSAXParser().parse(new File(xmlFile), handler);
    }
    assertTrue(compareWithGold(goldFile, outputFile));

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SAXParserNSTableTest.java

示例6: testWrite_SingleWriter

import org.testng.annotations.Test; //导入依赖的package包/类
/**
   * Simple test for record-writer where number of rows are written to Geode, based on
   * the specified block-size.
   * The sample file contains 30 lines/rows. Here with block-size 10 total four blocks
   * are stored each with max 10 records/rows.
   *
   * @throws Exception
   */
  @Test
  public void testWrite_SingleWriter() throws Exception {
//    System.out.println("MonarchRecordWriterTest.testWrite_SingleWriter");
    final List<String> lines = TestHelper.getResourceAsString(resourceFile);
    final Map<String, Integer> expectedMap = new HashMap<String, Integer>(4) {{
      put("0", 10);
      put("1", 10);
      put("2", 10);
      put("3", 1);
    }};
    final int blockSize = 10;

    assertOnRecordWriter(lines, expectedMap, "", blockSize);

    Configuration conf = new Configuration();
    conf.set("monarch.locator.port", testBase.getLocatorPort());
  }
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:MonarchRecordWriterFTableTest.java

示例7: returnsResultsFromEveryHandler

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void returnsResultsFromEveryHandler() {
    BogusMavenInvocationOutputHandler handler1 = Mockito.mock(BogusMavenInvocationOutputHandler.class);
    Mockito.doReturn("data0").when(mockHandler).getResult();
    Mockito.doReturn("data1").when(handler1).getResult();
    multiHandler.register(mockHandler);
    multiHandler.register(handler1);
    multiHandler.consumeLine("line1");
    multiHandler.consumeLine("line2");
    Map<Class<? extends MavenInvocationOutputHandler>, Object> results = multiHandler.getResult();

    Assert.assertEquals(2, results.size());

    Assert.assertEquals(results.get(mockHandler.getClass()), "data0");
    Assert.assertEquals(results.get(handler1.getClass()), "data1");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:17,代码来源:MultipleOutputHandlerTest.java

示例8: test_isBeforeIsAfterIsEqual2nanos

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void test_isBeforeIsAfterIsEqual2nanos() {
    OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1));
    OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);  // a is before b due to offset
    assertEquals(a.isBefore(b), true);
    assertEquals(a.isEqual(b), false);
    assertEquals(a.isAfter(b), false);

    assertEquals(b.isBefore(a), false);
    assertEquals(b.isEqual(a), false);
    assertEquals(b.isAfter(a), true);

    assertEquals(a.isBefore(a), false);
    assertEquals(b.isBefore(b), false);

    assertEquals(a.isEqual(a), true);
    assertEquals(b.isEqual(b), true);

    assertEquals(a.isAfter(a), false);
    assertEquals(b.isAfter(b), false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:TCKOffsetTime.java

示例9: testIndexedCorola

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void testIndexedCorola() throws IOException, SAXException, ParserConfigurationException, GGSException {
    IndexedLuceneCorpus t;
    try {
        t = new IndexedLuceneCorpus(new File("TestData/inputCorpora/corola.index"));
    } catch (IOException e) {
        throw new SkipException("indexed corola not present");
    }
    Grammar g = new Grammar();
    //g.load(new FileInputStream("TestData/inputGrammars/roNPchunker_grammar.ggf"));
    //g.load(new FileInputStream("TestData/inputGrammars/npexample.ggf"));
    g.load(new FileInputStream("TestData/inputGrammars/verysimplegrammar.ggf"));

    SparseBitSet.compressionPolicy = SparseBitSet.SparseBitSetCompressionPolicy.none;
    CompiledGrammar compiledGrammar = new CompiledGrammar(g);
    List<Match> matches = compiledGrammar.GetMatches(t, true);

    assert (matches.size() == matches.size());
}
 
开发者ID:radsimu,项目名称:UaicNlpToolkit,代码行数:20,代码来源:GrammarTest.java

示例10: testSubtraction

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void testSubtraction() {
  b1 = rampdouble(-1,1,n1);               assertEqual(b1,sub(a1,1));
  b2 = rampdouble(-1,1,10,n1,n2);         assertEqual(b2,sub(a2,1));
  b3 = rampdouble(-1,1,10,100,n1,n2,n3);  assertEqual(b3,sub(a3,1));

  b1 = rampdouble(1,-1,n1);               assertEqual(b1,sub(1,a1));
  b2 = rampdouble(1,-1,-10,n1,n2);        assertEqual(b2,sub(1,a2));
  b3 = rampdouble(1,-1,-10,-100,n1,n2,n3);assertEqual(b3,sub(1,a3));

  zero(b1);                               assertEqual(b1,sub(a1,a1));
  zero(b2);                               assertEqual(b2,sub(a2,a2));
  zero(b3);                               assertEqual(b3,sub(a3,a3));

  sub(a1,a1,a1);                          assertEqual(b1,a1);
  sub(a2,a2,a2);                          assertEqual(b2,a2);
  sub(a3,a3,a3);                          assertEqual(b3,a3);
}
 
开发者ID:MinesJTK,项目名称:jtk,代码行数:19,代码来源:ArrayMathDoubleTest.java

示例11: testResourceMonthDetailDAOCount

import org.testng.annotations.Test; //导入依赖的package包/类
@Deprecated
@Test(enabled = false)
public void testResourceMonthDetailDAOCount() throws Exception {
  String environemntName = environemntNames[0];

  long statusOnlineCount = aggregatedStatusDAO.getStatusCount(environemntName, resource.getId(), Status.Online, startDate, endDate);
  Assert.assertTrue(statusOnlineCount > 0);
  Assert.assertEquals(statusOnlineCount, 100);

  long statusUnavailableCount = aggregatedStatusDAO.getStatusCount(environemntName, resource.getId(), Status.Unavailable, startDate, endDate);
  Assert.assertTrue(statusUnavailableCount > 0);
  Assert.assertEquals(statusUnavailableCount, 100);

  long statusUnknownCount = aggregatedStatusDAO.getStatusCount(environemntName, resource.getId(), Status.Unknown, startDate, endDate);
  Assert.assertTrue(statusUnknownCount > 0);
  Assert.assertEquals(statusUnknownCount, 100);

}
 
开发者ID:YagelNasManit,项目名称:environment.monitor,代码行数:19,代码来源:AggregatedStatusDAOTest.java

示例12: testGetSecretsGroupIdentifiers

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void testGetSecretsGroupIdentifiers() throws Exception {
    ListPoliciesRequest request = new ListPoliciesRequest().withMaxItems(1000).withPathPrefix("/strongbox/");
    Policy policyUS1 = new Policy().withPolicyName("strongbox_us-west-1_test-group1_admin");
    Policy policyUS2 = new Policy().withPolicyName("strongbox_us-west-1_test-group2_admin");
    Policy policyEU1 = new Policy().withPolicyName("strongbox_eu-west-1_test-group1_admin");
    Policy policyEU1readonly = new Policy().withPolicyName("strongbox_eu-west-1_test-group1_readonly");
    ListPoliciesResult result = new ListPoliciesResult()
            .withPolicies(policyUS1, policyUS2, policyEU1, policyEU1readonly);
    when(mockClient.listPolicies(request)).thenReturn(new ListPoliciesResult()
            .withPolicies(policyUS1, policyUS2, policyEU1, policyEU1readonly));

    Set<SecretsGroupIdentifier> identifiers = partiallyMockedPolicyManager.getSecretsGroupIdentifiers();
    assertEquals(identifiers.size(), 3);
    assertTrue(identifiers.contains(new SecretsGroupIdentifier(Region.US_WEST_1, "test.group1")));
    assertTrue(identifiers.contains(new SecretsGroupIdentifier(Region.US_WEST_1, "test.group2")));
    assertTrue(identifiers.contains(new SecretsGroupIdentifier(Region.EU_WEST_1, "test.group1")));

    verify(mockClient, times(1)).listPolicies(request);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:21,代码来源:IAMPolicyManagerTest.java

示例13: test_next

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void test_next() {
    for (Month month : Month.values()) {
        for (int i = 1; i <= month.length(false); i++) {
            LocalDate date = date(2007, month, i);

            for (DayOfWeek dow : DayOfWeek.values()) {
                LocalDate test = (LocalDate) TemporalAdjusters.next(dow).adjustInto(date);

                assertSame(test.getDayOfWeek(), dow, date + " " + test);

                if (test.getYear() == 2007) {
                    int dayDiff = test.getDayOfYear() - date.getDayOfYear();
                    assertTrue(dayDiff > 0 && dayDiff < 8);
                } else {
                    assertSame(month, Month.DECEMBER);
                    assertTrue(date.getDayOfMonth() > 24);
                    assertEquals(test.getYear(), 2008);
                    assertSame(test.getMonth(), Month.JANUARY);
                    assertTrue(test.getDayOfMonth() < 8);
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TCKTemporalAdjusters.java

示例14: testNotEqualsHashCode

import org.testng.annotations.Test; //导入依赖的package包/类
@Test
public void testNotEqualsHashCode() throws Exception {
  final Route route1 = ImmutableRoute.builder()
    .targetPrefix(GLOBAL_TARGET_PREFIX)
    .nextHopLedgerAccount(DEFAULT_CONNECTOR_ACCOUNT)
    .build();
  final Route route2 = ImmutableRoute.builder()
    .targetPrefix(GLOBAL_TARGET_PREFIX)
    .nextHopLedgerAccount(DEFAULT_CONNECTOR_ACCOUNT)
    .sourcePrefixRestrictionRegex(ACCEPT_NO_SOURCES_PATTERN)
    .build();

  assertThat(route1, is(not(route2)));
  assertThat(route2, is(not(route1)));
  assertThat(route1.hashCode(), is(not(route2.hashCode())));
}
 
开发者ID:interledger,项目名称:java-ilp-connector,代码行数:17,代码来源:RouteTest.java

示例15: performTestResultsVerificationFailTest

import org.testng.annotations.Test; //导入依赖的package包/类
@Test(expectedExceptions = AssertionError.class)
public void performTestResultsVerificationFailTest() {
    Map<String, String> testResults =
            new HashMap<>();

    testResults.
            put("SomeField:",
                    "TestMe");
    testResults.
            put("Status:",
                    "QWE");

    performTestResultsVerification(
            generateVerificationEntities(
                    UI_COMMON_RULES),
            testResults,
            UI_COMMON.name());
}
 
开发者ID:shimkiv,项目名称:trust-java,代码行数:19,代码来源:TrustTest.java


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