How to use method of org.easymock.tests.ObjectMethodsTest class

Best Easymock code snippet using org.easymock.tests.ObjectMethodsTest.

Run Easymock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1/*
2 * Copyright (c) 2001-2007 OFFIS, Tammo Freese.
3 * This program is made available under the terms of the MIT License.
4 */
5package org.easymock.tests;
6
7import static org.junit.Assert.*;
8
9import java.lang.reflect.Method;
10
11import org.easymock.MockControl;
12import org.easymock.internal.ObjectMethodsFilter;
13import org.junit.Before;
14import org.junit.Test;
15
16public class ObjectMethodsTest {
17    private MockControl<EmptyInterface> control;
18
19    private EmptyInterface mock;
20
21    private interface EmptyInterface {
22    }
23
24    @Before
25    public void setup() {
26        control = MockControl.createControl(EmptyInterface.class);
27        mock = control.getMock();
28    }
29
30    @Test
31    public void equalsBeforeActivation() {
32        assertEquals(mock, mock);
33        assertTrue(!mock.equals(null));
34    }
35
36    @Test
37    public void equalsAfterActivation() {
38        control.replay();
39        assertEquals(mock, mock);
40        assertTrue(!mock.equals(null));
41    }
42
43    @Test
44    public void testHashCode() {
45        int hashCodeBeforeActivation = mock.hashCode();
46        control.replay();
47        int hashCodeAfterActivation = mock.hashCode();
48        assertEquals(hashCodeBeforeActivation, hashCodeAfterActivation);
49    }
50
51    @Test
52    public void toStringBeforeActivation() {
53        assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock.toString());
54    }
55
56    @Test
57    public void toStringAfterActivation() {
58        control.replay();
59        assertEquals("EasyMock for " + EmptyInterface.class.toString(), mock.toString());
60    }
61
62    private static class MockedClass {
63    }
64
65    private static class DummyProxy extends MockedClass {
66    }
67
68    // if the class is no Proxy, ObjectMethodFilter should use the
69    // superclasses' name. This is needed for the class extension.
70    @Test
71    public void toStringForClasses() throws Throwable {
72        ObjectMethodsFilter filter = new ObjectMethodsFilter(Object.class, null, null);
73        Method toString = Object.class.getMethod("toString", new Class[0]);
74        assertEquals("EasyMock for " + MockedClass.class.toString(), filter.invoke(new DummyProxy(), toString,
75                new Object[0]));
76    }
77
78}
79
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger code on LambdaTest Cloud Grid

Execute automation tests with on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)