aboutsummaryrefslogtreecommitdiff
path: root/dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2018-08-28 16:57:52 +0000
committerPhilip P. Moltmann <moltmann@google.com>2018-08-28 10:01:00 -0700
commit70402ca5b8eeb3969d5a64acb65188856d48240a (patch)
treefed16a0794e87ff35a1ce663ace3c05f87ce0966 /dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java
parent7b4a547ee48fdb2e47e24d483a246c3c7e4a62ef (diff)
downloaddexmaker-70402ca5b8eeb3969d5a64acb65188856d48240a.tar.gz
Revert "Revert "Update dexmaker on AOSP to same version as on internal master""
This reverts commit 0ad4f18077e9cac496e836c82ef99763bd7ce094. Reason for revert: Fix in I5094fa145fc5f6d5c5d9426b07d764c07e545819 Change-Id: I5015d35f5fd464f6f86631ecb5b45e2fbbedffab
Diffstat (limited to 'dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java')
-rw-r--r--dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java b/dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java
new file mode 100644
index 0000000..be9d790
--- /dev/null
+++ b/dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/PartialClasses.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package com.android.dx.mockito.tests;
+
+import org.junit.Test;
+import org.mockito.exceptions.base.MockitoException;
+
+import java.util.AbstractList;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests what happens if code tries to call real methods of abstract classed and in interfaces
+ */
+public class PartialClasses {
+ @Test
+ public void callRealMethodOnInterface() {
+ Runnable r = mock(Runnable.class);
+
+ try {
+ doCallRealMethod().when(r).run();
+ fail();
+ } catch (MockitoException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void callAbstractRealMethodOnAbstractClass() {
+ AbstractList l = mock(AbstractList.class);
+
+ try {
+ when(l.size()).thenCallRealMethod();
+ fail();
+ } catch (MockitoException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void callRealMethodOnAbstractClass() {
+ AbstractList l = mock(AbstractList.class);
+
+ doCallRealMethod().when(l).clear();
+
+ l.clear();
+ }
+}