1 4 package com.tctest; 5 6 import com.tc.util.Assert; 7 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 14 public class AsmMethodInfoTestHelper { 15 AsmMethodInfoTestHelper(int countStart) { 16 this.count = countStart; 17 try { 18 myRoot = new HashMap (); 19 } catch (Exception e) { 20 e.printStackTrace(); 21 } 22 } 23 24 private static Map myRoot; private long count; 26 27 private int commits = 0; 28 29 public long test4(int i, Object foo) { 30 synchronized (myRoot) { 31 long start = System.currentTimeMillis(); 32 commits++; 33 int s = myRoot.size(); 34 long c = count++; 35 if (myRoot.containsKey(new Long (c))) { 36 Assert.eval(false); 37 } 38 myRoot.put(new Long (c), new TestObj(new TestObj(null))); 39 if (myRoot.size() != s + 1) System.out.println("Wrong size!:" + s + " new size:" + myRoot.size()); 40 Assert.eval(myRoot.size() == s + 1); 41 return System.currentTimeMillis() - start; 43 } 44 } 45 46 public long test5(int i, Object foo) { 47 synchronized (myRoot) { 48 long start = System.currentTimeMillis(); 49 commits++; 50 int s = myRoot.size(); 51 myRoot.remove(new Long (count - 1)); 52 if (myRoot.size() != s - 1) System.out.println("Wrong size!:" + s + " new size:" + myRoot.size()); 53 Assert.eval(myRoot.size() == s - 1); 54 return System.currentTimeMillis() - start; 56 } 57 } 58 59 public static class TestObj { 60 private TestObj obj; 61 private String string = "Steve"; 62 private int integer = 22; 63 private boolean bool = false; 64 private Map map = new HashMap (); 65 66 private TestObj() { 67 } 69 70 public TestObj(TestObj obj) { 71 this.obj = obj; 72 for (int i = 0; i < 30; i++) { 73 map.put(new Long (i), new TestObj()); 74 } 75 } 76 77 public Object getObject() { 78 return this.obj; 79 } 80 81 public boolean check() { 82 return string.equals("Steve") && integer == 22 && bool == false; 83 } 84 } 85 } | Popular Tags |