Exemplo n.º 1
0
  @Test
  public void test() throws DatastoreException, ValidationException {
    command.execute(
        new FakeChannel(),
        new String[] {"telnet", "MetricName", "12345678999", "789", "foo=bar", "fum=barfum"});

    assertThat(datastore.getSet().getName(), equalTo("MetricName"));
    assertThat(datastore.getSet().getTags().size(), equalTo(2));
    assertThat(datastore.getSet().getTags().get("foo"), equalTo("bar"));
    assertThat(datastore.getSet().getTags().get("fum"), equalTo("barfum"));
    assertThat(datastore.getSet().getDataPoints().get(0).getTimestamp(), equalTo(12345678999L));
    assertThat(datastore.getSet().getDataPoints().get(0).getLongValue(), equalTo(789L));
  }
Exemplo n.º 2
0
 @Test
 public void test_metricName_empty_invalid() throws DatastoreException, ValidationException {
   try {
     command.execute(
         new FakeChannel(),
         new String[] {"telnet", "", "12345678999", "789", "foo=bar", "fum=barfum"});
     fail("ValidationException expected");
   } catch (DatastoreException e) {
     fail("ValidationException expected");
   } catch (ValidationException e) {
     assertThat(e.getMessage(), equalTo("metricName may not be empty."));
   }
 }
Exemplo n.º 3
0
 @Test
 public void test_tag_invalid() throws DatastoreException, ValidationException {
   try {
     command.execute(
         new FakeChannel(),
         new String[] {"telnet", "metricName", "12345678999", "789", "foo=bar", "fum-barfum"});
     fail("ValidationException expected");
   } catch (DatastoreException e) {
     fail("ValidationException expected");
   } catch (ValidationException e) {
     assertThat(e.getMessage(), equalTo("tag[1] must be in the format 'name=value'."));
   }
 }
Exemplo n.º 4
0
 @Test
 public void test_metricName_characters_invalid() throws DatastoreException, ValidationException {
   try {
     command.execute(
         new FakeChannel(),
         new String[] {"telnet", "foo:bar", "12345678999", "789", "foo=bar", "fum=barfum"});
     fail("ValidationException expected");
   } catch (DatastoreException e) {
     fail("ValidationException expected");
   } catch (ValidationException e) {
     assertThat(
         e.getMessage(),
         equalTo(
             "metricName may only contain alphanumeric characters plus periods '.', slash '/', dash '-', and underscore '_'."));
   }
 }