1 22 23 package org.objectweb.jonas.jtests.clients.entity; 24 25 import java.util.Collection ; 26 import java.util.Iterator ; 27 28 import org.objectweb.jonas.jtests.util.JTestCase; 29 30 31 35 36 public abstract class A_Cmp2Util extends JTestCase { 37 38 static final int TX_NO = 1; 40 static final int TX_CALL = 2; 42 static final int TX_CONT = 3; 44 static final int TX_RB = 4; 46 47 public A_Cmp2Util(String name) { 48 super(name); 49 } 50 51 abstract boolean initStateOK() throws Exception ; 52 53 57 void checkIsInitialState() throws Exception { 58 boolean isOk = true; 59 try { 60 isOk = initStateOK(); 61 } catch (Exception e) { 62 isOk = false; 63 } 64 assertTrue("Bad Initial State: " + msgerror.toString(), isOk); 65 } 66 67 70 static boolean isCollectionEqual(Collection c1, Collection c2) { 71 if (c1.size() != c2.size()) { 73 return false; 74 } 75 Iterator it = c1.iterator(); 77 boolean b = true; 78 while(it.hasNext() && (b = c2.contains(it.next()))); 79 if (it.hasNext() || !b) { 80 return false; 81 } 82 it = c2.iterator(); 84 b = true; 85 while(it.hasNext() && (b = c1.contains(it.next()))); 86 return !it.hasNext() && b; 87 } 88 89 93 public static String getStringBeforeDash(String s) { 94 int iDash = s.indexOf("-"); 95 if (iDash < 0) { 96 throw new IllegalArgumentException ("Bad string format for getStringBeforeDash(): "+s); 97 } 98 String value = s.substring(0, iDash); 99 return value ; 101 } 102 103 107 public static int getIntAfterDash(String s) { 108 int iDash = s.indexOf("-"); 109 if (iDash < 0) { 110 throw new IllegalArgumentException ("Bad string format for getStringBeforeDash(): "+s); 111 } 112 String sInt = s.substring(iDash+1); 113 int value = (new Integer (sInt)).intValue(); 114 return value; 116 } 117 118 } 119
| Popular Tags
|