Example usage for java.lang Throwable toString

List of usage examples for java.lang Throwable toString

Introduction

In this page you can find the example usage for java.lang Throwable toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.vmware.photon.controller.api.client.resource.ProjectApiTest.java

@Test
public void testGetProjectTasksAsyncForPagination() 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);

    ProjectApi projectApi = new ProjectApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getTasksForProjectAsync("foo", new FutureCallback<ResourceList<Task>>() {
        @Override//from  w  w w  .j av  a 2  s . com
        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.ProjectRestApiTest.java

@Test
public void testGetProjectTasksAsyncForPagination() 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);

    ProjectApi projectApi = new ProjectRestApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getTasksForProjectAsync("foo", new FutureCallback<ResourceList<Task>>() {
        @Override//from www.  j  a v a 2 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.vmware.photon.controller.api.client.resource.ProjectApiTest.java

@Test
public void testGetPersistentDisksAsyncForPagination() throws IOException, InterruptedException {
    PersistentDisk persistentDisk1 = new PersistentDisk();
    persistentDisk1.setId("persistentDisk1");

    PersistentDisk persistentDisk2 = new PersistentDisk();
    persistentDisk2.setId("persistentDisk2");

    PersistentDisk persistentDisk3 = new PersistentDisk();
    persistentDisk3.setId("persistentDisk3");

    String nextPageLink = "nextPageLink";

    ResourceList<PersistentDisk> persistentDiskResourceList = new ResourceList<>(
            Arrays.asList(persistentDisk1, persistentDisk2), nextPageLink, null);
    ResourceList<PersistentDisk> persistentDiskResourceListNextPage = new ResourceList<>(
            Arrays.asList(persistentDisk3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(persistentDiskResourceList);
    String serializedTaskNextPage = mapper.writeValueAsString(persistentDiskResourceListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getDisksInProjectAsync("foo", new FutureCallback<ResourceList<PersistentDisk>>() {
        @Override//from   www . ja v  a2 s. com
        public void onSuccess(@Nullable ResourceList<PersistentDisk> result) {
            assertEquals(result.getItems().size(), persistentDiskResourceList.getItems().size()
                    + persistentDiskResourceListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(persistentDiskResourceList.getItems()));
            assertTrue(result.getItems().containsAll(persistentDiskResourceListNextPage.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.ProjectRestApiTest.java

@Test
public void testGetPersistentDisksAsyncForPagination() throws IOException, InterruptedException {
    PersistentDisk persistentDisk1 = new PersistentDisk();
    persistentDisk1.setId("persistentDisk1");

    PersistentDisk persistentDisk2 = new PersistentDisk();
    persistentDisk2.setId("persistentDisk2");

    PersistentDisk persistentDisk3 = new PersistentDisk();
    persistentDisk3.setId("persistentDisk3");

    String nextPageLink = "nextPageLink";

    ResourceList<PersistentDisk> persistentDiskResourceList = new ResourceList<>(
            Arrays.asList(persistentDisk1, persistentDisk2), nextPageLink, null);
    ResourceList<PersistentDisk> persistentDiskResourceListNextPage = new ResourceList<>(
            Arrays.asList(persistentDisk3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(persistentDiskResourceList);
    String serializedTaskNextPage = mapper.writeValueAsString(persistentDiskResourceListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectRestApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getDisksInProjectAsync("foo", new FutureCallback<ResourceList<PersistentDisk>>() {
        @Override/*from  ww w .  j  av  a2 s .co m*/
        public void onSuccess(@Nullable ResourceList<PersistentDisk> result) {
            assertEquals(result.getItems().size(), persistentDiskResourceList.getItems().size()
                    + persistentDiskResourceListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(persistentDiskResourceList.getItems()));
            assertTrue(result.getItems().containsAll(persistentDiskResourceListNextPage.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.ProjectApiTest.java

@Test
public void testGetVmsAsyncForPagination() throws IOException, InterruptedException {
    FlavoredCompact vm1 = new FlavoredCompact();
    vm1.setId("vm1");
    vm1.setKind("vm");

    FlavoredCompact vm2 = new FlavoredCompact();
    vm2.setId("vm2");
    vm2.setKind("vm");

    FlavoredCompact vm3 = new FlavoredCompact();
    vm3.setId("vm3");
    vm3.setKind("vm3");

    String nextPageLink = "nextPageLink";

    ResourceList<FlavoredCompact> vmSummaryList = new ResourceList<>(Arrays.asList(vm1, vm2), nextPageLink,
            null);//from w  ww .j  a  v a 2  s .  com
    ResourceList<FlavoredCompact> vmSummaryListNextPage = new ResourceList<>(Arrays.asList(vm3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(vmSummaryList);
    String serializedTaskNextPage = mapper.writeValueAsString(vmSummaryListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getVmsInProjectAsync("foo", new FutureCallback<ResourceList<FlavoredCompact>>() {
        @Override
        public void onSuccess(@Nullable ResourceList<FlavoredCompact> result) {
            assertEquals(result.getItems().size(),
                    vmSummaryList.getItems().size() + vmSummaryListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(vmSummaryList.getItems()));
            assertTrue(result.getItems().containsAll(vmSummaryListNextPage.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.ProjectApiTest.java

@Test
public void testGetClustersAsyncForPagination() throws IOException, InterruptedException {
    Cluster cluster1 = new Cluster();
    cluster1.setId("cluster1");
    cluster1.setName("cluster1Name");

    Cluster cluster2 = new Cluster();
    cluster2.setId("cluster2");
    cluster2.setName("cluster2Name");

    Cluster cluster3 = new Cluster();
    cluster3.setId("cluster3");
    cluster3.setName("cluster3Name");

    String nextPageLink = "nextPageLink";

    ResourceList<Cluster> clusterList = new ResourceList<>(Arrays.asList(cluster1, cluster2), nextPageLink,
            null);//from   w ww . j  a  v  a 2  s. co m
    ResourceList<Cluster> clusterListNextPage = new ResourceList<>(Arrays.asList(cluster3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(clusterList);
    String serializedTaskNextPage = mapper.writeValueAsString(clusterListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getClustersInProjectAsync("foo", new FutureCallback<ResourceList<Cluster>>() {
        @Override
        public void onSuccess(@Nullable ResourceList<Cluster> result) {
            assertEquals(result.getItems().size(),
                    clusterList.getItems().size() + clusterListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(clusterList.getItems()));
            assertTrue(result.getItems().containsAll(clusterListNextPage.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.ProjectRestApiTest.java

@Test
public void testGetVmsAsyncForPagination() throws IOException, InterruptedException {
    FlavoredCompact vm1 = new FlavoredCompact();
    vm1.setId("vm1");
    vm1.setKind("vm");

    FlavoredCompact vm2 = new FlavoredCompact();
    vm2.setId("vm2");
    vm2.setKind("vm");

    FlavoredCompact vm3 = new FlavoredCompact();
    vm3.setId("vm3");
    vm3.setKind("vm3");

    String nextPageLink = "nextPageLink";

    ResourceList<FlavoredCompact> vmSummaryList = new ResourceList<>(Arrays.asList(vm1, vm2), nextPageLink,
            null);//from   w ww. j  a v a 2 s  . c  o m
    ResourceList<FlavoredCompact> vmSummaryListNextPage = new ResourceList<>(Arrays.asList(vm3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(vmSummaryList);
    String serializedTaskNextPage = mapper.writeValueAsString(vmSummaryListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectRestApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getVmsInProjectAsync("foo", new FutureCallback<ResourceList<FlavoredCompact>>() {
        @Override
        public void onSuccess(@Nullable ResourceList<FlavoredCompact> result) {
            assertEquals(result.getItems().size(),
                    vmSummaryList.getItems().size() + vmSummaryListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(vmSummaryList.getItems()));
            assertTrue(result.getItems().containsAll(vmSummaryListNextPage.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.ProjectRestApiTest.java

@Test
public void testGetClustersAsyncForPagination() throws IOException, InterruptedException {
    Cluster cluster1 = new Cluster();
    cluster1.setId("cluster1");
    cluster1.setName("cluster1Name");

    Cluster cluster2 = new Cluster();
    cluster2.setId("cluster2");
    cluster2.setName("cluster2Name");

    Cluster cluster3 = new Cluster();
    cluster3.setId("cluster3");
    cluster3.setName("cluster3Name");

    String nextPageLink = "nextPageLink";

    ResourceList<Cluster> clusterList = new ResourceList<>(Arrays.asList(cluster1, cluster2), nextPageLink,
            null);//from ww  w  .j av a2  s.  c  o m
    ResourceList<Cluster> clusterListNextPage = new ResourceList<>(Arrays.asList(cluster3));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(clusterList);
    String serializedTaskNextPage = mapper.writeValueAsString(clusterListNextPage);

    setupMocksForPagination(serializedTask, serializedTaskNextPage, nextPageLink, HttpStatus.SC_OK);

    ProjectApi projectApi = new ProjectRestApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    projectApi.getClustersInProjectAsync("foo", new FutureCallback<ResourceList<Cluster>>() {
        @Override
        public void onSuccess(@Nullable ResourceList<Cluster> result) {
            assertEquals(result.getItems().size(),
                    clusterList.getItems().size() + clusterListNextPage.getItems().size());
            assertTrue(result.getItems().containsAll(clusterList.getItems()));
            assertTrue(result.getItems().containsAll(clusterListNextPage.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.vuze.plugin.azVPN_Helper.CheckerCommon.java

public final String portBindingCheck() {
    synchronized (this) {
        if (checkingPortBinding) {
            return lastPortCheckStatus;
        }/*from w ww . j ava  2  s.co  m*/
        checkingPortBinding = true;
    }

    CheckerListener[] triggers = PluginVPNHelper.instance.getCheckerListeners();
    for (CheckerListener l : triggers) {
        try {
            l.portCheckStart();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    StringBuilder sReply = new StringBuilder();

    try {
        int newStatusID = findBindingAddress(sReply);

        boolean doPortForwarding = config.getPluginBooleanParameter(PluginConstants.CONFIG_DO_PORT_FORWARDING);

        if (doPortForwarding) {
            boolean rpcCalled = false;
            if (newStatusID != STATUS_ID_BAD && vpnIP != null) {
                rpcCalled = callRPCforPort(vpnIP, sReply);
            }

            if (!rpcCalled) {
                if (newStatusID != STATUS_ID_BAD) {
                    newStatusID = STATUS_ID_WARN;

                    addReply(sReply, CHAR_WARN, "vpnhelper.port.forwarding.get.failed");
                }
            }
        }

        if (newStatusID != -1) {
            currentStatusID = newStatusID;
        }
        String msgID = null;
        if (newStatusID == STATUS_ID_BAD) {
            msgID = "vpnhelper.topline.bad";
        } else if (newStatusID == STATUS_ID_OK) {
            msgID = "vpnhelper.topline.ok";
        } else if (newStatusID == STATUS_ID_WARN) {
            msgID = "vpnhelper.topline.warn";
        }
        if (msgID != null) {
            sReply.insert(0, texts.getLocalisedMessageText(msgID) + "\n");
        }

    } catch (Throwable t) {
        t.printStackTrace();
        PluginVPNHelper.log(t.toString());
    }

    lastPortCheckStatus = sReply.toString();

    triggers = PluginVPNHelper.instance.getCheckerListeners();
    for (CheckerListener l : triggers) {
        try {
            l.portCheckStatusChanged(lastPortCheckStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    synchronized (this) {
        checkingPortBinding = false;
    }
    return lastPortCheckStatus;
}

From source file:com.mirth.connect.client.ui.SettingsPanelResources.java

@Override
public boolean doSave() {
    resetInvalidProperties();/*from  w  w  w .j  a  va2  s .  com*/
    final String errors = checkProperties().trim();
    if (StringUtils.isNotEmpty(errors)) {
        getFrame().alertError(getFrame(), "Error validating resource settings:\n\n" + errors);
        return false;
    }

    if (!getFrame().alertOption(getFrame(),
            "<html>Libraries associated with any changed resources will be reloaded.<br/>Any channels / connectors using those libraries will be affected.<br/>Also, a maximum of 1000 files may be loaded into a directory<br/>resource, with additional files being skipped.<br/>Are you sure you wish to continue?</html>")) {
        return false;
    }

    updateResource(resourceTable.getSelectedRow());

    final String workingId = getFrame().startWorking("Saving resources...");
    final List<ResourceProperties> resources = new ArrayList<ResourceProperties>();

    for (int row = 0; row < resourceTable.getRowCount(); row++) {
        resources.add((ResourceProperties) resourceTable.getModel().getValueAt(row, PROPERTIES_COLUMN));
    }

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        @Override
        public Void doInBackground() throws ClientException {
            getFrame().mirthClient.setResources(resources);
            return null;
        }

        @Override
        public void done() {
            try {
                get();
                setSaveEnabled(false);
            } catch (Throwable t) {
                if (t instanceof ExecutionException) {
                    t = t.getCause();
                }
                getFrame().alertThrowable(getFrame(), t, "Error saving resources: " + t.toString());
            } finally {
                getFrame().stopWorking(workingId);
            }
        }
    };

    worker.execute();

    return true;
}