Skip to content

Commit

Permalink
Merge pull request #259 from Fuzzlemann/master
Browse files Browse the repository at this point in the history
PR for 3.6.4 (Fuzzlemann) (4)
  • Loading branch information
AuroraLS3 authored Aug 18, 2017
2 parents a19fca8 + 5eecaf0 commit 541eab1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 32 deletions.
13 changes: 0 additions & 13 deletions .idea/libraries/Maven__com_djrapitops_PlanPluginBridge_3_6_0.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ private Sql() {
}

public static String varchar(int length) {
return "varchar("+length+")";
return "varchar(" + length + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DumpLog {
*
* @param header The name of the header
*/
void addHeader(String header) {
public void addHeader(String header) {
addLine("");
addLine("--- " + header + " ---");
}
Expand All @@ -28,7 +28,7 @@ void addHeader(String header) {
* @param key The key
* @param value The value
*/
void add(String key, String value) {
public void add(String key, String value) {
addLine(key + ": " + value);
}

Expand All @@ -38,7 +38,7 @@ void add(String key, String value) {
* @param key The key
* @param value The value
*/
void add(String key, boolean value) {
public void add(String key, boolean value) {
addLine(key + ": " + value);
}

Expand All @@ -49,7 +49,7 @@ void add(String key, boolean value) {
* @param key The key
* @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));
}

Expand All @@ -58,7 +58,7 @@ void add(String key, Iterable<? extends CharSequence> value) {
*
* @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);
}

Expand All @@ -67,7 +67,7 @@ void addLines(Iterable<? extends CharSequence> lines) {
*
* @param lines The lines
*/
void addLines(CharSequence... lines) {
public void addLines(CharSequence... lines) {
Arrays.stream(lines).forEach(this::addLine);
}

Expand All @@ -76,7 +76,7 @@ void addLines(CharSequence... lines) {
*
* @param line The content of the line
*/
private void addLine(CharSequence line) {
public void addLine(CharSequence line) {
lines.add(line == null ? "\n" : line.toString());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import test.java.utils.TestInit;

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.assertNotNull;
Expand All @@ -28,7 +28,7 @@
@PrepareForTest(JavaPlugin.class)
public class HastebinTest {

private AtomicBoolean hastebinAvailable = new AtomicBoolean();
private AtomicReference<String> testLink = new AtomicReference<>(null);

@Before
public void checkAvailability() throws Exception {
Expand All @@ -40,27 +40,25 @@ public void checkAvailability() throws Exception {
link = Hastebin.upload(RandomData.randomString(10));
} catch (IOException e) {
if (e.getMessage().contains("503")) {
hastebinAvailable.set(false);
return;
}
} catch (ParseException e) {
/* Ignored */
}

if (link == null) {
hastebinAvailable.set(false);
}

Log.info("Availability Test Link: " + link);
Log.info(link);
testLink.set(link);
});

thread.start();

try {
thread.join(5000);
} 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
Expand All @@ -75,7 +73,8 @@ public void testSplitting() {

@Test
public void testUpload() throws Exception {
if (!hastebinAvailable.get()) {
if (testLink.get() == null) {
Log.info("Hastebin not available, skipping testUpload()");
return;
}

Expand Down

0 comments on commit 541eab1

Please sign in to comment.