Adds some still not working code for building spigot and bukkit .jar files
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

This commit is contained in:
2021-06-11 20:41:30 +02:00
parent 8cdb1f143c
commit 123a8eddda
10 changed files with 245 additions and 21 deletions

View File

@ -1,11 +1,11 @@
package net.knarcraft.minecraftserverlauncher.server;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import javax.naming.ConfigurationException;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
public class ServerTest {

View File

@ -1,13 +1,13 @@
package net.knarcraft.minecraftserverlauncher.server;
import net.knarcraft.minecraftserverlauncher.server.servertypes.ServerType;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import javax.naming.ConfigurationException;
import java.util.Arrays;
import static junit.framework.TestCase.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServerTypeHandlerTest {

View File

@ -2,13 +2,13 @@ package net.knarcraft.minecraftserverlauncher.server;
import net.knarcraft.minecraftserverlauncher.Main;
import net.knarcraft.minecraftserverlauncher.utility.CommonFunctions;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.*;
import static junit.framework.TestCase.assertEquals;
import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.createAllFolders;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServerVersionContainerTest {
@ -16,7 +16,7 @@ public class ServerVersionContainerTest {
private final String versionFile = filesDirectory + File.separator + "versions.csv";
private ServerVersionContainer serverVersionContainer;
@Before
@BeforeEach
public void setUp() {
try {
createAllFolders();

View File

@ -1,10 +1,10 @@
package net.knarcraft.minecraftserverlauncher.utility;
import net.knarcraft.minecraftserverlauncher.Main;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.stringBetween;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CommonFunctionsTest {

View File

@ -0,0 +1,79 @@
package net.knarcraft.minecraftserverlauncher.utility;
import net.knarcraft.minecraftserverlauncher.Main;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import java.io.File;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class JarBuilderTest {
private static JarBuilder jarBuilder;
private static String targetDirectory;
private static String jarDirectory;
@BeforeEach
public void setUp() {
targetDirectory = Main.getApplicationWorkDirectory() + File.separator + "files" + File.separator +
"BuildTools" + File.separator;
jarDirectory = Main.getApplicationWorkDirectory() + File.separator + "files" + File.separator +
"testjars" + File.separator;
jarBuilder = new JarBuilder(targetDirectory, jarDirectory);
removeBuildToolsFiles();
}
@Test
@Order(3)
public void buildLatestSpigotJarTest() {
jarBuilder.buildSpigotJar();
assertTrue(new File(jarDirectory + "SpigotLatest.jar").exists());
}
@Test
@Order(4)
public void buildLatestBukkitJarTest() {
jarBuilder.buildBukkitJar();
assertTrue(new File(jarDirectory + "BukkitLatest.jar").exists());
}
@Test
@Order(2)
public void downloadLatestBuildToolsJarTest() {
jarBuilder.downloadBuildTools();
assertTrue(new File(targetDirectory + "BuildTools.jar").exists());
}
@Test
@Order(1)
public void getLatestBuildToolsVersionTest() {
try {
String latestVersion = jarBuilder.getLatestBuildToolsVersion();
assertNotEquals("", latestVersion);
int newVersion = Integer.parseInt(latestVersion);
assertNotEquals(newVersion, 0);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Removes build tools files
*/
private static void removeBuildToolsFiles() {
File target = new File(targetDirectory);
if (!target.exists() && !target.mkdirs()) {
throw new IllegalArgumentException("Unable to create the test files directory");
}
CommonFunctions.removeFilesRecursively(target);
}
}

View File

@ -4,28 +4,29 @@ import net.knarcraft.minecraftserverlauncher.Main;
import net.knarcraft.minecraftserverlauncher.server.ServerTypeHandler;
import net.knarcraft.minecraftserverlauncher.server.servertypes.ServerType;
import net.knarcraft.minecraftserverlauncher.userinterface.FakeGUI;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import javax.naming.ConfigurationException;
import java.io.File;
import java.io.IOException;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class JarDownloaderTest {
private static String targetDirectory;
@BeforeClass
@BeforeAll
public static void setUp() {
targetDirectory = Main.getApplicationWorkDirectory() + File.separator + "files" + File.separator +
"testjars" + File.separator;
removeDownloadedFiles();
}
@AfterClass
@AfterAll
public static void cleanUp() {
removeDownloadedFiles();
}