1 package com.atlassian.plugin.osgi.factory.descriptor;
2
3 import junit.framework.TestCase;
4 import org.dom4j.DocumentHelper;
5 import org.dom4j.Element;
6 import static org.mockito.Mockito.mock;
7 import static org.mockito.Mockito.when;
8 import static org.mockito.Matchers.anyObject;
9 import com.atlassian.plugin.Plugin;
10
11 public class TestComponentModuleDescriptor extends TestCase
12 {
13 public void testEnableDoesNotLoadClass() throws ClassNotFoundException
14 {
15 ComponentModuleDescriptor desc = new ComponentModuleDescriptor();
16
17 Element e = DocumentHelper.createElement("foo");
18 e.addAttribute("key", "foo");
19 e.addAttribute("class", Foo.class.getName());
20
21 Plugin plugin = mock(Plugin.class);
22 when(plugin.<Foo>loadClass((String)anyObject(), (Class<?>) anyObject())).thenReturn(Foo.class);
23 desc.init(plugin, e);
24
25 Foo.called = false;
26 desc.enabled();
27 assertFalse(Foo.called);
28 }
29
30 public static class Foo
31 {
32 public static boolean called;
33
34 public Foo()
35 {
36 called = true;
37 }
38 }
39 }