Search in sources :

Example 1 with RuneLiteModule

use of net.runelite.client.RuneLiteModule in project runelite by runelite.

the class PluginManagerTest method before.

@Before
public void before() throws IOException {
    RuneLite.setOptions(mock(OptionSet.class));
    Injector injector = Guice.createInjector(new RuneLiteModule(), BoundFieldModule.of(this));
    RuneLite.setInjector(injector);
    runelite = injector.getInstance(RuneLite.class);
    // Find plugins we expect to have
    pluginClasses = new HashSet<>();
    Set<ClassInfo> classes = ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(PLUGIN_PACKAGE);
    for (ClassInfo classInfo : classes) {
        Class<?> clazz = classInfo.load();
        PluginDescriptor pluginDescriptor = clazz.getAnnotation(PluginDescriptor.class);
        if (pluginDescriptor != null) {
            pluginClasses.add(clazz);
        }
    }
}
Also used : Injector(com.google.inject.Injector) RuneLite(net.runelite.client.RuneLite) OptionSet(joptsimple.OptionSet) RuneLiteModule(net.runelite.client.RuneLiteModule) ClassInfo(com.google.common.reflect.ClassPath.ClassInfo) Before(org.junit.Before)

Example 2 with RuneLiteModule

use of net.runelite.client.RuneLiteModule in project runelite by runelite.

the class PluginManagerTest method dumpGraph.

@Test
public void dumpGraph() throws Exception {
    List<Module> modules = new ArrayList<>();
    modules.add(new GraphvizModule());
    modules.add(new RuneLiteModule());
    runelite.setClient(client);
    PluginManager pluginManager = new PluginManager();
    pluginManager.loadCorePlugins();
    for (Plugin p : pluginManager.getPlugins()) {
        modules.add(p);
    }
    File file = folder.newFile();
    try (PrintWriter out = new PrintWriter(file, "UTF-8")) {
        Injector injector = Guice.createInjector(modules);
        GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class);
        grapher.setOut(out);
        grapher.setRankdir("TB");
        grapher.graph(injector);
    }
}
Also used : Injector(com.google.inject.Injector) ArrayList(java.util.ArrayList) GraphvizModule(com.google.inject.grapher.graphviz.GraphvizModule) Module(com.google.inject.Module) RuneLiteModule(net.runelite.client.RuneLiteModule) BoundFieldModule(com.google.inject.testing.fieldbinder.BoundFieldModule) GraphvizModule(com.google.inject.grapher.graphviz.GraphvizModule) GraphvizGrapher(com.google.inject.grapher.graphviz.GraphvizGrapher) RuneLiteModule(net.runelite.client.RuneLiteModule) File(java.io.File) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)2 RuneLiteModule (net.runelite.client.RuneLiteModule)2 ClassInfo (com.google.common.reflect.ClassPath.ClassInfo)1 Module (com.google.inject.Module)1 GraphvizGrapher (com.google.inject.grapher.graphviz.GraphvizGrapher)1 GraphvizModule (com.google.inject.grapher.graphviz.GraphvizModule)1 BoundFieldModule (com.google.inject.testing.fieldbinder.BoundFieldModule)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 OptionSet (joptsimple.OptionSet)1 RuneLite (net.runelite.client.RuneLite)1 Before (org.junit.Before)1 Test (org.junit.Test)1