mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 20:17:42 +01:00
Merge pull request #259 from Fuzzlemann/master
PR for 3.6.4 (Fuzzlemann) (4)
This commit is contained in:
commit
541eab13c0
@ -1,13 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: com.djrapitops:PlanPluginBridge:3.6.0">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/PlanPluginBridge/3.6.0/PlanPluginBridge-3.6.0.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/PlanPluginBridge/3.6.0/PlanPluginBridge-3.6.0-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/PlanPluginBridge/3.6.0/PlanPluginBridge-3.6.0-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
@ -11,6 +11,6 @@ public class Sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String varchar(int length) {
|
public static String varchar(int length) {
|
||||||
return "varchar("+length+")";
|
return "varchar(" + length + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class DumpLog {
|
|||||||
*
|
*
|
||||||
* @param header The name of the header
|
* @param header The name of the header
|
||||||
*/
|
*/
|
||||||
void addHeader(String header) {
|
public void addHeader(String header) {
|
||||||
addLine("");
|
addLine("");
|
||||||
addLine("--- " + header + " ---");
|
addLine("--- " + header + " ---");
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ public class DumpLog {
|
|||||||
* @param key The key
|
* @param key The key
|
||||||
* @param value The value
|
* @param value The value
|
||||||
*/
|
*/
|
||||||
void add(String key, String value) {
|
public void add(String key, String value) {
|
||||||
addLine(key + ": " + value);
|
addLine(key + ": " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class DumpLog {
|
|||||||
* @param key The key
|
* @param key The key
|
||||||
* @param value The value
|
* @param value The value
|
||||||
*/
|
*/
|
||||||
void add(String key, boolean value) {
|
public void add(String key, boolean value) {
|
||||||
addLine(key + ": " + value);
|
addLine(key + ": " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class DumpLog {
|
|||||||
* @param key The key
|
* @param key The key
|
||||||
* @param value The CharSequences stored in an Iterable
|
* @param value The CharSequences stored in an Iterable
|
||||||
*/
|
*/
|
||||||
void add(String key, Iterable<? extends CharSequence> value) {
|
public void add(String key, Iterable<? extends CharSequence> value) {
|
||||||
addLine(key + ": " + String.join(", ", value));
|
addLine(key + ": " + String.join(", ", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class DumpLog {
|
|||||||
*
|
*
|
||||||
* @param lines The CharSequences stored in an Iterable
|
* @param lines The CharSequences stored in an Iterable
|
||||||
*/
|
*/
|
||||||
void addLines(Iterable<? extends CharSequence> lines) {
|
public void addLines(Iterable<? extends CharSequence> lines) {
|
||||||
lines.forEach(this::addLine);
|
lines.forEach(this::addLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class DumpLog {
|
|||||||
*
|
*
|
||||||
* @param lines The lines
|
* @param lines The lines
|
||||||
*/
|
*/
|
||||||
void addLines(CharSequence... lines) {
|
public void addLines(CharSequence... lines) {
|
||||||
Arrays.stream(lines).forEach(this::addLine);
|
Arrays.stream(lines).forEach(this::addLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class DumpLog {
|
|||||||
*
|
*
|
||||||
* @param line The content of the line
|
* @param line The content of the line
|
||||||
*/
|
*/
|
||||||
private void addLine(CharSequence line) {
|
public void addLine(CharSequence line) {
|
||||||
lines.add(line == null ? "\n" : line.toString());
|
lines.add(line == null ? "\n" : line.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package test.java.main.java.com.djrapitops.plan.utilities.dump;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.utilities.file.dump.DumpLog;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fuzzlemann
|
||||||
|
*/
|
||||||
|
public class DumpLogTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDumpLogCreation() {
|
||||||
|
DumpLog testLog = new DumpLog();
|
||||||
|
|
||||||
|
testLog.addHeader("Test Header");
|
||||||
|
testLog.add("StringValue", "Test");
|
||||||
|
testLog.add("BooleanValue", true);
|
||||||
|
testLog.add("IterableValue", Arrays.asList("Iterable 1", "Iterable 2"));
|
||||||
|
|
||||||
|
testLog.addLine(new StringBuilder("CharSequence Test"));
|
||||||
|
testLog.addLines(new StringBuilder("CharSequences Test"), new StringBuilder("CharSequences Test"));
|
||||||
|
testLog.addLines(Arrays.asList("Iterable 1", "Iterable 2"));
|
||||||
|
|
||||||
|
String expResult = "\n--- Test Header ---\n" +
|
||||||
|
"StringValue: Test\n" +
|
||||||
|
"BooleanValue: true\n" +
|
||||||
|
"IterableValue: Iterable 1, Iterable 2\n" +
|
||||||
|
"CharSequence Test\n" +
|
||||||
|
"CharSequences Test\n" +
|
||||||
|
"CharSequences Test\n" +
|
||||||
|
"Iterable 1\n" +
|
||||||
|
"Iterable 2";
|
||||||
|
String result = testLog.toString();
|
||||||
|
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ import test.java.utils.RandomData;
|
|||||||
import test.java.utils.TestInit;
|
import test.java.utils.TestInit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNotNull;
|
import static junit.framework.TestCase.assertNotNull;
|
||||||
@ -28,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull;
|
|||||||
@PrepareForTest(JavaPlugin.class)
|
@PrepareForTest(JavaPlugin.class)
|
||||||
public class HastebinTest {
|
public class HastebinTest {
|
||||||
|
|
||||||
private AtomicBoolean hastebinAvailable = new AtomicBoolean();
|
private AtomicReference<String> testLink = new AtomicReference<>(null);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void checkAvailability() throws Exception {
|
public void checkAvailability() throws Exception {
|
||||||
@ -40,27 +40,25 @@ public class HastebinTest {
|
|||||||
link = Hastebin.upload(RandomData.randomString(10));
|
link = Hastebin.upload(RandomData.randomString(10));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (e.getMessage().contains("503")) {
|
if (e.getMessage().contains("503")) {
|
||||||
hastebinAvailable.set(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
/* Ignored */
|
/* Ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link == null) {
|
Log.info(link);
|
||||||
hastebinAvailable.set(false);
|
testLink.set(link);
|
||||||
}
|
|
||||||
|
|
||||||
Log.info("Availability Test Link: " + link);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
thread.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
thread.join(5000);
|
thread.join(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
hastebinAvailable.set(false);
|
Log.info("Hastebin timed out");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("Hastebin Available: " + hastebinAvailable.get());
|
Log.info("Hastebin Availability Test Link: " + testLink.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -75,7 +73,8 @@ public class HastebinTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpload() throws Exception {
|
public void testUpload() throws Exception {
|
||||||
if (!hastebinAvailable.get()) {
|
if (testLink.get() == null) {
|
||||||
|
Log.info("Hastebin not available, skipping testUpload()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user