How to use method of org.easymock.tests2.ConstraintsToStringTest class

Best Easymock code snippet using org.easymock.tests2.ConstraintsToStringTest.

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.tests2;
6
7import static org.junit.Assert.*;
8
9import java.util.ArrayList;
10import java.util.List;
11
12import org.easymock.IArgumentMatcher;
13import org.easymock.internal.matchers.And;
14import org.easymock.internal.matchers.Any;
15import org.easymock.internal.matchers.Contains;
16import org.easymock.internal.matchers.EndsWith;
17import org.easymock.internal.matchers.Equals;
18import org.easymock.internal.matchers.Find;
19import org.easymock.internal.matchers.Matches;
20import org.easymock.internal.matchers.Not;
21import org.easymock.internal.matchers.NotNull;
22import org.easymock.internal.matchers.Null;
23import org.easymock.internal.matchers.Or;
24import org.easymock.internal.matchers.Same;
25import org.easymock.internal.matchers.StartsWith;
26import org.junit.Before;
27import org.junit.Test;
28
29public class ConstraintsToStringTest {
30    private StringBuffer buffer;
31
32    @Before
33    public void setup() {
34        buffer = new StringBuffer();
35    }
36
37    @Test
38    public void sameToStringWithString() {
39        new Same("X").appendTo(buffer);
40        assertEquals("same(\"X\")", buffer.toString());
41
42    }
43
44    @Test
45    public void nullToString() {
46        Null.NULL.appendTo(buffer);
47        assertEquals("isNull()", buffer.toString());
48    }
49
50    @Test
51    public void notNullToString() {
52        NotNull.NOT_NULL.appendTo(buffer);
53        assertEquals("notNull()", buffer.toString());
54    }
55
56    @Test
57    public void anyToString() {
58        Any.ANY.appendTo(buffer);
59        assertEquals("<any>", buffer.toString());
60    }
61
62    @Test
63    public void sameToStringWithChar() {
64        new Same('x').appendTo(buffer);
65        assertEquals("same('x')", buffer.toString());
66    }
67
68    @Test
69    public void sameToStringWithObject() {
70        Object o = new Object() {
71            @Override
72            public String toString() {
73                return "X";
74            }
75        };
76        new Same(o).appendTo(buffer);
77        assertEquals("same(X)", buffer.toString());
78    }
79
80    @Test
81    public void equalsToStringWithString() {
82        new Equals("X").appendTo(buffer);
83        assertEquals("\"X\"", buffer.toString());
84
85    }
86
87    @Test
88    public void equalsToStringWithChar() {
89        new Equals('x').appendTo(buffer);
90        assertEquals("'x'", buffer.toString());
91    }
92
93    @Test
94    public void equalsToStringWithObject() {
95        Object o = new Object() {
96            @Override
97            public String toString() {
98                return "X";
99            }
100        };
101        new Equals(o).appendTo(buffer);
102        assertEquals("X", buffer.toString());
103    }
104
105    @Test
106    public void orToString() {
107        List<IArgumentMatcher> matchers = new ArrayList<IArgumentMatcher>();
108        matchers.add(new Equals(1));
109        matchers.add(new Equals(2));
110        new Or(matchers).appendTo(buffer);
111        assertEquals("or(1, 2)", buffer.toString());
112    }
113
114    @Test
115    public void notToString() {
116        new Not(new Equals(1)).appendTo(buffer);
117        assertEquals("not(1)", buffer.toString());
118    }
119
120    @Test
121    public void andToString() {
122        List<IArgumentMatcher> matchers = new ArrayList<IArgumentMatcher>();
123        matchers.add(new Equals(1));
124        matchers.add(new Equals(2));
125        new And(matchers).appendTo(buffer);
126        assertEquals("and(1, 2)", buffer.toString());
127    }
128
129    @Test
130    public void startsWithToString() {
131        new StartsWith("AB").appendTo(buffer);
132        assertEquals("startsWith(\"AB\")", buffer.toString());
133    }
134
135    @Test
136    public void endsWithToString() {
137        new EndsWith("AB").appendTo(buffer);
138        assertEquals("endsWith(\"AB\")", buffer.toString());
139    }
140
141    @Test
142    public void containsToString() {
143        new Contains("AB").appendTo(buffer);
144        assertEquals("contains(\"AB\")", buffer.toString());
145    }
146
147    @Test
148    public void findToString() {
149        new Find("\\s+").appendTo(buffer);
150        assertEquals("find(\"\\\\s+\")", buffer.toString());
151    }
152
153    @Test
154    public void matchesToString() {
155        new Matches("\\s+").appendTo(buffer);
156        assertEquals("matches(\"\\\\s+\")", buffer.toString());
157    }
158
159}
160
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
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)