You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 07:26:18 +00:00
Merge pull request #177 from simoleo89/style/startup-console
style(startup): console banner/splash/colors
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.eu.habbo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class ConsoleLogbackLayoutTest {
|
||||
@Test
|
||||
void consolePatternKeepsStartupMessagesReadable() throws Exception {
|
||||
String logback = Files.readString(Path.of("src/main/resources/logback.xml"));
|
||||
|
||||
assertTrue(logback.contains("morningstarLevel"), "console should use the adaptive level formatter");
|
||||
assertTrue(logback.contains("morningstarLogger"), "console should use the adaptive logger formatter");
|
||||
assertTrue(logback.contains("| %msg%n"), "console should leave a clear message column");
|
||||
assertFalse(logback.contains("%-36logger{36}"), "wide package loggers waste console space");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.eu.habbo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class EmulatorStartupConsoleTest {
|
||||
@Test
|
||||
void startupHeroUsesUniversalAsciiLayout() {
|
||||
String hero = Emulator.startupHero();
|
||||
|
||||
assertTrue(hero.contains("__ __ ___ ____"));
|
||||
assertTrue(hero.contains("MORNINGSTAR EXTENDED"));
|
||||
assertTrue(hero.contains("Version"));
|
||||
assertTrue(hero.contains("Build"));
|
||||
assertFalse(hero.contains("\u001B["), "startup hero must not require ANSI support");
|
||||
}
|
||||
|
||||
@Test
|
||||
void startupHeroCanRenderStyledLayoutWhenAnsiIsAvailable() {
|
||||
String hero = Emulator.startupHero(true);
|
||||
|
||||
assertTrue(hero.contains("\u001B["), "styled hero should include ANSI colors");
|
||||
assertTrue(hero.contains("[OK] MORNINGSTAR EXTENDED"));
|
||||
assertTrue(hero.contains("[JVM]"));
|
||||
assertTrue(hero.endsWith("\u001B[0m\n"), "styled hero should reset terminal attributes");
|
||||
}
|
||||
|
||||
@Test
|
||||
void consoleStyleAutoDetectsWindowsTerminal() {
|
||||
assertTrue(Emulator.shouldStyleConsole(
|
||||
Map.of("WT_SESSION", "abc123"),
|
||||
true,
|
||||
"Windows 11",
|
||||
"auto"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void consoleStyleFallsBackWhenOutputIsNotInteractive() {
|
||||
assertFalse(Emulator.shouldStyleConsole(
|
||||
Map.of("WT_SESSION", "abc123"),
|
||||
false,
|
||||
"Windows 11",
|
||||
"auto"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void consoleStyleCanBeForcedOff() {
|
||||
assertFalse(Emulator.shouldStyleConsole(
|
||||
Map.of("WT_SESSION", "abc123"),
|
||||
true,
|
||||
"Windows 11",
|
||||
"plain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void windowsAnsiModeInstallsJansiBeforePrintingStartupHero() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/com/eu/habbo/Emulator.java"));
|
||||
|
||||
assertTrue(source.contains("AnsiConsole.systemInstall()"),
|
||||
"forced ANSI mode must install the Jansi bridge for Windows CMD/System.out");
|
||||
assertTrue(source.contains("configureAnsiConsole(styledConsole)"),
|
||||
"console bridge must be configured before startupHero is printed");
|
||||
assertTrue(source.indexOf("configureAnsiConsole(styledConsole)") < source.indexOf("startupHero(styledConsole)"),
|
||||
"Jansi must be installed before writing ANSI startup output");
|
||||
}
|
||||
|
||||
@Test
|
||||
void registersGuiEnabledBeforeReadingIt() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/com/eu/habbo/Emulator.java"));
|
||||
|
||||
assertTrue(source.contains("register(\"gui.enabled\", \"0\")"),
|
||||
"gui.enabled must be registered disabled by default so it does not log missing config errors or start the UI unexpectedly");
|
||||
assertTrue(source.contains("register(\"gui.autostart.enabled\", \"0\")"),
|
||||
"GUI autostart must use a new disabled-by-default key so old gui.enabled=1 settings do not launch the current UI");
|
||||
assertTrue(source.indexOf("register(\"gui.autostart.enabled\", \"0\")") < source.indexOf("shouldLaunchGui()"),
|
||||
"GUI autostart must be registered before the launch decision");
|
||||
assertFalse(source.contains("getBoolean(\"gui.enabled\", true)"),
|
||||
"GUI must not use a true fallback");
|
||||
assertFalse(source.contains("getBoolean(\"gui.enabled\", false)"),
|
||||
"legacy gui.enabled must not control startup anymore");
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.eu.habbo.habbohotel.users.infostand;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class InfostandBackgroundManagerTest {
|
||||
@Test
|
||||
void summaryKeepsStartupLogCompact() {
|
||||
assertEquals(
|
||||
"Infostand Background Manager -> Loaded! (260 assets)",
|
||||
InfostandBackgroundManager.summary(188, 22, 9, 16, 25));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.eu.habbo.util.logback;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class ConsoleStyleTest {
|
||||
@Test
|
||||
void formatsLevelWithIconAndColorWhenStyled() {
|
||||
String formatted = ConsoleStyle.level(Level.WARN, true);
|
||||
|
||||
assertTrue(formatted.contains("\u001B["));
|
||||
assertTrue(formatted.contains("[!] WARN "));
|
||||
assertTrue(formatted.endsWith("\u001B[0m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void formatsLevelAsPlainTextWhenNotStyled() {
|
||||
assertEquals("WARN ", ConsoleStyle.level(Level.WARN, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void formatsLoggerWithColorWhenStyled() {
|
||||
String formatted = ConsoleStyle.logger("com.eu.habbo.networking.Server", true);
|
||||
|
||||
assertTrue(formatted.contains("\u001B["));
|
||||
assertTrue(formatted.contains("Server"));
|
||||
assertTrue(formatted.endsWith("\u001B[0m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsLoggerPlainAndCompactWhenNotStyled() {
|
||||
assertEquals("Server ", ConsoleStyle.logger("com.eu.habbo.networking.Server", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void honorsPlainOverrideEvenInWindowsTerminal() {
|
||||
assertFalse(ConsoleStyle.isEnabled(
|
||||
Map.of("WT_SESSION", "abc123"),
|
||||
true,
|
||||
"Windows 11",
|
||||
"plain"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user