Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to #10832
- Loading branch information
Showing
4 changed files
with
179 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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.remote; | ||
|
||
public class Status { | ||
private final boolean ready; | ||
private final String message; | ||
|
||
public Status(boolean ready, String message) { | ||
this.ready = ready; | ||
this.message = message; | ||
} | ||
|
||
public boolean isReady() { | ||
return ready; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
java/test/org/openqa/selenium/grid/router/RemoteWebDriverStatusTest.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,47 @@ | ||
// 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.grid.router; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.grid.config.TomlConfig; | ||
import org.openqa.selenium.grid.router.DeploymentTypes.Deployment; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
import org.openqa.selenium.remote.Status; | ||
import org.openqa.selenium.testing.drivers.Browser; | ||
|
||
import java.io.StringReader; | ||
|
||
class RemoteWebDriverStatusTest { | ||
|
||
@Test | ||
void shouldBeAbleToGetRemoteEndStatus() { | ||
Browser browser = Browser.FIREFOX; | ||
|
||
Deployment deployment = DeploymentTypes.STANDALONE.start( | ||
browser.getCapabilities(), | ||
new TomlConfig(new StringReader( | ||
"[node]\n" + | ||
"driver-implementation = " + browser.displayName()))); | ||
|
||
Status status = RemoteWebDriver.status(deployment.getServer().getUrl()); | ||
assertThat(status.isReady()).isTrue(); | ||
assertThat(status.getMessage()).isEqualTo("Selenium Grid ready."); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
java/test/org/openqa/selenium/remote/WebDriverStatusTest.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,76 @@ | ||
// 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.remote; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.firefox.FirefoxDriver; | ||
import org.openqa.selenium.remote.service.DriverService; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.net.URI; | ||
import java.net.URL; | ||
|
||
@Tag("UnitTests") | ||
public class WebDriverStatusTest { | ||
|
||
@Test | ||
public void shouldGetStatusForWebDriverInstance() throws IOException { | ||
URI uri = URI.create("http://localhost:9898"); | ||
URL url = uri.toURL(); | ||
|
||
DriverService service = new FakeDriverService() { | ||
@Override | ||
public URL getUrl() { | ||
return url; | ||
} | ||
}; | ||
|
||
assertThrows(UncheckedIOException.class, | ||
() -> FirefoxDriver.status(service.getUrl())); | ||
} | ||
|
||
private static class FakeDriverService extends DriverService { | ||
|
||
private boolean started; | ||
|
||
FakeDriverService() throws IOException { | ||
super(new File("."), 0, DEFAULT_TIMEOUT, null, null); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
started = true; | ||
} | ||
|
||
@Override | ||
public boolean isRunning() { | ||
return started; | ||
} | ||
|
||
@Override | ||
protected void waitUntilAvailable() { | ||
// return immediately | ||
} | ||
} | ||
} |