List of usage examples for java.lang Throwable toString
public String toString()
From source file:com.vmware.photon.controller.api.client.resource.ClusterRestApiTest.java
@Test public void testResizeAsync() throws IOException, InterruptedException { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); ClusterApi clusterApi = new ClusterRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); clusterApi.resizeAsync("dummy-cluster-id", 100, new FutureCallback<Task>() { @Override/*from w w w . j a va2 s .c o m*/ public void onSuccess(Task result) { assertEquals(result, responseTask); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.api.client.resource.ClusterApiTest.java
@Test public void testGetVmsAsync() throws IOException, InterruptedException { Vm vm1 = new Vm(); vm1.setId("vm1"); Vm vm2 = new Vm(); vm2.setId("vm2"); final ResourceList<Vm> vmList = new ResourceList<>(Arrays.asList(vm1, vm2)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(vmList); setupMocks(serializedTask, HttpStatus.SC_OK); ClusterApi clusterApi = new ClusterApi(restClient); final CountDownLatch latch = new CountDownLatch(1); clusterApi.getVmsInClusterAsync("foo", new FutureCallback<ResourceList<Vm>>() { @Override/*from ww w . j a v a 2 s .c o m*/ public void onSuccess(ResourceList<Vm> result) { assertEquals(result.getItems(), vmList.getItems()); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.api.client.resource.ClusterRestApiTest.java
@Test public void testGetVmsAsync() throws IOException, InterruptedException { Vm vm1 = new Vm(); vm1.setId("vm1"); Vm vm2 = new Vm(); vm2.setId("vm2"); final ResourceList<Vm> vmList = new ResourceList<>(Arrays.asList(vm1, vm2)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(vmList); setupMocks(serializedTask, HttpStatus.SC_OK); ClusterApi clusterApi = new ClusterRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); clusterApi.getVmsInClusterAsync("foo", new FutureCallback<ResourceList<Vm>>() { @Override//from w ww .jav a2 s. c o m public void onSuccess(ResourceList<Vm> result) { assertEquals(result.getItems(), vmList.getItems()); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.mobicage.rogerthat.CallbackProcessor.java
@SuppressWarnings("unchecked") public void process(final JSONObject request, final JSONObject response, final RequestContext requestContext) { final String method = (String) request.get("method"); final JSONObject params = (JSONObject) request.get("params"); response.put("id", requestContext.getRequestId()); response.put("error", null); response.put("result", null); try {//w ww . jav a2 s. co m // Handle if ("test.test".equals(method)) { if (testTestHandler != null) { com.mobicage.rogerthat.callbacks.test.TestRequest req = new com.mobicage.rogerthat.callbacks.test.TestRequest( requestContext, params); com.mobicage.rogerthat.callbacks.test.TestResponse resp = testTestHandler.handle(req); response.put("result", resp.toJSONObject()); } } else if ("messaging.update".equals(method)) { if (messagingUpdateHandler != null) { com.mobicage.rogerthat.callbacks.messaging.UpdateRequest req = new com.mobicage.rogerthat.callbacks.messaging.UpdateRequest( requestContext, params); com.mobicage.rogerthat.callbacks.messaging.UpdateResponse resp = messagingUpdateHandler .handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("messaging.poke".equals(method)) { if (messagingPokeHandler != null) { com.mobicage.rogerthat.callbacks.messaging.PokeRequest req = new com.mobicage.rogerthat.callbacks.messaging.PokeRequest( requestContext, params); com.mobicage.rogerthat.callbacks.messaging.PokeResponse resp = messagingPokeHandler.handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("friend.invite_result".equals(method)) { if (friendInviteResultHandler != null) { com.mobicage.rogerthat.callbacks.friend.InviteResultRequest req = new com.mobicage.rogerthat.callbacks.friend.InviteResultRequest( requestContext, params); com.mobicage.rogerthat.callbacks.friend.InviteResultResponse resp = friendInviteResultHandler .handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("friend.invited".equals(method)) { if (friendInvitedHandler != null) { com.mobicage.rogerthat.callbacks.friend.InvitedRequest req = new com.mobicage.rogerthat.callbacks.friend.InvitedRequest( requestContext, params); com.mobicage.rogerthat.callbacks.friend.InvitedResponse resp = friendInvitedHandler.handle(req); response.put("result", resp.getResult()); } } else if ("friend.broke_up".equals(method)) { if (friendBrokeUpHandler != null) { com.mobicage.rogerthat.callbacks.friend.BrokeUpRequest req = new com.mobicage.rogerthat.callbacks.friend.BrokeUpRequest( requestContext, params); com.mobicage.rogerthat.callbacks.friend.BrokeUpResponse resp = friendBrokeUpHandler.handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("friend.in_reach".equals(method)) { if (friendInReachHandler != null) { com.mobicage.rogerthat.callbacks.friend.InReachRequest req = new com.mobicage.rogerthat.callbacks.friend.InReachRequest( requestContext, params); com.mobicage.rogerthat.callbacks.friend.InReachResponse resp = friendInReachHandler.handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("friend.out_of_reach".equals(method)) { if (friendOutOfReachHandler != null) { com.mobicage.rogerthat.callbacks.friend.OutOfReachRequest req = new com.mobicage.rogerthat.callbacks.friend.OutOfReachRequest( requestContext, params); com.mobicage.rogerthat.callbacks.friend.OutOfReachResponse resp = friendOutOfReachHandler .handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("messaging.form_update".equals(method)) { if (messagingFormUpdateHandler != null) { com.mobicage.rogerthat.callbacks.messaging.FormUpdateRequest req = new com.mobicage.rogerthat.callbacks.messaging.FormUpdateRequest( requestContext, params); com.mobicage.rogerthat.callbacks.messaging.FormUpdateResponse resp = messagingFormUpdateHandler .handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("messaging.flow_member_result".equals(method)) { if (messagingFlowMemberResultHandler != null) { com.mobicage.rogerthat.callbacks.messaging.FlowMemberResultRequest req = new com.mobicage.rogerthat.callbacks.messaging.FlowMemberResultRequest( requestContext, params); com.mobicage.rogerthat.callbacks.messaging.FlowMemberResultResponse resp = messagingFlowMemberResultHandler .handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } else if ("system.api_call".equals(method)) { if (systemApiCallHandler != null) { com.mobicage.rogerthat.callbacks.system.ApiCallRequest req = new com.mobicage.rogerthat.callbacks.system.ApiCallRequest( requestContext, params); com.mobicage.rogerthat.callbacks.system.ApiCallResponse resp = systemApiCallHandler.handle(req); response.put("result", resp == null ? null : resp.toJSONObject()); } } } catch (Throwable e) { log.log(Level.WARNING, "Caught exception in CallBackApiListener", e); response.put("error", e.toString()); } }
From source file:de.unisb.cs.st.javalanche.rhino.RhinoTestRunnable.java
public void run() { List<String> argList = getArgs(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream err = new ByteArrayOutputStream(); String[] arguments = argList.toArray(new String[0]); try {/*from www .j ava 2 s. c o m*/ stopWatch.start(); exitCode = WrappedMain.wrappedExec(arguments, new PrintStream(out), new PrintStream(err)); } catch (Throwable t) { String message = "Caught exception during mutation testing. Exception is most probably caused by the mutation"; logger.warn(message, t); logger.warn(t.toString() + " " + Arrays.toString(t.getStackTrace())); exitCode = -1; } finally { stopWatch.stop(); } byte[] outByteArray = out.toByteArray(); outString = new String(outByteArray); byte[] errByteArray = err.toByteArray(); errString = new String(errByteArray); synchronized (this) { hasRun = true; } logger.info("Runnable finsihed Took " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime()) + " \nOUT:\n" + outString + " \nERR\n" + errString); }
From source file:com.vmware.photon.controller.nsxclient.apis.FabricApiTest.java
@Test public void testUnregisterFabricNode() throws IOException, InterruptedException { setupMocks(null, HttpStatus.SC_OK);/*w w w. j av a2 s . c o m*/ FabricApi client = new FabricApi(restClient); final CountDownLatch latch = new CountDownLatch(1); client.unregisterFabricNode("nodeId", new com.google.common.util.concurrent.FutureCallback<Void>() { @Override public void onSuccess(Void result) { latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.nsxclient.apis.FabricApiTest.java
@Test public void testDeleteTransportNode() throws IOException, InterruptedException { setupMocks(null, HttpStatus.SC_OK);/*from w ww . ja va2 s. co m*/ FabricApi client = new FabricApi(restClient); final CountDownLatch latch = new CountDownLatch(1); client.deleteTransportNode("id", new com.google.common.util.concurrent.FutureCallback<Void>() { @Override public void onSuccess(Void result) { latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.nsxclient.apis.FabricApiTest.java
@Test public void testDeleteTransportZone() throws IOException, InterruptedException { setupMocks(null, HttpStatus.SC_OK);// w ww . j av a 2 s . c o m FabricApi client = new FabricApi(restClient); final CountDownLatch latch = new CountDownLatch(1); client.deleteTransportZone("id", new com.google.common.util.concurrent.FutureCallback<Void>() { @Override public void onSuccess(Void result) { latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.nsxclient.apis.FabricApiTest.java
@Test public void testGetFabricNode() throws IOException, InterruptedException { final FabricNode mockResponse = new FabricNode(); mockResponse.setId("id"); setupMocks(objectMapper.writeValueAsString(mockResponse), HttpStatus.SC_OK); FabricApi client = new FabricApi(restClient); final CountDownLatch latch = new CountDownLatch(1); client.getFabricNode("nodeId", new com.google.common.util.concurrent.FutureCallback<FabricNode>() { @Override//from ww w .j ava 2s . c o m public void onSuccess(FabricNode result) { assertEquals(result, mockResponse); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }
From source file:com.vmware.photon.controller.nsxclient.apis.FabricApiTest.java
@Test public void testGetTransportNode() throws IOException, InterruptedException { final TransportNode mockResponse = new TransportNode(); mockResponse.setId("id"); setupMocks(objectMapper.writeValueAsString(mockResponse), HttpStatus.SC_OK); FabricApi client = new FabricApi(restClient); final CountDownLatch latch = new CountDownLatch(1); client.getTransportNode("id", new com.google.common.util.concurrent.FutureCallback<TransportNode>() { @Override/*w ww . j a va 2 s . c o m*/ public void onSuccess(TransportNode result) { assertEquals(result, mockResponse); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }