-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a jre-based app server for testing
Eventually, the goal is to untangle ourselves from Jetty entirely. The first step is to start replacing the test usages with something that doesn't depend on a third party library. Fortunately, since java 6 both OpenJDK and the Oracle JDK have shipped with an HTTP server as part of their own APIs. This has been exposed via a JPMS module, and so it should be safe to rely on since I don't think any of the developers use the IBM JDK for development work.
- Loading branch information
Showing
14 changed files
with
801 additions
and
33 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
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
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
41 changes: 41 additions & 0 deletions
41
java/client/test/org/openqa/selenium/environment/webserver/EncodingHandler.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,41 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.environment.webserver; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_16LE; | ||
|
||
import org.openqa.selenium.remote.http.HttpRequest; | ||
import org.openqa.selenium.remote.http.HttpResponse; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class EncodingHandler implements BiConsumer<HttpRequest, HttpResponse> { | ||
|
||
@Override | ||
public void accept(HttpRequest request, HttpResponse response) { | ||
// Data should be transferred using UTF-8. Pick a different encoding | ||
response.setHeader("Content-Type", "text/html;charset=UTF-16LE"); | ||
|
||
StringBuilder text = new StringBuilder("<html><title>Character encoding (UTF 16)</title>") | ||
.append("<body><p id='text'>") | ||
.append("\u05E9\u05DC\u05D5\u05DD") // "Shalom" | ||
.append("</p></body></html>"); | ||
|
||
response.setContent(text.toString().getBytes(UTF_16LE)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
java/client/test/org/openqa/selenium/environment/webserver/JettyAppServerTest.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,26 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.environment.webserver; | ||
|
||
public class JettyAppServerTest extends AppServerTestBase { | ||
|
||
@Override | ||
protected AppServer createAppServer() { | ||
return new JettyAppServer(); | ||
} | ||
} |
Oops, something went wrong.