1 package org.snipsnap.test.mock; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 public class MockObject { 7 private Map callCount; 8 9 public MockObject() { 10 callCount = new HashMap (); 11 } 12 13 public void clearCalls() { 14 callCount = new HashMap (); 15 } 16 17 protected void inc(String name) { 18 if (callCount.containsKey(name)) { 19 int count = ((Integer ) callCount.get(name)).intValue(); 20 count++; 21 callCount.put(name, new Integer (count)); 22 } else { 23 callCount.put(name, new Integer (1)); 24 } 25 } 26 27 public int getCount(String name) { 28 if (callCount.containsKey(name)) { 29 return ((Integer ) callCount.get(name)).intValue(); 30 } else { 31 return 1; 32 } 33 } 34 } 35 | Popular Tags |