#1232 #1239 Show legacy hint if Guava's MoreObjects class is missing

This commit is contained in:
ljacqu
2017-06-02 15:42:21 +02:00
parent 2974e4f5cb
commit 591d6f1d4c
3 changed files with 14 additions and 50 deletions
@@ -1,6 +1,5 @@
package fr.xephi.authme.initialization;
import ch.jalu.injector.exceptions.InjectorReflectionException;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.security.HashAlgorithm;
import org.junit.Test;
@@ -9,7 +8,6 @@ import java.util.logging.Logger;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
/**
@@ -17,44 +15,13 @@ import static org.mockito.Mockito.verifyZeroInteractions;
*/
public class OnStartupTasksTest {
@Test
public void shouldDisplayLegacyJarHint() {
// given
Logger logger = TestHelper.setupLogger();
NoClassDefFoundError noClassDefError = new NoClassDefFoundError("Lcom/google/gson/Gson;");
ReflectiveOperationException ex2 = new ReflectiveOperationException("", noClassDefError);
InjectorReflectionException ex = new InjectorReflectionException("", ex2);
// when
OnStartupTasks.displayLegacyJarHint(ex);
// then
verify(logger).warning("YOU MUST DOWNLOAD THE LEGACY JAR TO USE AUTHME ON YOUR SERVER");
}
@Test
public void shouldNotDisplayLegacyHintForDifferentException() {
// given
Logger logger = TestHelper.setupLogger();
NullPointerException npe = new NullPointerException();
// when
OnStartupTasks.displayLegacyJarHint(npe);
// then
verifyZeroInteractions(logger);
}
@Test
public void shouldNotDisplayLegacyHintForWrongCause() {
// given
Logger logger = TestHelper.setupLogger();
IllegalAccessException illegalAccessException = new IllegalAccessException("Lcom/google/gson/Gson;");
ReflectiveOperationException ex2 = new ReflectiveOperationException("", illegalAccessException);
InjectorReflectionException ex = new InjectorReflectionException("", ex2);
// when
OnStartupTasks.displayLegacyJarHint(ex);
OnStartupTasks.verifyIfLegacyJarIsNeeded();
// then
verifyZeroInteractions(logger);