Fixing windows build/test issues.

This commit is contained in:
Joakim Erdfelt 2020-10-16 13:54:27 -05:00
parent 91f4516ec2
commit 97f795160c
5 changed files with 33 additions and 17 deletions

View File

@ -38,8 +38,8 @@ import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.ajax.JSON;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@ -57,12 +57,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class ErrorHandlerTest
{
static StacklessLogging stacklessLogging;
static Server server;
static LocalConnector connector;
StacklessLogging stacklessLogging;
Server server;
LocalConnector connector;
@BeforeAll
public static void before() throws Exception
@BeforeEach
public void before() throws Exception
{
stacklessLogging = new StacklessLogging(HttpChannel.class);
server = new Server();
@ -134,8 +134,8 @@ public class ErrorHandlerTest
server.start();
}
@AfterAll
public static void after() throws Exception
@AfterEach
public void after() throws Exception
{
server.stop();
stacklessLogging.close();
@ -183,11 +183,21 @@ public class ErrorHandlerTest
"\r\n");
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
dump(response);
assertThat("Response status code", response.getStatus(), is(404));
assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), is(0));
assertThat("Response Content-Type", response.getField(HttpHeader.CONTENT_TYPE), is(nullValue()));
}
private void dump(HttpTester.Response response)
{
System.out.println("-------------");
System.out.println(response);
System.out.println(response.getContent());
System.out.println();
}
@Test
public void test404AllAccept() throws Exception
{
@ -291,6 +301,8 @@ public class ErrorHandlerTest
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
// System.out.println("response: " + response);
assertThat("Response status code", response.getStatus(), is(404));
assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0));
assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=ISO-8859-1"));
@ -454,6 +466,8 @@ public class ErrorHandlerTest
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
System.out.println("response: " + response);
assertThat("Response status code", response.getStatus(), is(500));
assertThat("Response Content-Length", response.getField(HttpHeader.CONTENT_LENGTH).getIntValue(), greaterThan(0));
assertThat("Response Content-Type", response.get(HttpHeader.CONTENT_TYPE), containsString("text/html;charset=UTF-8"));

View File

@ -1,5 +1,6 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
#org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.server.LEVEL=DEBUG
#org.eclipse.jetty.servlet.LEVEL=DEBUG
#org.eclipse.jetty.server.ConnectionLimit.LEVEL=DEBUG
#org.eclipse.jetty.server.AcceptRateLimit.LEVEL=DEBUG

View File

@ -188,7 +188,7 @@ public class FileSystemResourceTest
final URI alias = ritem.getAlias();
if (alias == null)
{
return ritem == null;
return resource.getAlias() == null;
}
else
{

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.util.ssl;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -260,7 +261,7 @@ public class SslContextFactoryTest
cf.setTrustStorePath("/foo");
cf.start();
});
assertThat(x.getMessage(), equalTo("/foo is not a valid keystore"));
assertThat(x.getMessage(), containsString(File.separator + "foo is not a valid keystore"));
}
}

View File

@ -327,13 +327,13 @@ public class WebAppContextTest
extLibs = extLibs.toAbsolutePath();
// Absolute reference with trailing slash and glob
references.add(Arguments.of(extLibs.toString() + File.separator + "*"));
references.add(Arguments.of("absolute extLibs with glob", extLibs.toString() + File.separator + "*"));
// Establish a relative extraClassPath reference
String relativeExtLibsDir = MavenTestingUtils.getBasePath().relativize(extLibs).toString();
// This will be in the String form similar to "src/test/resources/ext/*" (with trailing slash and glob)
references.add(Arguments.of(relativeExtLibsDir + File.separator + "*"));
references.add(Arguments.of("relative extLibs with glob", relativeExtLibsDir + File.separator + "*"));
return references.stream();
}
@ -341,9 +341,9 @@ public class WebAppContextTest
/**
* Test using WebAppContext.setExtraClassPath(String) with a reference to a glob
*/
@ParameterizedTest
@ParameterizedTest(name = "{0}")
@MethodSource("extraClasspathGlob")
public void testExtraClasspathGlob(String extraClasspathGlobReference) throws Exception
public void testExtraClasspathGlob(String description, String extraClasspathGlobReference) throws Exception
{
Server server = newServer();
@ -374,7 +374,7 @@ public class WebAppContextTest
{
actualPaths.add(Paths.get(url.toURI()));
}
assertThat("WebAppClassLoader.urls.length", actualPaths.size(), is(expectedPaths.size()));
assertThat("[" + description + "] WebAppClassLoader.urls.length", actualPaths.size(), is(expectedPaths.size()));
for (Path expectedPath : expectedPaths)
{
boolean found = false;
@ -385,7 +385,7 @@ public class WebAppContextTest
found = true;
}
}
assertTrue(found, "Not able to find expected jar in WebAppClassLoader: " + expectedPath);
assertTrue(found, "[" + description + "] Not able to find expected jar in WebAppClassLoader: " + expectedPath);
}
}