Package com.googlecode.jmxtrans.model

Examples of com.googlecode.jmxtrans.model.Result


  @Test
  public void writeSingleResult() throws Exception {
    // a lot of setup for not much of a test ...
    Server server = Server.builder().setHost("host").setPort("123").build();
    Query query = Query.builder().build();
    Result result = new Result("attributeName", "className", "classNameAlias", "typeName", ImmutableMap.of("key", (Object)1));

    GenericKeyedObjectPool<InetSocketAddress, Socket> pool = mock(GenericKeyedObjectPool.class);
    Socket socket = mock(Socket.class);
    when(pool.borrowObject(any(InetSocketAddress.class))).thenReturn(socket);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here


        runtime,
        ImmutableList.of(integerAttribute),
        runtime.getClassName()).getResults();

    assertThat(results).hasSize(1);
    Result integerResult = results.get(0);

    assertThat(integerResult.getAttributeName()).isEqualTo("StartTime");
    assertThat(integerResult.getClassName()).isEqualTo("sun.management.RuntimeImpl");
    assertThat(integerResult.getClassNameAlias()).isEqualTo("resultAlias");
    assertThat(integerResult.getTypeName()).isEqualTo("type=Runtime");
    assertThat(integerResult.getValues()).hasSize(1);
  }
View Full Code Here

        runtime,
        ImmutableList.of(integerAttribute),
        runtime.getClassName()).getResults();

    assertThat(results).hasSize(1);
    Result integerResult = results.get(0);

    assertThat(integerResult.getAttributeName()).isEqualTo("CollectionCount");
    assertThat(integerResult.getValues()).hasSize(1);

    Object objectValue = integerResult.getValues().get("CollectionCount");
    assertThat(objectValue).isInstanceOf(Long.class);

    Long integerValue = (Long) objectValue;
    assertThat(integerValue).isEqualTo(51L);
  }
View Full Code Here

        runtime,
        ImmutableList.of(booleanAttribute),
        runtime.getClassName()).getResults();

    assertThat(results).hasSize(1);
    Result result = results.get(0);

    assertThat(result.getAttributeName()).isEqualTo("BootClassPathSupported");
    assertThat(result.getValues()).hasSize(1);

    Object objectValue = result.getValues().get("BootClassPathSupported");
    assertThat(objectValue).isInstanceOf(Boolean.class);

    Boolean booleanValue = (Boolean) objectValue;
    assertThat(booleanValue).isEqualTo(TRUE);
  }
View Full Code Here

        attr.asList(),
        memory.getClassName()).getResults();

    assertThat(results).hasSize(1);

    Result result = results.get(0);

    assertThat(result.getAttributeName()).isEqualTo("HeapMemoryUsage");
    assertThat(result.getTypeName()).isEqualTo("type=Memory");

    Map<String,Object> values = result.getValues();
    assertThat(values).hasSize(4);

    Object objectValue = result.getValues().get("init");
    assertThat(objectValue).isInstanceOf(Long.class);
  }
View Full Code Here

    assertThat(queryCaptor.getValue()).isEqualTo(query);

    List<Result> results = resultsCaptor.getValue();
    assertThat(results).hasSize(1);

    Result result = results.get(0);
    assertThat(result.getValues().get("DummyValue")).isEqualTo(123);
  }
View Full Code Here

    } else if (value instanceof ObjectName[]) {
      Map<String, Object> values = newHashMap();
      for (ObjectName obj : (ObjectName[]) value) {
        values.put(obj.getCanonicalName(), obj.getKeyPropertyListString());
      }
      Result r = getNewResultObject(attribute.getName(), values);
      accumulator.add(r);
    } else if (value.getClass().isArray()) {
      // OMFG: this is nutty. some of the items in the array can be
      // primitive! great interview question!
      Map<String, Object> values = newHashMap();
      for (int i = 0; i < Array.getLength(value); i++) {
        Object val = Array.get(value, i);
        values.put(attribute.getName() + "." + i, val);
      }
      accumulator.add(getNewResultObject(attribute.getName(), values));
    } else if (value instanceof TabularDataSupport) {
      TabularDataSupport tds = (TabularDataSupport) value;
      Map<String, Object> values = Collections.emptyMap();
      Result r = getNewResultObject(attribute.getName(), values);
      processTabularDataSupport(accumulator, attribute.getName(), tds);
      accumulator.add(r);
    } else {
      Map<String, Object> values = newHashMap();
      values.put(attribute.getName(), value);
      Result r = getNewResultObject(attribute.getName(), values);
      accumulator.add(r);
    }
  }
View Full Code Here

        return; // because we don't want to add to the list yet.
      } else {
        values.put(key, value);
      }
    }
    Result r = getNewResultObject(attributeName, values);
    accumulator.add(r);
  }
View Full Code Here

  /**
   * Builds up the base Result object
   */
  private Result getNewResultObject(String attributeName, Map<String, Object> values) {
    return new Result(attributeName, className, query.getResultAlias(), objectInstance.getObjectName().getCanonicalKeyPropertyListString(), values);
  }
View Full Code Here

TOP

Related Classes of com.googlecode.jmxtrans.model.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.