Fix HastebinTest (Thread wasn't started...)

This commit is contained in:
Fuzzlemann 2017-08-17 14:29:18 +02:00
parent 5cc5d61816
commit 15587946e6
3 changed files with 12 additions and 26 deletions

View File

@ -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>

View File

@ -11,6 +11,6 @@ public class Sql {
}
public static String varchar(int length) {
return "varchar("+length+")";
return "varchar(" + length + ")";
}
}

View File

@ -15,7 +15,7 @@ import test.java.utils.RandomData;
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;
@ -28,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull;
@PrepareForTest(JavaPlugin.class)
public class HastebinTest {
private AtomicBoolean hastebinAvailable = new AtomicBoolean();
private AtomicReference<String> testLink = new AtomicReference<>(null);
@Before
public void checkAvailability() throws Exception {
@ -40,27 +40,25 @@ public class HastebinTest {
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);
thread.join();
} catch (InterruptedException e) {
hastebinAvailable.set(false);
Log.info("InterruptedException: " + e.getMessage());
}
Log.info("Hastebin Available: " + hastebinAvailable.get());
Log.info("Hastebin Availability Test Link: " + testLink.get());
}
@Test
@ -75,7 +73,8 @@ public class HastebinTest {
@Test
public void testUpload() throws Exception {
if (!hastebinAvailable.get()) {
if (testLink.get() == null) {
Log.info("Hastebin not available, skipping testUpload()");
return;
}