Skip to content

Commit

Permalink
Merge remote-tracking branch 'eclipse/jetty-10.0.x' into jetty-10.0.x…
Browse files Browse the repository at this point in the history
…-configuration-refactor

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed May 22, 2019
2 parents 5f62e0f + d370384 commit d6c68c4
Show file tree
Hide file tree
Showing 124 changed files with 2,771 additions and 1,991 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bin/
*.backup
*.debug
*.dump
.attach_pid*

# vim
.*.sw[a-p]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void service(HttpServletRequest req, HttpServletResponse resp) throws Ser
*/
private String addPaths(String servletPath, String pathInfo)
{
if (servletPath.length()==0)
if (servletPath.isEmpty())
return pathInfo;

if (pathInfo==null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void handle( String target,
ServletException
{
Map<String, String[]> params = request.getParameterMap();
if (params.size() > 0)
if (!params.isEmpty())
{
response.setContentType("text/plain");
response.getWriter().println(JSON.toString(params));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// 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.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// 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.
// ========================================================================
//

package org.eclipse.jetty.cdi.core;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Unit tests for class {@link NamedLiteral}.
*
* @see NamedLiteral
*/
public class NamedLiteralTest
{

@Test
public void testCreatesNamedLiteralWithNull()
{
assertEquals("", new NamedLiteral(null).value());
}

@Test
public void testGetValue()
{
assertEquals("a b", new NamedLiteral("a b").value());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.AuthenticationStore;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.B64Code;

/**
* Implementation of the HTTP "Basic" authentication defined in RFC 2617.
Expand Down Expand Up @@ -91,7 +91,8 @@ public BasicResult(URI uri, HttpHeader header, String user, String password)
{
this.uri = uri;
this.header = header;
this.value = "Basic " + B64Code.encode(user + ":" + password, StandardCharsets.ISO_8859_1);
byte[] authBytes = (user + ":" + password).getBytes(StandardCharsets.ISO_8859_1);
this.value = "Basic " + Base64.getEncoder().encodeToString(authBytes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -35,7 +35,6 @@
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.B64Code;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;

Expand Down Expand Up @@ -82,7 +81,7 @@ public void testProxyAuthentication(Scenario scenario) throws Exception
{
final String user = "foo";
final String password = "bar";
final String credentials = B64Code.encode(user + ":" + password, StandardCharsets.ISO_8859_1);
final String credentials = Base64.getEncoder().encodeToString((user + ":" + password).getBytes(StandardCharsets.ISO_8859_1));
final String serverHost = "server";
final String realm = "test_realm";
final int status = HttpStatus.NO_CONTENT_204;
Expand Down Expand Up @@ -162,7 +161,7 @@ public void testProxyAuthenticationWithRedirect(Scenario scenario) throws Except
{
String user = "foo";
String password = "bar";
String credentials = B64Code.encode(user + ":" + password, StandardCharsets.ISO_8859_1);
String credentials = Base64.getEncoder().encodeToString((user + ":" + password).getBytes(StandardCharsets.ISO_8859_1));
String proxyHost = "localhost";
String serverHost = "server";
int serverPort = HttpScheme.HTTP.is(scenario.getScheme()) ? 80 : 443;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void processField(HttpField field)
public void onRequest()
{
String uri = path;
if (query != null && query.length() > 0)
if (query != null && !query.isEmpty())
uri += "?" + query;
// TODO https?
onRequest(new MetaData.Request(method, HttpScheme.HTTP.asString(), hostPort, uri, HttpVersion.fromString(version), fields,Long.MIN_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.eclipse.jetty.util.HostPort;



/* ------------------------------------------------------------ */
/**
* A HttpField holding a preparsed Host and port number
* @see HostPort
*/
public class HostPortHttpField extends HttpField
{
Expand All @@ -35,7 +35,6 @@ public HostPortHttpField(String authority)
this(HttpHeader.HOST,HttpHeader.HOST.asString(),authority);
}

/* ------------------------------------------------------------ */
protected HostPortHttpField(HttpHeader header, String name, String authority)
{
super(header,name,authority);
Expand All @@ -49,7 +48,17 @@ protected HostPortHttpField(HttpHeader header, String name, String authority)
}
}

/* ------------------------------------------------------------ */
public HostPortHttpField(String host, int port)
{
this(new HostPort(host, port));
}

public HostPortHttpField(HostPort hostport)
{
super(HttpHeader.HOST,HttpHeader.HOST.asString(),hostport.toString());
_hostPort = hostport;
}

/** Get the host.
* @return the host
*/
Expand All @@ -58,7 +67,6 @@ public String getHost()
return _hostPort.getHost();
}

/* ------------------------------------------------------------ */
/** Get the port.
* @return the port
*/
Expand All @@ -67,7 +75,6 @@ public int getPort()
return _hostPort.getPort();
}

/* ------------------------------------------------------------ */
/** Get the port.
* @param defaultPort The default port to return if no port set
* @return the port
Expand All @@ -76,4 +83,9 @@ public int getPort(int defaultPort)
{
return _hostPort.getPort(defaultPort);
}

public HostPort getHostPort()
{
return _hostPort;
}
}
Loading

0 comments on commit d6c68c4

Please sign in to comment.