mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 03:25:29 +01:00
Fix some more failing tests
This commit is contained in:
parent
1c6641748b
commit
0958c042c9
@ -1,17 +1,5 @@
|
||||
package com.comphenix.protocol;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemFactory;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.comphenix.protocol.reflect.FieldUtils;
|
||||
import com.comphenix.protocol.utility.Constants;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
@ -22,20 +10,21 @@ import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
* @author Kristian
|
||||
*/
|
||||
public class BukkitInitialization {
|
||||
private static boolean initialized;
|
||||
// private static boolean initialized;
|
||||
|
||||
/**
|
||||
* Initialize Bukkit and ProtocolLib such that we can perfrom unit testing.
|
||||
* @throws IllegalAccessException If we are unable to initialize Bukkit.
|
||||
*/
|
||||
public static void initializeItemMeta() throws IllegalAccessException {
|
||||
/* None of this works in 1.8
|
||||
if (!initialized) {
|
||||
// Denote that we're done
|
||||
initialized = true;
|
||||
|
||||
initializePackage();
|
||||
|
||||
/* "Accessed X before bootstrap!
|
||||
// "Accessed X before bootstrap!
|
||||
try {
|
||||
Block.S(); // Block.register()
|
||||
} catch (Throwable ex) {
|
||||
@ -52,7 +41,7 @@ public class BukkitInitialization {
|
||||
StatisticList.a(); // StatisticList.register()
|
||||
} catch (Throwable ex) {
|
||||
System.err.println("Failed to register statistics: " + ex);
|
||||
} */
|
||||
}
|
||||
|
||||
// Mock the server object
|
||||
Server mockedServer = mock(Server.class);
|
||||
@ -68,7 +57,7 @@ public class BukkitInitialization {
|
||||
|
||||
// And the fake item factory
|
||||
FieldUtils.writeStaticField(CraftItemFactory.class, "instance", mockedFactory, true);
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,12 +26,10 @@ import java.util.UUID;
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
@ -46,7 +44,7 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
// Ensure that the CraftItemFactory is mockable
|
||||
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
|
||||
@PrepareForTest(CraftItemFactory.class)
|
||||
//@PrepareForTest(CraftItemFactory.class)
|
||||
public class PacketContainerTest {
|
||||
// Helper converters
|
||||
// private EquivalentConverter<WrappedDataWatcher> watchConvert = BukkitConverters.getDataWatcherConverter();
|
||||
|
@ -10,18 +10,16 @@ import java.io.IOException;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.IntHashMap;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
|
||||
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
|
||||
@PrepareForTest(CraftItemFactory.class)
|
||||
//@PrepareForTest(CraftItemFactory.class)
|
||||
public class StreamSerializerTest {
|
||||
@BeforeClass
|
||||
public static void initializeBukkit() throws IllegalAccessException {
|
||||
|
@ -26,19 +26,17 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.wrappers.nbt.io.NbtBinarySerializer;
|
||||
|
||||
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" })
|
||||
@PrepareForTest(CraftItemFactory.class)
|
||||
//@PrepareForTest(CraftItemFactory.class)
|
||||
public class NbtFactoryTest {
|
||||
@BeforeClass
|
||||
public static void initializeBukkit() throws IllegalAccessException {
|
||||
|
Loading…
Reference in New Issue
Block a user