Search in sources :

Example 1 with RMRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.RMRestInterface in project scheduling by ow2-proactive.

the class RMRestTest method callGetStatHistory.

private JSONObject callGetStatHistory() throws Exception {
    RMProxyUserInterface rmMock = mock(RMProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(rmMock);
    AttributeList value = new AttributeList(Collections.singletonList(new Attribute("test", createRrdDb().getBytes())));
    when(rmMock.getMBeanAttributes(Matchers.<ObjectName>any(), Matchers.<String[]>any())).thenReturn(value);
    RMRestInterface client = ProxyFactory.create(RMRestInterface.class, "http://localhost:" + port + "/");
    String statHistory = client.getStatHistory(sessionId, "hhhhh");
    return (JSONObject) new JSONParser().parse(statHistory);
}
Also used : JSONObject(org.json.simple.JSONObject) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) JSONParser(org.json.simple.parser.JSONParser) Matchers.anyString(org.mockito.Matchers.anyString)

Example 2 with RMRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.RMRestInterface in project scheduling by ow2-proactive.

the class RMRestTest method callGetStatHistory.

private JSONObject callGetStatHistory(byte[] rrdb, ConsolFun function) throws Exception {
    RMProxyUserInterface rmMock = mock(RMProxyUserInterface.class);
    String sessionId = SharedSessionStoreTestUtils.createValidSession(rmMock);
    AttributeList value = new AttributeList(Collections.singletonList(new Attribute("test", rrdb)));
    when(rmMock.getMBeanAttributes(Matchers.<ObjectName>any(), Matchers.<String[]>any())).thenReturn(value);
    RMRestInterface client = ProxyFactory.create(RMRestInterface.class, "http://localhost:" + port + "/");
    String statHistory = client.getStatHistory(sessionId, "hhhhh", function.name());
    return (JSONObject) new JSONParser().parse(statHistory);
}
Also used : JSONObject(org.json.simple.JSONObject) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) JSONParser(org.json.simple.parser.JSONParser) Matchers.anyString(org.mockito.Matchers.anyString) RMRestInterface(org.ow2.proactive_grid_cloud_portal.common.RMRestInterface)

Example 3 with RMRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.RMRestInterface in project scheduling by ow2-proactive.

the class RMClientExample method main.

public static void main(String[] args) throws LoginException, KeyException, RMException {
    System.out.println("Hello from example.");
    RMRestClient client = new RMRestClient("http://localhost:8080/rest/", null);
    RMRestInterface rm = client.getRm();
    String sessionId = rm.rmConnect("admin", "admin");
    System.out.println(sessionId);
}
Also used : RMRestInterface(org.ow2.proactive_grid_cloud_portal.common.RMRestInterface)

Example 4 with RMRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.RMRestInterface in project scheduling by ow2-proactive.

the class RMRestClient method createRestProxy.

private static RMRestInterface createRestProxy(ResteasyProviderFactory provider, String restEndpointURL, ClientHttpEngine httpEngine) {
    ResteasyClient client = buildResteasyClient(provider);
    ResteasyWebTarget target = client.target(restEndpointURL);
    RMRestInterface rmRestInterface = target.proxy(RMRestInterface.class);
    return createExceptionProxy(rmRestInterface);
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) RMRestInterface(org.ow2.proactive_grid_cloud_portal.common.RMRestInterface)

Aggregations

RMRestInterface (org.ow2.proactive_grid_cloud_portal.common.RMRestInterface)3 Attribute (javax.management.Attribute)2 AttributeList (javax.management.AttributeList)2 JSONObject (org.json.simple.JSONObject)2 JSONParser (org.json.simple.parser.JSONParser)2 Matchers.anyString (org.mockito.Matchers.anyString)2 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)2 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)1 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)1