Package org.easymock

Examples of org.easymock.ConstructorArgs


     *            constructors.
     * @return the mock object.
     */
    public static <T> T createPartialMock(Class<T> type, String methodName, Class<?>[] methodParameterTypes,
                                          Object[] constructorArguments, Class<?>[] constructorParameterTypes) {
        ConstructorArgs constructorArgs = new ConstructorArgs(Whitebox.getConstructor(type, constructorParameterTypes),
                constructorArguments);
        return doMockSpecific(type, new DefaultMockStrategy(), new String[] { methodName }, constructorArgs,
                methodParameterTypes);
    }
View Full Code Here


     *            constructors.
     * @return the mock object.
     */
    public static <T> T createStrictPartialMock(Class<T> type, String methodName, Class<?>[] methodParameterTypes,
                                                Object[] constructorArguments, Class<?>[] constructorParameterTypes) {
        ConstructorArgs constructorArgs = new ConstructorArgs(Whitebox.getConstructor(type, constructorParameterTypes),
                constructorArguments);
        return doMockSpecific(type, new StrictMockStrategy(), new String[] { methodName }, constructorArgs,
                methodParameterTypes);
    }
View Full Code Here

     *            constructors.
     * @return the mock object.
     */
    public static <T> T createNicePartialMock(Class<T> type, String methodName, Class<?>[] methodParameterTypes,
                                              Object[] constructorArguments, Class<?>[] constructorParameterTypes) {
        ConstructorArgs constructorArgs = new ConstructorArgs(Whitebox.getConstructor(type, constructorParameterTypes),
                constructorArguments);
        return doMockSpecific(type, new NiceMockStrategy(), new String[] { methodName }, constructorArgs,
                methodParameterTypes);
    }
View Full Code Here

  }

  @Test
  public void testGetTheSecret_defaultConstructor() throws Exception {
    final Constructor<ConstructorArgsDemo> constructor = ConstructorArgsDemo.class.getConstructor((Class<?>[]) null);
    ConstructorArgsDemo tested = createMock(ConstructorArgsDemo.class, new ConstructorArgs(constructor));
    assertEquals("default", Whitebox.getInternalState(tested, "secret", ConstructorArgsDemo.class));
  }
View Full Code Here

     * In the original test case PartialMockingWithConstructor had
     * constructor arguments which I removed to slim down the test case,
     * originally I was using the following method to create a partial mock.
     * Regardless the same problem still occurs.
     */
    ConstructorArgs args = new ConstructorArgs(PartialMockingWithConstructor.class.getConstructor());
    Method touchMethod = PartialMockingWithConstructor.class.getMethod("touch");

    PartialMockingWithConstructor nationPartialMock = createMock(PartialMockingWithConstructor.class, args, touchMethod);

    /*
 
View Full Code Here

  @Before
  public void setUp() throws Exception {
    businessMessagesMock = createMock(BusinessMessages.class);
    personServiceMock = createMock(PersonService.class);
    eventServiceMock = createMock(EventService.class);
    constructorArgs = new ConstructorArgs(SampleServiceWithoutPowerMockImpl.class.getConstructor(PersonService.class, EventService.class),
        personServiceMock, eventServiceMock);
    tested = createMock(SampleServiceWithoutPowerMockImpl.class, constructorArgs, new Method[] {});
  }
View Full Code Here

TOP

Related Classes of org.easymock.ConstructorArgs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.