1 /* 2 * Copyright (c) 2017 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.plugins; 6 7 import org.junit.Test; 8 import org.mockito.Mockito; 9 import org.mockito.internal.creation.instance.Instantiator; 10 import org.mockito.plugins.AnnotationEngine; 11 import org.mockito.plugins.InstantiatorProvider; 12 import org.mockito.plugins.InstantiatorProvider2; 13 import org.mockito.plugins.MockMaker; 14 import org.mockito.plugins.MockitoPlugins; 15 import org.mockito.plugins.PluginSwitch; 16 import org.mockito.plugins.StackTraceCleanerProvider; 17 import org.mockitoutil.TestBase; 18 19 import static org.junit.Assert.assertNotNull; 20 import static org.mockito.Mockito.withSettings; 21 22 public class MockitoPluginsTest extends TestBase { 23 24 private final MockitoPlugins plugins = Mockito.framework().getPlugins(); 25 26 @Test provides_built_in_plugins()27 public void provides_built_in_plugins() { 28 assertNotNull(plugins.getInlineMockMaker()); 29 assertNotNull(plugins.getDefaultPlugin(MockMaker.class)); 30 assertNotNull(plugins.getDefaultPlugin(StackTraceCleanerProvider.class)); 31 assertNotNull(plugins.getDefaultPlugin(PluginSwitch.class)); 32 assertNotNull(plugins.getDefaultPlugin(InstantiatorProvider.class)); 33 assertNotNull(plugins.getDefaultPlugin(InstantiatorProvider2.class)); 34 assertNotNull(plugins.getDefaultPlugin(AnnotationEngine.class)); 35 } 36 37 @SuppressWarnings("deprecation") 38 @Test instantiator_provider_backwards_compatibility()39 public void instantiator_provider_backwards_compatibility() { 40 InstantiatorProvider provider = plugins.getDefaultPlugin(InstantiatorProvider.class); 41 Instantiator instantiator = provider.getInstantiator(withSettings().build(MockitoPluginsTest.class)); 42 43 assertNotNull(instantiator.newInstance(MockitoPluginsTest.class)); 44 } 45 } 46