1 package com.atlassian.plugin.osgi.performance;
2
3 import com.atlassian.plugin.DefaultModuleDescriptorFactory;
4 import com.atlassian.plugin.hostcontainer.DefaultHostContainer;
5 import com.atlassian.plugin.osgi.hostcomponents.ComponentRegistrar;
6 import com.atlassian.plugin.osgi.hostcomponents.HostComponentProvider;
7 import com.atlassian.plugin.osgi.PluginInContainerTestBase;
8 import com.atlassian.plugin.osgi.DummyModuleDescriptor;
9 import com.atlassian.plugin.osgi.SomeInterface;
10 import com.atlassian.plugin.test.PluginJarBuilder;
11
12 import org.apache.commons.io.FileUtils;
13
14 import java.io.IOException;
15 import java.io.File;
16
17
18
19
20 public abstract class FrameworkRestartTestBase extends PluginInContainerTestBase
21 {
22 private static final int NUM_HOST_COMPONENTS = 200;
23 private static final int NUM_PLUGINS = 50;
24 HostComponentProvider prov = null;
25 DefaultModuleDescriptorFactory factory = null;
26
27 @Override
28 public void setUp() throws Exception
29 {
30 super.setUp();
31 factory = new DefaultModuleDescriptorFactory(new DefaultHostContainer());
32 factory.addModuleDescriptor("dummy", DummyModuleDescriptor.class);
33 prov = new HostComponentProvider()
34 {
35 public void provide(final ComponentRegistrar registrar)
36 {
37 for (int x = 0; x < NUM_HOST_COMPONENTS; x++)
38 {
39 registrar.register(SomeInterface.class).forInstance(new SomeInterface()
40 {});
41 }
42 }
43 };
44
45 for (int x = 0; x < NUM_PLUGINS; x++)
46 {
47 addPlugin(pluginsDir, x);
48 }
49
50
51
52 startPluginFramework();
53 pluginManager.shutdown();
54 }
55
56 protected abstract void addPlugin(File dir, int x) throws IOException;
57
58 protected void startPluginFramework() throws Exception
59 {
60 initPluginManager(prov, factory);
61 }
62
63 @Override
64 public void tearDown() throws Exception
65 {
66 super.tearDown();
67 }
68
69 public void testMultiplePlugins() throws Exception
70 {
71 startPluginFramework();
72 pluginManager.shutdown();
73 }
74 }