Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6443 - trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r6443 - trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6443 - trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging
  • Date: Fri, 5 Jul 2013 14:34:38 +0100 (BST)
  • Authentication-results: sfpop-ironport01.merit.edu; dkim=neutral (message not signed) header.i=none

Author: dante.delvaux
Date: 2013-07-05 14:34:38 +0100 (Fri, 05 Jul 2013)
New Revision: 6443

Modified:

trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/MethodOnObjectTest.java
Log:
pSbase3 messaging unit testing: adding synchronized blocks to avoid
ConcurrentModificationException errors.

Modified:
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/MethodOnObjectTest.java
===================================================================
---
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/MethodOnObjectTest.java
2013-07-05 13:05:39 UTC (rev 6442)
+++
trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging/MethodOnObjectTest.java
2013-07-05 13:34:38 UTC (rev 6443)
@@ -320,6 +320,7 @@
/**
* This test for Method.execute() to be ok in a threaded environment
* Play with instances
+ * FIXME: we need a lot of synchronized blocks in order to make this
test pass
*/
@Test
// CHECKSTYLE IGNORE IllegalThrow FOR NEXT 1 LINES
@@ -339,15 +340,17 @@
final String currentName = "My Router number " + current;
final Router myRouter = addARouter(currentId,
currentName);
// Check the router is indeed added to the instance Map
-
assertTrue(instances.get(Router.class).contains(myRouter));
// Check the instances count is coherent
-// assertEquals(1, instances.get(Command.class).size());
- assertTrue(current < instances.get(Router.class).size());
+ synchronized (instances) {
+
assertTrue(instances.get(Router.class).contains(myRouter));
+ assertTrue(current <
instances.get(Router.class).size());
+// assertEquals(1,
instances.get(Command.class).size());

- try {
- method.execute(currentId, instances, logger);
- } catch (PerfSONARException e) {
- logger.error("Error when executing {} {}",
method.toString(), currentId);
+ try {
+ method.execute(currentId, instances, logger);
+ } catch (PerfSONARException e) {
+ logger.error("Error when executing {} {}",
method.toString(), currentId);
+ }
}

// We have at least one execution more (but more
executions could have happened in between)
@@ -355,13 +358,15 @@
// We should still have a single element List for
Command.class
// FIXME: or should we have more? Why do I get 2
instances of the Command class now?
// assertEquals(1, instances.get(Command.class).size());
- // And router.Class count must must not have decreased
- assertTrue(current < instances.get(Router.class).size());
- // myRouter is still present in the instances list
-
assertTrue(instances.get(Router.class).contains(myRouter));
- int index =
instances.get(Router.class).indexOf(myRouter);
- // and its attributes are still the correct ones
- assertEquals(currentName, ((Router)
instances.get(Router.class).get(index)).getName());
+ synchronized (instances) {
+ // And router.Class count must must not have
decreased
+ assertTrue(current <
instances.get(Router.class).size());
+ // myRouter is still present in the instances list
+
assertTrue(instances.get(Router.class).contains(myRouter));
+ int index =
instances.get(Router.class).indexOf(myRouter);
+ // and its attributes are still the correct ones
+ assertEquals(currentName, ((Router)
instances.get(Router.class).get(index)).getName());
+ }
// assertEquals(expectedObject, ((Router)
instances.get(Router.class).get(index)).getCommands().get(0));
// assertEquals(OBJECT_NAME, ((Router)
instances.get(Router.class).get(index)).getCommands().get(0).getName());
logger.debug("{} finished, {} thread(s) complete, {}
currently running threads.",



  • [pS-dev] [GEANT/SA2/ps-java-services] r6443 - trunk/perfsonar-base/messaging/src/test/java/net/geant/perfsonar/messaging, svn-noreply, 07/05/2013

Archive powered by MHonArc 2.6.16.

Top of Page