21 |
22 |
23 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests2/EasyMockRuleTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests2;
17 |
18 | import org.easymock.EasyMockRule;
19 | import org.junit.Rule;
20 |
21 | /**
22 | * Runs annotation-driven tests from base class with the EasyMockRule JUnit Rule.
23 | *
24 | * @author Alistair Todd
25 | */
26 | public class EasyMockRuleTest extends EasyMockAnnotationsTest {
27 |
28 | @Rule
29 | public EasyMockRule mocks = new EasyMockRule(this);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/ObjenesisClassInstantiator.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | import org.objenesis.ObjenesisHelper;
19 |
20 | /**
21 | * @author Henri Tremblay
22 | */
23 | public class ObjenesisClassInstantiator implements IClassInstantiator {
24 |
25 | public Object newInstance(final Class> clazz) throws InstantiationException {
26 | return ObjenesisHelper.newInstance(clazz);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/website/api/easymock/3.2/overview-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Overview List (EasyMock 3.2 API)
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/ThrowableWrapper.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | /**
19 | * @author OFFIS, Tammo Freese
20 | */
21 | public class ThrowableWrapper extends Throwable {
22 |
23 | private static final long serialVersionUID = -4434322855124959723L;
24 |
25 | private final Throwable throwable;
26 |
27 | public ThrowableWrapper(final Throwable throwable) {
28 | this.throwable = throwable;
29 | }
30 |
31 | public Throwable getThrowable() {
32 | return throwable;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests2/UsageMatchersTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests2;
17 |
18 | import static org.easymock.EasyMock.*;
19 |
20 | import org.easymock.tests.IMethods;
21 | import org.junit.Test;
22 |
23 | /**
24 | * @author OFFIS, Tammo Freese
25 | */
26 | public class UsageMatchersTest {
27 | @Test(expected = IllegalStateException.class)
28 | public void additionalMatchersFailAtReplay() {
29 |
30 | final IMethods mock = createMock(IMethods.class);
31 | lt(5);
32 |
33 | replay(mock);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/AssertionErrorWrapper.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | /**
19 | * @author OFFIS, Tammo Freese
20 | */
21 | public class AssertionErrorWrapper extends RuntimeException {
22 |
23 | private static final long serialVersionUID = -2087349195182278608L;
24 |
25 | private final AssertionError error;
26 |
27 | public AssertionErrorWrapper(final AssertionError error) {
28 | this.error = error;
29 | }
30 |
31 | public AssertionError getAssertionError() {
32 | return error;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/3.2/org/easymock/classextension/internal/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | org.easymock.classextension.internal (EasyMock Class extension 3.2 API)
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/MockType.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock;
17 |
18 | /**
19 | * Enum describing the 3 possibles kind of mocks
20 | *
21 | * @author Henri Tremblay
22 | * @since 3.2
23 | */
24 | public enum MockType {
25 | /** A nice mock expects recorded calls in any order and returning null for other calls */
26 | NICE,
27 | /** A default mock expects only recorded calls but in any order */
28 | DEFAULT,
29 | /** A strict mock expects only recorded calls and they should be replayed in their recorded order */
30 | STRICT
31 | }
32 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests/MockNameTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests;
17 |
18 | import static org.easymock.EasyMock.*;
19 | import static org.junit.Assert.*;
20 |
21 | import org.junit.Test;
22 |
23 | /**
24 | * @author OFFIS, Tammo Freese
25 | */
26 | public class MockNameTest {
27 |
28 | @Test
29 | public void defaultName() {
30 | final IMethods mock = createMock(IMethods.class);
31 | final String expected = "EasyMock for " + IMethods.class.toString();
32 | final String actual = mock.toString();
33 | assertEquals(expected, actual);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/easymock-classextension/src/main/java/org/easymock/classextension/IMockBuilder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2003-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 | */
16 | package org.easymock.classextension;
17 |
18 | /**
19 | * This class is provided solely to allow an easier transition to EasyMock 3.0.
20 | * You should now use {@link org.easymock.IMockBuilder} instead.
21 | *
22 | * @param
23 | * type of the object being created
24 | *
25 | * @author Henri Tremblay
26 | *
27 | * @deprecated Use {@link org.easymock.IMockBuilder} instead
28 | */
29 | @Deprecated
30 | public interface IMockBuilder extends org.easymock.IMockBuilder {
31 | }
32 |
--------------------------------------------------------------------------------
/easymock-classextension/src/main/java/org/easymock/classextension/IMocksControl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2003-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 | */
16 | package org.easymock.classextension;
17 |
18 | /**
19 | * This class is provided solely to allow an easier transition to EasyMock 3.0.
20 | * You should now use {@link org.easymock.IMocksControl} for classes and
21 | * interfaces mocking.
22 | *
23 | * @author Henri Tremblay
24 | *
25 | * @deprecated You can now mock classes directly with
26 | * {@link org.easymock.IMocksControl}
27 | */
28 | @Deprecated
29 | public interface IMocksControl extends org.easymock.IMocksControl {
30 | }
31 |
--------------------------------------------------------------------------------
/easymock-classextension/src/main/java/org/easymock/classextension/internal/MockBuilder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2003-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 | */
16 | package org.easymock.classextension.internal;
17 |
18 | import org.easymock.classextension.IMockBuilder;
19 |
20 | /**
21 | *
22 | * @author Henri Tremblay
23 | *
24 | * @param type of the mock created
25 | */
26 | @SuppressWarnings("deprecation")
27 | @Deprecated
28 | public class MockBuilder extends org.easymock.internal.MockBuilder
29 | implements IMockBuilder {
30 |
31 | public MockBuilder(Class toMock) {
32 | super(toMock);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/TestSubject.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock;
17 |
18 | import java.lang.annotation.*;
19 |
20 | /**
21 | * Annotation to set on a field so that {@link EasyMockRunner}, {@link EasyMockRule} or {@link EasyMockSupport#injectMocks(Object)}
22 | * will inject mocks created with {@link Mock} on its fields.
23 | *
24 | * See {@link EasyMockSupport#injectMocks(Object)} for the injection rules.
25 | *
26 | * @author Henri Tremblay
27 | * @since 3.2
28 | */
29 | @Target(ElementType.FIELD)
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Documented
32 | public @interface TestSubject {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/easymock-classextension/src/main/java/org/easymock/classextension/internal/MocksClassControl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2003-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 | */
16 | package org.easymock.classextension.internal;
17 |
18 | import org.easymock.classextension.IMocksControl;
19 | import org.easymock.internal.MocksControl;
20 |
21 | /**
22 | * @author Henri Tremblay
23 | *
24 | */
25 | @Deprecated
26 | public class MocksClassControl extends MocksControl implements IMocksControl {
27 |
28 | private static final long serialVersionUID = 3968868667140288891L;
29 |
30 | public MocksClassControl(final MockType type) {
31 | super(type);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/RuntimeExceptionWrapper.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | /**
19 | * @author OFFIS, Tammo Freese
20 | */
21 | public class RuntimeExceptionWrapper extends RuntimeException {
22 |
23 | private static final long serialVersionUID = -3483500330975410177L;
24 |
25 | private final RuntimeException runtimeException;
26 |
27 | public RuntimeExceptionWrapper(final RuntimeException runtimeException) {
28 | this.runtimeException = runtimeException;
29 | }
30 |
31 | public RuntimeException getRuntimeException() {
32 | return runtimeException;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/easymock/ReleaseNotes.txt:
--------------------------------------------------------------------------------
1 | Release Notes - EasyMock - Version 3.2
2 |
3 | This release contains two important features:
4 | * A support for Android. EasyMock now works on Dalvik
5 | * New @Mock and @TestSubject annotations
6 |
7 | And the complete release notes:
8 |
9 | ** Bug
10 | * [EASYMOCK-101] - EasyMock not compiling with JDK 7 or Eclipse Helios or later (phase 2)
11 | * [EASYMOCK-106] - EasyMockProperties use of System properties isn't thread safe
12 | * [EASYMOCK-110] - bridged equals(Object) method causes StackOverflow
13 | * [EASYMOCK-117] - Exception mocks have a different behavior between Java 6 and 7
14 | * [EASYMOCK-121] - Upgrade to Objenesis 1.3
15 | * [EASYMOCK-124] - Website text gets badly truncate on certain screens
16 |
17 | ** Improvement
18 | * [EASYMOCK-107] - Remove the possibility to override easymock.properties with system properties
19 | * [EASYMOCK-108] - Android support
20 | * [EASYMOCK-115] - Improvement to org.easymock.Capture.java
21 |
22 | ** New Feature
23 | * [EASYMOCK-24] - Provide mockType to createMock() method
24 | * [EASYMOCK-51] - @Mock annotation to provide mock autowiring
25 | * [EASYMOCK-112] - anyString() in EasyMock desired
26 |
27 |
28 | ** Task
29 | * [EASYMOCK-122] - Move source code to GitHub
30 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/2.4/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/CaptureType.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock;
17 |
18 | /**
19 | * Defines how arguments will be captured by a Capture object
20 | *
21 | * @author Henri Tremblay
22 | * @see Capture
23 | */
24 | public enum CaptureType {
25 | /**
26 | * Do not capture anything
27 | */
28 | NONE,
29 |
30 | /**
31 | * Will capture the argument of the first matching call
32 | */
33 | FIRST,
34 |
35 | /**
36 | * Will capture the argument of the last matching call
37 | */
38 | LAST,
39 |
40 | /**
41 | * Will capture, in order, the arguments of each matching calls
42 | */
43 | ALL
44 | }
45 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/Any.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public final class Any implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = -3743894206806704049L;
28 |
29 | public static final Any ANY = new Any();
30 |
31 | private Any() {
32 |
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return true;
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/LessThan.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | /**
19 | * @param
20 | * Type of the values compared
21 | *
22 | * @author OFFIS, Tammo Freese
23 | */
24 | public class LessThan> extends CompareTo {
25 |
26 | private static final long serialVersionUID = 6004888476822043880L;
27 |
28 | public LessThan(final Comparable value) {
29 | super(value);
30 | }
31 |
32 | @Override
33 | protected String getName() {
34 | return "lt";
35 | }
36 |
37 | @Override
38 | protected boolean matchResult(final int result) {
39 | return result < 0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/Null.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class Null implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = 6077244839421122011L;
28 |
29 | public static final Null NULL = new Null();
30 |
31 | private Null() {
32 | }
33 |
34 | public boolean matches(final Object actual) {
35 | return actual == null;
36 | }
37 |
38 | public void appendTo(final StringBuffer buffer) {
39 | buffer.append("isNull()");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/GreaterThan.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | /**
19 | * @param
20 | * Type of the values compared
21 | *
22 | * @author OFFIS, Tammo Freese
23 | */
24 | public class GreaterThan> extends CompareTo {
25 |
26 | private static final long serialVersionUID = 2736983121197045828L;
27 |
28 | public GreaterThan(final Comparable value) {
29 | super(value);
30 | }
31 |
32 | @Override
33 | protected String getName() {
34 | return "gt";
35 | }
36 |
37 | @Override
38 | protected boolean matchResult(final int result) {
39 | return result > 0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/CompareEqual.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | /**
19 | * @param
20 | * Type of the values compared
21 | *
22 | * @author Henri Tremblay
23 | */
24 | public class CompareEqual> extends CompareTo {
25 |
26 | private static final long serialVersionUID = 7616033998227799268L;
27 |
28 | public CompareEqual(final Comparable value) {
29 | super(value);
30 | }
31 |
32 | @Override
33 | protected String getName() {
34 | return "cmpEq";
35 | }
36 |
37 | @Override
38 | protected boolean matchResult(final int result) {
39 | return result == 0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/LessOrEqual.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | /**
19 | * @param
20 | * Type of the values compared
21 | *
22 | * @author OFFIS, Tammo Freese
23 | */
24 | public class LessOrEqual> extends CompareTo {
25 |
26 | private static final long serialVersionUID = -2485406702001842607L;
27 |
28 | public LessOrEqual(final Comparable value) {
29 | super(value);
30 | }
31 |
32 | @Override
33 | protected String getName() {
34 | return "leq";
35 | }
36 |
37 | @Override
38 | protected boolean matchResult(final int result) {
39 | return result <= 0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/GreaterOrEqual.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | /**
19 | * @param
20 | * Type of the values compared
21 | *
22 | * @author OFFIS, Tammo Freese
23 | */
24 | public class GreaterOrEqual> extends CompareTo {
25 |
26 | private static final long serialVersionUID = -504083241204488174L;
27 |
28 | public GreaterOrEqual(final Comparable value) {
29 | super(value);
30 | }
31 |
32 | @Override
33 | protected String getName() {
34 | return "geq";
35 | }
36 |
37 | @Override
38 | protected boolean matchResult(final int result) {
39 | return result >= 0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/2.4/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | All Classes (EasyMockClassExtension)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | All Classes
20 |
21 |
22 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/easymock-test-deploy/src/test/java/org/easymock/test/EasyMockTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009-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 | */
16 | package org.easymock.test;
17 |
18 | import java.io.IOException;
19 |
20 | import org.junit.Test;
21 |
22 | import static org.easymock.EasyMock.*;
23 | import static org.junit.Assert.*;
24 |
25 | /**
26 | * Test that everything is working fine after a deployment to Sonatype
27 | *
28 | * @author Henri Tremblay
29 | */
30 | public class EasyMockTest {
31 |
32 | @Test
33 | public void test() throws IOException {
34 | Appendable mock = createMock(Appendable.class);
35 | expect(mock.append("test")).andReturn(mock);
36 | replay(mock);
37 | assertSame(mock, mock.append("test"));
38 | verify(mock);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/EasyMockRule.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock;
17 |
18 | import org.easymock.internal.EasyMockStatement;
19 | import org.junit.rules.TestRule;
20 | import org.junit.runner.Description;
21 | import org.junit.runners.model.Statement;
22 |
23 | /**
24 | * JUnit Rule used to process {@link Mock} and {@link TestSubject} annotations.
25 | *
26 | * @author Alistair Todd
27 | * @since 3.3
28 | */
29 | public class EasyMockRule implements TestRule {
30 |
31 | private final Object test;
32 |
33 | public EasyMockRule(final Object test) {
34 | this.test = test;
35 | }
36 |
37 | public Statement apply(final Statement base, final Description description) {
38 | return new EasyMockStatement(base, test);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/website/Error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | EasyMock : Error
8 |
9 |
10 |
11 |
12 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/IClassInstantiator.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | /**
19 | * Used to instantiate a given class.
20 | *
21 | * @author Henri Tremblay
22 | */
23 | public interface IClassInstantiator {
24 |
25 | /**
26 | * Return a new instance of the specified class. The recommended way is
27 | * without calling any constructor. This is usually done by doing like
28 | * ObjectInputStream.readObject() which is JVM specific.
29 | *
30 | * @param clazz
31 | * class to instantiate
32 | * @return new instance of clazz
33 | * @throws InstantiationException
34 | */
35 | Object newInstance(Class> clazz) throws InstantiationException;
36 | }
37 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests/Util.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests;
17 |
18 | import java.io.PrintWriter;
19 | import java.io.StringWriter;
20 |
21 | /**
22 | * @author OFFIS, Tammo Freese
23 | */
24 | public final class Util {
25 |
26 | private Util() {
27 | }
28 |
29 | public static String getStackTrace(final Throwable throwable) {
30 | final StringWriter stackTrace = new StringWriter();
31 | throwable.printStackTrace(new PrintWriter(stackTrace));
32 | return stackTrace.getBuffer().toString();
33 | }
34 |
35 | public static boolean startWithClass(final Throwable throwable, final Class> clazz) {
36 | final StackTraceElement[] elements = throwable.getStackTrace();
37 | return elements[0].getClassName().equals(clazz.getName());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/2.4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | EasyMockClassExtension
8 |
9 |
20 |
22 |
23 |
36 |
37 |
--------------------------------------------------------------------------------
/easymock-test-deploy/src/test/java/org/easymock/test/EasyMockClassExtensionTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2009-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 | */
16 | package org.easymock.test;
17 |
18 | import java.io.IOException;
19 | import java.util.ArrayList;
20 |
21 | import org.junit.Test;
22 |
23 | import static org.easymock.classextension.EasyMock.*;
24 | import static org.junit.Assert.*;
25 |
26 | /**
27 | * Test that everything is working fine after a deployment to Sonatype
28 | *
29 | * @author Henri Tremblay
30 | */
31 | public class EasyMockClassExtensionTest {
32 |
33 | @Test
34 | public void test() throws IOException {
35 | ArrayList> mock = createMock(ArrayList.class);
36 | expect(mock.size()).andReturn(5);
37 | replay(mock);
38 | assertEquals(5, mock.size());
39 | verify(mock);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/IAnswer.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock;
17 |
18 | /**
19 | * Used to answer expected calls.
20 | *
21 | * @param
22 | * the type to return.
23 | *
24 | * @author OFFIS, Tammo Freese
25 | */
26 | public interface IAnswer {
27 |
28 | /**
29 | * Is called by EasyMock to answer an expected call. The answer may be to
30 | * return a value, or to throw an exception. The arguments of the call for
31 | * which the answer is generated are available via
32 | * {@link EasyMock#getCurrentArguments()} - be careful here, using the
33 | * arguments is not refactoring-safe.
34 | *
35 | * @return the value to be returned
36 | * @throws Throwable
37 | * the throwable to be thrown
38 | */
39 | T answer() throws Throwable;
40 | }
41 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/JavaProxyFactory.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | import java.lang.reflect.InvocationHandler;
19 | import java.lang.reflect.Method;
20 | import java.lang.reflect.Proxy;
21 | import org.easymock.ConstructorArgs;
22 |
23 | /**
24 | * @author OFFIS, Tammo Freese
25 | */
26 | public class JavaProxyFactory implements IProxyFactory {
27 | @SuppressWarnings("unchecked")
28 | public T createProxy(Class toMock, InvocationHandler handler,
29 | Method[] mockedMethods, ConstructorArgs constructorArgs) {
30 | return (T) Proxy.newProxyInstance(toMock.getClassLoader(), new Class[] { toMock }, handler);
31 | }
32 |
33 | public InvocationHandler getInvocationHandler(Object mock) {
34 | return Proxy.getInvocationHandler(mock);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/EndsWith.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class EndsWith implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = 5159338714596685067L;
28 |
29 | private final String suffix;
30 |
31 | public EndsWith(final String suffix) {
32 | this.suffix = suffix;
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return (actual instanceof String) && ((String) actual).endsWith(suffix);
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("endsWith(\"" + suffix + "\")");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/InstanceOf.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class InstanceOf implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = -551735356674347591L;
28 |
29 | private final Class> clazz;
30 |
31 | public InstanceOf(final Class> clazz) {
32 | this.clazz = clazz;
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return (actual != null) && clazz.isAssignableFrom(actual.getClass());
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("isA(" + clazz.getName() + ")");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/Not.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class Not implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = -5160559075998939348L;
28 |
29 | private final IArgumentMatcher first;
30 |
31 | public Not(final IArgumentMatcher first) {
32 | this.first = first;
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return !first.matches(actual);
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("not(");
41 | first.appendTo(buffer);
42 | buffer.append(")");
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests/IVarArgs.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests;
17 |
18 | /**
19 | * @author OFFIS, Tammo Freese
20 | */
21 | public interface IVarArgs {
22 | public void withVarargsString(int value, String... s);
23 |
24 | public void withVarargsObject(int value, Object... o);
25 |
26 | public void withVarargsBoolean(int value, boolean... b);
27 |
28 | public void withVarargsByte(int value, byte... b);
29 |
30 | public void withVarargsChar(int value, char... c);
31 |
32 | public void withVarargsDouble(int value, double... d);
33 |
34 | public void withVarargsFloat(int value, float... f);
35 |
36 | public void withVarargsInt(int value, int... i);
37 |
38 | public void withVarargsLong(int value, long... l);
39 |
40 | public void withVarargsShort(int value, short... s);
41 | }
42 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/StartsWith.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class StartsWith implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = -658998692584342514L;
28 |
29 | private final String prefix;
30 |
31 | public StartsWith(final String prefix) {
32 | this.prefix = prefix;
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return (actual instanceof String) && ((String) actual).startsWith(prefix);
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("startsWith(\"" + prefix + "\")");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/Matches.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class Matches implements IArgumentMatcher, Serializable {
26 |
27 | private static final long serialVersionUID = -6657694947057597484L;
28 |
29 | private final String regex;
30 |
31 | public Matches(final String regex) {
32 | this.regex = regex;
33 | }
34 |
35 | public boolean matches(final Object actual) {
36 | return (actual instanceof String) && ((String) actual).matches(regex);
37 | }
38 |
39 | public void appendTo(final StringBuffer buffer) {
40 | buffer.append("matches(\"" + regex.replaceAll("\\\\", "\\\\\\\\") + "\")");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/website/api/easymock/2.4/stylesheet.css:
--------------------------------------------------------------------------------
1 | /* Javadoc style sheet */
2 |
3 | /* Define colors, fonts and other style attributes here to override the defaults */
4 |
5 | /* Page background color */
6 | body { background-color: #FFFFFF; color:#000000 }
7 |
8 | /* Headings */
9 | h1 { font-size: 145% }
10 |
11 | /* Table colors */
12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */
15 |
16 | /* Font used in left-hand frame lists */
17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
20 |
21 | /* Navigation bar fonts and colors */
22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
26 |
27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
29 |
30 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/3.1/overview-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Overview List (EasyMock class extension 3.1 API)
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/ExpectedInvocationAndResults.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * @author OFFIS, Tammo Freese
22 | */
23 | public class ExpectedInvocationAndResults implements Serializable {
24 |
25 | private static final long serialVersionUID = 8189985418895395472L;
26 |
27 | private final ExpectedInvocation expectedInvocation;
28 |
29 | private final Results results;
30 |
31 | public ExpectedInvocationAndResults(final ExpectedInvocation expectedInvocation, final Results results) {
32 | this.expectedInvocation = expectedInvocation;
33 | this.results = results;
34 | }
35 |
36 | public ExpectedInvocation getExpectedInvocation() {
37 | return expectedInvocation;
38 | }
39 |
40 | public Results getResults() {
41 | return results;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return expectedInvocation.toString() + ": " + results.toString();
47 | }
48 | }
--------------------------------------------------------------------------------
/easymock/src/samples/java/org/easymock/samples/AnnotatedMockWithRuleTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.samples;
17 |
18 | import org.easymock.EasyMockRule;
19 | import org.easymock.EasyMockSupport;
20 | import org.easymock.Mock;
21 | import org.easymock.TestSubject;
22 | import org.junit.Rule;
23 | import org.junit.Test;
24 |
25 | /**
26 | * Example of how to use @Mock and @TestSubject annotations with Junit Rule.
27 | *
28 | * @author Alistair Todd
29 | */
30 | public class AnnotatedMockWithRuleTest extends EasyMockSupport {
31 |
32 | @Rule
33 | public EasyMockRule mocks = new EasyMockRule(this);
34 |
35 | @TestSubject
36 | private final ClassTested classUnderTest = new ClassTested();
37 |
38 | @Mock
39 | private Collaborator collaborator;
40 |
41 | @Test
42 | public void addDocument() {
43 | collaborator.documentAdded("New Document");
44 | replayAll();
45 | classUnderTest.addDocument("New Document", new byte[0]);
46 | verifyAll();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/3.1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | EasyMock class extension 3.1 API
9 |
10 |
21 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Frame Alert
33 |
34 |
35 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
36 |
37 | Link toNon-frame version.
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/easymock/src/samples/java/org/easymock/samples/AnnotatedMockWithRunnerTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.samples;
17 |
18 | import org.easymock.EasyMockRunner;
19 | import org.easymock.EasyMockSupport;
20 | import org.easymock.Mock;
21 | import org.easymock.TestSubject;
22 | import org.junit.Test;
23 | import org.junit.runner.RunWith;
24 |
25 | /**
26 | * Example of how to use @Mock and @TestSubject annotations with JUnit Runner.
27 | *
28 | * @author Henri Tremblay
29 | */
30 | @RunWith(EasyMockRunner.class)
31 | public class AnnotatedMockWithRunnerTest extends EasyMockSupport {
32 |
33 | @TestSubject
34 | private final ClassTested classUnderTest = new ClassTested();
35 |
36 | @Mock
37 | private Collaborator collaborator;
38 |
39 | @Test
40 | public void addDocument() {
41 | collaborator.documentAdded("New Document");
42 | replayAll();
43 | classUnderTest.addDocument("New Document", new byte[0]);
44 | verifyAll();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/IMocksControlState.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | import org.easymock.IAnswer;
19 |
20 | /**
21 | * @author OFFIS, Tammo Freese
22 | */
23 | public interface IMocksControlState {
24 |
25 | Object invoke(Invocation invocation) throws Throwable;
26 |
27 | void assertRecordState();
28 |
29 | void andReturn(Object value);
30 |
31 | void andThrow(Throwable throwable);
32 |
33 | void andAnswer(IAnswer> answer);
34 |
35 | void andDelegateTo(Object answer);
36 |
37 | void andStubReturn(Object value);
38 |
39 | void andStubThrow(Throwable throwable);
40 |
41 | void andStubAnswer(IAnswer> answer);
42 |
43 | void andStubDelegateTo(Object delegateTo);
44 |
45 | void asStub();
46 |
47 | void times(Range range);
48 |
49 | void checkOrder(boolean value);
50 |
51 | void makeThreadSafe(boolean threadSafe);
52 |
53 | void checkIsUsedInOneThread(boolean shouldBeUsedInOneThread);
54 |
55 | void replay();
56 |
57 | void verify();
58 | }
59 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/2.4/org/easymock/classextension/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | org.easymock.classextension (EasyMockClassExtension)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | org.easymock.classextension
20 |
30 | Release Notes prior to version 3.2 are also available at the end of the documentation for each version. They could be a bit
31 | more accurate and explained than what you will find in Jira.
32 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/easymock/src/test/java/org/easymock/tests2/NiceMockTest.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.tests2;
17 |
18 | import static org.easymock.EasyMock.*;
19 | import static org.junit.Assert.*;
20 |
21 | import org.easymock.tests.IMethods;
22 | import org.junit.Before;
23 | import org.junit.Test;
24 |
25 | /**
26 | * @author OFFIS, Tammo Freese
27 | */
28 | public class NiceMockTest {
29 |
30 | IMethods mock;
31 |
32 | @Before
33 | public void setup() {
34 | mock = createNiceMock(IMethods.class);
35 | replay(mock);
36 | }
37 |
38 | @Test
39 | public void defaultReturnValueBoolean() {
40 | assertEquals(false, mock.booleanReturningMethod(12));
41 | verify(mock);
42 | }
43 |
44 | @Test
45 | public void defaultReturnValueFloat() {
46 | assertEquals(0.0f, mock.floatReturningMethod(12), 0.0f);
47 | verify(mock);
48 | }
49 |
50 | @Test
51 | public void defaultReturnValueDouble() {
52 | assertEquals(0.0d, mock.doubleReturningMethod(12), 0.0d);
53 | verify(mock);
54 | }
55 |
56 | @Test
57 | public void defaultReturnValueObject() {
58 | assertEquals(null, mock.objectReturningMethod(12));
59 | verify(mock);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/IProxyFactory.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal;
17 |
18 | import java.lang.reflect.InvocationHandler;
19 | import java.lang.reflect.Method;
20 |
21 | import org.easymock.ConstructorArgs;
22 |
23 | /**
24 | * @author OFFIS, Tammo Freese
25 | */
26 | public interface IProxyFactory {
27 |
28 | /**
29 | * @param toMock the class to mock by the factory
30 | * @param handler the handler that will be linked to the created proxy
31 | * @param mockedMethods the subset of {@code toMock}'s methods to mock, or
32 | * null to mock all methods.
33 | * @param constructorArgs the constructor arguments to use, or null to use
34 | * heuristics to choose a constructor.
35 | * @return the newly created proxy
36 | */
37 | T createProxy(Class toMock, InvocationHandler handler, Method[] mockedMethods,
38 | ConstructorArgs constructorArgs);
39 |
40 | /**
41 | * Returns the invocation handler for {@code mock};
42 | *
43 | * @param mock a mock instance previously returned by {@code createProxy}.
44 | * @return the handler handling method calls for the {@code mock}
45 | */
46 | InvocationHandler getInvocationHandler(Object mock);
47 | }
48 |
--------------------------------------------------------------------------------
/easymock-classextension/src/test/java/org/easymock/classextension/tests2/ClassProxyFactoryTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2003-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 | */
16 | package org.easymock.classextension.tests2;
17 |
18 | import static org.junit.Assert.*;
19 |
20 | import java.lang.reflect.Field;
21 |
22 | import net.sf.cglib.proxy.Callback;
23 |
24 | import org.easymock.internal.ClassProxyFactory;
25 | import org.junit.Test;
26 |
27 | /**
28 | * @author Henri Tremblay
29 | */
30 | public class ClassProxyFactoryTest {
31 |
32 | private final ClassProxyFactory factory = new ClassProxyFactory();
33 |
34 | @SuppressWarnings("unchecked")
35 | @Test
36 | public void testRegisterClassNotLeaking() throws Exception {
37 | final ClassProxyFactoryTest mock = factory.createProxy(ClassProxyFactoryTest.class,
38 | NopInvocationHandler.NOP, null, null);
39 | // Go deep in the cglib implementation to make sure the callback was released on the mocked class
40 | final Field field = mock.getClass().getDeclaredField("CGLIB$THREAD_CALLBACKS");
41 | field.setAccessible(true);
42 | final ThreadLocal tl = (ThreadLocal) field.get(mock);
43 | final Callback callback = tl.get();
44 | assertNull(callback);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/And.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | import org.easymock.IArgumentMatcher;
23 |
24 | /**
25 | * @author OFFIS, Tammo Freese
26 | */
27 | public class And implements IArgumentMatcher, Serializable {
28 |
29 | private static final long serialVersionUID = 3874580646798403818L;
30 |
31 | private final List matchers;
32 |
33 | public And(final List matchers) {
34 | this.matchers = matchers;
35 | }
36 |
37 | public boolean matches(final Object actual) {
38 | for (final IArgumentMatcher matcher : matchers) {
39 | if (!matcher.matches(actual)) {
40 | return false;
41 | }
42 | }
43 | return true;
44 | }
45 |
46 | public void appendTo(final StringBuffer buffer) {
47 | buffer.append("and(");
48 | for (final Iterator it = matchers.iterator(); it.hasNext();) {
49 | it.next().appendTo(buffer);
50 | if (it.hasNext()) {
51 | buffer.append(", ");
52 | }
53 | }
54 | buffer.append(")");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/easymock/src/main/java/org/easymock/internal/matchers/Or.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.internal.matchers;
17 |
18 | import java.io.Serializable;
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | import org.easymock.IArgumentMatcher;
23 |
24 | /**
25 | * @author OFFIS, Tammo Freese
26 | */
27 | public class Or implements IArgumentMatcher, Serializable {
28 |
29 | private static final long serialVersionUID = -5701204283180444317L;
30 |
31 | private final List matchers;
32 |
33 | public Or(final List matchers) {
34 | this.matchers = matchers;
35 | }
36 |
37 | public boolean matches(final Object actual) {
38 | for (final IArgumentMatcher matcher : matchers) {
39 | if (matcher.matches(actual)) {
40 | return true;
41 | }
42 | }
43 | return false;
44 | }
45 |
46 | public void appendTo(final StringBuffer buffer) {
47 | buffer.append("or(");
48 | for (final Iterator it = matchers.iterator(); it.hasNext();) {
49 | it.next().appendTo(buffer);
50 | if (it.hasNext()) {
51 | buffer.append(", ");
52 | }
53 | }
54 | buffer.append(")");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/easymock/src/samples/java/org/easymock/samples/ThrowableEquals.java:
--------------------------------------------------------------------------------
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 | */
16 | package org.easymock.samples;
17 |
18 | import static org.easymock.EasyMock.*;
19 |
20 | import org.easymock.IArgumentMatcher;
21 |
22 | /**
23 | * @author OFFIS, Tammo Freese
24 | */
25 | public class ThrowableEquals implements IArgumentMatcher {
26 | private final Throwable expected;
27 |
28 | public ThrowableEquals(final Throwable expected) {
29 | this.expected = expected;
30 | }
31 |
32 | public boolean matches(final Object actual) {
33 | if (!(actual instanceof Throwable)) {
34 | return false;
35 | }
36 | final String actualMessage = ((Throwable) actual).getMessage();
37 | return expected.getClass().equals(actual.getClass()) && expected.getMessage().equals(actualMessage);
38 | }
39 |
40 | public void appendTo(final StringBuffer buffer) {
41 | buffer.append("<");
42 | buffer.append(expected.getClass().getName());
43 | buffer.append(" with message \"");
44 | buffer.append(expected.getMessage());
45 | buffer.append("\">");
46 |
47 | }
48 |
49 | public static T eqException(final T in) {
50 | reportMatcher(new ThrowableEquals(in));
51 | return in;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/website/api/easymockclassextension/2.5/org/easymock/classextension/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | org.easymock.classextension (EasyMock class extension 2.5 API)
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | org.easymock.classextension
21 |