How to use method of org.easymock.internal.matchers.Captures class

Best Easymock code snippet using org.easymock.internal.matchers.Captures.

Run Easymock automation tests on LambdaTest cloud grid

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

copy
1/**
2 * Copyright 2001-2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.easymock.tests;
17
18import static org.junit.Assert.*;
19
20import org.easymock.Capture;
21import org.easymock.CaptureType;
22import org.easymock.internal.Invocation;
23import org.easymock.internal.LastControl;
24import org.easymock.internal.matchers.Captures;
25import org.junit.After;
26import org.junit.Before;
27import org.junit.Test;
28
29/**
30 * @author Henri Tremblay
31 */
32public class CapturesMatcherTest {
33
34    private final Capture<String> capture = new Capture<String>(CaptureType.ALL);
35
36    private final Captures<String> matcher = new Captures<String>(capture);
37
38    private StringBuffer buffer;
39
40    @Before
41    public void setUp() throws Exception {
42        LastControl.pushCurrentInvocation(new Invocation(this, getClass().getMethod("test"), new Object[0]));
43        buffer = new StringBuffer();
44    }
45
46    @After
47    public void tearDown() {
48        LastControl.popCurrentInvocation();
49    }
50
51    @Test
52    public void test() throws Exception {
53
54        matcher.appendTo(buffer);
55        assertEquals("capture(Nothing captured yet)", buffer.toString());
56
57        assertTrue(matcher.matches(null));
58
59        matcher.validateCapture();
60
61        clearBuffer();
62        matcher.appendTo(buffer);
63        assertEquals("capture(null)", buffer.toString());
64
65        assertTrue(matcher.matches("s"));
66
67        matcher.validateCapture();
68
69        clearBuffer();
70        matcher.appendTo(buffer);
71        assertEquals("capture([null, s])", buffer.toString());
72    }
73
74    private void clearBuffer() {
75        buffer.delete(0, buffer.length());
76    }
77}
78
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)