List of usage examples for java.lang Throwable toString
public String toString()
From source file:com.vmware.photon.controller.api.client.resource.ResourceTicketRestApiTest.java
@Test public void testGetResourceTicketAsync() throws IOException, InterruptedException { final ResourceTicket resourceTicket1 = new ResourceTicket(); resourceTicket1.setId("resourceTicket1"); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(resourceTicket1); setupMocks(serializedTask, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); resourceTicketApi.getResourceTicketAsync("foo", new FutureCallback<ResourceTicket>() { @Override/* w w w .j a v a 2 s . com*/ public void onSuccess(@Nullable ResourceTicket result) { assertEquals(result, resourceTicket1); 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.ResourceTicketApiTest.java
@Test public void testGetResourceTicketTasksAsync() throws IOException, InterruptedException { Task task1 = new Task(); task1.setId("task1"); Task task2 = new Task(); task2.setId("task2"); final ResourceList<Task> taskResourceList = new ResourceList<>(Arrays.asList(task1, task2)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(taskResourceList); setupMocks(serializedTask, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketApi(restClient); final CountDownLatch latch = new CountDownLatch(1); resourceTicketApi.getTasksForResourceTicketAsync("foo", new FutureCallback<ResourceList<Task>>() { @Override// w w w .ja v a 2 s .c om public void onSuccess(@Nullable ResourceList<Task> result) { assertEquals(result.getItems(), taskResourceList.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.ResourceTicketRestApiTest.java
@Test public void testGetResourceTicketTasksAsync() throws IOException, InterruptedException { Task task1 = new Task(); task1.setId("task1"); Task task2 = new Task(); task2.setId("task2"); final ResourceList<Task> taskResourceList = new ResourceList<>(Arrays.asList(task1, task2)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(taskResourceList); setupMocks(serializedTask, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); resourceTicketApi.getTasksForResourceTicketAsync("foo", new FutureCallback<ResourceList<Task>>() { @Override//w w w. j av a2s . c om public void onSuccess(@Nullable ResourceList<Task> result) { assertEquals(result.getItems(), taskResourceList.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.lucidtechnics.blackboard.util.PropertyUtil.java
public synchronized boolean loadProperties(String _propertyResourceName, String _shortName, boolean _swallowException) { boolean successful = false; try {// w w w . j av a 2s .c o m loadProperties(_propertyResourceName, _shortName); successful = true; } catch (Throwable t) { log.warn("On loading property file: " + _propertyResourceName + " the following exception was thrown:"); log.warn(t.toString()); if (_swallowException == false) { throw new RuntimeException("Unable to load: " + _propertyResourceName, t); } log.warn("As requested exception was swallowed and processing continues"); } return successful; }
From source file:com.sap.prd.mobile.ios.mios.TestLog.java
private void print(Severity level, Throwable error) { String stackTrace = ExceptionUtils.getStackTrace(error); BUFFER.append(format("%s: %s%s%s", level, error.toString(), NL, stackTrace)); }
From source file:com.appeligo.search.entity.SetPermissionsInViewFilter.java
/** * /* ww w. j a v a 2s . c om*/ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { User user = null; if (request instanceof HttpServletRequest) { String username = ((HttpServletRequest) request).getRemoteUser(); if (username != null) { user = User.findByUsername(username); } } Permissions.setCurrentUser(user); try { chain.doFilter(request, response); } catch (ServletException se) { String message = se.toString(); if (se.getRootCause() != null) { message = se.getRootCause().toString(); } if (message != null && ((message.indexOf("ClientAbortException") >= 0) || (message.indexOf("Connection reset by peer") >= 0))) { log.warn(message); } else { if (printFullExceptions) { log.error("Caught servlet exception:"); if (se.getRootCause() != null) { log.error(message, se.getRootCause()); } else { log.error(message, se); } } else { log.error(message); } throw se; } } catch (Throwable t) { if (printFullExceptions) { log.error(t.getMessage(), t); } else { log.error(t.toString()); } throw new ServletException(t); } finally { Permissions.setCurrentUser(null); } }
From source file:com.vmware.photon.controller.client.resource.DeploymentApiTest.java
@Test public void testGetHostsAsync() 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); DeploymentApi deploymentApi = new DeploymentApi(restClient); final CountDownLatch latch = new CountDownLatch(1); deploymentApi.getAllDeploymentVmsAsync("foo", new FutureCallback<ResourceList<Vm>>() { @Override// w w w. j ava 2 s. com 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.ResourceTicketApiTest.java
@Test public void testGetResourceTicketTasksAsyncForPagination() throws IOException, InterruptedException { Task task1 = new Task(); task1.setId("task1"); Task task2 = new Task(); task2.setId("task2"); Task task3 = new Task(); task3.setId("task3"); String nextPageLink = "nextPageLink"; ResourceList<Task> taskResourceList = new ResourceList<>(Arrays.asList(task1, task2), nextPageLink, null); ResourceList<Task> taskResourceListNextPage = new ResourceList<>(Arrays.asList(task3)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(taskResourceList); String serializedTaskNextPage = mapper.writeValueAsString(taskResourceListNextPage); setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketApi(restClient); final CountDownLatch latch = new CountDownLatch(1); resourceTicketApi.getTasksForResourceTicketAsync("foo", new FutureCallback<ResourceList<Task>>() { @Override/*from w ww . j ava 2 s . co m*/ public void onSuccess(@Nullable ResourceList<Task> result) { assertEquals(result.getItems().size(), taskResourceList.getItems().size() + taskResourceListNextPage.getItems().size()); assertTrue(result.getItems().containsAll(taskResourceList.getItems())); assertTrue(result.getItems().containsAll(taskResourceListNextPage.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.ResourceTicketRestApiTest.java
@Test public void testGetResourceTicketTasksAsyncForPagination() throws IOException, InterruptedException { Task task1 = new Task(); task1.setId("task1"); Task task2 = new Task(); task2.setId("task2"); Task task3 = new Task(); task3.setId("task3"); String nextPageLink = "nextPageLink"; ResourceList<Task> taskResourceList = new ResourceList<>(Arrays.asList(task1, task2), nextPageLink, null); ResourceList<Task> taskResourceListNextPage = new ResourceList<>(Arrays.asList(task3)); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(taskResourceList); String serializedTaskNextPage = mapper.writeValueAsString(taskResourceListNextPage); setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK); ResourceTicketApi resourceTicketApi = new ResourceTicketRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); resourceTicketApi.getTasksForResourceTicketAsync("foo", new FutureCallback<ResourceList<Task>>() { @Override//from www . j a v a2 s. c o m public void onSuccess(@Nullable ResourceList<Task> result) { assertEquals(result.getItems().size(), taskResourceList.getItems().size() + taskResourceListNextPage.getItems().size()); assertTrue(result.getItems().containsAll(taskResourceList.getItems())); assertTrue(result.getItems().containsAll(taskResourceListNextPage.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.haulmont.cuba.security.auth.AuthenticationServiceBean.java
@Override public void logout() { try {//from w w w. j av a 2 s.co m UserSession session = userSessionSource.getUserSession(); if (session != null && session.isSystem()) { throw new RuntimeException("Logout of system session from client is not permitted"); } userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT); authenticationManager.logout(); userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT); } catch (Throwable e) { log.error("Logout error", e); throw new RuntimeException("Logout error: " + e.toString()); } }