*
* @see PluginUtil
*/
+@SuppressWarnings("unchecked")
public class PluginUtilTest {
/**
* mock up test extension point id
*/
- private static final String TEST_EXT_ID = "test-ep";
+ public static String TEST_EXT_ID = "test-ep";
/**
* mock up test class id
*/
- private static final String TEST_CLS_ID = "test-class";
+ public static String TEST_CLS_ID = "test-class";
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() throws Exception {
- PluginUtil.platformSurrogate = mock(Surrogate.class);
- }
-
- @After
- public void tearDown() throws Exception {
- PluginUtil.platformSurrogate = null;
- }
-
/**
- * Test {@link PluginUtil#loadClasses(String)}
- *
- * @throws Exception in case of failure in test
- *
- * @see PluginUtil#loadClasses(String)
+ * mock up IConfigurationElement
*/
- @Test
- public void testLoadClasses() throws Exception {
+ public static IConfigurationElement config;
+
+ @Before
+ public void setUp() {
+ PluginUtil.platformSurrogate = mock(Surrogate.class);
final IExtensionRegistry registry = mock(IExtensionRegistry.class);
when(PluginUtil.platformSurrogate.getAdapter()).thenReturn(registry);
final IExtension ext = mock(IExtension.class);
exts[0] = ext;
- final IConfigurationElement config = mock(IConfigurationElement.class);
final IConfigurationElement[] configs = new IConfigurationElement[1];
when(ext.getConfigurationElements()).thenReturn(configs);
- configs[0] = config;
+ config = mock(IConfigurationElement.class);
+ configs[0] = config;
+ }
+
+ @After
+ public void tearDown() {
+ PluginUtil.platformSurrogate = null;
+ }
+
+ /**
+ * Test {@link PluginUtil#loadClasses(String)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see PluginUtil#loadClasses(String)
+ */
+ @Test
+ public void testLoadClasses() throws Exception {
PluginUtil.loadClasses(TEST_EXT_ID);
Mockito.verify(config).createExecutableExtension("class");
}
*/
@Test
public void testLoadClass() throws Exception {
-
- final IExtensionRegistry registry = mock(IExtensionRegistry.class);
- when(PluginUtil.platformSurrogate.getAdapter()).thenReturn(registry);
-
- final IExtensionPoint ep = mock(IExtensionPoint.class);
- when(registry.getExtensionPoint(TEST_EXT_ID)).thenReturn(ep);
-
- IExtension[] exts = new IExtension[1];
- when(ep.getExtensions()).thenReturn(exts);
-
- final IExtension ext = mock(IExtension.class);
- exts[0] = ext;
-
- final IConfigurationElement config = mock(IConfigurationElement.class);
when(config.getAttribute("id")).thenReturn(TEST_CLS_ID);
- final IConfigurationElement[] configs = new IConfigurationElement[1];
- when(ext.getConfigurationElements()).thenReturn(configs);
- configs[0] = config;
PluginUtil.loadClass(TEST_EXT_ID, TEST_CLS_ID);
Mockito.verify(config).createExecutableExtension("class");