diff --git a/httpclient/.classpath b/httpclient/.classpath
new file mode 100644
index 0000000000..c370943e8c
--- /dev/null
+++ b/httpclient/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
new file mode 100644
index 0000000000..627021fb96
--- /dev/null
+++ b/httpclient/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/httpclient/.gitignore b/httpclient/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/httpclient/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/httpclient/.project b/httpclient/.project
new file mode 100644
index 0000000000..83c3ed0493
--- /dev/null
+++ b/httpclient/.project
@@ -0,0 +1,36 @@
+
+
+ httpclient
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+
+
diff --git a/httpclient/.settings/.jsdtscope b/httpclient/.settings/.jsdtscope
new file mode 100644
index 0000000000..7b3f0c8b9f
--- /dev/null
+++ b/httpclient/.settings/.jsdtscope
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/httpclient/.settings/org.eclipse.jdt.core.prefs b/httpclient/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..723e5b1245
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,95 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=error
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=error
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/httpclient/.settings/org.eclipse.jdt.ui.prefs b/httpclient/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000000..471e9b0d81
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,55 @@
+#Sat Jan 21 23:04:06 EET 2012
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=true
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=true
+sp_cleanup.make_private_fields_final=false
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=false
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/httpclient/.settings/org.eclipse.m2e.core.prefs b/httpclient/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000000..f897a7f1cb
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/httpclient/.settings/org.eclipse.m2e.wtp.prefs b/httpclient/.settings/org.eclipse.m2e.wtp.prefs
new file mode 100644
index 0000000000..ef86089622
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.m2e.wtp.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false
diff --git a/httpclient/.settings/org.eclipse.wst.common.component b/httpclient/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000000..e98377cb0f
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml b/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000000..bc0009a455
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000000..3bd5d0a480
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000000..05bd71b6ec
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/httpclient/.settings/org.eclipse.wst.validation.prefs b/httpclient/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000000..cacf5451ae
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,14 @@
+DELEGATES_PREFERENCE=delegateValidatorList
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;
+USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300
+eclipse.preferences.version=1
+override=true
+suspend=false
+vals/org.eclipse.jst.jsf.ui.JSFAppConfigValidator/global=FF01
+vals/org.eclipse.jst.jsp.core.JSPBatchValidator/global=FF01
+vals/org.eclipse.jst.jsp.core.JSPContentValidator/global=FF01
+vals/org.eclipse.jst.jsp.core.TLDValidator/global=FF01
+vals/org.eclipse.wst.dtd.core.dtdDTDValidator/global=FF01
+vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/global=TF02
+vf.version=3
diff --git a/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs b/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs
new file mode 100644
index 0000000000..9cfcabe16f
--- /dev/null
+++ b/httpclient/.settings/org.eclipse.wst.ws.service.policy.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.wst.ws.service.policy.projectEnabled=false
diff --git a/httpclient/.springBeans b/httpclient/.springBeans
new file mode 100644
index 0000000000..a79097f40d
--- /dev/null
+++ b/httpclient/.springBeans
@@ -0,0 +1,14 @@
+
+
+ 1
+
+
+
+
+
+
+ src/main/webapp/WEB-INF/api-servlet.xml
+
+
+
+
diff --git a/httpclient/README.md b/httpclient/README.md
new file mode 100644
index 0000000000..3479832586
--- /dev/null
+++ b/httpclient/README.md
@@ -0,0 +1,8 @@
+=========
+
+## Mockito Cookbooks and Examples
+
+
+### Relevant Articles:
+- [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify)
+
diff --git a/httpclient/pom.xml b/httpclient/pom.xml
new file mode 100644
index 0000000000..cf6ba14ed6
--- /dev/null
+++ b/httpclient/pom.xml
@@ -0,0 +1,116 @@
+
+ 4.0.0
+ org.baeldung
+ httpclient
+ 0.1-SNAPSHOT
+
+ httpclient
+
+
+
+
+
+
+ com.google.guava
+ guava
+ 15.0
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+
+
+
+
+ junit
+ junit-dep
+ ${junit.version}
+ test
+
+
+
+ org.hamcrest
+ hamcrest-core
+ ${org.hamcrest.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+
+
+
+ spring-rest
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+
+
+
+
+
+
+ 3.2.5.RELEASE
+ 3.1.4.RELEASE
+
+
+ 4.2.7.SP1
+ 5.1.27
+
+
+ 1.7.5
+ 1.0.11
+
+
+ 5.0.1.Final
+
+
+ 15.0
+ 3.1
+
+
+ 1.3
+ 4.11
+ 1.9.5
+
+ 4.3
+ 4.3.1
+
+ 1.8.1
+ 1.8.9
+
+
+ 1.4.5
+ 2.16
+
+
+
\ No newline at end of file
diff --git a/httpclient/src/main/resources/logback.xml b/httpclient/src/main/resources/logback.xml
new file mode 100644
index 0000000000..1146dade63
--- /dev/null
+++ b/httpclient/src/main/resources/logback.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ web - %date [%thread] %-5level %logger{36} - %message%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/httpclient/src/main/webapp/WEB-INF/api-servlet.xml b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml
new file mode 100644
index 0000000000..5463820874
--- /dev/null
+++ b/httpclient/src/main/webapp/WEB-INF/api-servlet.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/httpclient/src/main/webapp/WEB-INF/web.xml b/httpclient/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..48d4b8fe61
--- /dev/null
+++ b/httpclient/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+
+
+
+ Spring MVC Application
+
+
+
+ contextClass
+
+ org.springframework.web.context.support.AnnotationConfigWebApplicationContext
+
+
+
+ contextConfigLocation
+ org.baeldung.config
+
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ api
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+ api
+ /
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java
new file mode 100644
index 0000000000..399c511d4e
--- /dev/null
+++ b/httpclient/src/test/java/org/baeldung/mockito/MockitoConfigExamplesTest.java
@@ -0,0 +1,105 @@
+package org.baeldung.mockito;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+public class MockitoConfigExamplesTest {
+
+ // tests
+
+ @Test
+ public final void whenMockReturnBehaviorIsConfigured_thenBehaviorIsVerified() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ when(listMock.add(anyString())).thenReturn(false);
+
+ final boolean added = listMock.add(randomAlphabetic(6));
+ assertThat(added, is(false));
+ }
+
+ @Test
+ public final void whenMockReturnBehaviorIsConfigured2_thenBehaviorIsVerified() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ doReturn(false).when(listMock).add(anyString());
+
+ final boolean added = listMock.add(randomAlphabetic(6));
+ assertThat(added, is(false));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ when(listMock.add(anyString())).thenThrow(IllegalStateException.class);
+
+ listMock.add(randomAlphabetic(6));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public final void whenMethodHasNoReturnType_whenConfiguringBehaviorOfMethod_thenPossible() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ doThrow(NullPointerException.class).when(listMock).clear();
+
+ listMock.clear();
+ }
+
+ @Test
+ public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingOnlyOnce_thenNoExceptionIsThrown() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class);
+
+ listMock.add(randomAlphabetic(6));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingTwice_thenExceptionIsThrown() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class);
+
+ listMock.add(randomAlphabetic(6));
+ listMock.add(randomAlphabetic(6));
+ }
+
+ @Test
+ public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMetehodIsCalled() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ when(listMock.size()).thenCallRealMethod();
+
+ assertThat(listMock.size(), equalTo(1));
+ }
+
+ @Test
+ public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMetehodIsCalled() {
+ final MyList listMock = Mockito.mock(MyList.class);
+ doAnswer(new Answer() {
+ @Override
+ public final String answer(final InvocationOnMock invocation) {
+ return "Always the same";
+ }
+ }).when(listMock).get(anyInt());
+
+ final String element = listMock.get(1);
+ assertThat(element, is(equalTo("Always the same")));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public final void givenSpy_whenConfiguringBehaviorOfSpy_thenCorrectlyConfigured() {
+ final MyList instance = new MyList();
+ final MyList spy = Mockito.spy(instance);
+
+ doThrow(NullPointerException.class).when(spy).size();
+ spy.size();
+ }
+
+}
diff --git a/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java b/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java
new file mode 100644
index 0000000000..6875a9f819
--- /dev/null
+++ b/httpclient/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesTest.java
@@ -0,0 +1,125 @@
+package org.baeldung.mockito;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.mockito.Mockito;
+import org.mockito.exceptions.verification.NoInteractionsWanted;
+
+import com.google.common.collect.Lists;
+
+public class MockitoVerifyExamplesTest {
+
+ // tests
+
+ @Test
+ public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.size();
+ verify(mockedList).size();
+ }
+
+ @Test
+ public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.size();
+ verify(mockedList, times(1)).size();
+ }
+
+ @Test
+ public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ verifyZeroInteractions(mockedList);
+ }
+
+ @Test
+ public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ verify(mockedList, times(0)).size();
+ }
+
+ @Test(expected = NoInteractionsWanted.class)
+ public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() {
+ final List mockedList = mock(MyList.class);
+ mockedList.size();
+ mockedList.clear();
+
+ verify(mockedList).size();
+ verifyNoMoreInteractions(mockedList);
+ }
+
+ @Test
+ public final void whenVerifyingOrderOfInteractions_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.size();
+ mockedList.add("a parameter");
+ mockedList.clear();
+
+ final InOrder inOrder = Mockito.inOrder(mockedList);
+ inOrder.verify(mockedList).size();
+ inOrder.verify(mockedList).add("a parameter");
+ inOrder.verify(mockedList).clear();
+ }
+
+ @Test
+ public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.size();
+
+ verify(mockedList, never()).clear();
+ }
+
+ @Test
+ public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.clear();
+ mockedList.clear();
+ mockedList.clear();
+
+ verify(mockedList, atLeast(1)).clear();
+ verify(mockedList, atMost(10)).clear();
+ }
+
+ // with arguments
+
+ @Test
+ public final void whenVerifyingAnInteractionWithExactArgument_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.add("test");
+
+ verify(mockedList).add("test");
+ }
+
+ @Test
+ public final void whenVerifyingAnInteractionWithAnyArgument_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.add("test");
+
+ verify(mockedList).add(anyString());
+ }
+
+ @Test
+ public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() {
+ final List mockedList = mock(MyList.class);
+ mockedList.addAll(Lists. newArrayList("someElement"));
+ final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class);
+ verify(mockedList).addAll(argumentCaptor.capture());
+ final List capturedArgument = argumentCaptor.> getValue();
+ assertThat(capturedArgument, hasItem("someElement"));
+ }
+
+}
diff --git a/httpclient/src/test/java/org/baeldung/mockito/MyList.java b/httpclient/src/test/java/org/baeldung/mockito/MyList.java
new file mode 100644
index 0000000000..548596e6b6
--- /dev/null
+++ b/httpclient/src/test/java/org/baeldung/mockito/MyList.java
@@ -0,0 +1,17 @@
+package org.baeldung.mockito;
+
+import java.util.AbstractList;
+
+public class MyList extends AbstractList {
+
+ @Override
+ public String get(final int index) {
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return 1;
+ }
+
+}
diff --git a/httpclient/src/test/resources/.gitignore b/httpclient/src/test/resources/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/httpclient/src/test/resources/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file