Skip to content

Commit

Permalink
Breaking another dependency of Grid on RC server
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Oct 13, 2015
1 parent 7c99758 commit 3047aa7
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
1 change: 1 addition & 0 deletions java/server/src/org/openqa/grid/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ java_library(name = "grid",
deps = [
"//java/client/src/org/openqa/selenium:webdriver-api",
"//java/server/src/org/openqa/grid/common",
"//java/server/src/org/openqa/selenium/server:base",
"//third_party/java/httpcomponents:httpclient",
"//third_party/java/guava-libraries",
"//third_party/java/jcip_annotations",
Expand Down
2 changes: 1 addition & 1 deletion java/server/src/org/openqa/grid/common/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ java_library(name = 'common',
'//java/client/src/org/openqa/selenium:platform',
'//java/client/src/org/openqa/selenium/net:net',
'//java/client/src/org/openqa/selenium/remote:remote',
'//java/server/src/org/openqa/selenium/server:server',
'//java/server/src/org/openqa/selenium/server:shared',
'//third_party/java/gson:gson',
'//third_party/java/guava-libraries:guava-libraries',
],
Expand Down
8 changes: 4 additions & 4 deletions java/server/src/org/openqa/grid/common/GridDocHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.gson.JsonIOException;
import com.google.gson.JsonParser;

import org.openqa.selenium.server.cli.RemoteControlLauncher;
import org.openqa.selenium.server.shared.CliUtils;

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

public static void printHubHelp(String msg, boolean error) {
printHelpInConsole(msg, "hub", hubOptions, error);
RemoteControlLauncher.printWrappedLine(
CliUtils.printWrappedLine(
"",
"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.");
}
Expand All @@ -55,7 +55,7 @@ public static void printNodeHelp(String msg) {

public static void printNodeHelp(String msg, boolean error) {
printHelpInConsole(msg, "node", nodeOptions, error);
RemoteControlLauncher.printWrappedLine(
CliUtils.printWrappedLine(
"",
"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.");
}
Expand Down Expand Up @@ -90,7 +90,7 @@ private static void printHelpInConsole(String msg, String role, List<Option> opt
System.out.println("Usage: java -jar selenium-server.jar -role " + role + " [options]\n");
for (Option option : options) {
System.out.println(indent + "-" + option.name + ":");
RemoteControlLauncher.printWrappedLine(System.out, indent2x, option.description, true);
CliUtils.printWrappedLine(System.out, indent2x, option.description, true);
System.out.println("");
}
}
Expand Down
2 changes: 1 addition & 1 deletion java/server/src/org/openqa/grid/common/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ java_library(name = "common",
deps = [
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/remote:common",
"//java/server/src/org/openqa/selenium/server:base",
"//java/server/src/org/openqa/selenium/server:shared",
"//third_party/java/guava-libraries",
])
7 changes: 7 additions & 0 deletions java/server/src/org/openqa/selenium/server/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ java_library(name = 'server',
],
)

java_library(name = 'shared',
srcs = glob(['shared/*.java']),
visibility = [
'//java/server/src/org/openqa/grid/common:common',
],
)

prebuilt_jar(name = 'selenium-core',
binary_jar = '//javascript/selenium-core:selenium-core',
)
Expand Down
5 changes: 5 additions & 0 deletions java/server/src/org/openqa/selenium/server/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ java_library(name = "base",
"//third_party/java/servlet:servlet-api"
])

java_library(name = "shared",
srcs = [
"shared/*.java",
])

53 changes: 53 additions & 0 deletions java/server/src/org/openqa/selenium/server/shared/CliUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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.server.shared;

import java.io.File;
import java.io.PrintStream;

/**
* CLI utility methods shared among RC and WebDriver server implementations.
*/
public class CliUtils {

public static void printWrappedLine(String prefix, String msg) {
printWrappedLine(System.out, prefix, msg, true);
}

public static void printWrappedLine(PrintStream output, String prefix, String msg, boolean first) {
output.print(prefix);
if (!first) {
output.print(" ");
}
int defaultWrap = 70;
int wrap = defaultWrap - prefix.length();
if (wrap > msg.length()) {
output.println(msg);
return;
}
String lineRaw = msg.substring(0, wrap);
int spaceIndex = lineRaw.lastIndexOf(' ');
if (spaceIndex == -1) {
spaceIndex = lineRaw.length();
}
String line = lineRaw.substring(0, spaceIndex);
output.println(line);
printWrappedLine(output, prefix, msg.substring(spaceIndex + 1), false);
}

}

0 comments on commit 3047aa7

Please sign in to comment.