diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
index 1a9a5e9396fb..3229bcbff6d4 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
@@ -74,6 +74,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jetty.http.tools.matchers.HttpFieldsMatchers.containsHeader;
import static org.eclipse.jetty.http.tools.matchers.HttpFieldsMatchers.containsHeaderValue;
+import static org.eclipse.jetty.http.tools.matchers.HttpFieldsMatchers.headerValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
@@ -881,25 +882,25 @@ public void testWelcomeRedirect() throws Exception
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.html"));
+ assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
createFile(inde, "
Hello Inde
");
rawResponse = connector.getResponse("GET /context/dir HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/"));
+ assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/"));
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.html"));
+ assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
if (deleteFile(index))
{
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.htm"));
+ assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.htm"));
if (deleteFile(inde))
{
@@ -937,20 +938,17 @@ public void testRelativeRedirect() throws Exception
rawResponse = connector.getResponse("GET /context/dir HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "/context/dir/"));
- assertThat(response, not(containsHeaderValue("Location", "http://")));
+ assertThat(response, headerValue("Location", "/context/dir/"));
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "/context/dir/index.html"));
- assertThat(response, not(containsHeaderValue("Location", "http://")));
+ assertThat(response, headerValue("Location", "/context/dir/index.html"));
rawResponse = connector.getResponse("GET /context/dir/index.html/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
- assertThat(response, containsHeaderValue("Location", "/context/dir/index.html"));
- assertThat(response, not(containsHeaderValue("Location", "http://")));
+ assertThat(response, headerValue("Location", "/context/dir/index.html"));
}
/**
diff --git a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsHeaderValue.java b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsHeaderValue.java
index 047926279987..095d9b6c9707 100644
--- a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsHeaderValue.java
+++ b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsHeaderValue.java
@@ -1,22 +1,17 @@
//
-// ========================================================================
-// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
+// ========================================================================
+// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
+// 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.
//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
+// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+// ========================================================================
//
-package org.eclipse.jetty.http.matchers;
+package org.eclipse.jetty.http.tools.matchers;
import java.util.Objects;
diff --git a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsMatchers.java b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsMatchers.java
index 2a0a6ff3e9d1..93c56cf10736 100644
--- a/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsMatchers.java
+++ b/tests/jetty-http-tools/src/main/java/org/eclipse/jetty/http/tools/matchers/HttpFieldsMatchers.java
@@ -29,6 +29,11 @@ public static Matcher containsHeader(HttpHeader header)
return new HttpFieldsContainsHeaderKey(header);
}
+ public static Matcher headerValue(String keyName, String value)
+ {
+ return new HttpFieldsHeaderValue(keyName, value);
+ }
+
public static Matcher containsHeaderValue(String keyName, String value)
{
return new HttpFieldsContainsHeaderValue(keyName, value);