Java Code Examples for org.testng.Assert#assertNotEquals()

The following examples show how to use org.testng.Assert#assertNotEquals() . 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: PostgreSqlSaltLiveTest.java    From brooklyn-library with Apache License 2.0 6 votes vote down vote up
@Test(groups="Live")
public void testPostgresStartsAndStops() throws Exception {
    psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class, PostgreSqlNodeSaltImpl.class)
            .configure(SaltConfig.MASTERLESS_MODE, true));

    app.start(ImmutableList.of(targetLocation));

    Entities.submit(psql, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").requiringExitCodeZero());
    SshMachineLocation targetMachine = EffectorTasks.getSshMachine(psql);

    psql.stop();

    try {
        // if host is still contactable ensure postgres is not running
        ProcessTaskWrapper<Integer> t = Entities.submit(app, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").machine(targetMachine).allowingNonZeroExitCode());
        t.getTask().blockUntilEnded(Duration.TEN_SECONDS);
        if (!t.isDone()) {
            Assert.fail("Task not finished yet: "+t.getTask());
        }
        Assert.assertNotEquals(t.get(), (Integer)0, "Task ended with code "+t.get()+"; output: "+t.getStdout() );
    } catch (Exception e) {
        // host has been killed, that is fine
        log.info("Machine "+targetMachine+" destroyed on stop (expected - "+e+")");
    }
}
 
Example 2
Source File: SessionTest.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
@Test(dataProvider = "getSessionManager")
public void testInvalidateAngGet(WxSessionManager sessionManager) {

  WxSession session1 = sessionManager.getSession("abc");
  session1.invalidate();
  WxSession session2 = sessionManager.getSession("abc");
  Assert.assertNotEquals(session1, session2);
  InternalSessionManager ism = (InternalSessionManager) sessionManager;
  Assert.assertEquals(ism.getActiveSessions(), 1);

}
 
Example 3
Source File: SshEffectorTasksTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test(groups="Integration")
public void testNonRunningPid() {
    ProcessTaskWrapper<Integer> t = submit(SshEffectorTasks.codePidRunning(99999));
    Assert.assertNotEquals(t.getTask().getUnchecked(), 0);
    Assert.assertNotEquals(t.getExitCode(), 0);
    ProcessTaskWrapper<Boolean> t2 = submit(SshEffectorTasks.isPidRunning(99999));
    Assert.assertFalse(t2.getTask().getUnchecked());
}
 
Example 4
Source File: TestTopic.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUniqueId() {
    Topic<String> topicA = Topic.create();
    for (int i = 0; i < 1000; i++) {
        Topic<String> topicB = Topic.create();
        Assert.assertNotEquals(topicA, topicB);
    }
}
 
Example 5
Source File: AnalyzeSaturationMutagenesisUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testInterval() {
    final Interval interval1 = new Interval(1, 3);
    Assert.assertEquals(interval1.size(), 2);
    final Interval interval2 = new Interval(1, 3);
    Assert.assertEquals(interval1, interval2);
    Assert.assertEquals(interval1.hashCode(), interval2.hashCode());
    final Interval interval3 = new Interval(1, 4);
    Assert.assertNotEquals(interval1, interval3);
    Assert.assertNotEquals(interval1.hashCode(), interval3.hashCode());
}
 
Example 6
Source File: EqualsTests.java    From quandl4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testSearchResult() {
  SearchResult searchResult1 = SearchResult.of(getTestObj1());
  SearchResult searchResult2 = SearchResult.of(getTestObj2());
  SearchResult searchResult3 = SearchResult.of(getTestObj1());
  Assert.assertEquals(searchResult1, searchResult1);
  Assert.assertEquals(searchResult1, searchResult3);
  Assert.assertEquals(searchResult3, searchResult1);
  Assert.assertNotEquals(searchResult1, searchResult2);
  Assert.assertNotEquals(searchResult2, searchResult1);
  // not strictly within the hashCode requirements, but we'd like this to be the case.
  Assert.assertNotEquals(searchResult1.hashCode(), searchResult2.hashCode());
  Assert.assertEquals(searchResult1.hashCode(), searchResult1.hashCode());
  Assert.assertEquals(searchResult1.hashCode(), searchResult3.hashCode());
}
 
Example 7
Source File: DeviceTypeManagerServiceTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Test(description = "This test case tests the populateNotificationConfig method and retrieval of the same.")
public void testPopulatePushNotificationConfig() throws InvocationTargetException, IllegalAccessException {
    populatePushNotificationConfig
            .invoke(androidDeviceTypeManagerService, androidDeviceConfiguration.getPushNotificationProvider());
    PushNotificationConfig pushNotificationConfig = androidDeviceTypeManagerService.getPushNotificationConfig();
    Assert.assertNotEquals(pushNotificationConfig, null, "Push notification configuration is set even though "
            + "Push notfication configuration was not mentioned.");

    populatePushNotificationConfig.invoke(rasberrypiDeviceTypeManagerService,
            rasberrypiDeviceConfiguration.getPushNotificationProvider());
    pushNotificationConfig = rasberrypiDeviceTypeManagerService.getPushNotificationConfig();
    PushNotificationProvider pushNotificationProvider = rasberrypiDeviceConfiguration.getPushNotificationProvider();
    Assert.assertEquals(pushNotificationConfig.getType(), pushNotificationProvider.getType());
    Assert.assertEquals(pushNotificationConfig.isScheduled(), pushNotificationProvider.isScheduled());
}
 
Example 8
Source File: GeneTester.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void notEqualsAllele() {
	for (int i = 0; i < 1000; ++i) {
		final Object that = factory().newInstance().allele();
		final Object other = factory().newInstance().allele();

		if (that.equals(other)) {
			Assert.assertEquals(other, that);
			Assert.assertEquals(that.hashCode(), other.hashCode());
		} else {
			Assert.assertNotEquals(other, that);
			Assert.assertNotEquals(that, other);
		}
	}
}
 
Example 9
Source File: GzipCompressorTest.java    From flashback with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCompress()
    throws IOException {
  String str = "Hello world";
  String charset = "ISO-8859-1";
  byte[] content = str.getBytes(charset);
  GzipCompressor gzipCompressor = new GzipCompressor();

  byte[] compressedContent = gzipCompressor.compress(content);
  Assert.assertNotEquals(compressedContent.length, content.length);

  GzipDecompressor gzipDecompressor = new GzipDecompressor();
  Assert.assertEquals(gzipDecompressor.decompress(compressedContent), content);
}
 
Example 10
Source File: FlagStatIntegrationTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testNonEqualFS(){
    FlagStat.FlagStatus l1 = makeFlagStatus();
    FlagStat.FlagStatus l2 = makeFlagStatus();
    l2.duplicates++;
    Assert.assertNotEquals(l1, l2);
    Assert.assertNotEquals(l1.hashCode(), l2.hashCode());
    Assert.assertNotSame(l1, l2);
}
 
Example 11
Source File: TreeTestBase.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void nonEquals() {
	final T tree1 = newTree(6, new Random(123));
	final T tree2 = newTree(6, new Random(1232));

	Assert.assertNotEquals(tree2, tree1);
}
 
Example 12
Source File: WxMpBaseAPITest.java    From weixin-java-tools with Apache License 2.0 5 votes vote down vote up
public void testRefreshAccessToken() throws WxErrorException {
  WxMpConfigStorage configStorage = wxService.wxMpConfigStorage;
  String before = configStorage.getAccessToken();
  wxService.getAccessToken(false);

  String after = configStorage.getAccessToken();
  Assert.assertNotEquals(before, after);
  Assert.assertTrue(StringUtils.isNotBlank(after));
}
 
Example 13
Source File: AuraTests.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAura() {
	GameContext context = createContext(HeroClass.MAGE, HeroClass.WARRIOR);
	Player player = context.getPlayer1();
	Player opponent = context.getPlayer2();

	TestMinionCard minionCard = new TestMinionCard(1, 1);
	minionCard.getMinion().addSpellTrigger(new BuffAura(1, 1, EntityReference.OTHER_FRIENDLY_MINIONS, null));
	playCard(context, player, minionCard);

	Actor minion1 = getSingleMinion(player.getMinions());
	Assert.assertEquals(minion1.getAttack(), 1);

	minionCard = new TestMinionCard(1, 1);
	minionCard.getMinion().addSpellTrigger(new BuffAura(1, 1, EntityReference.OTHER_FRIENDLY_MINIONS, null));
	Actor minion2 = playMinionCard(context, player, minionCard);

	Assert.assertNotEquals(minion1, minion2);
	Assert.assertEquals(minion1.getAttack(), 2);
	Assert.assertEquals(minion2.getAttack(), 2);

	TestMinionCard minionCardOpponent = new TestMinionCard(3, 3);
	Actor enemyMinion = playMinionCard(context, opponent, minionCardOpponent);
	Assert.assertEquals(enemyMinion.getAttack(), 3);

	Assert.assertEquals(minion1.getAttack(), 2);
	Assert.assertEquals(minion2.getAttack(), 2);
	PhysicalAttackAction attackAction = new PhysicalAttackAction(enemyMinion.getReference());
	attackAction.setTarget(minion2);
	context.getLogic().performGameAction(opponent.getId(), attackAction);
	Assert.assertEquals(minion1.getAttack(), 1);

	minionCard = new TestMinionCard(1, 1);
	minion2 = playMinionCard(context, player, minionCard);
	Assert.assertEquals(minion1.getAttack(), 1);
	Assert.assertEquals(minion2.getAttack(), 2);
}
 
Example 14
Source File: JobMetricsTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobMetricsGet() {
  String jobName = "testJob";
  String jobId = "job_123";

  JobState jobState = new JobState(jobName, jobId);
  JobMetrics jobMetrics = JobMetrics.get(jobState);

  Assert.assertNotNull(jobMetrics.getMetricContext());

  List<Tag<?>> tags = jobMetrics.getMetricContext().getTags();
  Map<String, ?> tagMap = jobMetrics.getMetricContext().getTagMap();
  String contextId = tagMap.get(MetricContext.METRIC_CONTEXT_ID_TAG_NAME).toString();
  String contextName = tagMap.get(MetricContext.METRIC_CONTEXT_NAME_TAG_NAME).toString();

  Assert.assertEquals(tagMap.size(), 4);
  Assert.assertEquals(tagMap.get(JobEvent.METADATA_JOB_ID), jobId);
  Assert.assertEquals(tagMap.get(JobEvent.METADATA_JOB_NAME), jobName);
  Assert.assertEquals(tagMap.get(MetricContext.METRIC_CONTEXT_ID_TAG_NAME), contextId);
  Assert.assertEquals(tagMap.get(MetricContext.METRIC_CONTEXT_NAME_TAG_NAME), contextName);

  // should get the original jobMetrics, can check by the id
  JobMetrics jobMetrics1 = JobMetrics.get(jobName + "_", jobId);
  Assert.assertNotNull(jobMetrics1.getMetricContext());

  tagMap = jobMetrics1.getMetricContext().getTagMap();
  Assert.assertEquals(tags.size(), 4);
  Assert.assertEquals(tagMap.get(MetricContext.METRIC_CONTEXT_ID_TAG_NAME), contextId);
  Assert.assertEquals(tagMap.get(MetricContext.METRIC_CONTEXT_NAME_TAG_NAME), contextName);

  // remove original jobMetrics, should create a new one
  GobblinMetricsRegistry.getInstance().remove(jobMetrics.getId());
  JobMetrics jobMetrics2 = JobMetrics.get(jobName + "_", jobId);
  Assert.assertNotNull(jobMetrics2.getMetricContext());

  tagMap = jobMetrics2.getMetricContext().getTagMap();
  Assert.assertEquals(tags.size(), 4);
  Assert.assertNotEquals(tagMap.get(MetricContext.METRIC_CONTEXT_ID_TAG_NAME), contextId);
  Assert.assertNotEquals(tagMap.get(MetricContext.METRIC_CONTEXT_NAME_TAG_NAME), contextName);
}
 
Example 15
Source File: StateTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Test
public void testState()
    throws IOException {
  State state = new State();

  Assert.assertEquals(state.getProp("string", "some string"), "some string");
  Assert.assertEquals(state.getPropAsList("list", "item1,item2").get(0), "item1");
  Assert.assertEquals(state.getPropAsList("list", "item1,item2").get(1), "item2");
  Assert.assertEquals(state.getPropAsLong("long", Long.MAX_VALUE), Long.MAX_VALUE);
  Assert.assertEquals(state.getPropAsInt("int", Integer.MAX_VALUE), Integer.MAX_VALUE);
  Assert.assertEquals(state.getPropAsDouble("double", Double.MAX_VALUE), Double.MAX_VALUE);
  Assert.assertEquals(state.getPropAsBoolean("boolean", true), true);

  state.setProp("string", "some string");
  state.setProp("list", "item1,item2");
  state.setProp("long", Long.MAX_VALUE);
  state.setProp("int", Integer.MAX_VALUE);
  state.setProp("double", Double.MAX_VALUE);
  state.setProp("boolean", true);

  Assert.assertEquals(state.getProp("string"), "some string");
  Assert.assertEquals(state.getPropAsList("list").get(0), "item1");
  Assert.assertEquals(state.getPropAsList("list").get(1), "item2");
  Assert.assertEquals(state.getPropAsLong("long"), Long.MAX_VALUE);
  Assert.assertEquals(state.getPropAsInt("int"), Integer.MAX_VALUE);
  Assert.assertEquals(state.getPropAsDouble("double"), Double.MAX_VALUE);
  Assert.assertEquals(state.getPropAsBoolean("boolean"), true);

  state.setProp("string", "some other string");
  state.setProp("list", "item3,item4");
  state.setProp("long", Long.MIN_VALUE);
  state.setProp("int", Integer.MIN_VALUE);
  state.setProp("double", Double.MIN_VALUE);
  state.setProp("boolean", false);

  Assert.assertNotEquals(state.getProp("string", "some string"), "some string");
  Assert.assertNotEquals(state.getPropAsList("list", "item1,item2").get(0), "item1");
  Assert.assertNotEquals(state.getPropAsList("list", "item1,item2").get(1), "item2");
  Assert.assertNotEquals(state.getPropAsLong("long", Long.MAX_VALUE), Long.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsInt("int", Integer.MAX_VALUE), Integer.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsDouble("double", Double.MAX_VALUE), Double.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsBoolean("boolean", true), true);

  Assert.assertNotEquals(state.getProp("string"), "some string");
  Assert.assertNotEquals(state.getPropAsList("list").get(0), "item1");
  Assert.assertNotEquals(state.getPropAsList("list").get(1), "item2");
  Assert.assertNotEquals(state.getPropAsLong("long"), Long.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsInt("int"), Integer.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsDouble("double"), Double.MAX_VALUE);
  Assert.assertNotEquals(state.getPropAsBoolean("boolean"), true);

  Assert.assertEquals(state.getProp("string"), "some other string");
  Assert.assertEquals(state.getPropAsList("list").get(0), "item3");
  Assert.assertEquals(state.getPropAsList("list").get(1), "item4");
  Assert.assertEquals(state.getPropAsLong("long"), Long.MIN_VALUE);
  Assert.assertEquals(state.getPropAsInt("int"), Integer.MIN_VALUE);
  Assert.assertEquals(state.getPropAsDouble("double"), Double.MIN_VALUE);
  Assert.assertEquals(state.getPropAsBoolean("boolean"), false);

  ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024);
  DataOutputStream out = new DataOutputStream(byteStream);

  state.write(out);

  DataInputStream in = new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray()));

  state = new State();

  Assert.assertEquals(state.getProp("string"), null);
  Assert.assertEquals(state.getProp("list"), null);
  Assert.assertEquals(state.getProp("long"), null);
  Assert.assertEquals(state.getProp("int"), null);
  Assert.assertEquals(state.getProp("double"), null);
  Assert.assertEquals(state.getProp("boolean"), null);

  state.readFields(in);

  Assert.assertEquals(state.getProp("string"), "some other string");
  Assert.assertEquals(state.getPropAsList("list").get(0), "item3");
  Assert.assertEquals(state.getPropAsList("list").get(1), "item4");
  Assert.assertEquals(state.getPropAsLong("long"), Long.MIN_VALUE);
  Assert.assertEquals(state.getPropAsInt("int"), Integer.MIN_VALUE);
  Assert.assertEquals(state.getPropAsDouble("double"), Double.MIN_VALUE);
  Assert.assertEquals(state.getPropAsBoolean("boolean"), false);

  State state2 = new State();
  state2.addAll(state);

  Assert.assertEquals(state2.getProp("string"), "some other string");
  Assert.assertEquals(state2.getPropAsList("list").get(0), "item3");
  Assert.assertEquals(state2.getPropAsList("list").get(1), "item4");
  Assert.assertEquals(state2.getPropAsLong("long"), Long.MIN_VALUE);
  Assert.assertEquals(state2.getPropAsInt("int"), Integer.MIN_VALUE);
  Assert.assertEquals(state2.getPropAsDouble("double"), Double.MIN_VALUE);
  Assert.assertEquals(state2.getPropAsBoolean("boolean"), false);
}
 
Example 16
Source File: ODataETagTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.dss", description = "etag concurrent handling with delete method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForPatchMethod")
public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Exception {
	String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES";
	String content = "{\"FILENAME\": \"M.K.H.Gunasekara\" ,\"TYPE\" : \"dss\"}";
	Map<String, String> headers = new HashMap<>();
	headers.put("Accept", "application/json");
	Object[] response = sendPOST(endpoint, content, headers);
	Assert.assertEquals(response[0], ODataTestUtils.CREATED);
	endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'M.K.H.Gunasekara\')";
	response = sendGET(endpoint, headers);
	Assert.assertEquals(response[0], ODataTestUtils.OK);
	String etag = ODataTestUtils.getETag(response[1].toString());
	headers.put("If-None-Match", etag);
	int responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED);
	headers.remove("If-None-Match");
	headers.put("If-Match", etag);
	responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT);
	responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND);

	// To insert values
	validateETagRetrievalTestCase();

	//testing concurrent test with put method
	// get the E-Tag
	response = sendGET(endpoint, headers);
	Assert.assertEquals(response[0], ODataTestUtils.OK);
	etag = getETag(response[1].toString());
	content = "{\"TYPE\" : \"SriLanka\"}";
	headers.remove("If-Match");
	ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint);
	threadExecutor.run();
	Thread.sleep(1000);
	response = sendGET(endpoint, headers);
	Assert.assertEquals(response[0], ODataTestUtils.OK);
	String tempETag = getETag(response[1].toString());
	Assert.assertNotEquals(etag, tempETag);
	headers.put("If-Match", etag);
	responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED);
	headers.put("If-Match", tempETag);
	responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT);
	responseCode = sendDELETE(endpoint, headers);
	Assert.assertEquals(responseCode, 404);
}
 
Example 17
Source File: MathUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * This is not really a test but a demo that adding doubles can have different results depending on the order.
 * You can remedy that my using multipliers but that too can lead to different results depending on the multiplier.
 */
@Test
public void testAddDoubles() throws Exception {
    final double[] ds =
            {0.125,
             0.125,
             0.125, 0.125, 0.125, 0.125,
                    0.125, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285,
                    0.14285714285714285, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285,
                    0.125, 0.125, 0.125, 0.125,
                    0.125, 0.125, 0.125, 0.125};

    final double[] ds_reordered = {
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.125,
    0.14285714285714285,
    0.14285714285714285,
    0.14285714285714285,
    0.14285714285714285,
    0.14285714285714285,
    0.14285714285714285,
    0.14285714285714285};

    //Use different multipliers, see that the results are all different
    double sumNoMult = 0.0;
    for (int i = 0; i < ds.length; i++) {
        sumNoMult += ds[i];
    }
    double sumNoMult_reordered = 0.0;
    for (int i = 0; i < ds_reordered.length; i++) {
        sumNoMult_reordered += ds[i];
    }

    double sumMult1000 = 0.0;
    for (int i = 0; i < ds.length; i++) {
        sumMult1000 += ds[i] * 1000.0;
    }
    sumMult1000 /= 1000.0;

    double sumMult10000 = 0.0;
    for (int i = 0; i < ds.length; i++) {
        sumMult10000 += ds[i] * 10000.0;
    }
    sumMult10000 /= 10000.0;

    double sumMult100000 = 0.0;
    for (int i = 0; i < ds.length; i++) {
        sumMult100000 += ds[i] * 100000.0;
    }
    sumMult100000 /= 100000.0;

    double sumMult100000_reordered = 0.0;
    for (int i = 0; i < ds_reordered.length; i++) {
        sumMult100000_reordered += ds_reordered[i] * 100000.0;
    }
    sumMult100000_reordered /= 100000.0;

    double sumMult1000_reordered = 0.0;
    for (int i = 0; i < ds_reordered.length; i++) {
        sumMult1000_reordered += ds_reordered[i] * 1000.0;
    }
    sumMult1000_reordered /= 1000.0;

    //They are all different
    Assert.assertNotEquals(sumNoMult, sumMult1000);
    Assert.assertNotEquals(sumNoMult, sumMult10000);
    Assert.assertNotEquals(sumMult1000, sumMult10000);

    Assert.assertNotEquals(sumMult1000, sumMult1000_reordered); //not equal to itself when reordered

    //But these ones is the same ordered or not (though not equal to each other)
    Assert.assertEquals(sumNoMult, sumNoMult_reordered, sumNoMult + " vs " + sumNoMult_reordered);
    Assert.assertEquals(sumMult100000_reordered, sumMult100000);
    Assert.assertNotEquals(sumNoMult, sumMult100000);
}
 
Example 18
Source File: TestEntityInitTest.java    From extentreports-java with Apache License 2.0 4 votes vote down vote up
@org.testng.annotations.Test
public void testId1OrGreaterOnInit() {
    Test test = Test.builder().build();
    Assert.assertNotEquals(test.getId(), 0);
}
 
Example 19
Source File: ODataETagTestCase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Test(groups = "wso2.dss", description = "etag concurrent handling with patch method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForPutMethod")
public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Exception {
    String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')";
    Map<String, String> headers = new HashMap<>();
    headers.put("Accept", "application/json");
    Object[] response = sendGET(endpoint, headers);
    Assert.assertEquals(response[0], ODataTestUtils.OK);
    String etag = getETag(response[1].toString());
    //modifying data - E-Tag should be changed after processing the below request
    headers.put("If-Match", etag);
    String content = "{\"TYPE\" : \"ml\"}";
    int responseCode = sendPATCH(endpoint, content, headers);
    Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT);
    // Data has been modified therefore E-Tag has been changed, Then If-None-Match should be worked with previous E-Tag
    headers.remove("If-Match");
    headers.put("If-None-Match", etag);
    content = "{\"TYPE\" : \"test\"}";
    responseCode = sendPATCH(endpoint, content, headers);
    Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT);

    //testing concurrent test with put method
    // get the E-Tag
    response = sendGET(endpoint, headers);
    Assert.assertEquals(response[0], ODataTestUtils.OK);
    etag = getETag(response[1].toString());
    content = "{\"TYPE\" : \"SriLanka\"}";
    headers.remove("If-None-Match");
    ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint);
    threadExecutor.run();
    Thread.sleep(1000);
    response = sendGET(endpoint, headers);
    Assert.assertEquals(response[0], ODataTestUtils.OK);
    String tempETag = getETag(response[1].toString());
    Assert.assertNotEquals(etag, tempETag);
    headers.put("If-Match", etag);
    content = "{\"TYPE\" : \"MB\"}";
    responseCode = sendPATCH(endpoint, content, headers);
    Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED);
    headers.put("If-Match", tempETag);
    response = sendGET(endpoint, headers);
    Assert.assertEquals(response[0], ODataTestUtils.OK);
    // Data validation
    Assert.assertFalse(response[1].toString().contains("MB"), "E-Tag with put method failed");
    Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with put method failed");

    //testing concurrent test with delete method
    // get the E-Tag
    response = sendGET(endpoint, headers);
    Assert.assertEquals(response[0], ODataTestUtils.OK);
    headers.remove("If-Match");
    threadExecutor = new ODataRequestThreadExecutor("DELETE", null, headers, endpoint);
    threadExecutor.run();
    Thread.sleep(1000);
    headers.put("If-Match", etag);
    content = "{\"TYPE\" : \"MB\"}";
    responseCode = sendPATCH(endpoint, content, headers);
    Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND);
}
 
Example 20
Source File: TasmoViewModelTest.java    From tasmo with Apache License 2.0 4 votes vote down vote up
/**
 * Test of loadModel method, of class TasmoViewModel.
 */
@Test (invocationCount = 1, singleThreaded = true)
public void testLoadModel() throws Exception {
    System.out.println("loadModel");

    ChainedVersion version1 = new ChainedVersion("0", "1");
    ChainedVersion version2 = new ChainedVersion("1", "2");
    Views views1 = makeViews("Foo", version1, "A", "x", "y", "z");
    Views views2 = makeViews("Bar", version2, "B", "j", "k", "l");

    ObjectNode event = mapper.createObjectNode();
    ObjectNode instance = mapper.createObjectNode();
    instance.put("j", "j");
    instance.put("k", "k");
    instance.put("l", "l");

    JsonEventConventions jec = new JsonEventConventions();
    jec.setActorId(event, new Id(1));
    jec.setUserId(event, new Id(1));
    jec.setEventId(event, 2);
    jec.setInstanceClassName(event, "Bar");
    jec.setTenantId(event, tenantId);
    jec.setInstanceId(event, new Id(3), "Bar");
    jec.setInstanceNode(event, "Bar", instance);

    Mockito.when(viewsProvider.getCurrentViewsVersion(tenantId)).thenReturn(version1, version2);
    Mockito.when(viewsProvider.getViews(Mockito.any(ViewsProcessorId.class))).thenReturn(views1, views2);

    tasmoViewModel.loadModel(tenantId);
    VersionedTasmoViewModel first = tasmoViewModel.getVersionedTasmoViewModel(tenantId);
    Assert.assertEquals(version1, first.getVersion());
    Assert.assertTrue(first.getWriteTraversers().containsKey("A"));
    Assert.assertFalse(first.getWriteTraversers().containsKey("B"));

    tasmoViewModel.loadModel(tenantId);
    VersionedTasmoViewModel second = tasmoViewModel.getVersionedTasmoViewModel(tenantId);
    Assert.assertNotEquals(first, second);
    Assert.assertEquals(version2, second.getVersion());
    Assert.assertTrue(second.getWriteTraversers().containsKey("B"));
    Assert.assertFalse(second.getWriteTraversers().containsKey("A"));

}