Skip to content

Commit

Permalink
Merge pull request #23 from GoogleCloudPlatform/monitoring
Browse files Browse the repository at this point in the history
Java main args don't include the command name.
  • Loading branch information
jerjou committed Jul 23, 2015
2 parents 9f976bf + f314892 commit ba5d859
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions monitoring/src/main/java/CloudMonitoringAuthSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ private static CloudMonitoring authenticate()
* @throws Exception if something goes wrong.
*/
public static void main(final String[] args) throws Exception {
if (args.length != 2) {
System.err.println(String.format("Usage: %s <project-name>", args[0]));
if (args.length != 1) {
System.err.println(String.format("Usage: %s <project-name>",
CloudMonitoringAuthSample.class.getSimpleName()));
return;
}

String project = args[1];
String project = args[0];

// Create an authorized API client
CloudMonitoring cloudmonitoring = authenticate();
Expand Down
6 changes: 3 additions & 3 deletions monitoring/src/test/java/CloudMonitoringAuthSampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public void tearDown() {

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

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

0 comments on commit ba5d859

Please sign in to comment.