Correct the WrappedGameProfile unit test.
Dieser Commit ist enthalten in:
Ursprung
4bd9a1f01e
Commit
b3cda21fe5
@ -40,18 +40,21 @@ public final class PluginContext {
|
||||
/**
|
||||
* Lookup the plugin that this method invocation belongs to, and return its file name.
|
||||
* @param element - the method invocation.
|
||||
* @return Pluing name, or NULL if not found.
|
||||
* @return Plugin name, or NULL if not found.
|
||||
*
|
||||
*/
|
||||
public static String getPluginName(StackTraceElement element) {
|
||||
try {
|
||||
if (Bukkit.getServer() == null)
|
||||
return null;
|
||||
CodeSource codeSource = Class.forName(element.getClassName()).getProtectionDomain().getCodeSource();
|
||||
|
||||
|
||||
if (codeSource != null) {
|
||||
String encoding = codeSource.getLocation().getPath();
|
||||
File path = new File(URLDecoder.decode(encoding, "UTF-8"));
|
||||
|
||||
if (folderContains(getPluginFolder(), path)) {
|
||||
File plugins = getPluginFolder();
|
||||
|
||||
if (plugins != null && folderContains(plugins, path)) {
|
||||
return path.getName();
|
||||
}
|
||||
}
|
||||
@ -88,12 +91,12 @@ public final class PluginContext {
|
||||
|
||||
/**
|
||||
* Retrieve the folder that contains every plugin on the server.
|
||||
* @return Folder with every plugin.
|
||||
* @return Folder with every plugin, or NULL if Bukkit has not been initialized yet.
|
||||
*/
|
||||
private static File getPluginFolder() {
|
||||
File folder = pluginFolder;
|
||||
|
||||
if (folder == null) {
|
||||
if (folder == null && Bukkit.getServer() != null) {
|
||||
Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
||||
|
||||
if (plugins.length > 0) {
|
||||
|
@ -2,10 +2,13 @@ package com.comphenix.protocol.wrappers;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
public class WrappedGameProfileTest {
|
||||
@BeforeClass
|
||||
@ -13,15 +16,16 @@ public class WrappedGameProfileTest {
|
||||
BukkitInitialization.initializePackage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testSkinUpdate() {
|
||||
final String nullUUID = "00000000-0000-0000-0000-000000000000";
|
||||
final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8));
|
||||
|
||||
assertEquals(null, new WrappedGameProfile((String)null, "Test").getId());
|
||||
assertEquals(nullUUID, new WrappedGameProfile("", "Test").getId());
|
||||
assertEquals(nullUUID, new WrappedGameProfile("0", "Test").getId());
|
||||
assertEquals(nullUUID, new WrappedGameProfile("00-0", "Test").getId());
|
||||
assertEquals(uuid, new WrappedGameProfile("123", "Test").getUUID());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullFailure() {
|
||||
new WrappedGameProfile((String)null, null);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren