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