Skip to content

Commit ba5d859

Browse files
committed
Merge pull request GoogleCloudPlatform#23 from GoogleCloudPlatform/monitoring
Java main args don't include the command name.
2 parents 9f976bf + f314892 commit ba5d859

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

monitoring/src/main/java/CloudMonitoringAuthSample.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ private static CloudMonitoring authenticate()
8080
* @throws Exception if something goes wrong.
8181
*/
8282
public static void main(final String[] args) throws Exception {
83-
if (args.length != 2) {
84-
System.err.println(String.format("Usage: %s <project-name>", args[0]));
83+
if (args.length != 1) {
84+
System.err.println(String.format("Usage: %s <project-name>",
85+
CloudMonitoringAuthSample.class.getSimpleName()));
8586
return;
8687
}
8788

88-
String project = args[1];
89+
String project = args[0];
8990

9091
// Create an authorized API client
9192
CloudMonitoring cloudmonitoring = authenticate();

monitoring/src/test/java/CloudMonitoringAuthSampleTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public void tearDown() {
4848

4949
@Test
5050
public void testUsage() throws Exception {
51-
CloudMonitoringAuthSample.main(new String[] { "command-name" });
52-
assertEquals("Usage: command-name <project-name>\n", stderr.toString());
51+
CloudMonitoringAuthSample.main(new String[] { });
52+
assertEquals("Usage: CloudMonitoringAuthSample <project-name>\n", stderr.toString());
5353
}
5454

5555
@Test
5656
public void testListTimeSeries() throws Exception {
57-
CloudMonitoringAuthSample.main(new String[] { "", "cloud-samples-tests" });
57+
CloudMonitoringAuthSample.main(new String[] { "cloud-samples-tests" });
5858
String out = stdout.toString();
5959
assertThat(out, containsPattern("Timeseries.list raw response:"));
6060
assertThat(out, containsPattern("\\{\\s*\"kind\" *: *\"cloudmonitoring#listTimeseriesResponse\","));

0 commit comments

Comments
 (0)