-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #5357 - Fixing demo /proxy/ url to use https://eclipse.org... p…
…roperly Signed-off-by: Joakim Erdfelt <[email protected]>
- Loading branch information
Showing
6 changed files
with
146 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...s/test-proxy-webapp/src/main/java/org/eclipse/jetty/demos/EclipseJavadocProxyServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2020 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. | ||
// | ||
// 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.demos; | ||
|
||
import org.eclipse.jetty.client.HttpClient; | ||
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; | ||
import org.eclipse.jetty.proxy.ProxyServlet; | ||
import org.eclipse.jetty.util.ssl.SslContextFactory; | ||
|
||
/** | ||
* Transparent Proxy to Eclipse hosted Javadoc | ||
*/ | ||
public class EclipseJavadocProxyServlet extends ProxyServlet.Transparent | ||
{ | ||
@Override | ||
protected HttpClient newHttpClient() | ||
{ | ||
int selectorCount = 1; | ||
HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP(selectorCount); | ||
SslContextFactory.Client clientSsl = new SslContextFactory.Client(); | ||
return new HttpClient(transport, clientSsl); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...pps/test-proxy-webapp/src/test/java/org/eclipse/jetty/EclipseJavadocProxyServletTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2020 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. | ||
// | ||
// 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; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import org.eclipse.jetty.client.HttpClient; | ||
import org.eclipse.jetty.client.api.ContentResponse; | ||
import org.eclipse.jetty.http.HttpStatus; | ||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.server.ServerConnector; | ||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; | ||
import org.eclipse.jetty.util.component.LifeCycle; | ||
import org.eclipse.jetty.util.resource.PathResource; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class EclipseJavadocProxyServletTest | ||
{ | ||
private Server server; | ||
private HttpClient client; | ||
|
||
@BeforeEach | ||
public void setup() throws Exception | ||
{ | ||
server = new Server(); | ||
|
||
ServerConnector connector = new ServerConnector(server); | ||
connector.setPort(0); | ||
server.addConnector(connector); | ||
|
||
WebAppContext webapp = new WebAppContext(); | ||
// This is a pieced together WebApp. | ||
// We don't have a valid WEB-INF/lib to rely on at this point. | ||
// So, open up server classes here, for purposes of this testcase. | ||
webapp.getServerClasspathPattern().add( | ||
"-org.eclipse.jetty.proxy.", | ||
"-org.eclipse.jetty.client.", | ||
"-org.eclipse.jetty.util.ssl."); | ||
webapp.getSystemClasspathPattern().add( | ||
"org.eclipse.jetty.proxy.", | ||
"org.eclipse.jetty.client.", | ||
"org.eclipse.jetty.util.ss."); | ||
webapp.setBaseResource(new PathResource(MavenTestingUtils.getProjectDirPath("src/main/webapp"))); | ||
webapp.setExtraClasspath(MavenTestingUtils.getTargetPath().resolve("classes").toString()); | ||
server.setHandler(webapp); | ||
|
||
server.start(); | ||
|
||
client = new HttpClient(); | ||
client.start(); | ||
} | ||
|
||
@AfterEach | ||
public void teardown() | ||
{ | ||
LifeCycle.stop(client); | ||
LifeCycle.stop(server); | ||
} | ||
|
||
@Test | ||
@Tag("external") | ||
public void testProxyRequest() throws InterruptedException, ExecutionException, TimeoutException | ||
{ | ||
ContentResponse response = client.newRequest(server.getURI().resolve("/proxy/current/")) | ||
.followRedirects(false) | ||
.send(); | ||
|
||
assertThat("response status", response.getStatus(), is(HttpStatus.OK_200)); | ||
} | ||
} |
135 changes: 0 additions & 135 deletions
135
...webapps/test-proxy-webapp/src/test/java/org/eclipse/jetty/TestTransparentProxyServer.java
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
tests/test-webapps/test-proxy-webapp/src/test/resources/jetty-logging.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog | ||
#org.eclipse.jetty.LEVEL=WARN | ||
#org.eclipse.jetty.client.LEVEL=DEBUG | ||
#org.eclipse.jetty.http.LEVEL=DEBUG | ||
#org.eclipse.jetty.proxy.LEVEL=DEBUG |