mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-12-11 03:53:32 +01:00
Undo mocking when we're done with the test.
This commit is contained in:
parent
38c62c4cfd
commit
f4f8817fd5
@ -19,6 +19,7 @@ package com.comphenix.protocol.utility;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
@ -60,12 +61,15 @@ class CachedPackage {
|
|||||||
*/
|
*/
|
||||||
public Class<?> getPackageClass(String className) {
|
public Class<?> getPackageClass(String className) {
|
||||||
try {
|
try {
|
||||||
Class<?> result = cache.get(className);
|
Class<?> result = cache.get(Preconditions.checkNotNull(className, "className cannot be NULL"));
|
||||||
|
|
||||||
// Concurrency is not a problem - we don't care if we look up a class twice
|
// Concurrency is not a problem - we don't care if we look up a class twice
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
// Look up the class dynamically
|
// Look up the class dynamically
|
||||||
result = source.loadClass(combine(packageName, className));
|
result = source.loadClass(combine(packageName, className));
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
throw new IllegalArgumentException("Source " + source + " returned NULL for " + className);
|
||||||
cache.put(className, result);
|
cache.put(className, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -45,6 +45,7 @@ public class MinecraftReflectionTest {
|
|||||||
@AfterClass
|
@AfterClass
|
||||||
public static void undoMocking() {
|
public static void undoMocking() {
|
||||||
// NOP
|
// NOP
|
||||||
|
MinecraftReflection.minecraftPackage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user