@Test
public void testCancelDataSinkTask() {

	super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE);
	super.addInput(new InfiniteInputIterator(), 0);
	
	final DataSinkTask<Record> testTask = new DataSinkTask<Record>();
	Configuration stubParams = new Configuration();
	super.getTaskConfig().setStubParameters(stubParams);
	
	super.registerFileOutputTask(testTask, MockOutputFormat.class,  new File(tempTestPath).toURI().toString());
	
	Thread taskRunner = new Thread() {
		@Override
		public void run() {
			try {
				testTask.invoke();
			} catch (Exception ie) {
				ie.printStackTrace();
				Assert.fail("Task threw exception although it was properly canceled");
			}
		}
	};
	taskRunner.start();
	
	TaskCancelThread tct = new TaskCancelThread(1, taskRunner, testTask);
	tct.start();
	
	try {
		tct.join();
		taskRunner.join();		
	} catch(InterruptedException ie) {
		Assert.fail("Joining threads failed");
	}
	
	// assert that temp file was created
	File tempTestFile = new File(this.tempTestPath);
	Assert.assertTrue("Temp output file does not exist",tempTestFile.exists());
			
}