mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 09:42:06 -07:00
convert API/server tests to mockito (#8848)
* convert API tests to mockito * convert server tests to mockito * add co-author
This commit is contained in:
@@ -170,38 +170,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -0,0 +0,0 @@ public final class DummyServer implements InvocationHandler {
|
||||
}
|
||||
}
|
||||
);
|
||||
- Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
|
||||
+ // Paper start - modeled off of TestServer in the API tests module
|
||||
+ methods.put(
|
||||
+ Server.class.getMethod("getPluginManager"),
|
||||
+ new MethodHandler() {
|
||||
+ @Override
|
||||
+ public Object handle(DummyServer server, Object[] args) {
|
||||
+ return server.pluginManager;
|
||||
+ }
|
||||
+ }
|
||||
+ );
|
||||
+ DummyServer server = new DummyServer();
|
||||
+ Server instance = Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(server);
|
||||
+ Bukkit.setServer(instance);
|
||||
+ server.pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
|
||||
+ // Paper end
|
||||
} catch (Throwable t) {
|
||||
throw new Error(t);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public final class DummyServer implements InvocationHandler {
|
||||
|
||||
private DummyServer() {};
|
||||
|
||||
+ private org.bukkit.plugin.PluginManager pluginManager; // Paper
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
MethodHandler handler = DummyServer.methods.get(method);
|
||||
|
Reference in New Issue
Block a user