DistributionAssetsTest.java

/*******************************************************************************
 * Copyright (c) 2025 Eclipse RDF4J contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Distribution License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *******************************************************************************/
// Some portions generated by Codex

package org.eclipse.rdf4j.tools.server.boot;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class DistributionAssetsTest {

	private static final Path SCRIPT = Path.of("src", "main", "dist", "bin", "rdf4j-server.sh");
	private static final Path LOGBACK = Path.of("src", "main", "dist", "config", "logback-spring.xml");
	private static final Path APP_PROPS = Path.of("src", "main", "dist", "config", "application.properties");

	@Test
	@DisplayName("run script must define sensible defaults")
	void runScriptDefinesDefaults() throws IOException {
		assertThat(Files.exists(SCRIPT)).as("run script missing").isTrue();

		String script = Files.readString(SCRIPT);
		assertThat(script).contains("RDF4J_JVM_MIN_HEAP:-512m");
		assertThat(script).contains("RDF4J_JVM_MAX_HEAP:-2g");
		assertThat(script).contains("org.eclipse.rdf4j.appdata.basedir");
		assertThat(script).contains("logging.config");
		assertThat(script).contains("spring.config.additional-location");
	}

	@Test
	@DisplayName("logback config keeps most loggers at WARN")
	void logbackConfigDefaultsToWarn() throws IOException {
		assertThat(Files.exists(LOGBACK)).as("logback config missing").isTrue();

		String loggingConfig = Files.readString(LOGBACK);
		assertThat(loggingConfig).contains("root level=\"WARN\"");
		assertThat(loggingConfig).contains("logger name=\"org.eclipse.rdf4j.http.server\" level=\"INFO\"");
	}

	@Test
	@DisplayName("application properties prefill the HTTP port")
	void applicationPropertiesPrefillsPort() throws IOException {
		assertThat(Files.exists(APP_PROPS)).as("application.properties missing").isTrue();

		String props = Files.readString(APP_PROPS);
		assertThat(props).contains("server.port=${RDF4J_SERVER_PORT:8080}");
	}
}