WebXmlServletMappingExtractorTest.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.serverboot;

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

import java.util.List;

import org.junit.jupiter.api.Test;

class WebXmlServletMappingExtractorTest {

	@Test
	void serverServletMappingsIncludeBaseAndPrefixedPatterns() {
		List<String> mappings = WebXmlServletMappingExtractor.extractMappings(
				"rdf4j/server-webapp/WEB-INF/web.xml", "rdf4j-http-server", "/rdf4j-server", true);

		assertThat(mappings).contains(
				"/protocol/*",
				"/protocol",
				"/repositories/*",
				"/repositories",
				"*.view",
				"*.form",
				"/rdf4j-server/protocol/*",
				"/rdf4j-server/protocol",
				"/rdf4j-server/repositories/*",
				"/rdf4j-server/repositories");
	}

	@Test
	void workbenchServletMappingsIncludePrefixedRepositoryPath() {
		List<String> mappings = WebXmlServletMappingExtractor.extractMappings(
				"rdf4j/workbench-webapp/WEB-INF/web.xml", "workbench", "/rdf4j-workbench", false);

		assertThat(mappings).containsExactlyInAnyOrder(
				"/rdf4j-workbench/repositories/*",
				"/rdf4j-workbench/repositories");
	}
}