diff options
| author | Michael Peter Christen <mc@yacy.net> | 2026-07-12 00:49:49 +0200 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2026-07-12 00:49:49 +0200 |
| commit | b2e9142ea9a61af8c6e55a39a392136306dc0312 (patch) | |
| tree | 918e2fc6308b9ed040d8470c21a4731e9766a0a2 /test/java | |
| parent | bfddfe5e7ed90a80b4acf9a71a567b61b77cfcc4 (diff) | |
towards a Jetty 9 decoupling baseline for the Jetty 12 migration
Diffstat (limited to 'test/java')
5 files changed, 152 insertions, 0 deletions
diff --git a/test/java/net/yacy/cora/federate/solr/connector/RemoteSolrSmoke.java b/test/java/net/yacy/cora/federate/solr/connector/RemoteSolrSmoke.java new file mode 100644 index 000000000..480579150 --- /dev/null +++ b/test/java/net/yacy/cora/federate/solr/connector/RemoteSolrSmoke.java @@ -0,0 +1,32 @@ +package net.yacy.cora.federate.solr.connector; + +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.common.params.ModifiableSolrParams; + +import net.yacy.cora.federate.solr.instance.RemoteInstance; + +/** Command-line integration probe for YaCY's Apache-based remote Solr path. */ +public final class RemoteSolrSmoke { + + private RemoteSolrSmoke() { + } + + public static void main(final String[] args) throws Exception { + if (args.length != 1) { + throw new IllegalArgumentException("usage: RemoteSolrSmoke SOLR_BASE_URL"); + } + final RemoteInstance instance = new RemoteInstance( + args[0], null, "collection1", 10_000, false, Long.MAX_VALUE, false); + try { + final RemoteSolrConnector connector = new RemoteSolrConnector(instance, false); + final QueryResponse response = connector.getResponseByParams( + new ModifiableSolrParams().set("q", "*:*").set("rows", 0)); + if (response.getResults() == null) { + throw new IllegalStateException("remote Solr response has no result list"); + } + System.out.println("Remote Solr numFound=" + response.getResults().getNumFound()); + } finally { + instance.close(); + } + } +} diff --git a/test/java/net/yacy/http/HttpServerBootstrapConfigTest.java b/test/java/net/yacy/http/HttpServerBootstrapConfigTest.java new file mode 100644 index 000000000..7f2f71120 --- /dev/null +++ b/test/java/net/yacy/http/HttpServerBootstrapConfigTest.java @@ -0,0 +1,25 @@ +package net.yacy.http; + +import org.junit.Assert; +import org.junit.Test; + +public class HttpServerBootstrapConfigTest { + + @Test + public void testAcceptorCountIsClamped() { + Assert.assertEquals(1, HttpServerBootstrapConfig.acceptorCountFor(1)); + Assert.assertEquals(1, HttpServerBootstrapConfig.acceptorCountFor(2)); + Assert.assertEquals(2, HttpServerBootstrapConfig.acceptorCountFor(4)); + Assert.assertEquals(4, HttpServerBootstrapConfig.acceptorCountFor(8)); + Assert.assertEquals(4, HttpServerBootstrapConfig.acceptorCountFor(64)); + } + + @Test + public void testFixedConnectorLimits() { + Assert.assertEquals(16_384, HttpServerBootstrapConfig.REQUEST_HEADER_SIZE); + Assert.assertEquals(9_000L, HttpServerBootstrapConfig.CONNECTOR_IDLE_TIMEOUT_MILLIS); + Assert.assertEquals(128, HttpServerBootstrapConfig.ACCEPT_QUEUE_SIZE); + Assert.assertEquals(4_096, HttpServerBootstrapConfig.REQUEST_INFLATE_BUFFER_SIZE); + Assert.assertEquals(-1, HttpServerBootstrapConfig.MAX_FORM_CONTENT_SIZE); + } +} diff --git a/test/java/net/yacy/http/Jetty9LoggingFacadeTest.java b/test/java/net/yacy/http/Jetty9LoggingFacadeTest.java new file mode 100644 index 000000000..bba2b6924 --- /dev/null +++ b/test/java/net/yacy/http/Jetty9LoggingFacadeTest.java @@ -0,0 +1,16 @@ +package net.yacy.http; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jetty.util.log.Log; +import org.junit.Test; + +/** Jetty 9 baseline only; replace this test when Jetty9HttpServerImpl is removed. */ +public class Jetty9LoggingFacadeTest { + + @Test + public void jetty9UsesItsSlf4jFacade() { + assertEquals("org.eclipse.jetty.util.log.Slf4jLog", + Log.getLogger("org.eclipse.jetty.yacy.logging.test").getClass().getName()); + } +} diff --git a/test/java/net/yacy/http/ProxyAccessPolicyTest.java b/test/java/net/yacy/http/ProxyAccessPolicyTest.java new file mode 100644 index 000000000..ce67c6ce3 --- /dev/null +++ b/test/java/net/yacy/http/ProxyAccessPolicyTest.java @@ -0,0 +1,20 @@ +package net.yacy.http; + +import org.junit.Assert; +import org.junit.Test; + +public class ProxyAccessPolicyTest { + + @Test + public void testConfiguredClientPatterns() { + Assert.assertTrue(ProxyAccessPolicy.isClientAllowed("*", "198.51.100.7")); + Assert.assertTrue(ProxyAccessPolicy.isClientAllowed( + "localhost,127\\.0\\.0\\.1,192\\.168\\..*", "127.0.0.1")); + Assert.assertTrue(ProxyAccessPolicy.isClientAllowed( + "localhost,127\\.0\\.0\\.1,192\\.168\\..*", "192.168.2.15")); + Assert.assertFalse(ProxyAccessPolicy.isClientAllowed( + "localhost,127\\.0\\.0\\.1,192\\.168\\..*", "198.51.100.7")); + Assert.assertFalse(ProxyAccessPolicy.isClientAllowed(null, "127.0.0.1")); + Assert.assertFalse(ProxyAccessPolicy.isClientAllowed("127\\.0\\.0\\.1", null)); + } +} diff --git a/test/java/net/yacy/http/Slf4jJulBridgeTest.java b/test/java/net/yacy/http/Slf4jJulBridgeTest.java new file mode 100644 index 000000000..b1448eae6 --- /dev/null +++ b/test/java/net/yacy/http/Slf4jJulBridgeTest.java @@ -0,0 +1,59 @@ +package net.yacy.http; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.junit.Test; +import org.slf4j.LoggerFactory; + +/** Version-neutral contract for the public SLF4J 2 to JUL logging path. */ +public class Slf4jJulBridgeTest { + + @Test + public void publicSlf4jProviderRoutesJettyNamespaceToJul() { + assertEquals("org.slf4j.jul.JDK14LoggerFactory", + LoggerFactory.getILoggerFactory().getClass().getName()); + + final String loggerName = "org.eclipse.jetty.yacy.logging.test"; + final Logger julLogger = Logger.getLogger(loggerName); + final Level previousLevel = julLogger.getLevel(); + final boolean previousUseParentHandlers = julLogger.getUseParentHandlers(); + final AtomicReference<LogRecord> received = new AtomicReference<>(); + final Handler capture = new Handler() { + @Override + public void publish(final LogRecord record) { + received.set(record); + } + + @Override + public void flush() { + } + + @Override + public void close() { + } + }; + + try { + julLogger.setUseParentHandlers(false); + julLogger.setLevel(Level.INFO); + capture.setLevel(Level.ALL); + julLogger.addHandler(capture); + + LoggerFactory.getLogger(loggerName).info("Jetty SLF4J to JUL bridge test"); + + assertTrue("SLF4J log record did not reach java.util.logging", received.get() != null); + assertEquals("Jetty SLF4J to JUL bridge test", received.get().getMessage()); + } finally { + julLogger.removeHandler(capture); + julLogger.setLevel(previousLevel); + julLogger.setUseParentHandlers(previousUseParentHandlers); + } + } +} |
