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