public Collection<Object> toJson() throws PreloadException { if (t instanceof PreloadException) { throw (PreloadException) t; } throw new PreloadException(t); } }
public Collection<Object> toJson() throws PreloadException { if (t instanceof PreloadException) { throw (PreloadException) t; } throw new PreloadException(t); } }
public Collection<Object> toJson() throws PreloadException { if (t instanceof PreloadException) { throw (PreloadException) t; } throw new PreloadException(t); } }
public Collection<Object> toJson() throws PreloadException { throw new PreloadException("test"); } };
public Collection<Object> toJson() throws PreloadException { throw new PreloadException("test"); } };
public Collection<Object> toJson() throws PreloadException { throw new PreloadException("test"); } };
public PreloadedData call() throws Exception { executedThread = Thread.currentThread(); if (preload == null) { throw new PreloadException("No preload for this test."); } return preload; } }
public PreloadedData call() throws Exception { executedThread = Thread.currentThread(); if (preload == null) { throw new PreloadException("No preload for this test."); } return preload; } }
public PreloadedData call() throws Exception { executedThread = Thread.currentThread(); if (preload == null) { throw new PreloadException("No preload for this test."); } return preload; } }
public PreloadedData get() throws InterruptedException, ExecutionException { if (throwsInterrupted) { throw new InterruptedException("Interrupted!"); } if (throwsExecution) { throw new ExecutionException(new RuntimeException("Fail")); } if (throwsExecutionWrapped) { throw new ExecutionException(new PreloadException("Preload failed.")); } return new PreloadedData() { public Collection<Object> toJson() { return expectedResult(key); } }; }
public PreloadedData get() throws InterruptedException, ExecutionException { if (throwsInterrupted) { throw new InterruptedException("Interrupted!"); } if (throwsExecution) { throw new ExecutionException(new RuntimeException("Fail")); } if (throwsExecutionWrapped) { throw new ExecutionException(new PreloadException("Preload failed.")); } return new PreloadedData() { public Collection<Object> toJson() { return expectedResult(key); } }; }
public PreloadedData get() throws InterruptedException, ExecutionException { if (throwsInterrupted) { throw new InterruptedException("Interrupted!"); } if (throwsExecution) { throw new ExecutionException(new RuntimeException("Fail")); } if (throwsExecutionWrapped) { throw new ExecutionException(new PreloadException("Preload failed.")); } return new PreloadedData() { public Collection<Object> toJson() { return expectedResult(key); } }; }
@Test public void executePreloadException() throws Exception { PipelinedData pipeline = getPipelinedData(CONTENT); final PreloadedData willThrow = control.createMock(PreloadedData.class); Callable<PreloadedData> callable = new Callable<PreloadedData>() { public PreloadedData call() throws Exception { return willThrow; } }; // One batch expect(preloader.createPreloadTasks(same(context), isA(PipelinedData.Batch.class))).andReturn(ImmutableList.of(callable)); // And PreloadedData that throws an exception expect(willThrow.toJson()).andThrow(new PreloadException("Failed")); control.replay(); PipelineExecutor.Results results = executor.execute(context, ImmutableList.of(pipeline)); // The exception is fully handled, and leads to empty results assertEquals(0, results.results.size()); assertTrue(results.keyedResults.isEmpty()); assertTrue(results.remainingPipelines.isEmpty()); control.verify(); }
@Test public void executePreloadException() throws Exception { PipelinedData pipeline = getPipelinedData(CONTENT); final PreloadedData willThrow = control.createMock(PreloadedData.class); Callable<PreloadedData> callable = new Callable<PreloadedData>() { public PreloadedData call() throws Exception { return willThrow; } }; // One batch expect(preloader.createPreloadTasks(same(context), isA(PipelinedData.Batch.class))).andReturn(ImmutableList.of(callable)); // And PreloadedData that throws an exception expect(willThrow.toJson()).andThrow(new PreloadException("Failed")); control.replay(); PipelineExecutor.Results results = executor.execute(context, ImmutableList.of(pipeline)); // The exception is fully handled, and leads to empty results assertEquals(0, results.results.size()); assertTrue(results.keyedResults.isEmpty()); assertTrue(results.remainingPipelines.isEmpty()); control.verify(); }
@Test public void executePreloadException() throws Exception { PipelinedData pipeline = getPipelinedData(CONTENT); final PreloadedData willThrow = control.createMock(PreloadedData.class); Callable<PreloadedData> callable = new Callable<PreloadedData>() { public PreloadedData call() throws Exception { return willThrow; } }; // One batch expect(preloader.createPreloadTasks(same(context), isA(PipelinedData.Batch.class))).andReturn(ImmutableList.of(callable)); // And PreloadedData that throws an exception expect(willThrow.toJson()).andThrow(new PreloadException("Failed")); control.replay(); PipelineExecutor.Results results = executor.execute(context, ImmutableList.of(pipeline)); // The exception is fully handled, and leads to empty results assertEquals(0, results.results.size()); assertTrue(results.keyedResults.isEmpty()); assertTrue(results.remainingPipelines.isEmpty()); control.verify(); }