Java Code Examples for org.eclipse.core.runtime.NullProgressMonitor#setCanceled()

The following examples show how to use org.eclipse.core.runtime.NullProgressMonitor#setCanceled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractStatsAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the cancel operation
 *
 * @throws TmfAnalysisException
 *             should not happen
 */
@Test
public void testPartialPerTypeStatsCancel() throws TmfAnalysisException {
    TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
    StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
    NullProgressMonitor monitor = new NullProgressMonitor();
    monitor.setCanceled(true);
    Map<@NonNull String, IStatistics<@NonNull ISegment>> perTypeStats = fixture.getStatsPerTypeForRange(100, 1100, monitor);
    assertEquals(Collections.emptyMap(), perTypeStats);
    trace.dispose();
    fixture.dispose();
}
 
Example 2
Source File: ImportLibsOperationTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void tesNoImportIfMonitorCancelled() throws IOException, InvocationTargetException, InterruptedException {
    final File tmpFileWhichWillBeCopied = tmpFolder.newFile("test.jar");
    FileUtil.copy(this.getClass().getResourceAsStream("test.jar"), new FileOutputStream(tmpFileWhichWillBeCopied));
    final String[] jarAndZips = new String[] { tmpFileWhichWillBeCopied.toString() };
    final ImportLibsOperation importLibsRunnable = new ImportLibsOperation(libStore, jarAndZips, "");
    final NullProgressMonitor monitor = new NullProgressMonitor();
    monitor.setCanceled(true);
    importLibsRunnable.run(monitor);

    verify(libStore, never()).createRepositoryFileStore(tmpFileWhichWillBeCopied.getName());
    verify(libFileStore, never()).save(notNull(Object.class));
}