当前位置: 首页>>代码示例>>Java>>正文


Java JSONRPC2Response.getResult方法代码示例

本文整理汇总了Java中com.thetransactioncompany.jsonrpc2.JSONRPC2Response.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java JSONRPC2Response.getResult方法的具体用法?Java JSONRPC2Response.getResult怎么用?Java JSONRPC2Response.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thetransactioncompany.jsonrpc2.JSONRPC2Response的用法示例。


在下文中一共展示了JSONRPC2Response.getResult方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ContextChangesPending

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
@Override
public Form ContextChangesPending(final long contextCoupon) throws Exception {

	final JSONRPC2Request request = new JSONRPC2Request("ContextParticipant.ContextChangesPending", UUID.randomUUID().toString());
	final SettableFuture<JSONRPC2Response> future = SettableFuture.create();
	cache.put(request.getID().toString(), future);
	session.getBasicRemote().sendObject(request);

	final JSONRPC2Response response = future.get(3000, TimeUnit.MILLISECONDS);
	if(!response.indicatesSuccess())
		throw new RuntimeException("Error processing request: " + response.toJSONString());
	final Form form = new Form();
	final JSONObject r = (JSONObject) response.getResult();
	r.forEach((k,v)->form.add(k, v));
	return form;
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:17,代码来源:WSContextParticipantProxy.java

示例2: testCreateSingleSwitch

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Test whether the creation of a host actually succeeds.
 */
@SuppressWarnings("unchecked")
public void testCreateSingleSwitch() {
    final PhysicalSwitch sw = new PhysicalSwitch(1);
    PhysicalNetwork.getInstance().addSwitch(sw);

    super.createNetwork();
    final JSONRPC2Response resp = super.createSwitch(1,
            Collections.singletonList(1));

    Assert.assertNull("CreateOVXSwitch should not return null",
            resp.getError());

    Assert.assertTrue("CreateOVXSwitch has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals((long) 46200400562356225L,
            result.get(TenantHandler.VDPID));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:24,代码来源:PassingAPITest.java

示例3: testCreatePort

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a create port call succeeds.
 */
@SuppressWarnings("unchecked")
public void testCreatePort() {
    final TestSwitch sw = new TestSwitch(1);
    PhysicalNetwork.getInstance().addSwitch(sw);
    final PhysicalPort port = new PhysicalPort(new OFPhysicalPort(), sw,
            true);
    port.setHardwareAddress(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
    port.setPortNumber((short) 1);
    sw.addPort(port);

    super.createNetwork();
    super.createSwitch(1, Collections.singletonList(1));

    final JSONRPC2Response resp = super.createPort(1, (long) 1, (short) 1);

    Assert.assertNull("CreateOVXPort should not return null",
            resp.getError());

    Assert.assertTrue("CreateOVXPort has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals((short) 1, result.get(TenantHandler.VPORT));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:29,代码来源:PassingAPITest.java

示例4: onPostExecute

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
@Override
protected void onPostExecute(JSONRPC2Response response) {
    if(response == null || response.getError() != null) {
        callback.onError(R.string.connectiontesterror);
        return;
    }
    if(response.getResult() == null) {
        callback.onSuccess();
        return;
    }
    try {
        net.minidev.json.JSONObject object = (net.minidev.json.JSONObject) response.getResult();
        callback.onSuccess(object);

    }catch(Exception e){
        callback.onError(R.string.connectiontesterror);
    }
}
 
开发者ID:Urucas,项目名称:popcorntime-remote-control,代码行数:19,代码来源:RemoteControl.java

示例5: testCreateBigSwitch

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Test whether the creation of a host actually succeeds.
 */
@SuppressWarnings("unchecked")
public void testCreateBigSwitch() {
    final PhysicalSwitch sw1 = new PhysicalSwitch(1);
    final PhysicalSwitch sw2 = new PhysicalSwitch(2);
    PhysicalNetwork.getInstance().addSwitch(sw1);
    PhysicalNetwork.getInstance().addSwitch(sw2);
    final PhysicalPort p1 = new PhysicalPort(new OFPhysicalPort(), sw1,
            false);
    final PhysicalPort p2 = new PhysicalPort(new OFPhysicalPort(), sw2,
            false);
    PhysicalNetwork.getInstance().createLink(p1, p2);
    PhysicalNetwork.getInstance().createLink(p2, p1);
    super.createNetwork();
    final List<Integer> l = new LinkedList<>();
    l.add(1);
    l.add(2);
    final JSONRPC2Response resp = super.createSwitch(1, l);

    Assert.assertNull("CreateOVXSwitch should not return null",
            resp.getError());

    Assert.assertTrue("CreateOVXSwitch has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals((long) 46200400562356225L,
            result.get(TenantHandler.VDPID));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:33,代码来源:PassingAPITest.java

示例6: testConnectHost

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a connect host call succeeds.
 */
@SuppressWarnings("unchecked")
public void testConnectHost() {
    final TestSwitch sw1 = new TestSwitch(1);
    PhysicalNetwork.getInstance().addSwitch(sw1);
    final PhysicalPort port = new PhysicalPort(new OFPhysicalPort(), sw1,
            true);
    port.setHardwareAddress(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
    port.setPortNumber((short) 1);
    sw1.addPort(port);

    super.createNetwork();
    super.createSwitch(1, Collections.singletonList(1));
    super.createPort(1, (long) 1, (short) 1);
    JSONRPC2Response resp = super.connectHost(1, (long) 46200400562356225L,
            (short) 1, "00:00:00:00:00:01");

    Assert.assertNull(
            resp.getError() == null ? "ConnectHost should not return null"
                    : resp.getError().getMessage(), resp.getError());

    Assert.assertTrue("ConnectHost has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals(1, result.get(TenantHandler.HOST));

    // Try to create another host with same MAC
    resp = super.connectHost(1, (long) 46200400562356225L, (short) 1,
            "00:00:00:00:00:01");
    Assert.assertNotNull("ConnectHost should not allow duplicate MACs",
            resp.getError());
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:37,代码来源:PassingAPITest.java

示例7: testCreateNetPass

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a create network call succeeds.
 */
@SuppressWarnings("unchecked")
public void testCreateNetPass() {

    final JSONRPC2Response resp = super.createNetwork();

    Assert.assertNull("CreateOVXNetwork should not return null",
            resp.getError());

    Assert.assertTrue("CreateOVXNetwork has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals(1, result.get(TenantHandler.TENANT));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:19,代码来源:PassingAPITest.java

示例8: testConnectLink

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a connect link call succeeds.
 */
@SuppressWarnings("unchecked")
public void testConnectLink() {
    super.createNetwork();
    final TestSwitch sw1 = new TestSwitch(1);
    final TestSwitch sw2 = new TestSwitch(2);
    PhysicalNetwork.getInstance().addSwitch(sw1);
    PhysicalNetwork.getInstance().addSwitch(sw2);
    final PhysicalPort p1 = new PhysicalPort(new OFPhysicalPort(), sw1,
            false);
    p1.setHardwareAddress(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
    p1.setPortNumber((short) 1);
    sw1.addPort(p1);

    final PhysicalPort p2 = new PhysicalPort(new OFPhysicalPort(), sw2,
            false);
    p2.setHardwareAddress(new byte[] {0x11, 0x12, 0x13, 0x14, 0x15, 0x16});
    p2.setPortNumber((short) 1);
    sw2.addPort(p2);
    PhysicalNetwork.getInstance().createLink(p1, p2);
    PhysicalNetwork.getInstance().createLink(p2, p1);

    super.createSwitch(1, Collections.singletonList(1));
    super.createSwitch(1, Collections.singletonList(2));
    super.createPort(1, (long) 1, (short) 1);
    super.createPort(1, (long) 2, (short) 1);

    JSONRPC2Response resp = super.connectLink(1, (long) 46200400562356225L,
            (short) 1, (long) 46200400562356226L, (short) 1, "manual",
            (byte) 0);

    Assert.assertNull(
            resp.getError() == null ? "ConnectLink should not return null"
                    : resp.getError().getMessage(), resp.getError());

    Assert.assertTrue("ConnectLink has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals(1, result.get(TenantHandler.LINK));

    // TODO: should this not be its own separate test?

    resp = super.setLinkPath(1, 1, "1/1-2/1", (byte) 100);

    Assert.assertNull(
            resp.getError() == null ? "SetLinkPath should not return null"
                    : resp.getError().getMessage(), resp.getError());

    Assert.assertTrue("SetLinkPath has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    result = (Map<String, Object>) resp.getResult();

    // TODO: we should check if the path really has been set
    // can't do this now as map is not working properly in the tests

    Assert.assertEquals(1, result.get(TenantHandler.LINK));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:63,代码来源:PassingAPITest.java

示例9: testConnectRoutePass

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a create switch route call succeeds.
 */
@SuppressWarnings("unchecked")
public void testConnectRoutePass() {
    // set the physical network (linear 2 sws with 1 host x sw)
    final TestSwitch sw1 = new TestSwitch(1);
    final TestSwitch sw2 = new TestSwitch(2);
    PhysicalNetwork.getInstance().addSwitch(sw1);
    PhysicalNetwork.getInstance().addSwitch(sw2);
    final PhysicalPort p1 = new PhysicalPort(new OFPhysicalPort(), sw1,
            false);
    p1.setHardwareAddress(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
    p1.setPortNumber((short) 1);
    sw1.addPort(p1);
    final PhysicalPort p2 = new PhysicalPort(new OFPhysicalPort(), sw1,
            true);
    p2.setHardwareAddress(new byte[] {0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c});
    p2.setPortNumber((short) 2);
    sw1.addPort(p2);
    final PhysicalPort p3 = new PhysicalPort(new OFPhysicalPort(), sw2,
            false);
    p3.setHardwareAddress(new byte[] {0x11, 0x12, 0x13, 0x14, 0x15, 0x16});
    p3.setPortNumber((short) 1);
    sw2.addPort(p3);
    final PhysicalPort p4 = new PhysicalPort(new OFPhysicalPort(), sw2,
            true);
    p4.setHardwareAddress(new byte[] {0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c});
    p4.setPortNumber((short) 2);
    sw2.addPort(p4);
    PhysicalNetwork.getInstance().createLink(p1, p3);
    PhysicalNetwork.getInstance().createLink(p3, p1);

    // set the virtual network (copy of the phy network)
    super.createNetwork();
    final List<Integer> l = new LinkedList<>();
    l.add(1);
    l.add(2);
    super.createSwitch(1, l);
    super.createPort(1, (long) 1, (short) 2);
    super.createPort(1, (long) 2, (short) 2);
    super.connectHost(1, (long) 46200400562356225L, (short) 1,
            "00:00:00:00:00:01");
    super.connectHost(1, (long) 46200400562356225L, (short) 2,
            "00:00:00:00:00:02");

    final JSONRPC2Response resp = super.connectRoute(1, 46200400562356225L,
            (short) 1, (short) 2, "1/1-2/1", (byte) 100);

    Assert.assertNull("ConnectOVXRoute should not return null",
            resp.getError());

    Assert.assertTrue("ConnectOVXRoute has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals(1, result.get(TenantHandler.ROUTE));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:60,代码来源:PassingAPITest.java

示例10: testStopNetPass

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
/**
 * Tests whether a disconnect host call succeeds.
 */
@SuppressWarnings("unchecked")
public void testStopNetPass() {
    // set the physical network (linear 2 sws with 1 host x sw)
    final TestSwitch sw1 = new TestSwitch(1);
    final TestSwitch sw2 = new TestSwitch(2);
    PhysicalNetwork.getInstance().addSwitch(sw1);
    PhysicalNetwork.getInstance().addSwitch(sw2);
    final PhysicalPort p1 = new PhysicalPort(new OFPhysicalPort(), sw1,
            false);
    p1.setHardwareAddress(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06});
    p1.setPortNumber((short) 1);
    sw1.addPort(p1);
    final PhysicalPort p2 = new PhysicalPort(new OFPhysicalPort(), sw1,
            true);
    p2.setHardwareAddress(new byte[] {0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c});
    p2.setPortNumber((short) 2);
    sw1.addPort(p2);
    final PhysicalPort p3 = new PhysicalPort(new OFPhysicalPort(), sw2,
            false);
    p3.setHardwareAddress(new byte[] {0x11, 0x12, 0x13, 0x14, 0x15, 0x16});
    p3.setPortNumber((short) 1);
    sw2.addPort(p3);
    final PhysicalPort p4 = new PhysicalPort(new OFPhysicalPort(), sw2,
            true);
    p4.setHardwareAddress(new byte[] {0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c});
    p4.setPortNumber((short) 2);
    sw2.addPort(p4);
    PhysicalNetwork.getInstance().createLink(p1, p3);
    PhysicalNetwork.getInstance().createLink(p3, p1);

    // set the virtual network (copy of the phy network)
    super.createNetwork();
    super.createSwitch(1, Collections.singletonList(1));
    super.createSwitch(1, Collections.singletonList(2));
    super.createPort(1, (long) 1, (short) 1);
    super.createPort(1, (long) 2, (short) 1);
    super.createPort(1, (long) 1, (short) 2);
    super.createPort(1, (long) 2, (short) 2);
    super.connectHost(1, (long) 46200400562356225L, (short) 2,
            "00:00:00:00:00:01");
    super.connectHost(1, (long) 46200400562356226L, (short) 2,
            "00:00:00:00:00:02");
    super.connectLink(1, (long) 46200400562356225L, (short) 1,
            (long) 46200400562356226L, (short) 1, "manual", (byte) 0);
    super.setLinkPath(1, 1, "1/1-2/1", (byte) 100);
    final JSONRPC2Response resp = super.stopNetwork(1);

    Assert.assertNull("Stop network should not return null",
            resp.getError());

    Assert.assertTrue("Stop network has incorrect return type",
            resp.getResult() instanceof Map<?, ?>);

    Map<String, Object> result = (Map<String, Object>) resp.getResult();

    Assert.assertEquals(1, result.get(TenantHandler.TENANT));

    Assert.assertEquals(false, result.get(TenantHandler.IS_BOOTED));
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:63,代码来源:PassingAPITest.java

示例11: executeJSONRPCRequest

import com.thetransactioncompany.jsonrpc2.JSONRPC2Response; //导入方法依赖的package包/类
protected Object executeJSONRPCRequest(String method, String nameOfRootElement, HashMap<String, Object> params) throws SessionExpired, RequestTimeout, InvalidRequest, InvalidParameters, InvalidJSON, RequestTooLarge, ResourceAlreadyExists, ResourceDontExists, Forbidden, GeneralException {
  JSONRPC2Request request = new JSONRPC2Request(method, requestId());
  if (params != null && !params.isEmpty()) {
    request.setNamedParams(params);
  }

  try {
    JSONRPC2Response response = jsonSession.send(request);

    if (response.indicatesSuccess()) {

      JSONObject result = (JSONObject)response.getResult();
      if (nameOfRootElement == null) {
        return result;
      }
      Object rootElement = result.get(nameOfRootElement);
      return rootElement;
    } else {
      switch (response.getError().getCode()) {
      case -32001:
        throw new SessionExpired(response.getError().getMessage());
      case -32002:
        throw new RequestTimeout(response.getError().getMessage());
      case -32600:
        throw new InvalidRequest(response.getError().getMessage());
      case -32602:
        throw new InvalidParameters(response.getError().getMessage());
      case -32700:
        throw new InvalidJSON(response.getError().getMessage());
      case 413:
        throw new RequestTooLarge(response.getError().getMessage());
      case 1001:
        throw new ResourceAlreadyExists(response.getError().getMessage());
      case 1002:
        throw new ResourceDontExists(response.getError().getMessage());
      case 1003:
        throw new Forbidden(response.getError().getMessage());
      case 1004:
        throw new Forbidden(response.getError().getMessage());
      default:
        throw new GeneralException(response.getError().getMessage());
      }
    }
  } catch (JSONRPC2SessionException e) {
    throw new GeneralException(e);      
  }
}
 
开发者ID:pascalrobert,项目名称:kerio-admin,代码行数:48,代码来源:KCApi.java


注:本文中的com.thetransactioncompany.jsonrpc2.JSONRPC2Response.getResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。