Skip to content

Commit

Permalink
test enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Osiris-Team committed Oct 1, 2024
1 parent d37395f commit a9a27db
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

public class ConsoleOutputCapturer {
Expand Down Expand Up @@ -54,7 +55,12 @@ public void stop() {
}

public String getNewOutput() {
String newOutput = baos.toString(StandardCharsets.UTF_8);
String newOutput = null;
try {
newOutput = baos.toString(StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); // Never should be thrown
}
baos.reset();
return newOutput;
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/osiris/autoplug/client/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public static MyBThreadManager createManagerWithDisplayer() throws JLineLinkExce
}

public static void init() throws IOException {
initDefaults();
initLogger();
initDefaults();
}

public static void initDefaults() throws IOException {
private static void initDefaults() throws IOException {
GD.VERSION = "AutoPlug-Client Test-Version";
GD.WORKING_DIR = new File(System.getProperty("user.dir") + "/test");
System.setProperty("user.dir", GD.WORKING_DIR.getAbsolutePath());
Expand All @@ -57,7 +57,7 @@ public static void initDefaults() throws IOException {
if (!serverJar.exists()) serverJar.createNewFile();
}

public static void initLogger() {
private static void initLogger() {
File logFile = new File(System.getProperty("user.dir") + "/logs/latest.log");
logFile.getParentFile().mkdirs();
new AL().start("AL", true, logFile, false, false);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2024 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
* of the MIT-License. Consult the "LICENSE" file for details.
*/

package com.osiris.autoplug.client.tasks.updater;

import com.osiris.autoplug.client.UtilsTest;
import com.osiris.autoplug.client.tasks.updater.mods.ModrinthAPI;
import com.osiris.autoplug.client.tasks.updater.plugins.MinecraftPlugin;
import com.osiris.autoplug.client.tasks.updater.search.CustomCheckURL;
import com.osiris.autoplug.client.tasks.updater.search.SearchResult;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertSame;


class TestPluginUpdaters {
@Test
void testCustom() throws IOException {
UtilsTest.init();
MinecraftPlugin pl = new MinecraftPlugin("./plugins/", "Chunky", "0.0.0", "pop4959", 0, 0, null);
pl.customCheckURL = "https://api.modrinth.com/v2/project/chunky/version";
pl.customDownloadURL = "https://cdn.modrinth.com/data/fALzjamp/versions/dPliWter/Chunky-1.4.16.jar";
SearchResult sr = new CustomCheckURL().doCustomCheck(pl.customCheckURL, pl.getVersion());
assertSame(SearchResult.Type.UPDATE_AVAILABLE, sr.type);
}

@Test
void testModrinth() throws IOException {
UtilsTest.init();
MinecraftPlugin pl = new MinecraftPlugin("./plugins/", "BMMarker", "0.0.0", "Miraculixx", 0, 0, null);
pl.modrinthId = "a8UoyV2h";
SearchResult sr = new ModrinthAPI().searchUpdatePlugin(pl, "1.21.1");
assertSame(SearchResult.Type.UPDATE_AVAILABLE, sr.type);
}
}

0 comments on commit a9a27db

Please sign in to comment.