fixed assertion error in ShardedDOMDataWriteTransactionTest 56/40856/2
authorPeter Nosal <peter.nosal@pantheon.tech>
Mon, 27 Jun 2016 08:50:59 +0000 (10:50 +0200)
committerPeter Nosal <peter.nosal@pantheon.tech>
Mon, 27 Jun 2016 09:58:25 +0000 (09:58 +0000)
getIdentifier() method returns String (as a name) and counter in form
of incremented Atomic long in every new instantiation. Before this
change test exactly expected to have an 0 and then 1 at counter side,
but if some other test create an instance of
ShardedDOMDataWriteTransaction before this test, counter will alredy be
greater than 0 so presumably that is what happend and test is order
dependant. I removed this dependency and now test is checking for
non-equality of two differend object identifiers, so does not matter
what is at counter side at beggining of this test.

Change-Id: I65401ea99bc7d8d94e4ef1fc9b52a1b9909f63fe
Signed-off-by: Peter Nosal <peter.nosal@pantheon.tech>
dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataWriteTransactionTest.java

index c312a97acfdf495a7e2cf65bfe3af552cf7e8996..380633e247ecc2d42b86bc9846630618a043ad10 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.mdsal.dom.broker;
 
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -70,8 +71,9 @@ public class ShardedDOMDataWriteTransactionTest {
         assertTrue(shardedDOMDataWriteTransaction.cancel());
         assertFalse(shardedDOMDataWriteTransaction.cancel());
 
-        assertTrue(shardedDOMDataWriteTransaction.getIdentifier().contains("0"));
-        assertTrue(otherShardedDOMDataWriteTransaction.getIdentifier().contains("1"));
+        assertTrue(shardedDOMDataWriteTransaction.getIdentifier().matches("^SHARDED-DOM-\\d$"));
+        assertNotEquals(shardedDOMDataWriteTransaction.getIdentifier(),
+                otherShardedDOMDataWriteTransaction.getIdentifier());
     }
 
     private final class TestDOMStoreWriteTransaction implements DOMStoreWriteTransaction {