Merge "Add EasyMock 3.1, Objenesis 1.2 and cglib 2.2.3"
diff --git a/common/asm-tools/Android.mk b/common/asm-tools/Android.mk
index 95c136a..9f247dd 100644
--- a/common/asm-tools/Android.mk
+++ b/common/asm-tools/Android.mk
@@ -16,7 +16,10 @@
include $(CLEAR_VARS)
+# Note: common/cglib 2.2 requires the old asm 3.3.x.
+
LOCAL_PREBUILT_JAVA_LIBRARIES := \
+ asm-3-tools:asm-3.3.1$(COMMON_JAVA_PACKAGE_SUFFIX) \
asm-tools:asm-4.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
asm-tree-tools:asm-tree-4.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
asm-analysis-tools:asm-analysis-4.0$(COMMON_JAVA_PACKAGE_SUFFIX)
diff --git a/common/asm-tools/asm-3.3.1.jar b/common/asm-tools/asm-3.3.1.jar
new file mode 100644
index 0000000..349f0d4
--- /dev/null
+++ b/common/asm-tools/asm-3.3.1.jar
Binary files differ
diff --git a/common/asm-tools/src-3.3.1.zip b/common/asm-tools/src-3.3.1.zip
new file mode 100644
index 0000000..5b7a876
--- /dev/null
+++ b/common/asm-tools/src-3.3.1.zip
Binary files differ
diff --git a/common/asm-tools/src.zip b/common/asm-tools/src-4.0.zip
similarity index 100%
rename from common/asm-tools/src.zip
rename to common/asm-tools/src-4.0.zip
Binary files differ
diff --git a/common/cglib/Android.mk b/common/cglib/Android.mk
new file mode 100644
index 0000000..d842310
--- /dev/null
+++ b/common/cglib/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Note: To use cglib, please also add target asm-3-tools.
+
+LOCAL_PREBUILT_JAVA_LIBRARIES := \
+ cglib:cglib-2.2.3$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_PREBUILT)
diff --git a/common/cglib/MODULE_LICENSE_APACHE2 b/common/cglib/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/cglib/MODULE_LICENSE_APACHE2
diff --git a/common/cglib/PREBUILT.txt b/common/cglib/PREBUILT.txt
new file mode 100644
index 0000000..88c512a
--- /dev/null
+++ b/common/cglib/PREBUILT.txt
@@ -0,0 +1,8 @@
+Cglib 2.2
+
+Home page: http://cglib.sourceforge.net/
+License: Apache 2.0
+Version: 2.2.3
+Description: A powerful, high performance and quality Code Generation Library, It is used to extend JAVA classes and implements interfaces at runtime.
+
+Download URL: http://sourceforge.net/projects/cglib/files/cglib2/2.2.3/cglib.2.2.3.zip/download
diff --git a/common/cglib/README b/common/cglib/README
new file mode 100755
index 0000000..da5a9ef
--- /dev/null
+++ b/common/cglib/README
@@ -0,0 +1,2 @@
+CGLIB 2.2.3 contains bug fix to solve heavy memory usage issues.
+http://cglib.cvs.sourceforge.net/viewvc/cglib/cglib/src/proxy/net/sf/cglib/transform/impl/UndeclaredThrowableStrategy.java?r1=1.3&r2=1.3.2.1&pathrev=RELEASE_2_2_3
\ No newline at end of file
diff --git a/common/cglib/cglib-2.2.3.jar b/common/cglib/cglib-2.2.3.jar
new file mode 100644
index 0000000..41651f8
--- /dev/null
+++ b/common/cglib/cglib-2.2.3.jar
Binary files differ
diff --git a/common/cglib/cglib-docs-2.2.3.jar b/common/cglib/cglib-docs-2.2.3.jar
new file mode 100644
index 0000000..a5925b4
--- /dev/null
+++ b/common/cglib/cglib-docs-2.2.3.jar
Binary files differ
diff --git a/common/cglib/cglib-nodep-2.2.3.jar b/common/cglib/cglib-nodep-2.2.3.jar
new file mode 100644
index 0000000..35d6d7c
--- /dev/null
+++ b/common/cglib/cglib-nodep-2.2.3.jar
Binary files differ
diff --git a/common/cglib/cglib-src-2.2.3.jar b/common/cglib/cglib-src-2.2.3.jar
new file mode 100644
index 0000000..4c5e62a
--- /dev/null
+++ b/common/cglib/cglib-src-2.2.3.jar
Binary files differ
diff --git a/common/easymock-tools/Android.mk b/common/easymock-tools/Android.mk
new file mode 100644
index 0000000..2ce89f7
--- /dev/null
+++ b/common/easymock-tools/Android.mk
@@ -0,0 +1,24 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PREBUILT_JAVA_LIBRARIES := \
+ easymock-tools:easymock-3.1$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_PREBUILT)
diff --git a/common/easymock-tools/Documentation.html b/common/easymock-tools/Documentation.html
new file mode 100644
index 0000000..4b27752
--- /dev/null
+++ b/common/easymock-tools/Documentation.html
@@ -0,0 +1,1183 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<title>EasyMock 3.1 Readme</title>
+<link rel="stylesheet" href="easymock.css" />
+</head>
+<body><div class="bodywidth">
+
+<h2>EasyMock 3.1 Readme</h2>
+
+<p>Documentation for release 3.1 (2011-11-10)<br />
+© 2001-2011 <a href="http://www.offis.de">OFFIS</a>, <a href="http://tammofreese.de">Tammo Freese</a>, <a href="http://www.ossia-conseil.com/blog/henri/">Henri Tremblay</a>.
+</p>
+<p>
+EasyMock is a library that provides an easy way to use Mock Objects for given
+interfaces or classes. EasyMock is available under the terms of the <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">Apache 2 license</a>.
+</p>
+<p>
+Mock Objects simulate parts of the behavior of domain code,
+and are able to check whether they are used as defined.
+Domain classes can be tested in isolation
+by simulating their collaborators with Mock Objects.
+</p>
+<p>
+Writing and maintaining Mock Objects often is a tedious
+task that may introduce errors. EasyMock generates Mock Objects
+dynamically - no need to write them, and no generated code!
+</p>
+<h2>
+EasyMock Benefits
+</h2>
+<ul>
+<li>Hand-writing classes for Mock Objects is not needed.
+</li>
+<li>Supports refactoring-safe Mock Objects: test code will not break at runtime when renaming methods or reordering method parameters
+</li>
+<li>Supports return values and exceptions.
+</li>
+<li>Supports checking the order of method calls, for one or more Mock Objects.
+</li>
+</ul>
+<h2>
+Requirements
+</h2>
+<ul>
+<li>EasyMock only works with Java 1.5.0 and above.</li>
+<li>cglib (2.2) and Objenesis (1.2) must be in the classpath to perform class mocking</li>
+</ul>
+<h2>
+Installation
+</h2>
+<h3>Using Maven</h3>
+EasyMock is available in the Maven central repository. Just add the following dependency to your pom.xml:
+<pre>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+</pre>
+You can obviously use any other dependency tool compatible with the Maven repository.
+
+<h3>Manually</h3>
+<ul>
+<li>Unzip the EasyMock zip file (<code>easymock-3.1.zip</code>).</li>
+<li>Go into the <code>easymock-3.1</code> directory.</li>
+<li>Add the EasyMock jar file (<code>easymock.jar</code>) to your classpath.</li>
+<li>To perform class mocking, also add <a href="http://www.objenesis.org">Objenesis</a> and <a href="http://cglib.sourceforge.net/">Cglib</a> to your classpath.</li>
+<li>The tests are in <code>easymock-3.1-tests.jar</code> and can be launched with a JUnit TestRunner
+having JUnit 4.7 on top of EasyMock, cglib and Objenesis in your classpath.</li>
+<li>The source code of EasyMock is stored in <code>easymock-3.1-sources.jar</code>.</li>
+</ul>
+<h2>
+Usage
+</h2>
+<p>
+Most parts of a software system do not work in isolation, but collaborate
+with other parts to get their job done. In a lot of cases, we do not care
+about using collaborators in unit testing, as we trust these collaborators.
+If we <em>do</em> care about it, Mock Objects help us to test the unit under test
+in isolation. Mock Objects replace collaborators of the unit under
+test.
+</p>
+<p>
+The following examples use the interface <code>Collaborator</code>:
+</p>
+<pre>
+package org.easymock.samples;
+
+public interface Collaborator {
+ void documentAdded(String title);
+ void documentChanged(String title);
+ void documentRemoved(String title);
+ byte voteForRemoval(String title);
+ byte[] voteForRemovals(String[] title);
+}
+</pre>
+<p>
+Implementors of this interface are collaborators
+(in this case listeners) of a class named <code>ClassUnderTest</code>:
+</p>
+<pre>
+public class ClassUnderTest {
+ // ...
+ public void addListener(Collaborator listener) {
+ // ...
+ }
+ public void addDocument(String title, byte[] document) {
+ // ...
+ }
+ public boolean removeDocument(String title) {
+ // ...
+ }
+ public boolean removeDocuments(String[] titles) {
+ // ...
+ }
+}
+</pre>
+<p>
+The code for both the class and the interface may be found
+in the package <code>org.easymock.samples</code> in <code>easymock-3.1-samples.jar</code>
+from the EasyMock zip delivery.
+</p>
+<p>
+The following examples assume that you are familiar with the JUnit testing framework.
+Although the tests shown here use JUnit 4, you may as well use JUnit 3 or TestNG.
+</p>
+<h3>
+The first Mock Object
+</h3>
+<p>
+We will now build a test case and toy around with it to understand the
+functionality of the EasyMock package. <code>easymock-3.1-samples.jar</code>
+contains a modified version of this test. Our first test should check
+whether the removal of a non-existing document does <strong>not </strong> lead to a notification
+of the collaborator. Here is the test without the definition of the
+Mock Object:
+</p>
+<pre>
+package org.easymock.samples;
+
+import org.junit.*;
+
+public class ExampleTest {
+
+ private ClassUnderTest classUnderTest;
+ private Collaborator mock;
+
+ @Before
+ public void setUp() {
+ classUnderTest = new ClassUnderTest();
+ classUnderTest.addListener(mock);
+ }
+
+ @Test
+ public void testRemoveNonExistingDocument() {
+ // This call should not lead to any notification
+ // of the Mock Object:
+ classUnderTest.removeDocument("Does not exist");
+ }
+}
+</pre>
+<p>
+For many tests using EasyMock,
+we only need a static import of methods of <code>org.easymock.EasyMock</code>.
+</p>
+<pre>
+import static org.easymock.EasyMock.*;
+import org.junit.*;
+
+public class ExampleTest {
+
+ private ClassUnderTest classUnderTest;
+ private Collaborator mock;
+
+}
+</pre>
+<p>
+To get a Mock Object, we need to
+</p>
+<ol>
+<li>create a Mock Object for the interface we would like to simulate,
+</li>
+<li>record the expected behavior, and
+</li>
+<li>switch the Mock Object to replay state.
+</li>
+</ol>
+<p>
+Here is a first example:
+</p>
+<pre>
+ @Before
+ public void setUp() {
+ mock = createMock(Collaborator.class); // 1
+ classUnderTest = new ClassUnderTest();
+ classUnderTest.addListener(mock);
+ }
+
+ @Test
+ public void testRemoveNonExistingDocument() {
+ // 2 (we do not expect anything)
+ replay(mock); // 3
+ classUnderTest.removeDocument("Does not exist");
+ }
+</pre>
+<p>
+After activation in step 3, <code>mock</code>
+is a Mock Object for the <code>Collaborator</code>
+interface that expects no calls. This means that if we change
+our <code>ClassUnderTest</code> to call
+any of the interface's methods, the Mock Object will throw
+an <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentRemoved("Does not exist"):
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentRemoved(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentRemoved(ClassUnderTest.java:74)
+ at org.easymock.samples.ClassUnderTest.removeDocument(ClassUnderTest.java:33)
+ at org.easymock.samples.ExampleTest.testRemoveNonExistingDocument(ExampleTest.java:24)
+ ...
+</pre>
+
+<h3>
+ Adding Behavior
+</h3>
+<p>
+Let us write a second test. If a document
+is added on the class under test, we expect a call to <code>mock.documentAdded()</code>
+on the Mock Object with the title of the document as argument:
+</p>
+<pre>
+ @Test
+ public void testAddDocument() {
+ mock.documentAdded("New Document"); // 2
+ replay(mock); // 3
+ classUnderTest.addDocument("New Document", new byte[0]);
+ }
+</pre>
+<p>
+So in the record state (before calling <code>replay</code>),
+the Mock Object does <em>not</em> behave like a Mock Object,
+but it records method calls. After calling <code>replay</code>,
+it behaves like a Mock Object, checking whether the expected
+method calls are really done.
+</p>
+<p>
+If <code>classUnderTest.addDocument("New Document", new byte[0])</code>
+calls the expected method with a wrong argument, the Mock Object will complain
+with an <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentAdded("Wrong title"):
+ documentAdded("New Document"): expected: 1, actual: 0
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentAdded(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentAdded(ClassUnderTest.java:61)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:28)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:30)
+ ...
+</pre>
+<p>
+All missed expectations are shown, as well as all fulfilled
+expectations for the unexpected call (none in this case). If the method
+call is executed too often, the Mock Object complains, too:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentAdded("New Document"):
+ documentAdded("New Document"): expected: 1, actual: 2
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentAdded(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentAdded(ClassUnderTest.java:62)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:29)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:30)
+ ...
+</pre>
+<h3>
+Verifying Behavior
+</h3>
+<p>
+There is one error that we have not handled so far: If we specify
+behavior, we would like to verify that it is actually used. The current
+test would pass if no method on the Mock Object is called. To verify that the
+specified behavior has been used, we have to call
+<code>verify(mock)</code>:
+</p>
+<pre>
+ @Test
+ public void testAddDocument() {
+ mock.documentAdded("New Document"); // 2
+ replay(mock); // 3
+ classUnderTest.addDocument("New Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+If the method is not called on the Mock Object, we now get the
+following exception:
+</p>
+<pre>
+java.lang.AssertionError:
+ Expectation failure on verify:
+ documentAdded("New Document"): expected: 1, actual: 0
+ at org.easymock.internal.MocksControl.verify(MocksControl.java:70)
+ at org.easymock.EasyMock.verify(EasyMock.java:536)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:31)
+ ...
+</pre>
+<p>
+The message of the exception lists all missed expectations.
+</p>
+<h3>
+Expecting an Explicit Number of Calls
+</h3>
+<p>
+Up to now, our test has only considered a single method call. The next
+test should check whether the addition of an already existing
+document leads to a call to <code>mock.documentChanged()</code>
+with the appropriate argument. To be sure, we check this three
+times (hey, it is an example ;-)):
+</p>
+<pre>
+ @Test
+ public void testAddAndChangeDocument() {
+ mock.documentAdded("Document");
+ mock.documentChanged("Document");
+ mock.documentChanged("Document");
+ mock.documentChanged("Document");
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+To avoid the repetition of <code>mock.documentChanged("Document")</code>,
+EasyMock provides a shortcut. We may specify the call count with the method
+<code>times(int times)</code> on the object returned by
+<code>expectLastCall()</code>. The code then looks like:
+</p>
+<pre>
+ @Test
+ public void testAddAndChangeDocument() {
+ mock.documentAdded("Document");
+ mock.documentChanged("Document");
+ expectLastCall().times(3);
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+If the method is called too often, we get an exception that
+tells us that the method has been called too many times.
+The failure occurs immediately at the first method call
+exceeding the limit:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentChanged("Document"):
+ documentChanged("Document"): expected: 3, actual: 4
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentChanged(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentChanged(ClassUnderTest.java:67)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:26)
+ at org.easymock.samples.ExampleTest.testAddAndChangeDocument(ExampleTest.java:43)
+ ...
+</pre>
+<p>
+If there are too few calls, <code>verify(mock)</code>
+throws an <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Expectation failure on verify:
+ documentChanged("Document"): expected: 3, actual: 2
+ at org.easymock.internal.MocksControl.verify(MocksControl.java:70)
+ at org.easymock.EasyMock.verify(EasyMock.java:536)
+ at org.easymock.samples.ExampleTest.testAddAndChangeDocument(ExampleTest.java:43)
+ ...
+</pre>
+<h3>
+Specifying Return Values
+</h3>
+<p>
+For specifying return values,
+we wrap the expected call in <code>expect(T value)</code> and specify the return value
+with the method <code>andReturn(Object returnValue)</code> on the object returned by
+<code>expect(T value)</code>.
+</p>
+<p>
+As an example, we check the workflow for document
+removal. If <code>ClassUnderTest</code> gets a call for document
+removal, it asks all collaborators for their vote for removal
+with calls to <code>byte voteForRemoval(String title)</code> value.
+Positive return values are a vote for
+removal. If the sum of all values is positive, the document is removed
+and <code>documentRemoved(String title)</code> is called on
+all collaborators:
+</p>
+<pre>
+ @Test
+ public void testVoteForRemoval() {
+ mock.documentAdded("Document"); // expect document addition
+ // expect to be asked to vote for document removal, and vote for it
+ expect(mock.voteForRemoval("Document")).andReturn((byte) 42);
+ mock.documentRemoved("Document"); // expect document removal
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ assertTrue(classUnderTest.removeDocument("Document"));
+ verify(mock);
+ }
+
+ @Test
+ public void testVoteAgainstRemoval() {
+ mock.documentAdded("Document"); // expect document addition
+ // expect to be asked to vote for document removal, and vote against it
+ expect(mock.voteForRemoval("Document")).andReturn((byte) -42);
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ assertFalse(classUnderTest.removeDocument("Document"));
+ verify(mock);
+ }
+</pre>
+<p>
+The type of the returned value is checked at compile time. As an example,
+the following code will not compile, as the type of the provided return value
+does not match the method's return value:
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn("wrong type");
+</pre>
+<p>
+Instead of calling <code>expect(T value)</code>
+to retrieve the object for setting the return value,
+we may also use the object returned by <code>expectLastCall()</code>.
+Instead of
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn((byte) 42);
+</pre>
+<p>
+we may use
+</p>
+<pre>
+ mock.voteForRemoval("Document");
+ expectLastCall().andReturn((byte) 42);
+</pre>
+<p>
+This type of specification should only be used if the line gets too long,
+as it does not support type checking at compile time.
+</p>
+<h3>
+Working with Exceptions
+</h3>
+<p>
+For specifying exceptions (more exactly: Throwables) to be thrown, the object returned by
+<code>expectLastCall()</code> and <code>expect(T value)</code> provides the method
+<code>andThrow(Throwable throwable)</code>.
+The method has to be called in record state after the call to the Mock Object for
+which it specifies the <code>Throwable</code> to be thrown.
+</p>
+<p>
+Unchecked exceptions (that is, <code>RuntimeException</code>, <code>Error</code>
+and all their subclasses) can be thrown from every method. Checked exceptions can only be
+thrown from the methods that do actually throw them.
+</p>
+<h3>
+Creating Return Values or Exceptions
+</h3>
+<p>
+Sometimes we would like our mock object to return a value or throw an exception
+that is created at the time of the actual call. Since EasyMock 2.2, the object returned by
+<code>expectLastCall()</code> and <code>expect(T value)</code> provides the method
+<code>andAnswer(IAnswer answer)</code> which allows to specify an implementation of the
+interface <code>IAnswer</code> that is used to create the return value or exception.
+</p>
+<p>
+Inside an <code>IAnswer</code> callback, the arguments passed to the mock call
+are available via <code>EasyMock.getCurrentArguments()</code>.
+If you use these, refactorings like reordering parameters may break your tests.
+You have been warned.
+</p>
+<p>
+An alternative to <code>IAnswer</code> are the <code>andDelegateTo</code> and
+<code>andStubDelegateTo</code> methods. They allow to delegate the call to a
+concrete implementation of the mocked interface that will then provide the answer.
+The pros are that the arguments found in <code>EasyMock.getCurrentArguments()</code>
+for <code>IAnswer</code> are now passed to the method of the concrete implementation.
+This is refactoring safe. The cons are that you have to provide an implementation
+which is kind of doing a mock manually... Which is what you try to avoid by
+using EasyMock. It can also be painful if the interface has many methods. Finally,
+the type of the concrete class can't be checked statically against the mock type.
+If for some reason, the concrete class isn't implementing the method that is
+delegated, you will get an exception during the replay only. However, this
+case should be quite rare.
+</p>
+<p>
+To understand correctly the two options, here is an example:
+</p>
+<pre>
+ List<String> l = createMock(List.class);
+
+ // andAnswer style
+ expect(l.remove(10)).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return getCurrentArguments()[0].toString();
+ }
+ });
+
+ // andDelegateTo style
+ expect(l.remove(10)).andDelegateTo(new ArrayList<String>() {
+ @Override
+ public String remove(int index) {
+ return Integer.toString(index);
+ }
+ });
+</pre>
+<h3>
+Changing Behavior for the Same Method Call
+</h3>
+<p>
+It is also possible to specify a changing behavior for a method.
+The methods <code>times</code>, <code>andReturn</code>, and <code>andThrow</code>
+may be chained. As an example, we define <code>voteForRemoval("Document")</code> to
+</p>
+<ul>
+<li>return 42 for the first three calls,
+</li>
+<li>throw a <code>RuntimeException</code> for the next four calls,
+</li>
+<li>return -42 once.
+</li>
+</ul>
+<pre>
+ expect(mock.voteForRemoval("Document"))
+ .andReturn((byte) 42).times(3)
+ .andThrow(new RuntimeException(), 4)
+ .andReturn((byte) -42);
+</pre>
+<h3>
+Relaxing Call Counts
+</h3>
+<p>
+To relax the expected call counts, there are additional methods
+that may be used instead of <code>times(int count)</code>:
+</p>
+<dl>
+<dt><code>times(int min, int max)</code></dt>
+<dd>to expect between <code>min</code> and <code>max</code> calls,</dd>
+<dt><code>atLeastOnce()</code></dt>
+<dd>to expect at least one call, and</dd>
+<dt><code>anyTimes()</code></dt>
+<dd>to expected an unrestricted number of calls.</dd>
+</dl>
+<p>
+If no call count is specified, one call is expected. If we would like to state this
+explicitely, <code>once()</code> or <code>times(1)</code> may be used.
+</p>
+<h3>
+Strict Mocks
+</h3>
+<p>
+On a Mock Object returned by a <code>EasyMock.createMock()</code>,
+the order of method calls is not checked.
+If you would like a strict Mock Object that checks the order of method calls,
+use <code>EasyMock.create<i>Strict</i>Mock()</code> to create it.</p>
+<p>
+If an unexpected method is called on a strict Mock Object,
+the message of the exception will show the method calls
+expected at this point followed by the first conflicting one.
+<code>verify(mock)</code> shows all missing method calls.
+</p>
+<h3>
+Switching Order Checking On and Off
+</h3>
+<p>
+Sometimes, it is necessary to have a Mock Object that checks the order of only some calls.
+In record phase, you may switch order checking on by calling <code>checkOrder(mock, true)</code>
+and switch it off by calling <code>checkOrder(mock, false)</code>.
+</p>
+<p>
+There are two differences between a strict Mock Object and a normal Mock Object:
+</p>
+<ol>
+ <li> A strict Mock Object has order checking enabled after creation. </li>
+ <li> A strict Mock Object has order checking enabled after reset (see <em>Reusing a Mock Object</em>). </li>
+</ol>
+<h3>
+Flexible Expectations with Argument Matchers
+</h3>
+<p>
+To match an actual method call on the Mock Object with an
+expectation, <code>Object</code> arguments are by default compared with
+<code>equals()</code>. This may lead to problems. As an example,
+we consider the following expectation:
+</p>
+<pre>
+String[] documents = new String[] { "Document 1", "Document 2" };
+expect(mock.voteForRemovals(documents)).andReturn(42);
+</pre>
+<p>
+If the method is called with another array with the same contents,
+we get an exception, as <code>equals()</code> compares object
+identity for arrays:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call voteForRemovals([Ljava.lang.String;@9a029e):
+ voteForRemovals([Ljava.lang.String;@2db19d): expected: 1, actual: 0
+ documentRemoved("Document 1"): expected: 1, actual: 0
+ documentRemoved("Document 2"): expected: 1, actual: 0
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.voteForRemovals(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.listenersAllowRemovals(ClassUnderTest.java:88)
+ at org.easymock.samples.ClassUnderTest.removeDocuments(ClassUnderTest.java:48)
+ at org.easymock.samples.ExampleTest.testVoteForRemovals(ExampleTest.java:83)
+ ...
+</pre>
+<p>
+To specify that only array equality is needed for this call, we may use the method
+<code>aryEq</code> that is statically imported from the <code>EasyMock</code> class:
+</p>
+<pre>
+String[] documents = new String[] { "Document 1", "Document 2" };
+expect(mock.voteForRemovals(aryEq(documents))).andReturn(42);
+</pre>
+<p>
+If you would like to use matchers in a call, you have to specify matchers for all
+arguments of the method call.
+</p>
+<p>
+There are a couple of predefined argument matchers available.
+</p>
+<dl>
+
+<dt><code>eq(X value)</code></dt>
+<dd>Matches if the actual value is equals the expected value. Available for all primitive types and for objects.</dd>
+
+<dt><code>anyBoolean()</code>, <code>anyByte()</code>, <code>anyChar()</code>, <code>anyDouble()</code>, <code>anyFloat()</code>, <code>anyInt()</code>, <code>anyLong()</code>, <code>anyObject()</code>, <code>anyObject(Class clazz)</code>, <code>anyShort()</code></dt>
+<dd>Matches any value. Available for all primitive types and for objects.</dd>
+
+<dt><code>eq(X value, X delta)</code></dt>
+<dd>Matches if the actual value is equal to the given value allowing the given delta. Available for <code>float</code> and <code>double</code>.</dd>
+
+<dt><code>aryEq(X value)</code></dt>
+<dd>Matches if the actual value is equal to the given value according to <code>Arrays.equals()</code>. Available for primitive and object arrays.</dd>
+
+<dt><code>isNull()</code>, <code>isNull(Class clazz)</code></dt>
+<dd>Matches if the actual value is null. Available for objects.</dd>
+
+<dt><code>notNull()</code>, <code>notNull(Class clazz)</code></dt>
+<dd>Matches if the actual value is not null. Available for objects.</dd>
+
+<dt><code>same(X value)</code></dt>
+<dd>Matches if the actual value is the same as the given value. Available for objects.</dd>
+
+<dt><code>isA(Class clazz)</code></dt>
+<dd>Matches if the actual value is an instance of the given class, or if it is in instance of a class that extends or implements the given class. Null always return false. Available for objects.</dd>
+
+<dt><code>lt(X value)</code>, <code>leq(X value)</code>, <code>geq(X value)</code>, <code>gt(X value)</code></dt>
+<dd>Matches if the actual value is less/less or equal/greater or equal/greater than the given value. Available for all numeric primitive types and <code>Comparable</code>.</dd>
+
+<dt><code>startsWith(String prefix), contains(String substring), endsWith(String suffix)</code></dt>
+<dd>Matches if the actual value starts with/contains/ends with the given value. Available for <code>String</code>s.</dd>
+
+<dt><code>matches(String regex), find(String regex)</code></dt>
+<dd>Matches if the actual value/a substring of the actual value matches the given regular expression. Available for <code>String</code>s.</dd>
+
+<dt><code>and(X first, X second)</code></dt>
+<dd>Matches if the matchers used in <code>first</code> and <code>second</code> both match. Available for all primitive types and for objects.</dd>
+
+<dt><code>or(X first, X second)</code></dt>
+<dd>Matches if one of the matchers used in <code>first</code> and <code>second</code> match. Available for all primitive types and for objects.</dd>
+
+<dt><code>not(X value)</code></dt>
+<dd>Matches if the matcher used in <code>value</code> does not match.</dd>
+
+<dt><code>cmpEq(X value)</code></dt>
+<dd>Matches if the actual value is equals according to <code>Comparable.compareTo(X o)</code>. Available for all numeric primitive types and <code>Comparable</code>.</dd>
+
+<dt><code>cmp(X value, Comparator<X> comparator, LogicalOperator operator)</code></dt>
+<dd>Matches if <code>comparator.compare(actual, value) operator 0</code> where the operator is <,<=,>,>= or ==. Available for objects.</dd>
+
+<dt><code>capture(Capture<T> capture)</code>, <code>captureXXX(Capture<T> capture)</code></dt>
+<dd>Matches any value but captures it in the <code>Capture</code> parameter for later access. You can do <code>and(someMatcher(...), capture(c))</code> to
+capture a parameter from a specific call to the method. You can also specify a <code>CaptureType</code> telling that a given <code>Capture</code> should keep
+the first, the last, all or no captured values.</dd>
+
+</dl>
+
+<h3>
+Defining your own Argument Matchers
+</h3>
+<p>
+Sometimes it is desirable to define own argument matchers. Let's say that an
+argument matcher is needed that matches an exception if the given exception has the same type and an equal message.
+It should be used this way:
+</p>
+<pre>
+ IllegalStateException e = new IllegalStateException("Operation not allowed.")
+ expect(mock.logThrowable(eqException(e))).andReturn(true);
+</pre>
+<p>
+Two steps are necessary to achieve this: The new argument matcher has to be defined,
+and the static method <code>eqException</code> has to be declared.
+</p>
+<p>
+To define the new argument matcher, we implement the interface <code>org.easymock.IArgumentMatcher</code>.
+This interface contains two methods: <code>matches(Object actual)</code> checks whether the actual argument
+matches the given argument, and <code>appendTo(StringBuffer buffer)</code> appends a string representation
+of the argument matcher to the given string buffer. The implementation is straightforward:
+</p>
+<pre>
+import org.easymock.IArgumentMatcher;
+
+public class ThrowableEquals implements IArgumentMatcher {
+ private Throwable expected;
+
+ public ThrowableEquals(Throwable expected) {
+ this.expected = expected;
+ }
+
+ public boolean matches(Object actual) {
+ if (!(actual instanceof Throwable)) {
+ return false;
+ }
+ String actualMessage = ((Throwable) actual).getMessage();
+ return expected.getClass().equals(actual.getClass())
+ && expected.getMessage().equals(actualMessage);
+ }
+
+ public void appendTo(StringBuffer buffer) {
+ buffer.append("eqException(");
+ buffer.append(expected.getClass().getName());
+ buffer.append(" with message \"");
+ buffer.append(expected.getMessage());
+ buffer.append("\"")");
+
+ }
+}
+</pre>
+<p>
+The method <code>eqException</code> must create the argument matcher with the given Throwable,
+report it to EasyMock via the static method <code>reportMatcher(IArgumentMatcher matcher)</code>,
+and return a value so that it may be used inside the call
+(typically <code>0</code>, <code>null</code> or <code>false</code>). A first attempt may look like:
+</p>
+<pre>
+public static Throwable eqException(Throwable in) {
+ EasyMock.reportMatcher(new ThrowableEquals(in));
+ return null;
+}
+</pre>
+<p>
+However, this only works if the method <code>logThrowable</code> in the example usage accepts
+<code>Throwable</code>s, and does not require something more specific like a <code>RuntimeException</code>.
+In the latter case, our code sample would not compile:
+</p>
+<pre>
+ IllegalStateException e = new IllegalStateException("Operation not allowed.")
+ expect(mock.logThrowable(eqException(e))).andReturn(true);
+</pre>
+<p>
+Java 5.0 to the rescue: Instead of defining <code>eqException</code> with a <code>Throwable</code> as
+parameter and return value, we use a generic type that extends <code>Throwable</code>:
+</p>
+<pre>
+public static <T extends Throwable> T eqException(T in) {
+ reportMatcher(new ThrowableEquals(in));
+ return null;
+}
+</pre>
+<h3>
+Reusing a Mock Object
+</h3>
+<p>
+Mock Objects may be reset by <code>reset(mock)</code>.
+</p>
+<p>
+If needed, a mock can also be converted from one type to another by calling <code>resetToNice(mock)</code>,
+<code>resetToDefault(mock)</code> ou <code>resetToStrict(mock)</code>.
+</p>
+<h3>
+Using Stub Behavior for Methods
+</h3>
+<p>
+Sometimes, we would like our Mock Object to respond to some method calls, but we do not want to
+check how often they are called, when they are called, or even if they are called at all.
+This stub behavoir may be defined by using the methods <code>andStubReturn(Object value)</code>,
+<code>andStubThrow(Throwable throwable)</code>, <code>andStubAnswer(IAnswer<Tgt; answer)</code>
+and <code>asStub()</code>. The following code
+configures the MockObject to answer 42 to <code>voteForRemoval("Document")</code> once
+and -1 for all other arguments:
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn(42);
+ expect(mock.voteForRemoval(not(eq("Document")))).andStubReturn(-1);
+</pre>
+<h3>
+Nice Mocks
+</h3>
+<p>
+On a Mock Object returned by <code>createMock()</code> the default behavior for all methods is to throw an
+<code>AssertionError</code> for all unexpected method calls.
+If you would like a "nice" Mock Object that by default allows all method calls and returns
+appropriate empty values (<code>0</code>, <code>null</code> or <code>false</code>), use <code>create<i>Nice</i>Mock()</code> instead.
+</p>
+
+<a id="Object_Methods"/><h3>Object Methods</h3>
+<p>
+The behavior for the four Object methods <code>equals()</code>,
+<code>hashCode()</code>, <code>toString()</code> and <code>finalize()</code>
+cannot be changed for Mock Objects created with EasyMock,
+even if they are part of the interface for which the
+Mock Object is created.
+</p>
+<h3>Checking Method Call Order Between Mocks</h3>
+<p>
+Up to this point, we have seen a mock object as a single object that is configured by static methods
+on the class <code>EasyMock</code>. But many of these static methods just identify the hidden control of the Mock Object
+and delegate to it. A Mock Control is an object implementing the <code>IMocksControl</code> interface.
+</p>
+<p>
+So instead of
+</p>
+<pre>
+ IMyInterface mock = createStrictMock(IMyInterface.class);
+ replay(mock);
+ verify(mock);
+ reset(mock);
+</pre>
+<p>
+we may use the equivalent code:
+</p>
+<pre>
+ IMocksControl ctrl = createStrictControl();
+ IMyInterface mock = ctrl.createMock(IMyInterface.class);
+ ctrl.replay();
+ ctrl.verify();
+ ctrl.reset();
+</pre>
+<p>
+The IMocksControl allows to create more than one Mock Object, and so it is possible to check the order of method calls
+between mocks. As an example, we set up two mock objects for the interface <code>IMyInterface</code>, and we expect the calls
+<code>mock1.a()</code> and <code>mock2.a()</code> ordered, then an open number of calls to <code>mock1.c()</code>
+and <code>mock2.c()</code>, and finally <code>mock2.b()</code> and <code>mock1.b()</code>, in this order:
+</p>
+<pre>
+ IMocksControl ctrl = createStrictControl();
+ IMyInterface mock1 = ctrl.createMock(IMyInterface.class);
+ IMyInterface mock2 = ctrl.createMock(IMyInterface.class);
+
+ mock1.a();
+ mock2.a();
+
+ ctrl.checkOrder(false);
+
+ mock1.c();
+ expectLastCall().anyTimes();
+ mock2.c();
+ expectLastCall().anyTimes();
+
+ ctrl.checkOrder(true);
+
+ mock2.b();
+ mock1.b();
+
+ ctrl.replay();
+</pre>
+<h3>Naming Mock Objects</h3>
+<p>
+Mock Objects can be named at creation using
+<code>createMock(String name, Class<T> toMock)</code>,
+<code>createStrictMock(String name, Class<T> toMock)</code> or
+<code>createNiceMock(String name, Class<T> toMock)</code>.
+The names will be shown in exception failures.
+</p>
+<h3>Serializing Mocks</h3>
+<p>
+Mocks can be serialized at any time during their life. However, there are some obvious contraints:
+</p>
+<ul>
+<li>All used matchers should be serializable (all genuine EasyMock ones are)
+</li>
+<li>Recorded parameters should also be serializable
+</li>
+</ul>
+<h3>Multithreading</h3>
+<p>
+During recording, a mock is <b>not</b> thread-safe. So a giving mock (or mocks linked to the same <code>IMocksControl</code>)
+can only be recorded from a single thread. However, different mocks can be recorded simultaneously in different threads.
+</p>
+<p>
+During the replay phase, mocks are by default thread-safe. This can be change for a given mock if <code>makeThreadSafe(mock, false)</code>
+is called during the recording phase. This can prevent deadlocks in some rare situations.
+</p>
+<p>
+Finally, calling <code>checkIsUsedInOneThread(mock, true)</code> on a mock will make sure the mock is used in only one thread and
+throw an exception otherwise. This can be handy to make sure a thread-unsafe mocked object is used correctly.
+</p>
+<h3>EasyMockSupport</h3>
+<p>
+<code>EasyMockSupport</code> is a class that meant to be used as a helper or base class to your test cases. It will automatically registers all
+created mocks (or in fact all created controls) and to replay, reset or verify them in batch instead of explicitly. Here's a JUnit example:
+</p>
+<pre>
+public class SupportTest extends EasyMockSupport {
+
+ private Collaborator firstCollaborator;
+ private Collaborator secondCollaborator;
+ private ClassTested classUnderTest;
+
+ @Before
+ public void setup() {
+ classUnderTest = new ClassTested();
+ }
+
+ @Test
+ public void addDocument() {
+ // creation phase
+ firstCollaborator = createMock(Collaborator.class);
+ secondCollaborator = createMock(Collaborator.class);
+ classUnderTest.addListener(firstCollaborator);
+ classUnderTest.addListener(secondCollaborator);
+
+ // recording phase
+ firstCollaborator.documentAdded("New Document");
+ secondCollaborator.documentAdded("New Document");
+
+ replayAll(); // replay all mocks at once
+
+ // test
+ classUnderTest.addDocument("New Document", new byte[0]);
+
+ verifyAll(); // verify all mocks at once
+ }
+}
+</pre>
+<h3>Altering EasyMock default behavior</h3>
+<p>
+EasyMock provides a property mecanisim allowing to alter its behavior. It mainly aims
+at allowing to use a legacy behavior on a new version. Currently supported properties are:
+</p>
+<dl>
+<dt><code>easymock.notThreadSafeByDefault</code></dt>
+<dd>If true, a mock won't be thread-safe by default. Possible values are "true" or "false". Default is false</dd>
+<dt><code>easymock.enableThreadSafetyCheckByDefault</code></dt>
+<dd>If true, thread-safety check feature will be on by default. Possible values are "true" or "false". Default is false</dd>
+<dt><code>easymock.disableClassMocking</code></dt>
+<dd>Do not allow class mocking (only allow interface mocking). Possible values are "true" or "false". Default is false.</dd>
+</dl>
+<p>
+Properties can be set in three ways. Each step in the list can overwrite
+previous ones.
+</p>
+<ul>
+<li>In an <code>easymock.properties</code> file set in the classpath default package
+</li>
+<li>As a system property
+</li>
+<li>By calling <code>EasyMock.setEasyMockProperty</code>. Constants are available
+in the <code>EasyMock</code> class
+</li>
+</ul>
+<h3>Backward Compatibility</h3>
+<p>EasyMock 3 still has a Class Extension project (although deprecated) to
+allow an easier migration from EasyMock 2 to EasyMock 3. It is a source not a binary
+compatibility. So the code will need to be recompiled.
+</p>
+<p>EasyMock 2.1 introduced a callback feature that has been removed in EasyMock 2.2,
+as it was too complex. Since EasyMock 2.2, the <code>IAnswer</code> interface
+provides the functionality for callbacks.
+</p>
+<h3>OSGi</h3>
+<p>
+EasyMock jar can be used as an OSGi bundle. It exports <code>org.easymock</code>,
+<code>org.easymock.internal</code> and <code>org.easymock.internal.matchers</code>
+packages. However, to import the two latter, you need to specify the <code>poweruser</code>
+attribute at true (<code>poweruser=true</code>). These packages are meant to be
+used to extend EasyMock so they usually don't need to be imported.
+</p>
+<h3>Partial mocking</h3>
+<p>
+Sometimes you may need to mock only some methods of a class and keep
+the normal behavior of others. This usually happens when you want to
+test a method that calls some others in the same class. So you want to
+keep the normal behavior of the tested method and mock the others.
+</p>
+<p>
+In this case, the first thing to do is to consider a refactoring since
+most of the time this problem caused by a bad design. If it's not
+the case or if you can't do otherwise because of some development constraints,
+here's the solution.
+</p>
+<pre>
+ToMock mock = createMockBuilder(ToMock.class)
+ .addMockedMethod("mockedMethod").createMock();
+</pre>
+<p>In this case only the methods added with <code>addMockedMethod(s)</code> will be
+mocked (<code>mockedMethod()</code> in the example). The others will still
+behave as they used to. One exception: abstract methods are conveniently mocked by default.
+</p>
+<p><code>createMockBuilder</code> returns a <code>IMockBuilder</code> interface. It contains various methods to
+easily create a partial mock. Have a look at the javadoc.
+</p>
+<p>
+<b>Remark:</b> EasyMock provides a default behavior for Object's methods (<i>equals, hashCode, toString, finalize</i>).
+However, for a partial mock, if these methods are not mocked explicitly, they will have their normal behavior
+instead of EasyMock default's one.
+</p>
+<h3>Self testing</h3>
+<p>
+It is possible to create a mock by calling one of its constructor. This can be handy when a
+class method needs to be tested but the class other methods, mocked. For that you should do
+something like
+</p>
+<pre>
+ToMock mock = createMockBuilder(ToMock.class)
+ .withConstructor(1, 2, 3); // 1, 2, 3 are the constructor parameters
+</pre>
+<p>
+See the <code>ConstructorCalledMockTest</code> for an example.
+</p>
+<h3>Replace default class instantiator</h3>
+<p>
+For some reason (usually an unsupported JVM), it is possible that EasyMock isn't able to mock
+a class mock in your environment. Under the hood, class instantiation is implemented with a factory
+pattern. In case of failure, you can replace the default instantiator with:
+</p>
+<ul>
+<li>The good old <code>DefaultClassInstantiator</code> which works well with Serializable classes
+and otherwise tries to guess the best constructor and parameters to use.</li>
+<li>You own instantiator which only needs to implement <code>IClassInstantiator</code>.</li>
+</ul>
+<p>
+You set this new instantiator using <code>ClassInstantiatorFactory.setInstantiator()</code>.
+You can set back the default one with <code>setDefaultInstantiator()</code>.
+</p>
+<p>
+<b>Important:</b>
+The instantiator is kept statically so it will stick between your unit tests. Make sure you
+reset it if needed.
+</p>
+<h3>Serialize a class mock</h3>
+<p>
+A class mock can also be serialized. However, since it extends a serializable class, this class
+might have defined a special behavior using for instance <code>writeObject</code>. These methods
+will still be called when serializing the mock and might fail. The workaround is usually to call
+a constructor when creating the mock.
+</p>
+<p>
+Also, de-serializing the mock in a different class loader than the serialization might fail. It wasn't tested.
+</p>
+<h3>Class Mocking Limitations</h3>
+<ul>
+<li>To be coherent with interface mocking, EasyMock provides a built-in behavior
+for <code>equals()</code>, <code>toString()</code>, <code>hashCode()</code> and <code>finalize()</code>
+even for class mocking. It means that you cannot record your own behavior for
+these methods. This limitation is considered to be a feature
+that prevents you from having to care about these methods.
+</li>
+<li>Final methods cannot be mocked. If called, their normal code will be executed.
+</li>
+<li>Private methods cannot be mocked. If called, their normal code will be executed.
+During partial mocking, if your method under test is calling some private methods,
+you will need to test them as well since you cannot mock them.
+</li>
+<li>Class instantiation is performed using
+<a href="http://objenesis.googlecode.com/svn/docs/index.html">Objenesis</a>.
+Supported JVMs are listed
+<a href="http://code.google.com/p/objenesis/wiki/ListOfCurrentlySupportedVMs">here</a>.
+</li>
+</ul>
+
+<h2>
+EasyMock Development
+</h2>
+<p>
+EasyMock has been developed by Tammo Freese at OFFIS. It is maintained by Henri Tremblay
+since 2007. The development of EasyMock is hosted on <a href="http://sourceforge.net/projects/easymock/">SourceForge</a>
+to allow other developers and companies to contribute.
+</p>
+<p>
+Class mocking (previously known as EasyMock Class Extension) was initially developed
+by Joel Shellman, Chad Woolley and Henri Tremblay on the files section of Yahoo!Groups.
+</p>
+<p>
+Thanks to the people who gave feedback or provided patches, including
+Nascif Abousalh-Neto, Dave Astels, Francois Beausoleil, George Dinwiddie, Shane Duan,
+Wolfgang Frech, Steve Freeman, Oren Gross, John D. Heintz, Dale King, Brian Knorr,
+Dierk Koenig, Chris Kreussling, Robert Leftwich, Patrick Lightbody, Johannes Link,
+Rex Madden, David McIntosh, Karsten Menne, Bill Michell,
+Stephan Mikaty, Ivan Moore, Ilja Preuss, Justin Sampson, Markus Schmidlin, Richard Scott,
+Joel Shellman, Jiří Mareš, Alexandre de Pellegrin
+Shaun Smith, Marco Struck, Ralf Stuckert, Victor Szathmary, Bill Uetrecht,
+Frank Westphal, Chad Woolley, Bernd Worsch,
+Rodrigo Damazio, Bruno Fonseca, Ben Hutchison and numerous others.
+</p>
+<p>
+Please check the <a href="http://www.easymock.org">EasyMock home page</a> for new versions,
+and send bug reports and suggestions to the
+<a href="mailto:easymock@yahoogroups.com?subject=EasyMock ${project.version} feedback">EasyMock Yahoo!Group</a>.
+If you would like to subscribe to the EasyMock Yahoo!Group, send a message to
+<a href="mailto:easymock-subscribe@yahoogroups.com">easymock-subscribe@yahoogroups.com</a>.
+</p>
+<h3>
+EasyMock Version 3.1 (2011-11-10) Release Notes
+</h3>
+<p>
+New in version 3.1:
+</p>
+<ul>
+<li>NoClassDefFoundError on calling EasyMock.replay/reset/verify on an interface mock without cglib in the classpath (EASYMOCK-40)
+</li>
+<li>Can compile in Java 7 (capture methods for primitive types are renamed and deprecated) (EASYMOCK-100)
+</li>
+<li>Fix memory leak in cglib callback registration process (EASYMOCK-89)
+</li>
+<li>Ignore calls to finalize on a mock (EASYMOCK-21)
+</li>
+<li>MockBuilder.addMockedMethod should fail for final methods (EASYMOCK-44)
+</li>
+<li>Bridge method should not be considered by MockBuilder.addMockedMethod (EASYMOCK-90)
+</li>
+<li>Perform a smoke test with PowerMock to make sure it is still working (EASYMOCK-88)
+</li>
+<li>Add the class or interface name in error message for each invocation (EASYMOCK-104)
+</li>
+</ul>
+<p>
+New in version 3.0:
+</p>
+<ul>
+<li>EasyMock CE is now merged into EasyMock (2325762)
+</li>
+<li>Add "boolean capture(...)" for completude (but I don't think it's useful)
+</li>
+<li>Can't answer by delegating to a protected method (2891256)
+</li>
+<li>Failure during recording phase can impact following tests (2914683)
+</li>
+<li>Return a specific error when null is recorded as return value on a method returning a primitive type (2936175)
+</li>
+<li>Can disable class mocking with <code>EasyMock.DISABLE_CLASS_MOCKING</code>
+</li>
+<li>Remove deprecated classes from EasyMock 1
+</li>
+<li>Should not fail on a mock not having a <code>toString</code> method (2937916)
+</li>
+<li>Improved error message when matchers are mixed with raw params during method recording (2860190)
+</li>
+<li>Check there are still results available in a recorded behaviour before trying to match with it (2940400)
+</li>
+<li>Allow to mock classes from an Eclipse plugin (2994002)
+</li>
+<li>Add <code>isNull(Class<T>)</code>, <code>notNull(Class<T>)</code> and <code>anyObject(Class<T>)</code> for easier generic handling (2958636)
+</li>
+</ul>
+<p>
+For older release notes, see <a href="Documentation.html">EasyMock 2 and EasyMock 2 Class Extension documentations</a>.
+</p>
+</div>
+</body>
+</html>
diff --git a/common/easymock-tools/Documentation_fr.html b/common/easymock-tools/Documentation_fr.html
new file mode 100644
index 0000000..e441bb2
--- /dev/null
+++ b/common/easymock-tools/Documentation_fr.html
@@ -0,0 +1,1244 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<title>EasyMock 3.1 Readme</title>
+<link rel="stylesheet" href="easymock.css" />
+</head>
+<body><div class="bodywidth">
+
+<h2>EasyMock 3.1 Readme</h2>
+
+<p>Documentation de la version 3.1 (2011-11-10)<br />
+© 2001-2011 <a href="http://www.offis.de">OFFIS</a>, <a href="http://tammofreese.de">Tammo Freese</a>, <a href="http://www.ossia-conseil.com/blog/henri/">Henri Tremblay</a>.
+</p>
+<p><i>Documentation traduite originellement de l'anglais par <a href="http://alexdp.free.fr">Alexandre de Pellegrin</a>.
+Maintenue par Henri Tremblay.</i>
+</p>
+<p>
+EasyMock est une librairie fournissant un moyen simple d'utiliser des Mock Objects pour
+une interface ou classe donnée. EasyMock est disponible sous <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">license Apache 2</a>.
+</p>
+<p>
+Les Mock Objects simulent le comportement du code
+métier et sont capables de vérifier s'il est utilisé
+comme prévu.
+Les classes métier peuvent être testées
+de façon isolée en simulant leurs objets
+liés par des Mock Objects.
+</p>
+<p>
+Écrire et maintenir des Mock Objects est souvent une
+tâche pénible et source d'erreurs. EasyMock génère les
+Mock Objects dynamiquement - pas besoin de les écrire, pas
+de code généré!
+</p>
+<h3>
+Avantages d'EasyMock
+</h3>
+<ul>
+<li>Pas d'écriture manuelle des Mock Objects.
+</li>
+<li>Supporte le refactoring sur les Mock Objects : le code de test ne sera pas cassé au runtime lors du renommage de
+ méthodes ou de la réorganisations de paramètres
+</li>
+<li>Supporte les valeurs de retour et les exceptions.
+</li>
+<li>Supporte la vérification de l'ordre d'appel des méthodes, sur un ou plusieurs Mock Objects.
+</li>
+</ul>
+<h2>
+Environnement Requis
+</h2>
+<ul>
+<li>EasyMock 2 fonctionne uniquement avec Java 1.5.0 ou supérieur.</li>
+<li>cglib (2.2) and Objenesis (1.2) doivent être présent dans le classpath pour faire du mocking de classes</li>
+</ul>
+<h2>
+Installation
+</h2>
+<h3>Avec Maven</h3>
+EasyMock est disponible dans le référentiel central de Maven. Ajoutez la dépendance
+suivante à votre pom.xml:
+<pre>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+</pre>
+Vous pouvez, bien évidemment, n'importe quel outil de gestion de dépendances compatible
+avec le référentiel Maven.
+<h3>Manuellement</h3>
+<ul>
+<li>Décompressez le fichier zip d'EasyMock (<code>easymock-3.1.zip</code>).</li>
+<li>Allez dans le répertoire <code>easymock-3.1</code>.</li>
+<li>Ajoutez le jar d'EasyMock (<code>easymock.jar</code>) à votre classpath.</li>
+<li>Pour pouvoir mocker des classes, ajoutez aussi <a href="http://www.objenesis.org">Objenesis</a> et <a href="http://cglib.sourceforge.net/">Cglib</a> à votre classpath.</li>
+<li>Les tests sont dans <code>easymock-3.1-tests.jar</code> et peuvent être lancés à l'aide d'un JUnit TestRunner
+en ayant JUnit 4.7, EasyMock, cglib et Objenesis dans votre classpath.</li>
+<li>Le code source d'EasyMock est situé dans <code>easymock-3.1-sources.jar</code>.</li>
+</ul>
+<h2>
+Utilisation
+</h2>
+<p>
+La plupart des éléments d'un logiciel ne fonctionnent
+pas de manière isolée mais en collaboration avec
+d'autres éléments (objets liés) pour effectuer leur
+tâche.
+Dans beaucoup de cas, nous ne nous soucions pas d'utiliser des objets
+liés pour nos tests unitaires du moment
+que nous avons confiance en eux. Si
+ce n'est pas le cas, les Mock Objects peuvent nous aider à
+tester unitairement de façon isolée. Les Mock Objects
+remplacent les objets liés de l'élément testé.
+</p>
+<p>
+Les exemples suivants utilisent l'interface <code>Collaborator</code>:
+</p>
+<pre>
+package org.easymock.samples;
+
+public interface Collaborator {
+ void documentAdded(String title);
+ void documentChanged(String title);
+ void documentRemoved(String title);
+ byte voteForRemoval(String title);
+ byte[] voteForRemovals(String[] title);
+}
+</pre>
+<p>
+Les implémentations de cette interface sont des
+objets liés (des listeners dans ce cas) à la classe nommée <code>ClassUnderTest</code>:
+</p>
+<pre>
+public class ClassUnderTest {
+ // ...
+ public void addListener(Collaborator listener) {
+ // ...
+ }
+ public void addDocument(String title, byte[] document) {
+ // ...
+ }
+ public boolean removeDocument(String title) {
+ // ...
+ }
+ public boolean removeDocuments(String[] titles) {
+ // ...
+ }
+}
+</pre>
+<p>
+Le code de la classe et de l'interface est disponible dans
+le package <code>org.easymock.samples</code> dans <code>easymock-3.1-samples.jar</code>
+inclue dans la livraison d'EasyMock.
+</p>
+<p>
+Les exemples qui suivent supposent que vous êtes familier avec le framework de test JUnit.
+Bien que les tests montrés ici utilisent JUnit 4, vous pouvez également utiliser JUnit 3 ou TestNG.
+</p>
+<h3>
+Votre premier Mock Object
+</h3>
+<p>
+Nous allons maintenant construire un cas de test et jouer avec pour
+comprendre les fonctionnalités du package EasyMock. Le
+fichier <code>easymock-3.1-samples.jar</code> contient une version modifiée de ce test.
+Notre premier test devra vérifier que la suppression d'un document non existant <strong>ne doit pas</strong>
+provoquer la notification de l'objet lié. Voici le test dans la définition du Mock Object:
+</p>
+<pre>
+package org.easymock.samples;
+
+import org.junit.*;
+
+public class ExampleTest {
+
+ private ClassUnderTest classUnderTest;
+ private Collaborator mock;
+
+ @Before
+ public void setUp() {
+ classUnderTest = new ClassUnderTest();
+ classUnderTest.addListener(mock);
+ }
+
+ @Test
+ public void testRemoveNonExistingDocument() {
+ // This call should not lead to any notification
+ // of the Mock Object:
+ classUnderTest.removeDocument("Does not exist");
+ }
+}
+</pre>
+<p>
+Pour beaucoup de tests utilisant EasyMock, nous avons
+uniquement besoin de l'import statique des méthodes de la classe
+<code>org.easymock.EasyMock</code>.
+Cette classe est la seule non interne et non dépréciée d'EasyMock 2.
+</p>
+<pre>
+import static org.easymock.EasyMock.*;
+import org.junit.*;
+
+public class ExampleTest {
+
+ private ClassUnderTest classUnderTest;
+ private Collaborator mock;
+
+}
+</pre>
+<p>
+Pour obtenir un Mock Object, il faut:
+</p>
+<ol>
+<li>créer un Mock Object pour l'interface à simuler,
+</li>
+<li>enregistrer le comportement attendu, puis
+</li>
+<li>basculer le Mock Object à l'état 'replay'.
+</li>
+</ol>
+<p>
+Voici le premier exemple:
+</p>
+<pre>
+ @Before
+ public void setUp() {
+ mock = createMock(Collaborator.class); // 1
+ classUnderTest = new ClassUnderTest();
+ classUnderTest.addListener(mock);
+ }
+
+ @Test
+ public void testRemoveNonExistingDocument() {
+ // 2 (we do not expect anything)
+ replay(mock); // 3
+ classUnderTest.removeDocument("Does not exist");
+ }
+</pre>
+<p>
+Après activation à l'étape 3, <code>mock</code>
+est un Mock Object de l'interface <code>Collaborator</code>
+qui n'attend aucun appel. Cela signifie que si nous changeons notre <code>ClassUnderTest</code>
+pour appeler n'importe quelle méthode de l'interface, le Mock Object lèvera
+une <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentRemoved("Does not exist"):
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentRemoved(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentRemoved(ClassUnderTest.java:74)
+ at org.easymock.samples.ClassUnderTest.removeDocument(ClassUnderTest.java:33)
+ at org.easymock.samples.ExampleTest.testRemoveNonExistingDocument(ExampleTest.java:24)
+ ...
+</pre>
+
+<h3>
+ Ajouter un comportement
+</h3>
+<p>
+Écrivons un second test. Si un document est ajouté à
+la classe testée, nous nous attendons à un appel à
+<code>mock.documentAdded()</code>
+sur le Mock Object avec le titre du document en argument:
+</p>
+<pre>
+ @Test
+ public void testAddDocument() {
+ mock.documentAdded("New Document"); // 2
+ replay(mock); // 3
+ classUnderTest.addDocument("New Document", new byte[0]);
+ }
+</pre>
+<p>
+Aussi, dans l'étape d'enregistrement (avant d'appeler <code>replay</code>),
+le Mock Object ne se comporte pas comme<em></em> un Mock Object mais enregistre
+les appels de méthode. Après l'appel à <code>replay</code>,
+il se comporte comme un Mock Object, vérifiant que les appels
+de méthode attendus ont bien lieu.
+</p>
+<p>
+Si <code>classUnderTest.addDocument("New Document", new byte[0])</code>
+appelle la méthode attendue avec un mauvais argument, le
+Mock Object lèvera une <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentAdded("Wrong title"):
+ documentAdded("New Document"): expected: 1, actual: 0
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentAdded(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentAdded(ClassUnderTest.java:61)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:28)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:30)
+ ...
+</pre>
+<p>
+Tous les appels attendus n'ayant pas eu lieu sont montrés, ainsi
+que tous les appels faits alors qu'ils étaient non attendus
+(aucun dans notre cas). Si l'appel à la méthode est
+effectué trop de fois, le Mock Object le signale
+également:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentAdded("New Document"):
+ documentAdded("New Document"): expected: 1, actual: 2
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentAdded(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentAdded(ClassUnderTest.java:62)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:29)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:30)
+ ...
+</pre>
+<h3>
+Vérifier le comportement
+</h3>
+<p>
+Il y a un type d'erreur dont nous ne nous sommes pas
+préoccupés jusqu'à présent: si nous décrivons un
+comportement, nous voulons vérifier qu'il est bien respecté.
+Le test qui suit passe si une méthode du Mock Object est appelée.
+Pour vérifier cela, nous devons appeler <code>verify(mock)</code>:
+</p>
+<pre>
+ @Test
+ public void testAddDocument() {
+ mock.documentAdded("New Document"); // 2
+ replay(mock); // 3
+ classUnderTest.addDocument("New Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+Si la méthode du Mock Object n'est pas appelée,
+l'exception suivante sera levée :
+</p>
+<pre>
+java.lang.AssertionError:
+ Expectation failure on verify:
+ documentAdded("New Document"): expected: 1, actual: 0
+ at org.easymock.internal.MocksControl.verify(MocksControl.java:70)
+ at org.easymock.EasyMock.verify(EasyMock.java:536)
+ at org.easymock.samples.ExampleTest.testAddDocument(ExampleTest.java:31)
+ ...
+</pre>
+<p>
+Le message de l'exception liste tous les appels attendus qui n'ont pas eu lieu.
+</p>
+<h3>
+Attendre un nombre explicite d'appels
+</h3>
+<p>
+Jusqu'à maintenant, nos tests ont été faits uniquement
+sur un seul appel de méthode. Le test suivant
+vérifiera que l'ajout d'un document déjà existant
+déclenche l'appel à <code>mock.documentChanged()</code>
+avec l'argument approprié. Pour en être certain, nous
+vérifions cela trois fois (après tout, c'est un exemple
+;-)):
+</p>
+<pre>
+ @Test
+ public void testAddAndChangeDocument() {
+ mock.documentAdded("Document");
+ mock.documentChanged("Document");
+ mock.documentChanged("Document");
+ mock.documentChanged("Document");
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+Afin d'éviter la répétition de <code>mock.documentChanged("Document")</code>,
+EasyMock fournit un raccourci. Nous pouvons spécifier le nombre d'appel avec la méthode
+<code>times(int times)</code> sur l'objet retourné par <code>expectLastCall()</code>.
+Le code ressemble alors à cela:
+</p>
+<pre>
+ @Test
+ public void testAddAndChangeDocument() {
+ mock.documentAdded("Document");
+ mock.documentChanged("Document");
+ expectLastCall().times(3);
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ classUnderTest.addDocument("Document", new byte[0]);
+ verify(mock);
+ }
+</pre>
+<p>
+Si la méthode est appelée un trop grand nombre de fois,
+une exception sera levée nous indiquant que la méthode a
+été appelée trop de fois.
+L'erreur est levée immédiatement après le premier
+appel dépassant la limite:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call documentChanged("Document"):
+ documentChanged("Document"): expected: 3, actual: 4
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.documentChanged(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.notifyListenersDocumentChanged(ClassUnderTest.java:67)
+ at org.easymock.samples.ClassUnderTest.addDocument(ClassUnderTest.java:26)
+ at org.easymock.samples.ExampleTest.testAddAndChangeDocument(ExampleTest.java:43)
+ ...
+</pre>
+<p>
+S'il y a trop peu d'appels, <code>verify(mock)</code>
+lève une <code>AssertionError</code>:
+</p>
+<pre>
+java.lang.AssertionError:
+ Expectation failure on verify:
+ documentChanged("Document"): expected: 3, actual: 2
+ at org.easymock.internal.MocksControl.verify(MocksControl.java:70)
+ at org.easymock.EasyMock.verify(EasyMock.java:536)
+ at org.easymock.samples.ExampleTest.testAddAndChangeDocument(ExampleTest.java:43)
+ ...
+</pre>
+<h3>
+Spécifier des valeurs de retour
+</h3>
+<p>
+Pour spécifier des valeurs de retour, nous encapsulons l'appel attendu dans
+<code>expect(T value)</code> et spécifions la valeur de retour avec la
+méthode <code>andReturn(Object returnValue)</code> sur l'objet retourné par
+<code>expect(T value)</code>.
+</p>
+<p>
+Prenons par exemple la vérification du workflow lors de la suppression d'un document.
+Si <code>ClassUnderTest</code> fait un appel pour supprimer un document,
+il doit demander aux objets liés de voter pour cette suppression
+par appel à <code>byte voteForRemoval(String title)</code>.
+Une réponse positive approuve la suppression. Si la somme de
+toutes les réponses est positive, alors le document est
+supprimé et l'appel à <code>documentRemoved(String title)</code>
+est effectué sur les objets liés:
+</p>
+<pre>
+ @Test
+ public void testVoteForRemoval() {
+ mock.documentAdded("Document"); // expect document addition
+ // expect to be asked to vote for document removal, and vote for it
+ expect(mock.voteForRemoval("Document")).andReturn((byte) 42);
+ mock.documentRemoved("Document"); // expect document removal
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ assertTrue(classUnderTest.removeDocument("Document"));
+ verify(mock);
+ }
+
+ @Test
+ public void testVoteAgainstRemoval() {
+ mock.documentAdded("Document"); // expect document addition
+ // expect to be asked to vote for document removal, and vote against it
+ expect(mock.voteForRemoval("Document")).andReturn((byte) -42);
+ replay(mock);
+ classUnderTest.addDocument("Document", new byte[0]);
+ assertFalse(classUnderTest.removeDocument("Document"));
+ verify(mock);
+ }
+</pre>
+<p>
+Le type de la valeur de retour est vérifié à la
+compilation. Par exemple, le code suivant ne compilera pas du fait que
+le type fourni ne correspond au type retourné par la
+méthode:
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn("wrong type");
+</pre>
+<p>
+Au lieu d'appeler <code>expect(T value)</code> pour
+récupérer l'objet auquel affecter une valeur de retour,
+nous pouvons aussi utiliser l'objet retourné par <code>expectLastCall()</code>.
+Ainsi, au lieu de
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn((byte) 42);
+</pre>
+<p>
+nous pouvons écrire
+</p>
+<pre>
+ mock.voteForRemoval("Document");
+ expectLastCall().andReturn((byte) 42);
+</pre>
+<p>
+Ce type d'écriture doit uniquement être utilisé
+si la ligne est trop longue car il n'inclut pas la vérification
+du type à la compilation.
+</p>
+<h3>
+Travailler avec les exceptions
+</h3>
+<p>
+Afin de spécifier les exceptions (plus précisément:
+les Throwables) devant être levées, l'objet
+retourné par <code>expectLastCall()</code> et <code>expect(T value)</code>
+fournit la méthode <code>andThrow(Throwable throwable)</code>.
+Cette méthode doit être appelée durant l'étape
+d'enregistrement après l'appel au Mock Object pour lequel le <code>Throwable</code>
+doit être levé.
+</p>
+<p>
+Les exception non "checkées" (comme <code>RuntimeException</code>,
+<code>Error</code> ainsi que toutes leurs sous classes) peuvent
+être levées de n'importe quelle méthode. Les
+exceptions "checkées" ne doivent être levées que
+pour méthodes où cela est prévu.
+</p>
+<h3>
+Créer des valeurs de retour ou des exceptions
+</h3>
+<p>
+Parfois, nous voulons que notre Mock Object retourne une valeur ou
+lève une exception créée au moment de l'appel.
+Depuis la version 2.2 d'EasyMock, l'objet retourné
+par <code>expectLastCall()</code> et <code>expect(T value)</code> fournit la méthode
+<code>andAnswer(IAnswer answer)</code> permettant de spécifier une implémentation
+de l'interface <code>IAnswer</code> utilisée pour créer
+une valeur de retour ou une exception.
+</p>
+<p>
+Au sein d'<code>IAnswer</code>, les arguments passés lors de l'appel au mock sont
+disponibles via <code>EasyMock.getCurrentArguments()</code>.
+Si vous utilisez cela, les refactorings du type réorganisation
+de l'ordre des arguments briseront vos tests. Vous êtes prévenu.
+</p>
+<p>
+Une alternative à <code>IAnswer</code> sont les méthodes <code>andDelegateTo</code> et
+<code>andStubDelegateTo</code>. Elles permettent de déléguer un appel à une
+implémentation concrète de l'interface "mockées" et qui fournira la valeur de retour.
+L'avantage est que les paramètres normalement récupéré avec <code>EasyMock.getCurrentArguments()</code>
+pour <code>IAnswer</code> sont maintenant passés à la méthode de l'implémentation concrète.
+Ça supporte donc le refactoring. Le désavantage est qu'il faut fournir une implémentation...
+ce qui resemble un peu à faire un mock à la main. Ce que vous tentez d'éviter en utilisant
+EasyMock. Il peut aussi être pénible d'implémenter l'interface si celle-ci à beaucoup de méthodes. Finalement,
+le type de l'implémentation ne peut être vérifié statiquement par rapport au type du Mock Object.
+Si pour une quelconque raison, la class concrète n'implémente plus la méthode sur laquelle est
+délégué l'appel, vous aurez une exception lors de la phase de "replay". Ce cas devrait toutefois
+être assez rare.
+</p>
+<p>
+Pour bien comprendre les deux options, voici un exemple:
+</p>
+<pre>
+ List<String> l = createMock(List.class);
+
+ // andAnswer style
+ expect(l.remove(10)).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return getCurrentArguments()[0].toString();
+ }
+ });
+
+ // andDelegateTo style
+ expect(l.remove(10)).andDelegateTo(new ArrayList<String>() {
+ @Override
+ public String remove(int index) {
+ return Integer.toString(index);
+ }
+ });
+</pre>
+<h3>
+Changer de comportement sur le même appel de méthode
+</h3>
+<p>
+Il est également possible de spécifier un changement de comportement pour une méthode.
+Les méthodes <code>times</code>, <code>andReturn</code> et <code>andThrow</code>
+peuvent être chaînées. Comme exemple,
+nous définissons <code>voteForRemoval("Document")</code> pour
+</p>
+<ul>
+<li>retourner 42 pour les trois premiers appels,
+</li>
+<li>lever une <code>RuntimeException</code> sur le quatrième appel,
+</li>
+<li>renvoyer -42 une fois.
+</li>
+</ul>
+<pre>
+ expect(mock.voteForRemoval("Document"))
+ .andReturn((byte) 42).times(3)
+ .andThrow(new RuntimeException(), 4)
+ .andReturn((byte) -42);
+</pre>
+<h3>
+Être plus permissif sur le nombre d'appels
+</h3>
+<p>
+Afin d'être plus permissif sur le nombre d'appels attendus,
+des méthodes additionnelles peuvent être
+utilisées à la place de <code>times(int count)</code>:
+</p>
+<dl>
+<dt><code>times(int min, int max)</code></dt>
+<dd>pour attendre entre <code>min</code> and <code>max</code> appels,</dd>
+<dt><code>atLeastOnce()</code></dt>
+<dd>pour attendre au moins un appel, et</dd>
+<dt><code>anyTimes()</code></dt>
+<dd>pour attendre une quantité non définie d'appels.</dd>
+</dl>
+<p>
+Si aucun nombre d'appels n'est explicitement défini,
+alors seul un appel est attendu. Pour le définir explicitement,
+vous pouvez utiliser <code>once()</code> ou <code>times(1)</code>.
+</p>
+<h3>
+Mocks stricts
+</h3>
+<p>
+Sur un Mock Object retourné par <code>EasyMock.createMock()</code>,
+l'ordre d'appel des méthodes n'est pas vérifié.
+Si vous souhaitez avoir un Mock Object 'strict' vérifiant cet ordre,
+utilisez <code>EasyMock.create<i>Strict</i>Mock()</code>.</p>
+<p>
+Lorsqu'un appel inattendu à une méthode est fait sur
+un Mock Object 'strict', le message de l'exception contient les appels
+de méthode attendus à ce moment, suivi du premier appel en
+conflit. <code>verify(mock)</code> montre tous les appels de méthode manqués.
+</p>
+<h3>
+Activer/Désactiver la vérification de l'ordre d'appel des méthodes
+</h3>
+<p>
+Il est parfois nécessaire qu'un Mock Object vérifie
+l'ordre d'appel sur certains appels uniquement. Pendant la phase
+d'enregistrement, vous pouvez activer la vérification de l'ordre
+d'appel en utilisant <code>checkOrder(mock, true)</code> et la
+désactiver en utilisant <code>checkOrder(mock, false)</code>.
+</p>
+<p>
+Il y a deux différences entre un Mock Object 'strict' et un Mock Object 'normal':
+</p>
+<ol>
+ <li> Un mock 'strict' a la vérification de l'ordre d'appel activé à la création. </li>
+ <li> Un mock 'strict' a la vérification de l'ordre d'appel activé après un reset (voir <em>Réutilisation d'un Mock Object</em>). </li>
+</ol>
+<h3>
+Définir des comparateurs d'arguments pour plus de souplesse
+</h3>
+<p>
+Pour vérifier la correspondance à un appel de méthode prévu sur un Mock Object,
+les arguments<code> de type Object</code> sont comparés, par défaut, avec
+<code>equals()</code>. Cela peut introduire des problèmes. Considérons l'exemple suivant:
+</p>
+<pre>
+String[] documents = new String[] { "Document 1", "Document 2" };
+expect(mock.voteForRemovals(documents)).andReturn(42);
+</pre>
+<p>
+Si la méthode est appelée avec un autre tableau ayant le même contenu,
+cela provoque une exception du fait que <code>equals()</code> compare l'identité
+des objets pour les tableaux:
+</p>
+<pre>
+java.lang.AssertionError:
+ Unexpected method call voteForRemovals([Ljava.lang.String;@9a029e):
+ voteForRemovals([Ljava.lang.String;@2db19d): expected: 1, actual: 0
+ documentRemoved("Document 1"): expected: 1, actual: 0
+ documentRemoved("Document 2"): expected: 1, actual: 0
+ at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:29)
+ at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
+ at $Proxy0.voteForRemovals(Unknown Source)
+ at org.easymock.samples.ClassUnderTest.listenersAllowRemovals(ClassUnderTest.java:88)
+ at org.easymock.samples.ClassUnderTest.removeDocuments(ClassUnderTest.java:48)
+ at org.easymock.samples.ExampleTest.testVoteForRemovals(ExampleTest.java:83)
+ ...
+</pre>
+<p>
+Pour spécifier que seule l'égalité de tableau
+est nécessaire pour cet appel, utilisez la méthode
+<code>aryEq</code>, importée statiquement de la classe <code>EasyMock</code>:
+</p>
+<pre>
+String[] documents = new String[] { "Document 1", "Document 2" };
+expect(mock.voteForRemovals(aryEq(documents))).andReturn(42);
+</pre>
+<p>
+Si vous souhaitez utiliser les comparateurs lors d'un appel, vous devez
+en utiliser pour chaque argument de la méthode appelée.
+</p>
+<p>
+Voici quelques comparateurs prédéfinis disponible:
+</p>
+<dl>
+
+<dt><code>eq(X value)</code></dt>
+<dd>Vérifie que la valeur reçue égale la valeur attendue. Disponible pour tous les types primitifs et objets.</dd>
+
+<dt><code>anyBoolean()</code>, <code>anyByte()</code>, <code>anyChar()</code>, <code>anyDouble()</code>, <code>anyFloat()</code>, <code>anyInt()</code>, <code>anyLong()</code>, <code>anyObject()</code>, <code>anyObject(Class clazz)</code>, <code>anyShort()</code></dt>
+<dd>Laisse passer n'importe quelle valeur. Disponible pour tous les types primitifs et objets.</dd>
+
+<dt><code>eq(X value, X delta)</code></dt>
+<dd>Vérifie que la valeur reçue égale la valeur attendue, plus ou moins un delta. Disponible pour les <code>float</code> et <code>double</code>.</dd>
+
+<dt><code>aryEq(X value)</code></dt>
+<dd>Vérifie que la valeur reçue égale la valeur attendue en s'appuyant sur <code>Arrays.equals()</code>. Disponible pour les tableaux d'objets et de types primitifs.</dd>
+
+<dt><code>isNull()</code>, <code>isNull(Class clazz)</code></dt>
+<dd>Vérifie que la valeur reçue est nulle. Disponible pour les objets.</dd>
+
+<dt><code>notNull()</code>, <code>notNull(Class clazz)</code></dt>
+<dd>Vérifie que la valeur reçue n'est pas nulle. Disponible pour les objets.</dd>
+
+<dt><code>same(X value)</code></dt>
+<dd>Vérifie que la valeur reçue est la même que la value attendue. Disponible pour les objets.</dd>
+
+<dt><code>isA(Class clazz)</code></dt>
+<dd>Vérifie que la valeur reçue est une instance de clazz ou d'une classe hérite ou implémente clazz. Disponible pour les objets.</dd>
+
+<dt><code>lt(X value)</code>, <code>leq(X value)</code>, <code>geq(X value)</code>, <code>gt(X value)</code></dt>
+<dd>Vérifie que la valeur reçue est inférieure/inférieure ou égale/supérieure
+ou égale/supérieure à la valeur attendue. Disponible pour tous les types primitifs numériques et les implémentations de <code>Comparable</code>.</dd>
+
+<dt><code>startsWith(String prefix), contains(String substring), endsWith(String suffix)</code></dt>
+<dd>Vérifie que la valeur reçue commence par/contient/se termine par la valeur attendue. Disponible pour les <code>String</code>s.</dd>
+
+<dt><code>matches(String regex), find(String regex)</code></dt>
+<dd>Vérifie que la valeur reçue/une sous-chaîne de la valeur reçue correspond à l'expression ré. Disponible pour les <code>String</code>s.</dd>
+
+<dt><code>and(X first, X second)</code></dt>
+<dd>Est valide si les résultats des deux comparateurs utilisés en <code>first</code> et <code>second</code> sont vérifiés. Disponible pour tous les types primitifs et objets.</dd>
+
+<dt><code>or(X first, X second)</code></dt>
+<dd>Est valide si l'un des résultats des deux comparateurs utilisés en <code>first</code> et <code>second</code> est vérifié. Disponible pour tous les types primitifs et objets.</dd>
+
+<dt><code>not(X value)</code></dt>
+<dd>Est valide si le résultat du comparateur utilisé dans <code>value</code> est négatif.</dd>
+
+<dt><code>cmpEq(X value)</code></dt>
+<dd>Vérifie que la valeur reçue égale la valeur attendue du point de vue de <code>Comparable.compareTo(X o)</code>. Disponible pour tous les types primitifs numériques et les implémentations de <code>Comparable</code>.</dd>
+
+<dt><code>cmp(X value, Comparator<X> comparator, LogicalOperator operator)</code></dt>
+<dd>Vérifie que <code>comparator.compare(reçue, value) operator 0</code> où <code>operator</code> est <,<=,>,>= ou ==.</dd>
+
+<dt><code>capture(Capture<T> capture)</code>, <code>captureXXX(Capture<T> capture)</code></dt>
+<dd>Laisse passer n'importe quelle valeur mais la capture dans le paramètre <code>Capture</code> pour un usage ultérieurs. Vous pouvez utiliser <code>and(someMatcher(...), capture(c))</code> pour
+capturer le paramètre d'un appel de méthode en particulier. Vous pouvez aussi spécifier le <code>CaptureType</code> pour indiquer à l'objet
+<code>Capture</code> de conserver le premier (<code>FIRST</code>), le dernier (<code>LAST</code>), tous (<code>ALL</code>) ou aucun (<code>NONE</code>) des objets capturés</dd>
+
+</dl>
+
+<h3>
+Définir son propre comparateur d'arguments
+</h3>
+<p>
+Il peut être intéressant de définir son propre
+comparateur d'argument. Prenons un comparateur dont le rôle
+serait de vérifier une exception par rapport à son
+type et message. Il pourrait être utilisé de la façon suivante:
+</p>
+<pre>
+ IllegalStateException e = new IllegalStateException("Operation not allowed.")
+ expect(mock.logThrowable(eqException(e))).andReturn(true);
+</pre>
+<p>
+Deux étapes sont nécessaires pour réaliser cela: le nouveau comparateur
+doit être défini et la méthode statique <code>eqException</code>
+doit être déclarée.
+</p>
+<p>
+Pour définir le nouveau comparateur d'argument, nous implémentons l'interface <code>org.easymock.IArgumentMatcher</code>.
+Cette interface contient deux méthodes: <code>matches(Object actual)</code>, vérifiant
+que l'argument reçu est bien celui attendu, et <code>appendTo(StringBuffer buffer)</code>,
+ajoutant au StringBuffer une chaîne de caractères représentative du comparateur d'argument.
+L'implémentation est la suivante :
+</p>
+<pre>
+import org.easymock.IArgumentMatcher;
+
+public class ThrowableEquals implements IArgumentMatcher {
+ private Throwable expected;
+
+ public ThrowableEquals(Throwable expected) {
+ this.expected = expected;
+ }
+
+ public boolean matches(Object actual) {
+ if (!(actual instanceof Throwable)) {
+ return false;
+ }
+ String actualMessage = ((Throwable) actual).getMessage();
+ return expected.getClass().equals(actual.getClass())
+ && expected.getMessage().equals(actualMessage);
+ }
+
+ public void appendTo(StringBuffer buffer) {
+ buffer.append("eqException(");
+ buffer.append(expected.getClass().getName());
+ buffer.append(" with message \"");
+ buffer.append(expected.getMessage());
+ buffer.append("\"")");
+
+ }
+}
+</pre>
+<p>
+La méthode <code>eqException</code> doit instancier le
+comparateur d'argument avec l'objet Throwable donné, le fournir
+à EasyMock via la méthode statique <code>reportMatcher(IArgumentMatcher matcher)</code>
+et retourner une valeur afin d'être utilisée au sein de l'appel à la méthode mockée
+(typiquement <code>0</code>, <code>null</code> ou <code>false</code>). Une première tentative ressemblerait à ceci:
+</p>
+<pre>
+public static Throwable eqException(Throwable in) {
+ EasyMock.reportMatcher(new ThrowableEquals(in));
+ return null;
+}
+</pre>
+<p>
+Cependant, cela ne fonctionnerait que si la méthode <code>logThrowable</code>
+de l'exemple acceptait <code>Throwable</code>s et quelque chose de plus spécifique du style de <code>RuntimeException</code>.
+Dans ce dernier cas, le code de notre exemple ne compilerait pas:
+</p>
+<pre>
+ IllegalStateException e = new IllegalStateException("Operation not allowed.")
+ expect(mock.logThrowable(eqException(e))).andReturn(true);
+</pre>
+<p>
+Java 5.0 à la rescousse: Au lieu de définir <code>eqException</code>
+avec un <code>Throwable</code> en paramètre, nous utilisons un type générique
+qui hérite de <code>Throwable</code>:
+</p>
+<pre>
+public static <T extends Throwable> T eqException(T in) {
+ reportMatcher(new ThrowableEquals(in));
+ return null;
+}
+</pre>
+<h3>
+Réutilisation d'un Mock Object
+</h3>
+<p>
+Les Mock Objects peuvent être réinitialisés avec <code>reset(mock)</code>.
+</p>
+<p>
+Au besoin, un Mock Object peut aussi être converti d'un type à l'autre en appelant <code>resetToNice(mock)</code>,
+<code>resetToDefault(mock)</code> ou <code>resetToStrict(mock)</code>.
+</p>
+<h3>
+Utilisation d'un comportement de "stub" pour les méthodes
+</h3>
+<p>
+Dans certains cas, nous voudrions que nos Mock Object répondent
+à certains appels, mais sans tenir compte du nombre de fois, de l'ordre
+ni même s'ils ont été eu lieu.
+Ce comportement de "stub" peut être défini en utilisant
+les méthodes <code>andStubReturn(Object value)</code>,
+<code>andStubThrow(Throwable throwable)</code>, <code>andStubAnswer(IAnswer<t> answer)</code>
+et <code>asStub()</code>. Le code suivant configure le Mock Object pour répondre 42
+à <code>voteForRemoval("Document")</code> une fois et -1 pour tous les autres arguments:
+</p>
+<pre>
+ expect(mock.voteForRemoval("Document")).andReturn(42);
+ expect(mock.voteForRemoval(not(eq("Document")))).andStubReturn(-1);
+</pre>
+<h3>
+Création de mocks dits "gentils"
+</h3>
+<p>
+Pour un Mock Object retourné par <code>createMock()</code>, le comportement par défaut pour toutes
+les méthodes est de lever une <code>AssertionError</code> pour tous les appels non prévus.
+Si vous souhaitez avoir un Mock Object "gentil" autorisant, par défaut, l'appel à
+toutes les méthodes et retournant la valeur vide appropriée (<code>0</code>, <code>null</code>
+ou <code>false</code>), utilisez <code>create<i>Nice</i>Mock()</code> au lieu de <code>createMock()</code>.
+</p>
+
+<a id="Object_Methods"/><h3>Méthodes de la classe Object</h3>
+<p>
+Les comportements des quatre méthodes <code>equals()</code>,
+<code>hashCode()</code>, <code>toString()</code> et <code>finalize()</code>
+ne peuvent être changés sur des Mock Objects créés avec EasyMock,
+même si elles font partie de l'interface duquel le Mock Object est créé.
+</p>
+<h3>Vérifier l'ordre d'appel des méthodes entre plusieurs Mocks</h3>
+<p>
+Jusqu'à présent, nous avons vu un Mock Object comme étant
+seul et configuré par les méthodes statiques de la classe <code>EasyMock</code>.
+Mais beaucoup de ces méthodes statiques font référence à l'objet "control"
+caché de chaque Mock Object et lui délègue l'appel. Un
+Mock Control est un objet implémentant l'interface <code>IMocksControl</code>.
+</p>
+<p>
+Du coup, au lieu de
+</p>
+<pre>
+ IMyInterface mock = createStrictMock(IMyInterface.class);
+ replay(mock);
+ verify(mock);
+ reset(mock);
+</pre>
+<p>
+nous pourrions utiliser le code équivalent:
+</p>
+<pre>
+ IMocksControl ctrl = createStrictControl();
+ IMyInterface mock = ctrl.createMock(IMyInterface.class);
+ ctrl.replay();
+ ctrl.verify();
+ ctrl.reset();
+</pre>
+<p>
+L'interface <code>IMocksControl</code> permet de créer plus d'un seul Mock Object.
+Ainsi, il est possible de vérifier l'ordre d'appel des méthodes entre les mocks.
+Par exemple, configurons deux mock objects pour l'interface <code>IMyInterface</code> pour lesquels
+nous attendons respectivement les appels à <code>mock1.a()</code> et <code>mock2.a()</code>,
+un nombre indéfini d'appels à <code>mock1.c()</code> et <code>mock2.c()</code>,
+et enfin <code>mock2.b()</code> et <code>mock1.b()</code>, dans cet ordre:
+</p>
+<pre>
+ IMocksControl ctrl = createStrictControl();
+ IMyInterface mock1 = ctrl.createMock(IMyInterface.class);
+ IMyInterface mock2 = ctrl.createMock(IMyInterface.class);
+
+ mock1.a();
+ mock2.a();
+
+ ctrl.checkOrder(false);
+
+ mock1.c();
+ expectLastCall().anyTimes();
+ mock2.c();
+ expectLastCall().anyTimes();
+
+ ctrl.checkOrder(true);
+
+ mock2.b();
+ mock1.b();
+
+ ctrl.replay();
+</pre>
+<h3>Nommer un Mock Object</h3>
+<p>
+Les Mock Objects peuvent ê nommés à leur création en utilisant
+<code>createMock(String name, Class<T> toMock)</code>,
+<code>createStrictMock(String name, Class<T> toMock)</code> ou
+<code>createNiceMock(String name, Class<T> toMock)</code>.
+Les noms seront affichés dans le message des <code>AssertionError</code>.
+</p>
+<h3>Sérializer un Mock Object</h3>
+<p>
+Un Mock Object peut être sérializé à n'importe quelle étape de son
+existence. Il y a toutefois des contraintes évidentes:
+</p>
+<ul>
+<li>Les comparateurs d'arguments utilisés doivent être sérializable (ceux fournis avec EasyMock le sont)
+</li>
+<li>Les paramètres enregistrés doivent être sérializable
+</li>
+</ul>
+<h3>Traitement multifil</h3>
+<p>
+Pendant la phase d'enregistrement un Mock Object <b>n'est pas</b> à fil sécurisé. Un Mock Object donné (ou des Mock Objects liés au
+même <code>IMocksControl</code>) ne peut être enregistré que d'un seul fil. Toutefois, plusieurs Mock Objects peuvent être enregistrés
+simultanément dans des fils différents.
+</p>
+<p>
+Durant la phase de rejeu, un Mock Object sera à fil sécurisé par défaut. Ceci peut être changé en appelant <code>makeThreadSafe(mock, false)</code>.
+durant la phase d'enregistrement. Cela peut permettre d'éviter des interblocages dans certaines rares situations.
+</p>
+<p>
+Finallement, appeler <code>checkIsUsedInOneThread(mock, true)</code> permet de s'assurer qu'un Mock Object ne sera appelé que d'un seul
+fil. Une exception sera lancé sinon. Cela peut être pratique dans le cas où l'objet "mocké" n'est pas à fil sécurisé et que l'on veut
+s'assurer qu'il est utilisé correctement.
+</p>
+<h3>EasyMockSupport</h3>
+<p>
+<code>EasyMockSupport</code> est une classe ayant pour but d'être utilisée comme classe utilitaire ou comme classe de base de vos classes
+de test. Elle se souvient de tous les "Mock Objects" créés (ou en fait de tous les "Mock Controls" créés) pour pouvoir faire un replay,
+reset ou verify de tous en un seul coup. Voici un exemple utilisant JUnit:
+</p>
+<pre>
+public class SupportTest extends EasyMockSupport {
+
+ private Collaborator firstCollaborator;
+ private Collaborator secondCollaborator;
+ private ClassTested classUnderTest;
+
+ @Before
+ public void setup() {
+ classUnderTest = new ClassTested();
+ }
+
+ @Test
+ public void addDocument() {
+ // phase de création
+ firstCollaborator = createMock(Collaborator.class);
+ secondCollaborator = createMock(Collaborator.class);
+ classUnderTest.addListener(firstCollaborator);
+ classUnderTest.addListener(secondCollaborator);
+
+ // phase d'enregistrement
+ firstCollaborator.documentAdded("New Document");
+ secondCollaborator.documentAdded("New Document");
+
+ replayAll(); // tous les mocks d'un seul coup
+
+ // test
+ classUnderTest.addDocument("New Document", new byte[0]);
+
+ verifyAll(); // tous les mocks d'un seul coup
+ }
+}
+</pre>
+<h3>Modifier les comportements par défaut d'EasyMock</h3>
+<p>
+EasyMock fournit un mécanisme de gestion de propriétés permettant de modifier son comportement. Il vise
+principalement à permettre le retour à un comportement antérieur à la version courante. Les propriétés
+actuellement supportées sont:
+</p>
+<dl>
+<dt><code>easymock.notThreadSafeByDefault</code></dt>
+<dd>Si true, les Mock Objects ne seront pas à fil sécurisé par défaut. Values possibles: "true" ou "false". Défaut: false</dd>
+<dt><code>easymock.enableThreadSafetyCheckByDefault</code></dt>
+<dd>Si true, un mock ne pourra être appelé que d'un seul fil. Values possibles: "true" ou "false". Défaut: false</dd>
+<dt><code>easymock.disableClassMocking</code></dt>
+<dd>Ne pas permettre le mocking de classes (permettre uniquement le mocking d'interfaces). Valeurs possibles: "true" ou "false". Défaut: false</dd>
+</dl>
+<p>
+Les propriétés peuvent être mise de trois façons. Chaque étape de la liste peut écraser une précédente.
+</p>
+<ul>
+<li>Dans le fichier <code>easymock.properties</code> mis dans le package défaut du classpath
+</li>
+<li>Comme propriété système
+</li>
+<li>En appelant <code>EasyMock.setEasyMockProperty</code>. Des constantes sont disponibles
+dans la classe <code>EasyMock</code>
+</li>
+</ul>
+<h3>
+Compatibilité avec les anciennes versions
+</h3>
+<p>EasyMock 3 fournit toujours le project Class Extension (qui est toutefois déprécié) pour
+permettre une migration plus facile de EasyMock 2 vers EasyMock 3. Il s'agit d'une compatibilité des
+sources et non des binaires. Le code devra donc être recompilé.
+</p>
+<p>EasyMock 2.1 introduisait une fonctionnalité de callback
+qui a été retirée dans EasyMock 2.2, car trop complexe.
+Depuis EasyMock 2.2, l'interface <code>IAnswer</code>
+fournit la fonctionnalité de callback.
+</p>
+<h3>OSGi</h3>
+<p>
+Le jar d'EasyMock peut être utilisé comme bundle OSGi. Il export les packages
+<code>org.easymock</code>, <code>org.easymock.internal</code>
+et <code>org.easymock.internal.matchers</code>. Toutefois, pour importer les deux
+derniers, vous spécifier l'attribut <code>poweruser</code> à "true" (<code>poweruser=true</code>).
+Ces packages sont prévus d'être utilisés pour étendre EasyMock, ils n'ont donc pas besoins d'être
+importés habituellement.
+</p>
+<h3>Mocking partiel</h3>
+<p>
+Dans certains cas, vous pouvez avoir besoin de "mocker" uniquement certaines
+méthodes d'une classe et de conserver un comportement normal pour
+les autres. Cela arrive habituellement lorsque pour souhaitez tester une
+méthode appelant d'autres méthodes de la même classe.
+Vous voulez donc garder le comportement normal de la méthode testée
+et "mocker" les autres.
+</p>
+<p>
+Dans ce cas, la premier réflexe à avoir est
+d'envisager un refactoring car, bien souvent, ce problème est la
+conséquence d'un mauvais design. Si ce n'est pas le cas ou si
+vous ne pouvez faire autrement pour une quelconque contrainte de
+développement, voici la solution:
+</p>
+<pre>
+ToMock mock = createMockBuilder(ToMock.class)
+ .addMockedMethod("mockedMethod").createMock();
+</pre>
+<p>Seules les méthodes ajoutées avec <code>addMockedMethod(s)</code> seront
+"mockées" (<code>mockedMethod()</code> dans l'exemple). Les autres conservent leur
+comportement habituel. Une exception: les méthodes abstraites sont "mockées" par défaut.
+</p>
+<p><code>createMockBuilder</code> retourne l'interface <code>IMockBuilder</code>. Elle contient
+diverses méthodes pour facilement créer un mock partiel. Jettez un coup d'oeil à la javadoc
+pour en savoir plus.
+</p>
+<p><b>Remarque:</b> EasyMock fournit un comportement par défault pour les méthodes de la classe
+Object (<i>equals, hashCode, toString, finalize</i>). Toutefois, pour un mock partiel, si ces méthodes ne sont pas
+mockées explicitement, elles auront leur comportement normal et non celui par défaut d'EasyMock.
+</p>
+<h3>Test interne d'une classe</h3>
+<p>
+Il est possible de créer un mock en appelant un constructeur de la classe. Ceci
+peut être utile lorsqu'une méthode doit être testée mais d'autres
+dans la même classe "mockées". Pour cela vous devez faire quelque chose comme
+</p>
+<pre>
+ToMock mock = createMockBuilder(ToMock.class)
+ .withConstructor(1, 2, 3); // 1, 2, 3 sont les paramètres passés au constructeur
+</pre>
+<p>
+Voir <code>ConstructorCalledMockTest</code> pour un exemple d'utilisation.
+</p>
+<h3>Remplacer l'instantiateur de classes par défaut</h3>
+<p>
+Parfois (habituellement à cause d'une JVM non supportée), il est possible
+que EasyMock ne soit pas capable de créer un mock dans votre environnement java.
+Sous le capot, l'instantiation de classes est implémentée par un pattern "factory".
+En cas de problème, vous pouvez remplacer l'instantiateur par défaut avec:
+</p>
+<ul>
+<li>L'ancien <code>DefaultClassInstantiator</code> qui fonctionne très bien avec les classes
+sérializable et sinon tente de deviner quel constructeur appeler et quels paramètres lui passer.</li>
+<li>Votre propre instantiateur. Celui-ci doit implémenter <code>IClassInstantiator</code>.</li>
+</ul>
+<p>
+Vous assignez ce nouvel instantiateur à l'aide de <code>ClassInstantiatorFactory.setInstantiator()</code>.
+Vous pouvez remettre celui par défaut avec <code>setDefaultInstantiator()</code>.
+</p>
+<p>
+<b>Important:</b>
+L'instantiateur est gardé statiquement et reste donc entre deux tests. Assurez-vous
+de le réinitialiser si nécessaire.
+</p>
+<h3>Sérializer une classe mockée</h3>
+<p>
+Une class mockée peut aussi être sérializé. Toutefois, comme celle-ci étant une classe sérializable,
+cette dernière peut avoir un comportement spécial dû à l'implémentation de méthodes tels
+que <code>writeObject</code>. Ces méthodes seront toujours appelées lorsque le mock sera sérializé
+et peuvent potentiellement échouer. Habituellement, le contournement consiste à créer le mock
+en appelant un constructeur.
+</p>
+<p>
+Aussi, il est possible que la dé-sérialization d'un mock ne fonctionne pas si elle est effectuée dans
+un class loader différent de la sérialization. Ce cas n'a pas été testé.
+</p>
+<h3>Limitations du mocking de classes</h3>
+<p>
+Pour être cohérent avec le mocking d'interfaces, EasyMock fournit aussi un comportement par défaut
+pour <code>equals()</code>, <code>toString()</code>, <code>hashCode()</code> et <code>finalize()</code> pour les classes mockées.
+Cela signifie que vous ne pourrez enregistrer votre propre comportement pour ces méthodes. Cette
+limitation être considérée comme une fonctionnalité permettant de ne pas s'occuper de ces
+méthodes.
+</p>
+<p>
+Les méthodes finales ne peuvent pas être "mockées". Si
+appelées, leur code normal sera exécuté.
+</p>
+<p>
+Les méthodes privées ne peuvent être "mockées". Si
+appelées, leur code normal sera exécuté. Pour un mock partiel, si
+la méthode testée appelle une méthode privée, vous devrez aussi tester
+cette dernière étant donné que vous ne pouvez pas la mocker.
+</p>
+<p>
+L'instantiation des classes est faite par
+<a href="http://objenesis.googlecode.com/svn/docs/index.html">Objenesis</a>.
+Les JVMs supportées sont listées <a href="http://code.google.com/p/objenesis/wiki/ListOfCurrentlySupportedVMs">ici</a>.
+</p>
+
+<h2>
+Développement d'EasyMock
+</h2>
+<p>
+EasyMock a été développé par Tammo Freese chez OFFIS. La maintenance est effectuée
+par Henri Tremblay depuis 2007. Le développement d'EasyMock est hébergé par
+<a href="http://sourceforge.net/projects/easymock/">SourceForge</a>
+pour permettre à d'autres développeurs et sociétés d'y contribuer.
+</p>
+<p>
+Les Mock Objects de classes (précédemment appelé EasyMock Class Extension) ont été initialement
+développée par Joel Shellman, Chad Woolley et Henri Tremblay dans la section
+fichiers du of Yahoo!Groups.
+</p>
+<p>
+Remerciements à ceux qui nous ont fourni retour d'expérience et rustines, incluant
+Nascif Abousalh-Neto, Dave Astels, Francois Beausoleil, George Dinwiddie, Shane Duan,
+Wolfgang Frech, Steve Freeman, Oren Gross, John D. Heintz, Dale King, Brian Knorr,
+Dierk Koenig, Chris Kreussling, Robert Leftwich, Patrick Lightbody, Johannes Link,
+Rex Madden, David McIntosh, Karsten Menne, Bill Michell,
+Stephan Mikaty, Ivan Moore, Ilja Preuss, Justin Sampson, Markus Schmidlin, Richard Scott,
+Joel Shellman, Jiří Mareš, Alexandre de Pellegrin
+Shaun Smith, Marco Struck, Ralf Stuckert, Victor Szathmary, Bill Uetrecht,
+Frank Westphal, Chad Woolley, Bernd Worsch,
+Rodrigo Damazio, Bruno Fonseca, Ben Hutchison et de nombreux autres.
+</p>
+<p>
+Merci de consulter la <a href="http://www.easymock.org">page d'accueil EasyMock</a>
+pour être informé des nouvelles versions et transmettez vos bogues et suggestions à
+<a href="mailto:easymock@yahoogroups.com?subject=EasyMock ${project.version} feedback">EasyMock Yahoo!Group</a> (en anglais SVP).
+Si vous souhaitez souscrire au EasyMock Yahoo!Group, envoyez un message à
+<a href="mailto:easymock-subscribe@yahoogroups.com">easymock-subscribe@yahoogroups.com</a>.
+</p>
+<h3>
+EasyMock Version 3.1 (2011-11-10), Notes de Mise à Jour
+</h3>
+<p>
+Nouveau dans la version 3.1:
+</p>
+<ul>
+<li>NoClassDefFoundError en appelant EasyMock.replay/reset/verify sur un mock d'interface si cglib n'est pas dans le classpath (EASYMOCK-40)
+</li>
+<li>Il est possible de compiler en Java 7 (les méthodes de capture des types primitifs sont renommées et dépréciées) (EASYMOCK-100)
+</li>
+<li>Réparer la fuite mémoire lors de l'enregistrement du callback dans cglib (EASYMOCK-89)
+</li>
+<li>Ignorer les appels à <code>finalize</code> sur un Mock Object (EASYMOCK-21)
+</li>
+<li>MockBuilder.addMockedMethod doit refuser les méthodes finales (EASYMOCK-44)
+</li>
+<li>Les méthodes "bridge" ne doivent pas être considérer par MockBuilder.addMockedMethod (EASYMOCK-90)
+</li>
+<li>Faire un test basique avec PowerMock pour vérifier qu'il fonctionne correctement (EASYMOCK-88)
+</li>
+<li>Ajout du nom de classe ou interface dans les messages d'erreur pour chaque invocation (EASYMOCK-104)
+</li>
+</ul>
+<p>
+Nouveau dans la version 3.0:
+</p>
+<ul>
+<li>EasyMock CE is maintenant fusionné avec EasyMock (2325762)
+</li>
+<li>Ajout de "boolean capture(...)" par complétion (je ne pense pas que c'est utile)
+</li>
+<li>Impossible de répondre en déléguant à une méthode protégée (2891256)
+</li>
+<li>Un échec lors de la phase d'enregistrement peut impacter les tests subséquents (2914683)
+</li>
+<li>Returner une erreur spécifique lorsqu'un null est enregistré comme retour sur une méthode retournant un type primitif (2936175)
+</li>
+<li>Désactiver le mocking de classes à l'aide de <code>EasyMock.DISABLE_CLASS_MOCKING</code>
+</li>
+<li>Retirer les classes dépréciées d'EasyMock 1
+</li>
+<li>Ne pas lancer d'exception si on mock n'a pas de méthode <code>toString</code> (2937916)
+</li>
+<li>Message d'erreur plus clair lorsque des paramètres nues sont mélangés avec des matchers lors de l'enregistrement d'une méthode (2860190)
+</li>
+<li>Vérifier s'il reste des résultats disponible dans un comportement enregistré avant de matcher avec celui-ci (2940400)
+</li>
+<li>Permettre les mocks de classes provenant d'un plugin Eclipse (2994002)
+</li>
+<li>Ajout de <code>isNull(Class<T>)</code>, <code>notNull(Class<T>)</code> et <code>anyObject(Class<T>)</code> pour faciliter la gestion des génériques (2958636)
+</li>
+</ul>
+<p>
+Pour des notes de mise à jour plus anciennes, voir la <a href="Documentation.html">documentation de EasyMock 2 et EasyMock 2 Class Extension</a>.
+</p>
+</div>
+</body>
+</html>
diff --git a/common/easymock-tools/LICENSE.txt b/common/easymock-tools/LICENSE.txt
new file mode 100644
index 0000000..75b5248
--- /dev/null
+++ b/common/easymock-tools/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/common/easymock-tools/MODULE_LICENSE_APACHE2 b/common/easymock-tools/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/easymock-tools/MODULE_LICENSE_APACHE2
diff --git a/common/easymock-tools/PREBUILT.txt b/common/easymock-tools/PREBUILT.txt
new file mode 100644
index 0000000..0b9e7b5
--- /dev/null
+++ b/common/easymock-tools/PREBUILT.txt
@@ -0,0 +1,8 @@
+Easymock 3.1
+
+Home page: http://www.easymock.org/
+License: Apache 2.0
+Version: 3.1 (2011-11-08)
+Description: Allowing Mock Objects for classes and interfaces.
+
+Download URL: http://sourceforge.net/projects/easymock/files/EasyMock/3.1/easymock-3.1.zip/download
diff --git a/common/easymock-tools/easymock-3.1-javadoc.jar b/common/easymock-tools/easymock-3.1-javadoc.jar
new file mode 100644
index 0000000..c0df6e1
--- /dev/null
+++ b/common/easymock-tools/easymock-3.1-javadoc.jar
Binary files differ
diff --git a/common/easymock-tools/easymock-3.1-samples.jar b/common/easymock-tools/easymock-3.1-samples.jar
new file mode 100644
index 0000000..bb3130c
--- /dev/null
+++ b/common/easymock-tools/easymock-3.1-samples.jar
Binary files differ
diff --git a/common/easymock-tools/easymock-3.1-sources.jar b/common/easymock-tools/easymock-3.1-sources.jar
new file mode 100644
index 0000000..002b20c
--- /dev/null
+++ b/common/easymock-tools/easymock-3.1-sources.jar
Binary files differ
diff --git a/common/easymock-tools/easymock-3.1-tests.jar b/common/easymock-tools/easymock-3.1-tests.jar
new file mode 100644
index 0000000..4fe8ecd
--- /dev/null
+++ b/common/easymock-tools/easymock-3.1-tests.jar
Binary files differ
diff --git a/common/easymock-tools/easymock-3.1.jar b/common/easymock-tools/easymock-3.1.jar
new file mode 100644
index 0000000..f56f07a
--- /dev/null
+++ b/common/easymock-tools/easymock-3.1.jar
Binary files differ
diff --git a/common/easymock-tools/easymock.css b/common/easymock-tools/easymock.css
new file mode 100644
index 0000000..9cd8c4f
--- /dev/null
+++ b/common/easymock-tools/easymock.css
@@ -0,0 +1,55 @@
+body {
+ font-family:Arial,Helvetica,sans-serif;
+ font-size:11pt;
+ color:#000000;
+ background-color:#ffffff;
+ text-align:left;
+}
+
+.bodywidth {
+ width:962px;
+}
+
+h1, h2, h3, .contentbar {
+ padding:3px;
+}
+
+
+h1, h2, h3 {
+ font-weight:bold;
+}
+
+h1 {
+ font-size:24pt;
+ text-align:center;
+}
+
+h2, h3, .contentbar {
+ color:#000000;
+ background-color:#ccccff;
+ border:none;
+}
+
+h2 {
+ font-size:14pt;
+}
+
+h3 {
+ font-size:10pt;
+}
+
+img {
+ border:0;
+}
+
+ul {
+ list-style-type:square;
+}
+
+pre {
+ color:#000000;
+ background-color:#cccccc;
+ font-family:monospace;
+ font-size:8pt;
+ padding:3px;
+}
diff --git a/common/objenesis/Android.mk b/common/objenesis/Android.mk
new file mode 100644
index 0000000..5bba184
--- /dev/null
+++ b/common/objenesis/Android.mk
@@ -0,0 +1,24 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PREBUILT_JAVA_LIBRARIES := \
+ objenesis:objenesis-1.2$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_PREBUILT)
diff --git a/common/objenesis/LICENSE b/common/objenesis/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/common/objenesis/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/common/objenesis/MODULE_LICENSE_APACHE2 b/common/objenesis/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/objenesis/MODULE_LICENSE_APACHE2
diff --git a/common/objenesis/NOTICE b/common/objenesis/NOTICE
new file mode 100644
index 0000000..0d2da6d
--- /dev/null
+++ b/common/objenesis/NOTICE
@@ -0,0 +1,9 @@
+// ------------------------------------------------------------------
+// NOTICE file corresponding to the section 4d of The Apache License,
+// Version 2.0, in this case for Objenesis
+// ------------------------------------------------------------------
+
+Objenesis
+Copyright 2006-2009 Joe Walnes, Henri Tremblay, Leonardo Mesquita
+
+
diff --git a/common/objenesis/PREBUILT.txt b/common/objenesis/PREBUILT.txt
new file mode 100644
index 0000000..42021f4
--- /dev/null
+++ b/common/objenesis/PREBUILT.txt
@@ -0,0 +1,9 @@
+Objenesis 1.2
+
+Home page: http://objenesis.googlecode.com/
+License: Apache 2.0
+Version: 1.2
+Description: A small Java library to instantiate a new object of a particular class.
+ (used by Easymock 3.x)
+
+Download URL: http://objenesis.googlecode.com/files/objenesis-1.2-bin.zip
diff --git a/common/objenesis/objenesis-1.2-javadoc.jar b/common/objenesis/objenesis-1.2-javadoc.jar
new file mode 100644
index 0000000..ffb26ff
--- /dev/null
+++ b/common/objenesis/objenesis-1.2-javadoc.jar
Binary files differ
diff --git a/common/objenesis/objenesis-1.2-sources.jar b/common/objenesis/objenesis-1.2-sources.jar
new file mode 100644
index 0000000..240b170
--- /dev/null
+++ b/common/objenesis/objenesis-1.2-sources.jar
Binary files differ
diff --git a/common/objenesis/objenesis-1.2.jar b/common/objenesis/objenesis-1.2.jar
new file mode 100644
index 0000000..45cb641
--- /dev/null
+++ b/common/objenesis/objenesis-1.2.jar
Binary files differ