1 5 package org.easymock.classextension; 6 7 import java.lang.reflect.Method ; 8 9 import org.easymock.MockControl; 10 import org.easymock.classextension.internal.ClassProxyFactory; 11 import org.easymock.internal.IBehaviorFactory; 12 13 20 public class MockClassControl extends MockControl { 21 22 32 public static MockControl createControl(Class classToMock) { 33 if (classToMock.isInterface()) { 34 return MockControl.createControl(classToMock); 35 } 36 return new MockClassControl(classToMock, UNORDERED_BEHAVIOR_FACTORY); 37 } 38 39 50 public static MockClassControl createControl(Class classToMock, 51 Method [] mockedMethods) { 52 return new MockClassControl(classToMock, mockedMethods, 53 UNORDERED_BEHAVIOR_FACTORY); 54 } 55 56 66 public static MockControl createStrictControl(Class classToMock) { 67 if (classToMock.isInterface()) { 68 return MockControl.createStrictControl(classToMock); 69 } 70 return new MockClassControl(classToMock, ORDERED_BEHAVIOR_FACTORY); 71 } 72 73 84 public static MockClassControl createStrictControl(Class classToMock, 85 Method [] mockedMethods) { 86 return new MockClassControl(classToMock, mockedMethods, 87 ORDERED_BEHAVIOR_FACTORY); 88 } 89 90 100 public static MockControl createNiceControl(Class classToMock) { 101 if (classToMock.isInterface()) { 102 return MockControl.createNiceControl(classToMock); 103 } 104 return new MockClassControl(classToMock, NICE_BEHAVIOR_FACTORY); 105 } 106 107 118 public static MockClassControl createNiceControl(Class classToMock, 119 Method [] mockedMethods) { 120 return new MockClassControl(classToMock, mockedMethods, 121 NICE_BEHAVIOR_FACTORY); 122 } 123 124 128 public static MockClassControl createControl(Class classToMock, 129 Class [] constructorTypes, Object [] constructorArgs) { 130 return new MockClassControl(classToMock, UNORDERED_BEHAVIOR_FACTORY); 131 } 132 133 138 public static MockClassControl createControl(Class classToMock, 139 Class [] constructorTypes, Object [] constructorArgs, 140 Method [] mockedMethods) { 141 return new MockClassControl(classToMock, mockedMethods, 142 UNORDERED_BEHAVIOR_FACTORY); 143 } 144 145 149 public static MockClassControl createStrictControl(Class classToMock, 150 Class [] constructorTypes, Object [] constructorArgs) { 151 return new MockClassControl(classToMock, ORDERED_BEHAVIOR_FACTORY); 152 } 153 154 159 public static MockClassControl createStrictControl(Class classToMock, 160 Class [] constructorTypes, Object [] constructorArgs, 161 Method [] mockedMethods) { 162 return new MockClassControl(classToMock, mockedMethods, 163 ORDERED_BEHAVIOR_FACTORY); 164 } 165 166 170 public static MockClassControl createNiceControl(Class classToMock, 171 Class [] constructorTypes, Object [] constructorArgs) { 172 return new MockClassControl(classToMock, NICE_BEHAVIOR_FACTORY); 173 } 174 175 180 public static MockClassControl createNiceControl(Class classToMock, 181 Class [] constructorTypes, Object [] constructorArgs, 182 Method [] mockedMethods) { 183 return new MockClassControl(classToMock, mockedMethods, 184 NICE_BEHAVIOR_FACTORY); 185 } 186 187 private MockClassControl(Class classToMock, Method [] mockedMethods, 188 IBehaviorFactory behaviorFactory) { 189 super(classToMock, new ClassProxyFactory(mockedMethods), 190 behaviorFactory); 191 } 192 193 private MockClassControl(Class classToMock, IBehaviorFactory behaviorFactory) { 194 this(classToMock, null, behaviorFactory); 195 } 196 } 197 | Popular Tags |