本文整理汇总了Java中org.testng.Assert.assertEquals方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertEquals方法的具体用法?Java Assert.assertEquals怎么用?Java Assert.assertEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.testng.Assert
的用法示例。
在下文中一共展示了Assert.assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyInjectedJTI2
import org.testng.Assert; //导入方法依赖的package包/类
@RunAsClient
@Test(groups = TEST_GROUP_CDI_PROVIDER,
description = "Verify that the injected jti claim is as expected")
public void verifyInjectedJTI2() throws Exception {
Reporter.log("Begin verifyInjectedJTI\n");
String uri = baseURL.toExternalForm() + "/endp/verifyInjectedJTI";
WebTarget echoEndpointTarget = ClientBuilder.newClient()
.target(uri)
.queryParam(Claims.jti.name(), "a-123")
.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"));
}
示例2: replaceLineNumber2Test
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void replaceLineNumber2Test() throws IOException {
ReplaceLine replaceLine = new ReplaceLine(2, "bar=barv-changed").relative("/src/main/resources/application.properties");
TOExecutionResult executionResult = replaceLine.execution(transformedAppFolder, transformationContext);
Assert.assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
assertChangedFile("/src/main/resources/application.properties");
assertLineCount("/src/main/resources/application.properties", 0);
Properties properties = getProperties("/src/main/resources/application.properties");
Assert.assertEquals(properties.size(), 3);
Assert.assertEquals(properties.getProperty("foo"), "foov");
Assert.assertEquals(properties.getProperty("bar"), "barv-changed");
Assert.assertEquals(properties.getProperty("foofoo"), "foofoov");
}
示例3: testGetOrderedBytes
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testGetOrderedBytes(){
byte min = Byte.MIN_VALUE;
Assert.assertEquals(min, -128);
byte max = Byte.MAX_VALUE;
Assert.assertEquals(max, 127);
Assert.assertTrue(min < max);
byte[] minArray = getComparableBytes(min);
byte[] maxArray = getComparableBytes(max);
Assert.assertTrue(ByteTool.bitwiseCompare(maxArray, minArray) > 0);
byte negative = -3;
byte positive = 5;
Assert.assertTrue(negative < positive);
byte[] negativeArray = getComparableBytes(negative);
byte[] positiveArray = getComparableBytes(positive);
Assert.assertTrue(ByteTool.bitwiseCompare(positiveArray, negativeArray) > 0);
}
示例4: testDuplicateNSDeclaration
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testDuplicateNSDeclaration() {
// expect only 1 Namespace Declaration
final String EXPECTED_OUTPUT = "<?xml version=\"1.0\" ?>" + "<ns1:foo" + " xmlns:ns1=\"http://example.com/\">" + "</ns1:foo>";
// have XMLOutputFactory repair Namespaces
XMLOutputFactory ofac = XMLOutputFactory.newInstance();
ofac.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
// send output to a Stream
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
StreamResult sr = new StreamResult(buffer);
XMLStreamWriter w = null;
// write a duplicate Namespace Declaration
try {
w = ofac.createXMLStreamWriter(sr);
w.writeStartDocument();
w.writeStartElement("ns1", "foo", "http://example.com/");
w.writeNamespace("ns1", "http://example.com/");
w.writeNamespace("ns1", "http://example.com/");
w.writeEndElement();
w.writeEndDocument();
w.close();
} catch (XMLStreamException xmlStreamException) {
xmlStreamException.printStackTrace();
Assert.fail(xmlStreamException.toString());
}
// debugging output for humans
System.out.println();
System.out.println("actual: \"" + buffer.toString() + "\"");
System.out.println("expected: \"" + EXPECTED_OUTPUT + "\"");
// are results as expected?
Assert.assertEquals(EXPECTED_OUTPUT, buffer.toString());
}
示例5: testMultipleFieldsCountDistinct
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testMultipleFieldsCountDistinct() {
BulletConfig config = makeConfiguration(4, 512);
CountDistinct countDistinct = makeCountDistinct(config, makeAttributes("myCount"), asList("fieldA", "fieldB"));
IntStream.range(0, 256).mapToObj(i -> RecordBox.get().add("fieldA", i).add("fieldB", 255 - i).getRecord())
.forEach(countDistinct::consume);
IntStream.range(0, 256).mapToObj(i -> RecordBox.get().add("fieldA", i).add("fieldB", 255 - i).getRecord())
.forEach(countDistinct::consume);
Clip clip = countDistinct.getAggregation();
Assert.assertEquals(clip.getRecords().size(), 1);
BulletRecord actual = clip.getRecords().get(0);
BulletRecord expected = RecordBox.get().add("myCount", 256.0).getRecord();
Assert.assertEquals(actual, expected);
}
示例6: defaultIfPresentTest
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void defaultIfPresentTest() throws IOException, XmlPullParserException {
PomAddDependency uut = new PomAddDependency("xmlunit", "xmlunit").relative("pom.xml");
TOExecutionResult executionResult = uut.execution(transformedAppFolder, transformationContext);
Assert.assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
Assert.assertNotNull(executionResult.getException());
Assert.assertEquals(executionResult.getException().getClass(), TransformationOperationException.class);
Dependency dependencyAfterChange = getDependencyInList(getTransformedPomModel("pom.xml"), "xmlunit", "xmlunit", "1.7");
Assert.assertNull(dependencyAfterChange);
}
示例7: fileNotFoundErrorTest
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void fileNotFoundErrorTest() {
FindFile findFile = new FindFile("cats.yaml").failIfNotFound(true);
TUExecutionResult executionResult = findFile.execution(transformedAppFolder, transformationContext);
Assert.assertEquals(executionResult.getType(), TUExecutionResult.Type.ERROR);
Assert.assertNull(executionResult.getValue());
Assert.assertEquals(findFile.getDescription(), "Find file named cats.yaml under root of application");
Assert.assertTrue(findFile.isFailIfNotFound());
Assert.assertEquals(findFile.getFileName(), "cats.yaml");
Assert.assertNotNull(executionResult.getException());
Assert.assertEquals(executionResult.getException().getClass(), TransformationUtilityException.class);
Assert.assertEquals(executionResult.getException().getMessage(), "No file named 'cats.yaml' has been found");
}
示例8: test
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void test(){
ThreadFactory threadFactory = new NamedThreadFactory(null, ScalingThreadPoolExecutorTests.class.getSimpleName(),
false);
ThreadPoolExecutor executor = new ScalingThreadPoolExecutor(0, MAX_THREADS, 0, TimeUnit.SECONDS, threadFactory);
Phaser phaser = new Phaser(1);
List<Future<?>> futures = new ArrayList<>();
for(int i = 0; i < MAX_THREADS; i++){
Assert.assertEquals(executor.getActiveCount(), i);
Assert.assertEquals(executor.getPoolSize(), i);
Assert.assertEquals(executor.getQueue().size(), 0);
phaser.register();
futures.add(executor.submit(new WaitRunnable(phaser)));
phaser.arriveAndAwaitAdvance();
}
Assert.assertEquals(executor.getActiveCount(), MAX_THREADS);
Assert.assertEquals(executor.getPoolSize(), MAX_THREADS);
Assert.assertEquals(executor.getQueue().size(), 0);
futures.add(executor.submit(new WaitRunnable(phaser)));
Assert.assertEquals(executor.getActiveCount(), MAX_THREADS);
Assert.assertEquals(executor.getPoolSize(), MAX_THREADS);
Assert.assertEquals(executor.getQueue().size(), 1);
futures.add(executor.submit(new WaitRunnable(phaser)));
Assert.assertEquals(executor.getActiveCount(), MAX_THREADS);
Assert.assertEquals(executor.getPoolSize(), MAX_THREADS);
Assert.assertEquals(executor.getQueue().size(), 2);
phaser.arrive();
FutureTool.getAllVaried(futures);
Assert.assertEquals(executor.getActiveCount(), 0);
Assert.assertEquals(executor.getCompletedTaskCount(), MAX_THREADS + 2);
Assert.assertEquals(executor.getQueue().size(), 0);
executor.shutdownNow();
}
示例9: setId_should_set_media_unique_ID_of_Type_Integer_StockLicenseHistoryFile
import org.testng.Assert; //导入方法依赖的package包/类
@Test(groups = { "Setters" })
void setId_should_set_media_unique_ID_of_Type_Integer_StockLicenseHistoryFile()
throws NoSuchFieldException, IllegalAccessException {
stocklicensehistoryfile.setId(1000);
Field f = stocklicensehistoryfile.getClass().getDeclaredField("mId");
f.setAccessible(true);
Assert.assertEquals(1000, f.get(stocklicensehistoryfile));
}
示例10: testSuccessfulRequests
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testSuccessfulRequests(){
int status = HttpStatus.SC_OK;
String expectedResponse = UUID.randomUUID().toString();
server.setResponse(status, expectedResponse);
DatarouterHttpClient client = new DatarouterHttpClientBuilder().build();
DatarouterHttpRequest request = new DatarouterHttpRequest(HttpRequestMethod.GET, URL, false);
DatarouterHttpResponse response = client.execute(request);
Assert.assertEquals(response.getEntity(), expectedResponse);
Assert.assertEquals(response.getStatusCode(), status);
}
示例11: listTest
import org.testng.Assert; //导入方法依赖的package包/类
@Test(dependsOnMethods = "createTest")
public void listTest()
{
ArrayNode all = institutions.list();
boolean scratchyFound = false;
boolean newFound = false;
for( JsonNode inst : all )
{
if( "AutoTest".equals(inst.get("name").asText()) )
{
scratchyFound = true;
Assert.assertEquals(inst.get("filestoreId").asText(), "autotest");
Assert.assertTrue(inst.get("enabled").asBoolean());
Assert.assertTrue(inst.get("url").asText().endsWith("/autotest/"));
Assert.assertNull(inst.get("password"));
}
else if( INST_NAME.equals(inst.get("name").asText()) )
{
newFound = true;
Assert.assertEquals(inst.get("filestoreId").asText(), INST_NAME);
Assert.assertTrue(inst.get("enabled").asBoolean());
Assert.assertTrue(inst.get("url").asText().endsWith("/" + INST_NAME + "/"));
Assert.assertNull(inst.get("password"));
}
if( scratchyFound && newFound )
{
break;
}
}
Assert.assertTrue(scratchyFound, "Scratchy not found");
Assert.assertTrue(newFound, "New institution not found");
}
示例12: testHTTPTextMappingXML
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testHTTPTextMappingXML() throws Exception {
SiddhiManager siddhiManager = new SiddhiManager();
siddhiManager.setExtension("xml-output-mapper", XMLSinkMapper.class);
String inStreamDefinition = "Define stream FooStream (message String,method String,headers String);"
+ "@sink(type='http',publisher.url='http://localhost:8005/abc',method='{{method}}',"
+ "headers='{{headers}}',"
+ "@map(type='xml', @payload('{{message}}'))) "
+ "Define stream BarStream (message String,method String,headers String);";
String query = ("@info(name = 'query') " +
"from FooStream select message,method,headers insert into BarStream;");
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition +
query);
InputHandler fooStream = siddhiAppRuntime.getInputHandler("FooStream");
siddhiAppRuntime.start();
HttpServerListenerHandler lst = new HttpServerListenerHandler(8005);
lst.run();
String payload = "<events>"
+ "<event>"
+ "<symbol>WSO2</symbol>"
+ "<price>55.645</price>"
+ "<volume>100</volume>"
+ "</event>"
+ "</events>";
fooStream.send(new Object[]{payload, "POST", "'Name:John','Age:23'"});
while (!lst.getServerListener().isMessageArrive()) {
Thread.sleep(10);
}
String eventData = lst.getServerListener().getData();
String expected = "<events>"
+ "<event>"
+ "<symbol>WSO2</symbol>"
+ "<price>55.645</price>"
+ "<volume>100</volume>"
+ "</event>"
+ "</events>\n";
Assert.assertEquals(eventData, expected);
siddhiAppRuntime.shutdown();
lst.shutdown();
}
示例13: testToReverseDateLong
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testToReverseDateLong(){
Date now = new Date(), zero = new Date(0L), max = new Date(Long.MAX_VALUE);
Assert.assertEquals(toReverseDateLong(now), (Long)(Long.MAX_VALUE - now.getTime()));
Assert.assertEquals(toReverseDateLong(zero), (Long)Long.MAX_VALUE);
Assert.assertEquals(toReverseDateLong(max), (Long)0L);
Assert.assertNull(toReverseDateLong(null));
}
示例14: testClear
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testClear ()
{
queue.offer (new FairQueueTestString ("key1", "item1"));
queue.offer (new FairQueueTestString ("key1", "item2"));
queue.offer (new FairQueueTestString ("key1", "item3"));
queue.offer (new FairQueueTestString ("key2", "item4"));
queue.offer (new FairQueueTestString ("key2", "item5"));
Assert.assertEquals (queue.size (), 5);
queue.clear ();
Assert.assertEquals (queue.size (), 0);
}
示例15: testMapList
import org.testng.Assert; //导入方法依赖的package包/类
@Test
public void testMapList() {
Projection projection = new Projection();
projection.setFields(singletonMap("list_field", "foo"));
BulletRecord record = RecordBox.get().addList("list_field", emptyMap(), singletonMap("foo", "baz"))
.getRecord();
BulletRecord expected = RecordBox.get().addList("foo", emptyMap(), singletonMap("foo", "baz"))
.getRecord();
BulletRecord actual = projection.project(record);
Assert.assertEquals(actual, expected);
}