Inject and load RS client and applet through Guice
Instead of requiring to create client from RuneLite just use Guice for it and separate applet provider. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -31,7 +31,9 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.grapher.graphviz.GraphvizGrapher;
|
||||
import com.google.inject.grapher.graphviz.GraphvizModule;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -63,11 +65,15 @@ public class PluginManagerTest
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private RuneLite runelite;
|
||||
private Set<Class> pluginClasses;
|
||||
@Mock
|
||||
@Bind
|
||||
public Applet applet;
|
||||
|
||||
@Mock
|
||||
Client client;
|
||||
@Bind
|
||||
public Client client;
|
||||
|
||||
private Set<Class> pluginClasses;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
@@ -78,8 +84,6 @@ public class PluginManagerTest
|
||||
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);
|
||||
@@ -105,12 +109,10 @@ public class PluginManagerTest
|
||||
long expected = pluginClasses.stream()
|
||||
.map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(pd -> pd.loadWhenOutdated())
|
||||
.filter(PluginDescriptor::loadWhenOutdated)
|
||||
.count();
|
||||
assertEquals(expected, plugins.size());
|
||||
|
||||
runelite.setClient(client);
|
||||
|
||||
pluginManager = new PluginManager();
|
||||
pluginManager.loadCorePlugins();
|
||||
plugins = pluginManager.getPlugins();
|
||||
@@ -130,8 +132,6 @@ public class PluginManagerTest
|
||||
modules.add(new GraphvizModule());
|
||||
modules.add(new RuneLiteModule());
|
||||
|
||||
runelite.setClient(client);
|
||||
|
||||
PluginManager pluginManager = new PluginManager();
|
||||
pluginManager.loadCorePlugins();
|
||||
for (Plugin p : pluginManager.getPlugins())
|
||||
|
||||
Reference in New Issue
Block a user