mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
@@ -23,6 +23,7 @@ public final class TestServer implements InvocationHandler {
|
||||
methodMap.put(
|
||||
Server.class.getMethod("isPrimaryThread"),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return Thread.currentThread().equals(server.creatingThread);
|
||||
}
|
||||
@@ -31,6 +32,7 @@ public final class TestServer implements InvocationHandler {
|
||||
methodMap.put(
|
||||
Server.class.getMethod("getPluginManager"),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return server.pluginManager;
|
||||
}
|
||||
@@ -40,6 +42,7 @@ public final class TestServer implements InvocationHandler {
|
||||
Server.class.getMethod("getLogger"),
|
||||
new MethodHandler() {
|
||||
final Logger logger = Logger.getLogger(TestServer.class.getCanonicalName());
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return logger;
|
||||
}
|
||||
@@ -48,6 +51,7 @@ public final class TestServer implements InvocationHandler {
|
||||
methodMap.put(
|
||||
Server.class.getMethod("getName"),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return TestServer.class.getSimpleName();
|
||||
}
|
||||
@@ -56,6 +60,7 @@ public final class TestServer implements InvocationHandler {
|
||||
methodMap.put(
|
||||
Server.class.getMethod("getVersion"),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return "Version_" + TestServer.class.getPackage().getImplementationVersion();
|
||||
}
|
||||
@@ -64,6 +69,7 @@ public final class TestServer implements InvocationHandler {
|
||||
methodMap.put(
|
||||
Server.class.getMethod("getBukkitVersion"),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
return "BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion();
|
||||
}
|
||||
@@ -88,6 +94,7 @@ public final class TestServer implements InvocationHandler {
|
||||
return Bukkit.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
MethodHandler handler = methods.get(method);
|
||||
if (handler != null) {
|
||||
|
@@ -89,10 +89,12 @@ public class ConversationTest {
|
||||
|
||||
private class FirstPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return "FirstPrompt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
assertEquals("FirstInput", input);
|
||||
context.setSessionData("data", 10);
|
||||
@@ -107,6 +109,7 @@ public class ConversationTest {
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
// Assert that session data passes from one prompt to the next
|
||||
assertEquals(context.getSessionData("data"), 10);
|
||||
|
@@ -15,29 +15,35 @@ public class FakeConversable implements Conversable {
|
||||
public Conversation abandonedConverstion;
|
||||
public ConversationAbandonedEvent abandonedConversationEvent;
|
||||
|
||||
@Override
|
||||
public boolean isConversing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptConversationInput(String input) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beginConversation(Conversation conversation) {
|
||||
begunConversation = conversation;
|
||||
conversation.outputNextPrompt();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
abandonedConverstion = conversation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
abandonedConverstion = conversation;
|
||||
abandonedConversationEvent = details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String message) {
|
||||
lastSentMessage = message;
|
||||
}
|
||||
|
@@ -57,6 +57,7 @@ public class ValidatingPromptTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
@@ -75,6 +76,7 @@ public class ValidatingPromptTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,6 +91,7 @@ public class ValidatingPromptTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
@@ -107,6 +110,7 @@ public class ValidatingPromptTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ public class LazyMetadataValueTest {
|
||||
@Test(expected=MetadataEvaluationException.class)
|
||||
public void testEvalException() {
|
||||
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_AFTER_FIRST_EVAL, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
throw new RuntimeException("Gotcha!");
|
||||
}
|
||||
@@ -56,6 +57,7 @@ public class LazyMetadataValueTest {
|
||||
final Counter counter = new Counter();
|
||||
final int value = 10;
|
||||
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_AFTER_FIRST_EVAL, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
counter.increment();
|
||||
return value;
|
||||
@@ -77,6 +79,7 @@ public class LazyMetadataValueTest {
|
||||
final Counter counter = new Counter();
|
||||
final int value = 10;
|
||||
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.NEVER_CACHE, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
counter.increment();
|
||||
return value;
|
||||
@@ -94,6 +97,7 @@ public class LazyMetadataValueTest {
|
||||
final Counter counter = new Counter();
|
||||
final int value = 10;
|
||||
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_ETERNALLY, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
counter.increment();
|
||||
return value;
|
||||
@@ -113,6 +117,7 @@ public class LazyMetadataValueTest {
|
||||
|
||||
private LazyMetadataValue makeSimpleCallable(final Object value) {
|
||||
return new LazyMetadataValue(plugin, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return value;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ public class MetadataStoreTest {
|
||||
final Counter counter = new Counter();
|
||||
|
||||
subject.setMetadata("subject", "key", new LazyMetadataValue(pluginX, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
counter.increment();
|
||||
return 10;
|
||||
@@ -52,6 +53,7 @@ public class MetadataStoreTest {
|
||||
final Counter counter = new Counter();
|
||||
|
||||
subject.setMetadata("subject", "key", new LazyMetadataValue(pluginX, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
counter.increment();
|
||||
return 10;
|
||||
|
@@ -85,10 +85,12 @@ public class MetadataValueAdapterTest {
|
||||
super(owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object value() {
|
||||
return ++internalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
internalValue = 0;
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ public class PluginManagerTest {
|
||||
final Event event = new TestEvent(true);
|
||||
Thread secondThread = new Thread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (pm) {
|
||||
@@ -63,6 +64,7 @@ public class PluginManagerTest {
|
||||
final Event event = new TestEvent(true);
|
||||
Thread secondThread = new Thread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
pm.callEvent(event);
|
||||
@@ -82,6 +84,7 @@ public class PluginManagerTest {
|
||||
final Event event = new TestEvent(false);
|
||||
Thread secondThread = new Thread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
pm.callEvent(event);
|
||||
@@ -105,6 +108,7 @@ public class PluginManagerTest {
|
||||
final Event event = new TestEvent(false);
|
||||
Thread secondThread = new Thread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (pm) {
|
||||
|
@@ -22,82 +22,102 @@ public class TestPlugin extends PluginBase {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginDescriptionFile getDescription() {
|
||||
return new PluginDescriptionFile(pluginName, "1.0", "test.test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResource(String filename) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDefaultConfig() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveResource(String resourcePath, boolean replace) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLogger getLogger() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLoader getPluginLoader() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaggable() {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNaggable(boolean canNag) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ public class TimedRegisteredListenerTest {
|
||||
public void testEventClass() throws EventException {
|
||||
Listener listener = new Listener() {};
|
||||
EventExecutor executor = new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) {}
|
||||
};
|
||||
TestPlugin plugin = new TestPlugin("Test");
|
||||
|
@@ -13,6 +13,7 @@ public class TestMessageListener implements PluginMessageListener {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
assertEquals(this.channel, channel);
|
||||
assertArrayEquals(this.message, message);
|
||||
|
@@ -39,6 +39,7 @@ public final class TestPlayer implements InvocationHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
MethodHandler handler = methods.get(method);
|
||||
if (handler != null) {
|
||||
|
Reference in New Issue
Block a user