Skip to content

Commit 3047aa7

Browse files
committed
Breaking another dependency of Grid on RC server
1 parent 7c99758 commit 3047aa7

File tree

7 files changed

+72
-6
lines changed

7 files changed

+72
-6
lines changed

java/server/src/org/openqa/grid/build.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ java_library(name = "grid",
1010
deps = [
1111
"//java/client/src/org/openqa/selenium:webdriver-api",
1212
"//java/server/src/org/openqa/grid/common",
13+
"//java/server/src/org/openqa/selenium/server:base",
1314
"//third_party/java/httpcomponents:httpclient",
1415
"//third_party/java/guava-libraries",
1516
"//third_party/java/jcip_annotations",

java/server/src/org/openqa/grid/common/BUCK

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ java_library(name = 'common',
55
'//java/client/src/org/openqa/selenium:platform',
66
'//java/client/src/org/openqa/selenium/net:net',
77
'//java/client/src/org/openqa/selenium/remote:remote',
8-
'//java/server/src/org/openqa/selenium/server:server',
8+
'//java/server/src/org/openqa/selenium/server:shared',
99
'//third_party/java/gson:gson',
1010
'//third_party/java/guava-libraries:guava-libraries',
1111
],

java/server/src/org/openqa/grid/common/GridDocHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.google.gson.JsonIOException;
2323
import com.google.gson.JsonParser;
2424

25-
import org.openqa.selenium.server.cli.RemoteControlLauncher;
25+
import org.openqa.selenium.server.shared.CliUtils;
2626

2727
import java.io.InputStream;
2828
import java.io.InputStreamReader;
@@ -44,7 +44,7 @@ public static void printHubHelp(String msg) {
4444

4545
public static void printHubHelp(String msg, boolean error) {
4646
printHelpInConsole(msg, "hub", hubOptions, error);
47-
RemoteControlLauncher.printWrappedLine(
47+
CliUtils.printWrappedLine(
4848
"",
4949
"This synopsis lists options available in hub role only. To get help on the command line options available for other roles run the server with -help name and the corresponding -role name value.");
5050
}
@@ -55,7 +55,7 @@ public static void printNodeHelp(String msg) {
5555

5656
public static void printNodeHelp(String msg, boolean error) {
5757
printHelpInConsole(msg, "node", nodeOptions, error);
58-
RemoteControlLauncher.printWrappedLine(
58+
CliUtils.printWrappedLine(
5959
"",
6060
"This synopsis lists options available in node role only. To get help on the command line options available for other roles run the server with -help name and the corresponding -role name value.");
6161
}
@@ -90,7 +90,7 @@ private static void printHelpInConsole(String msg, String role, List<Option> opt
9090
System.out.println("Usage: java -jar selenium-server.jar -role " + role + " [options]\n");
9191
for (Option option : options) {
9292
System.out.println(indent + "-" + option.name + ":");
93-
RemoteControlLauncher.printWrappedLine(System.out, indent2x, option.description, true);
93+
CliUtils.printWrappedLine(System.out, indent2x, option.description, true);
9494
System.out.println("");
9595
}
9696
}

java/server/src/org/openqa/grid/common/build.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ java_library(name = "common",
77
deps = [
88
"//java/client/src/org/openqa/selenium/net",
99
"//java/client/src/org/openqa/selenium/remote:common",
10-
"//java/server/src/org/openqa/selenium/server:base",
10+
"//java/server/src/org/openqa/selenium/server:shared",
1111
"//third_party/java/guava-libraries",
1212
])

java/server/src/org/openqa/selenium/server/BUCK

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ java_library(name = 'server',
3838
],
3939
)
4040

41+
java_library(name = 'shared',
42+
srcs = glob(['shared/*.java']),
43+
visibility = [
44+
'//java/server/src/org/openqa/grid/common:common',
45+
],
46+
)
47+
4148
prebuilt_jar(name = 'selenium-core',
4249
binary_jar = '//javascript/selenium-core:selenium-core',
4350
)

java/server/src/org/openqa/selenium/server/build.desc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ java_library(name = "base",
6161
"//third_party/java/servlet:servlet-api"
6262
])
6363

64+
java_library(name = "shared",
65+
srcs = [
66+
"shared/*.java",
67+
])
68+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.server.shared;
19+
20+
import java.io.File;
21+
import java.io.PrintStream;
22+
23+
/**
24+
* CLI utility methods shared among RC and WebDriver server implementations.
25+
*/
26+
public class CliUtils {
27+
28+
public static void printWrappedLine(String prefix, String msg) {
29+
printWrappedLine(System.out, prefix, msg, true);
30+
}
31+
32+
public static void printWrappedLine(PrintStream output, String prefix, String msg, boolean first) {
33+
output.print(prefix);
34+
if (!first) {
35+
output.print(" ");
36+
}
37+
int defaultWrap = 70;
38+
int wrap = defaultWrap - prefix.length();
39+
if (wrap > msg.length()) {
40+
output.println(msg);
41+
return;
42+
}
43+
String lineRaw = msg.substring(0, wrap);
44+
int spaceIndex = lineRaw.lastIndexOf(' ');
45+
if (spaceIndex == -1) {
46+
spaceIndex = lineRaw.length();
47+
}
48+
String line = lineRaw.substring(0, spaceIndex);
49+
output.println(line);
50+
printWrappedLine(output, prefix, msg.substring(spaceIndex + 1), false);
51+
}
52+
53+
}

0 commit comments

Comments
 (0)