Java Code Examples for org.testng.Assert#assertEquals()
The following examples show how to use
org.testng.Assert#assertEquals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MSeqTest.java From jenetics with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: TestDatastreamRestClient.java From brooklin with BSD 2-Clause "Simplified" License | 6 votes |
@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); }
Example 3
Source File: BPMNRestVariableTestCase.java From product-ei with Apache License 2.0 | 6 votes |
/** * 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()); }
Example 4
Source File: TestAuthZpe.java From athenz with Apache License 2.0 | 6 votes |
@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); }
Example 5
Source File: ArrayConverterTest.java From microprofile-config with Apache License 2.0 | 5 votes |
@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"))); }
Example 6
Source File: CMoveTest.java From Discord-Streambot with MIT License | 5 votes |
@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"); }
Example 7
Source File: TestFramework.java From curator with Apache License 2.0 | 5 votes |
@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); } }
Example 8
Source File: GenotypeLikelihoodCalculatorsUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); } }
Example 9
Source File: ReadOnlyMemoryTest.java From incubator-datasketches-java with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: AllocateTest.java From scheduler with GNU Lesser General Public License v3.0 | 5 votes |
@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))); }
Example 11
Source File: GroupDataTest.java From bullet-core with Apache License 2.0 | 5 votes |
@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); }
Example 12
Source File: LoaderTest.java From incubator-pinot with Apache License 2.0 | 5 votes |
@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(); }
Example 13
Source File: SimonUtilsAggregationTests.java From javasimon with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example 14
Source File: MutableListTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
public void testBuilderAddIfNotNull() throws Exception { List<Object> vals = MutableList.builder().addIfNotNull(1).addIfNotNull(null).build(); Assert.assertEquals(vals, ImmutableList.of(1)); }
Example 15
Source File: ScalaAkkaClientCodegenTest.java From openapi-generator with Apache License 2.0 | 4 votes |
@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); }
Example 16
Source File: BulletConfigTest.java From bullet-core with Apache License 2.0 | 4 votes |
@Test public void testMissingFile() { BulletConfig config = new BulletConfig("/path/to/non/existant/file"); Assert.assertEquals(config.get(BulletConfig.QUERY_MAX_DURATION), Long.MAX_VALUE); }
Example 17
Source File: SvnGetLocationsTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
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); }
Example 18
Source File: JmsPropertyTypeTest.java From ballerina-message-broker with Apache License 2.0 | 4 votes |
@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 = "!@#$%^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(); }
Example 19
Source File: SVUtilsUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(groups = "sv") void hashMapCapacityTest() { Assert.assertEquals(SVUtils.hashMapCapacity(150),201); }
Example 20
Source File: TestRailTest.java From carina with Apache License 2.0 | 3 votes |
@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, ""); }