* Issue #11573 - add new disable-urlcache.mod * Issue #11573 - Adding new testcase * Remove old tests * Prevent overlapping unzip("jetty-home.jar") errors
This commit is contained in:
parent
ea7982732f
commit
907f2001ff
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.ee10</groupId>
|
||||
<artifactId>jetty-ee10-tests</artifactId>
|
||||
<version>12.0.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jetty-ee10-test-log4j2-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>EE10 :: Tests :: Log4j2 WebApp</name>
|
||||
|
||||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.log4j2</bundle-symbolic-name>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.ee10.log4j2;
|
||||
|
||||
import jakarta.servlet.ServletContextEvent;
|
||||
import jakarta.servlet.ServletContextListener;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogContextListener implements ServletContextListener
|
||||
{
|
||||
private static final Logger LOG = LogManager.getLogger(LogContextListener.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce)
|
||||
{
|
||||
LOG.info("contextInitialized(): {}", sce);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce)
|
||||
{
|
||||
LOG.info("contextDestroyed(): {}", sce);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.ee10.log4j2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogServlet extends HttpServlet
|
||||
{
|
||||
private static final Logger LOG = LogManager.getLogger(LogServlet.class);
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
LOG.info("#### init()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
|
||||
{
|
||||
LOG.info("doGet() req={}", req);
|
||||
|
||||
resp.setCharacterEncoding("utf-8");
|
||||
resp.setContentType("text/plain");
|
||||
|
||||
resp.getWriter().println("GET at " + this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS}:%-5level:%logger:%t: %msg%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
|
||||
version="6.0">
|
||||
<servlet>
|
||||
<servlet-name>logservlet</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.ee10.log4j2.LogServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>logservlet</servlet-name>
|
||||
<url-pattern>/log/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.eclipse.jetty.ee10.log4j2.LogContextListener</listener-class>
|
||||
</listener>
|
||||
</web-app>
|
|
@ -24,6 +24,7 @@
|
|||
<module>jetty-ee10-test-jersey</module>
|
||||
<module>jetty-ee10-test-jmx</module>
|
||||
<module>jetty-ee10-test-jndi</module>
|
||||
<module>jetty-ee10-test-log4j2-webapp</module>
|
||||
<module>jetty-ee10-test-loginservice</module>
|
||||
<module>jetty-ee10-test-openid-webapp</module>
|
||||
<module>jetty-ee10-test-owb-cdi-webapp</module>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
|
||||
<Configure>
|
||||
<Call class="java.net.URLConnection" name="setDefaultUseCaches">
|
||||
<Arg>jar</Arg>
|
||||
<Arg type="boolean">false</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -0,0 +1,15 @@
|
|||
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
|
||||
|
||||
[description]
|
||||
A module that will disable java.net.URL internal cache of `jar` protocol URLs.
|
||||
This will allow hot reload of webapps on systems that are sensitive
|
||||
to file locks, like Microsoft Windows.
|
||||
|
||||
[tags]
|
||||
classpath
|
||||
|
||||
[before]
|
||||
server
|
||||
|
||||
[xml]
|
||||
etc/disable-urlcache.xml
|
|
@ -0,0 +1,120 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.ee10.tests.distribution;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.client.ContentResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest;
|
||||
import org.eclipse.jetty.tests.testers.JettyHomeTester;
|
||||
import org.eclipse.jetty.tests.testers.Tester;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.parallel.Isolated;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Isolated
|
||||
public class DisableUrlCacheTest extends AbstractJettyHomeTest
|
||||
{
|
||||
@Test
|
||||
public void testReloadWebAppWithLog4j2() throws Exception
|
||||
{
|
||||
Path jettyBase = newTestJettyBaseDirectory();
|
||||
String jettyVersion = System.getProperty("jettyVersion");
|
||||
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
|
||||
.jettyVersion(jettyVersion)
|
||||
.jettyBase(jettyBase)
|
||||
.build();
|
||||
|
||||
String[] setupArgs = {
|
||||
"--add-to-start=http,ee10-webapp,ee10-deploy,disable-urlcache"
|
||||
};
|
||||
|
||||
try (JettyHomeTester.Run setupRun = distribution.start(setupArgs))
|
||||
{
|
||||
assertTrue(setupRun.awaitFor(START_TIMEOUT, TimeUnit.SECONDS));
|
||||
assertEquals(0, setupRun.getExitValue());
|
||||
|
||||
Path webApp = distribution.resolveArtifact("org.eclipse.jetty.ee10:jetty-ee10-test-log4j2-webapp:war:" + jettyVersion);
|
||||
Path testWebApp = distribution.getJettyBase().resolve("webapps/test.war");
|
||||
|
||||
Files.copy(webApp, testWebApp);
|
||||
|
||||
Path tempDir = distribution.getJettyBase().resolve("work");
|
||||
FS.ensureEmpty(tempDir);
|
||||
|
||||
Path webappsDir = distribution.getJettyBase().resolve("webapps");
|
||||
String warXml = """
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
<Configure class="org.eclipse.jetty.ee10.webapp.WebAppContext">
|
||||
<Set name="contextPath">/test</Set>
|
||||
<Set name="war"><Property name="jetty.webapps"/>/test.war</Set>
|
||||
<Set name="tempDirectory"><Property name="jetty.base"/>/work/test</Set>
|
||||
<Set name="tempDirectoryPersistent">false</Set>
|
||||
</Configure>
|
||||
""";
|
||||
Path warXmlPath = webappsDir.resolve("test.xml");
|
||||
Files.writeString(warXmlPath, warXml, StandardCharsets.UTF_8);
|
||||
|
||||
int port = Tester.freePort();
|
||||
String[] runArgs = {
|
||||
"jetty.http.port=" + port,
|
||||
"jetty.deploy.scanInterval=1"
|
||||
//"jetty.server.dumpAfterStart=true",
|
||||
};
|
||||
try (JettyHomeTester.Run run2 = distribution.start(runArgs))
|
||||
{
|
||||
assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS));
|
||||
startHttpClient(false);
|
||||
|
||||
// Test webapp is there
|
||||
ContentResponse response = client.GET("http://localhost:" + port + "/test/log/");
|
||||
assertThat(response.getStatus(), is(HttpStatus.OK_200));
|
||||
String content = response.getContentAsString();
|
||||
assertThat(content, containsString("GET at LogServlet"));
|
||||
|
||||
// Trigger a hot-reload
|
||||
run2.getLogs().clear();
|
||||
touch(warXmlPath);
|
||||
|
||||
// Wait for reload
|
||||
assertTrue(run2.awaitConsoleLogsFor("Started oeje10w.WebAppContext@", START_TIMEOUT, TimeUnit.SECONDS));
|
||||
|
||||
// Is webapp still there?
|
||||
response = client.GET("http://localhost:" + port + "/test/log/");
|
||||
assertThat(response.getStatus(), is(HttpStatus.OK_200));
|
||||
content = response.getContentAsString();
|
||||
assertThat(content, containsString("GET at LogServlet"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void touch(Path path) throws IOException
|
||||
{
|
||||
FileTime now = FileTime.fromMillis(System.currentTimeMillis() + 2000);
|
||||
Files.setLastModifiedTime(path, now);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest;
|
|||
import org.eclipse.jetty.tests.testers.JettyHomeTester;
|
||||
import org.eclipse.jetty.tests.testers.Tester;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.parallel.Isolated;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -30,6 +31,7 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Isolated
|
||||
public class OpenIdTests extends AbstractJettyHomeTest
|
||||
{
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue