org.testng.Assert#assertEquals ( )源码实例Demo

下面列出了org.testng.Assert#assertEquals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: athenz   文件: TestAuthZpe.java
@Test(dataProvider = "x509CertData")
public void testX509CertificateReadAllowed(String issuer, String subject, AccessCheckStatus expectedStatus, String angResource) {

    final String issuers = "InvalidToBeSkipped | C=US, ST=CA, O=Athenz, OU=Testing Domain, CN=angler:role.public | C=US, ST=CA, O=Athenz, OU=Testing Domain2, CN=angler:role.public | C=US, ST=CA, O=Athenz, OU=Testing Domain, CN=angler.test:role.public";
    AuthZpeClient.setX509CAIssuers(issuers);

    final String action = "read";
    X509Certificate cert = Mockito.mock(X509Certificate.class);
    X500Principal x500Principal = Mockito.mock(X500Principal.class);
    X500Principal x500PrincipalS = Mockito.mock(X500Principal.class);
    Mockito.when(x500Principal.getName()).thenReturn(issuer);
    Mockito.when(x500PrincipalS.getName()).thenReturn(subject);
    Mockito.when(cert.getIssuerX500Principal()).thenReturn(x500Principal);
    Mockito.when(cert.getSubjectX500Principal()).thenReturn(x500PrincipalS);
    AccessCheckStatus status = AuthZpeClient.allowAccess(cert, angResource, action);
    Assert.assertEquals(status, expectedStatus);
}
 
源代码2 项目: product-ei   文件: BPMNRestVariableTestCase.java
/**
 * Test creating new process variables
 * TEST : POST runtime/process-instances/{processInstanceId}/variables
 * @throws Exception
 */
@Test(groups = {"wso2.bps.bpmn.rest.variableTest"}, description = "test variable creation with charset", priority = 1,
        singleThreaded = true)
public void testCreateVariables () throws Exception {

    String createVarRequest =   "[\n" +
            "    { \n" +
            "      \"name\":\""+variable1Name+"\",\n" +
            "      \"type\":\"integer\",\n" +
            "      \"value\":15000 \n" +
            "    },\n" +
            "    { \n" +
            "      \"name\":\""+variable2Name+"\",\n" +
            "      \"type\":\"string\",\n" +
            "      \"value\":\"test Variable text\" \n" +
            "    }\n" +
            "]";
    String postUrl = backEndUrl + instanceUrl + "/" + targetProcessInstance.getInstanceId() + "/variables";
    HttpResponse response = BPMNTestUtils.postRequest(postUrl, new JSONArray(createVarRequest));

    Assert.assertEquals(response.getStatusLine().getStatusCode(), 201, "Variable creation failed. Casue : " +
            response.getStatusLine().getReasonPhrase());
}
 
源代码3 项目: brooklin   文件: TestDatastreamRestClient.java
@Test
public void testCreateDatastreamToNonLeader() throws Exception {
  // Start the second DMS instance to be the follower
  _datastreamCluster.startupServer(1);

  Datastream datastream = generateDatastream(5);
  LOG.info("Datastream : {}", datastream);

  int followerDmsPort = _datastreamCluster.getDatastreamPorts().get(1);
  DatastreamRestClient restClient = DatastreamRestClientFactory.getClient("http://localhost:" + followerDmsPort);
  restClient.createDatastream(datastream);
  Datastream createdDatastream = restClient.waitTillDatastreamIsInitialized(datastream.getName(), WAIT_TIMEOUT_MS);
  LOG.info("Created Datastream : {}", createdDatastream);
  datastream.setDestination(new DatastreamDestination());
  // server might have already set the destination so we need to unset it for comparison
  clearDatastreamDestination(Collections.singletonList(createdDatastream));
  clearDynamicMetadata(Collections.singletonList(createdDatastream));
  Assert.assertEquals(createdDatastream, datastream);
}
 
源代码4 项目: jenetics   文件: MSeqTest.java
@Test(dataProvider = "subSequences")
public void subSeqImmutable(final Named<MSeq<Integer>> parameter) {
	final MSeq<Integer> seq = parameter.value;
	final Integer second = seq.get(1);

	final MSeq<Integer> slice = seq.subSeq(1);
	Assert.assertEquals(slice.get(0), second);

	final ISeq<Integer> islice = slice.toISeq();
	Assert.assertEquals(islice.get(0), second);

	final Integer newSecond = -22;
	seq.set(1, newSecond);
	Assert.assertEquals(slice.get(0), newSecond);
	Assert.assertEquals(islice.get(0), second);
}
 
源代码5 项目: microprofile-config   文件: ArrayConverterTest.java
@Test
public void testCustomTypeSetInjection()  {
    Assert.assertEquals(converterBean.getMyPizzaSet().size(), 3);
    Assert.assertEquals(converterBean.getMyPizzaSet(), new LinkedHashSet<>(Arrays.asList(
        new Pizza("cheese,mushroom", "large"),
        new Pizza("chicken", "medium"),
        new Pizza("pepperoni", "small"))));
    Assert.assertEquals(converterBean.getMySinglePizzaSet().size(), 1);
    Assert.assertEquals(converterBean.getMySinglePizzaSet(), Collections.singleton(new Pizza("cheese,mushroom", "large")));
}
 
源代码6 项目: javasimon   文件: SimonUtilsAggregationTests.java
@Test
public void testAggregateSingleStopwatch() {
	StopwatchSample sample = new StopwatchSample();
	sample.setTotal(1);

	Stopwatch stopwatch = createMockStopwatch("stopwatch", sample);

	StopwatchAggregate aggregate = SimonUtils.calculateStopwatchAggregate(stopwatch);
	Assert.assertEquals(aggregate.getTotal(), 1);
}
 
源代码7 项目: incubator-pinot   文件: LoaderTest.java
@Test
public void testDefaultBytesColumn()
    throws Exception {
  Schema schema = constructV1Segment();
  String newColumnName = "byteMetric";
  String defaultValue = "0000ac0000";

  FieldSpec byteMetric = new MetricFieldSpec(newColumnName, FieldSpec.DataType.BYTES, defaultValue);
  schema.addField(byteMetric);
  IndexSegment indexSegment = ImmutableSegmentLoader.load(_indexDir, _v3IndexLoadingConfig, schema);
  Assert
      .assertEquals(BytesUtils.toHexString((byte[]) indexSegment.getDataSource(newColumnName).getDictionary().get(0)),
          defaultValue);
  indexSegment.destroy();
}
 
源代码8 项目: bullet-core   文件: GroupDataTest.java
@Test
public void testNoRecordCount() {
    GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.COUNT, null, "count"));

    // Count should be 0 if there was no data presented.
    BulletRecord expected = RecordBox.get().add("count", 0L).getRecord();
    Assert.assertEquals(data.getMetricsAsBulletRecord(provider), expected);
}
 
源代码9 项目: scheduler   文件: AllocateTest.java
@Test
public void testApply() {
    Model mo = new DefaultModel();
    Allocate na = new Allocate(vms.get(0), ns.get(1), "foo", 3, 3, 5);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addRunningVM(vms.get(0), ns.get(0));
    Assert.assertFalse(na.apply(mo));
    ShareableResource rc = new ShareableResource("foo");
    mo.attach(rc);
    Assert.assertTrue(na.apply(mo));
    Assert.assertEquals(3, rc.getConsumption(vms.get(0)));
}
 
@Test
public void heapifyUnionFromSparse() {
  UpdateDoublesSketch s1 = DoublesSketch.builder().build();
  s1.update(1);
  s1.update(2);
  Memory mem = Memory.wrap(s1.toByteArray(false));
  DoublesUnion u = DoublesUnion.heapify(mem);
  u.update(3);
  DoublesSketch s2 = u.getResult();
  Assert.assertEquals(s2.getMinValue(), 1.0);
  Assert.assertEquals(s2.getMaxValue(), 3.0);
}
 
@Test(dataProvider = "genotypeCount")
public void testInstanceNewInstance(int ploidy, int alleleCount, int expected) throws Exception {
    if (ploidy > 0) {
        final GenotypeLikelihoodCalculator inst = new GenotypeLikelihoodCalculators().getInstance(ploidy, alleleCount);
        Assert.assertEquals(inst.genotypeCount(), expected);
        Assert.assertEquals(inst.ploidy(), ploidy);
        Assert.assertEquals(inst.alleleCount(), alleleCount);
    }
}
 
源代码12 项目: curator   文件: TestFramework.java
@Test
public void testNamespaceWithWatcher() throws Exception
{
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
    CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(new RetryOneTime(1)).build();
    client.start();
    try
    {
        AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
        BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
        async.create().forPath("/base").
            thenRun(() -> async.watched().getChildren().forPath("/base").event().handle((event, x) -> {
                try
                {
                    queue.put(event.getPath());
                }
                catch ( InterruptedException e )
                {
                    throw new Error(e);
                }
                return null;
            }))
            .thenRun(() -> async.create().forPath("/base/child"));

        String path = queue.take();
        Assert.assertEquals(path, "/base");
    }
    finally
    {
        CloseableUtils.closeQuietly(client);
    }
}
 
源代码13 项目: Discord-Streambot   文件: CMoveTest.java
@Test
public void testExecuteNotAllowed() throws Exception {
    User user = jda.getUserById("63263941735755776");
    Message message = new MessageImpl("", null).setChannelId("131483070464393216").setAuthor(user).setContent("test");
    MessageReceivedEvent mre = new MessageReceivedEvent(jda, 1, message);
    command.execute(mre, "");

    Assert.assertEquals(1, MessageHandler.getQueue().size());
    Assert.assertEquals(MessageHandler.getQueue().peek().getMessage().getRawContent(), "You are not allowed to use this command");
}
 
@Parameters({"broker-port", "admin-username", "admin-password", "broker-hostname"})
@Test
public void testStringProperty(String port,
                               String adminUsername,
                               String adminPassword,
                               String brokerHostname) throws NamingException, JMSException {
    String queueName = "testStringProperty";

    InitialContext initialContextForQueue = ClientHelper
            .getInitialContextBuilder(adminUsername, adminPassword, brokerHostname, port)
            .withQueue(queueName)
            .build();

    ConnectionFactory connectionFactory
            = (ConnectionFactory) initialContextForQueue.lookup(ClientHelper.CONNECTION_FACTORY);
    Connection connection = connectionFactory.createConnection();
    connection.start();

    // send messages
    Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = producerSession.createQueue(queueName);
    MessageProducer producer = producerSession.createProducer(queue);
    String stringPropertyName = "StringProperty";
    String stringProperty = "[email protected]#$%^QWERTYqwerty123456";
    TextMessage textMessage = producerSession.createTextMessage("Test message");
    textMessage.setStringProperty(stringPropertyName, stringProperty);
    producer.send(textMessage);
    producerSession.close();

    // receive messages
    Destination subscriberDestination = (Destination) initialContextForQueue.lookup(queueName);
    Session subscriberSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = subscriberSession.createConsumer(subscriberDestination);

    TextMessage message = (TextMessage) consumer.receive(1000);
    Assert.assertNotNull(message, "Message was not received");
    String receivedStringProperty = message.getStringProperty(stringPropertyName);
    Assert.assertEquals(stringProperty, receivedStringProperty, "String property not matched.");

    subscriberSession.close();
    connection.close();
}
 
源代码15 项目: bullet-core   文件: BulletConfigTest.java
@Test
public void testMissingFile() {
    BulletConfig config = new BulletConfig("/path/to/non/existant/file");
    Assert.assertEquals(config.get(BulletConfig.QUERY_MAX_DURATION), Long.MAX_VALUE);
}
 
@Test(description = "convert a simple scala model")
public void simpleModelTest() {
    final Schema model = new Schema()
            .description("a sample model")
            .addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
            .addProperties("name", new StringSchema())
            .addProperties("createdAt", new DateTimeSchema())
            .addRequiredItem("id")
            .addRequiredItem("name");
    final DefaultCodegen codegen = new ScalaAkkaClientCodegen();
    OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
    codegen.setOpenAPI(openAPI);
    final CodegenModel cm = codegen.fromModel("sample", model);

    Assert.assertEquals(cm.name, "sample");
    Assert.assertEquals(cm.classname, "Sample");
    Assert.assertEquals(cm.description, "a sample model");
    Assert.assertEquals(cm.vars.size(), 3);

    final CodegenProperty property1 = cm.vars.get(0);
    Assert.assertEquals(property1.baseName, "id");
    Assert.assertEquals(property1.getter, "getId");
    Assert.assertEquals(property1.setter, "setId");
    Assert.assertEquals(property1.dataType, "Long");
    Assert.assertEquals(property1.name, "id");
    Assert.assertNull(property1.defaultValue);
    Assert.assertEquals(property1.baseType, "Long");
    Assert.assertTrue(property1.hasMore);
    Assert.assertTrue(property1.required);
    Assert.assertFalse(property1.isContainer);

    final CodegenProperty property2 = cm.vars.get(1);
    Assert.assertEquals(property2.baseName, "name");
    Assert.assertEquals(property2.getter, "getName");
    Assert.assertEquals(property2.setter, "setName");
    Assert.assertEquals(property2.dataType, "String");
    Assert.assertEquals(property2.name, "name");
    Assert.assertNull(property2.defaultValue);
    Assert.assertEquals(property2.baseType, "String");
    Assert.assertTrue(property2.hasMore);
    Assert.assertTrue(property2.required);
    Assert.assertFalse(property2.isContainer);

    final CodegenProperty property3 = cm.vars.get(2);
    Assert.assertEquals(property3.baseName, "createdAt");
    Assert.assertEquals(property3.getter, "getCreatedAt");
    Assert.assertEquals(property3.setter, "setCreatedAt");
    Assert.assertEquals(property3.dataType, "DateTime");
    Assert.assertEquals(property3.name, "createdAt");
    Assert.assertNull(property3.defaultValue);
    Assert.assertEquals(property3.baseType, "DateTime");
    Assert.assertFalse(property3.hasMore);
    Assert.assertFalse(property3.required);
    Assert.assertFalse(property3.isContainer);
}
 
源代码17 项目: brooklyn-server   文件: MutableListTest.java
public void testBuilderAddIfNotNull() throws Exception {
    List<Object> vals = MutableList.builder().addIfNotNull(1).addIfNotNull(null).build();
    Assert.assertEquals(vals, ImmutableList.of(1));
}
 
源代码18 项目: git-as-svn   文件: SvnGetLocationsTest.java
private void checkGetSegments(@NotNull SVNRepository repo, @NotNull String path, long pegRev, long startRev, long endRev, @NotNull String... expected) throws SVNException {
  final List<String> actual = new ArrayList<>();
  final ISVNLocationSegmentHandler handler = locationEntry -> actual.add(locationEntry.getPath() + "@" + locationEntry.getStartRevision() + ":" + locationEntry.getEndRevision());
  repo.getLocationSegments(path, pegRev, startRev, endRev, handler);
  Assert.assertEquals(actual.toArray(new String[0]), expected);
}
 
源代码19 项目: gatk   文件: SVUtilsUnitTest.java
@Test(groups = "sv")
void hashMapCapacityTest() {
    Assert.assertEquals(SVUtils.hashMapCapacity(150),201);
}
 
源代码20 项目: carina   文件: TestRailTest.java
@Test
@TestRailCases(testCasesId = FIRST_TEST_ID, platform = "ios")
@TestRailCases(testCasesId = SECOND_TEST_ID, platform = "android")
public void testTestRailByPlatform() {
    ITestResult result = Reporter.getCurrentTestResult();

    Set<String> testRailUdids = getTestRailCasesUuid(result);

    Assert.assertEquals(testRailUdids.size(), 0);

    R.CONFIG.put(SpecialKeywords.MOBILE_DEVICE_PLATFORM, SpecialKeywords.IOS);

    testRailUdids = getTestRailCasesUuid(result);

    Assert.assertTrue(testRailUdids.contains(FIRST_TEST_ID), "TestRail should contain id=" + FIRST_TEST_ID);

    Assert.assertEquals(testRailUdids.size(), 1);

    R.CONFIG.put(SpecialKeywords.MOBILE_DEVICE_PLATFORM, SpecialKeywords.ANDROID);

    testRailUdids = getTestRailCasesUuid(result);

    Assert.assertTrue(testRailUdids.contains(SECOND_TEST_ID), "TestRail should contain id=" + SECOND_TEST_ID);

    Assert.assertEquals(testRailUdids.size(), 1);

    R.CONFIG.put(SpecialKeywords.MOBILE_DEVICE_PLATFORM, "");
}