mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Fix failing tests, Fix Format import
This commit is contained in:
parent
4c570520b8
commit
b466edf777
31
Plan/pom.xml
31
Plan/pom.xml
@ -1,31 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>Plan</artifactId>
|
||||
<version>3.5.4</version>
|
||||
<version>3.5.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- Spigot 1.12 built with Buildtools for Database classes.-->
|
||||
<!-- Spigot 1.12 built with Buildtools for Database classes.-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Framework for easier plugin development-->
|
||||
<!-- Framework for easier plugin development-->
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>AbstractPluginFramework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- bStats Metrics-->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<!-- SoftDepended Plugins-->
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
@ -33,7 +44,7 @@
|
||||
<version>3.5.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock</artifactId>
|
||||
@ -66,7 +77,7 @@
|
||||
<version>1.10.19</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
@ -88,9 +99,9 @@
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package install</defaultGoal>
|
||||
<finalName>${project.name}</finalName>
|
||||
@ -146,7 +157,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/test/*</exclude>
|
||||
@ -154,7 +165,7 @@
|
||||
<exclude>**/*/test.*</exclude>
|
||||
<exclude>**/test/**/*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.data.cache;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -70,24 +69,26 @@ public class GeolocationCacheHandler {
|
||||
* @see #getCountry(String)
|
||||
*/
|
||||
private static String getUncachedCountry(String ipAddress) {
|
||||
Benchmark.start("getUncachedCountry");
|
||||
try {
|
||||
Benchmark.start("getUncachedCountry");
|
||||
URL url = new URL("http://freegeoip.net/csv/" + ipAddress);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
String resultLine = in.readLine();
|
||||
Log.debug(resultLine);
|
||||
in.close();
|
||||
|
||||
String[] results = resultLine.split(",");
|
||||
String result = results[2];
|
||||
|
||||
String country = result.isEmpty() ? Phrase.DEM_UNKNOWN.toString() : result;
|
||||
|
||||
Benchmark.stop("getUncachedCountry");
|
||||
String country = result.isEmpty() ? "Not Known" : result;
|
||||
|
||||
return country;
|
||||
} catch (Exception exc) {
|
||||
return Phrase.DEM_UNKNOWN.toString();
|
||||
return "Not Known";
|
||||
} finally {
|
||||
Benchmark.stop("getUncachedCountry");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
import com.djrapitops.plugin.utilities.FormattingUtils;
|
||||
import java.text.DecimalFormat;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
@ -5,19 +5,29 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
||||
import static org.junit.Assert.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(JavaPlugin.class)
|
||||
public class LoginHandlingTest {
|
||||
|
||||
/**
|
||||
@ -31,6 +41,7 @@ public class LoginHandlingTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
TestInit.init();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,8 +63,8 @@ public class LoginHandlingTest {
|
||||
assertTrue("Logintimes not +1", data.getLoginTimes() == loginTimes + 1);
|
||||
assertTrue("Nick not added", data.getNicknames().contains(nick));
|
||||
assertTrue("Nick not last nick", data.getLastNick().equals(nick));
|
||||
String geo = data.getGeolocation();
|
||||
assertTrue("Wrong location " + geo, geo.equals("United States"));
|
||||
String result = data.getGeolocation();
|
||||
assertEquals("United States", result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +77,7 @@ public class LoginHandlingTest {
|
||||
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
||||
LoginHandling.updateGeolocation(ip, data);
|
||||
String result = data.getGeolocation();
|
||||
assertTrue("Wrong location " + result, result.equals("United States"));
|
||||
assertEquals("United States", result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,19 +6,29 @@
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
|
||||
import static org.junit.Assert.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(JavaPlugin.class)
|
||||
public class LoginInfoTest {
|
||||
|
||||
/**
|
||||
@ -32,6 +42,7 @@ public class LoginInfoTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
TestInit.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,19 +6,28 @@
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
|
||||
import static org.junit.Assert.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(JavaPlugin.class)
|
||||
public class ReloadInfoTest {
|
||||
|
||||
/**
|
||||
@ -32,6 +41,7 @@ public class ReloadInfoTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
TestInit.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>Plan</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user