Source:
<code>public void testPartitionManagedLockReleaseOnInterruptException() throws InterruptedException { Datastream datastream = KafkaMirrorMakerConnectorTestUtils.createDatastream("pizzaStream", _broker, "\\w+Pizza"); DatastreamTaskImpl task = new DatastreamTaskImpl(Collections.singletonList(datastream)); DatastreamEventProducer mockDatastreamEventProducer = mock(DatastreamEventProducer.class); doThrow(InterruptException.class).when(mockDatastreamEventProducer).flush(); <START> doNothing().when(mockDatastreamEventProducer).send(any(DatastreamProducerRecord.class), any(SendCallback.class)); <END> task.setEventProducer(mockDatastreamEventProducer); KafkaBasedConnectorConfig connectorConfig = new KafkaBasedConnectorConfigBuilder() .setConsumerFactory(new LiKafkaConsumerFactory()) .setCommitIntervalMillis(10000) .setEnablePartitionManaged(true) .build(); ZkAdapter zkAdatper = new ZkAdapter(_kafkaCluster.getZkConnection(), "testCluster", null, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, null); task.setZkAdapter(zkAdatper); zkAdatper.connect(); KafkaMirrorMakerConnectorTaskTest connectorTask = new KafkaMirrorMakerConnectorTaskTest(connectorConfig, task, "", false, new KafkaMirrorMakerGroupIdConstructor(false, "testCluster")); Thread connectorThread = new Thread(connectorTask, "connector thread"); connectorThread.setDaemon(true); AtomicReference<Throwable> uncaughtException = new AtomicReference<>(); connectorThread.setUncaughtExceptionHandler((t, e) -> uncaughtException.set(e)); connectorThread.start(); if (!connectorTask.awaitStart(60, TimeUnit.SECONDS)) { Assert.fail("connector did not start within timeout"); } connectorThread.join(); Assert.assertFalse(connectorTask.isPostShutdownHookExceptionCaught()); }</code><technical_language>need this line? I is Mockito's default behavior (unless instructed)</technical_language>

Target:
public void testPartitionManagedLockReleaseOnInterruptException() throws InterruptedException { Datastream datastream = KafkaMirrorMakerConnectorTestUtils.createDatastream("pizzaStream", _broker, "\\w+Pizza"); DatastreamTaskImpl task = new DatastreamTaskImpl(Collections.singletonList(datastream)); DatastreamEventProducer mockDatastreamEventProducer = mock(DatastreamEventProducer.class); doThrow(InterruptException.class).when(mockDatastreamEventProducer).flush(); task.setEventProducer(mockDatastreamEventProducer); KafkaBasedConnectorConfig connectorConfig = new KafkaBasedConnectorConfigBuilder() .setConsumerFactory(new LiKafkaConsumerFactory()) .setCommitIntervalMillis(10000) .setEnablePartitionManaged(true) .build(); ZkAdapter zkAdatper = new ZkAdapter(_kafkaCluster.getZkConnection(), "testCluster", null, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, null); task.setZkAdapter(zkAdatper); zkAdatper.connect(); KafkaMirrorMakerConnectorTaskTest connectorTask = new KafkaMirrorMakerConnectorTaskTest(connectorConfig, task, "", false, new KafkaMirrorMakerGroupIdConstructor(false, "testCluster")); Thread connectorThread = KafkaMirrorMakerConnectorTestUtils.runKafkaMirrorMakerConnectorTask(connectorTask); connectorThread.join(); Assert.assertFalse(connectorTask.isPostShutdownHookExceptionCaught()); }