У меня есть 2 модульных теста
, когда я их запускаю, у меня появляется ошибка ниже
1) test
@Test
public void simpleInsertAndOutputEventPrint() throws IOException, URISyntaxException {
GenericRecord record = getInitialEvent();
testDriver.pipeInput(recordFactory.create(record));
GenericRecord result = testDriver.readOutput(detailsEventTopic, stringDeserializer, genericAvroSerde.deserializer()).value();
Assert.assertEquals(1,result.get("tt"));
}
2) Test
@Test
public void stateStoreSimpleInsertOutputPrint() {
GenericRecord record = getInitialAvayaEvent();
testDriver.pipeInput(recordFactory.create(record));
Packet packet1 = (Packet) store.get("dddfdfdf");
Assert.assertEquals("ddd",packet1.getc1());
}
Метод init
@Before
public void setUp() throws IOException, RestClientException, URISyntaxException {
...
recordFactory = new ConsumerRecordFactory<>(initialSourceTopic,new StringSerializer(), genericAvroSerde.serializer());
testDriver = new TopologyTestDriver(topology, props);
this.store = testDriver.getKeyValueStore(db);
}
также, когда я пытался добавить следующий код:
@After
public void tearDown() {
testDriver.close(); // Close processors after finish the tests
}
я получил следующую ошибку:
[2018-09-25 22:45:38,178] ERROR stream-thread [main] Failed to delete the state directory. (org.apache.kafka.streams.processor.internals.StateDirectory)
java.nio.file.DirectoryNotEmptyException: \tmp\kafka-streams\ks-stock-analysis-appid\0_0
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
at java.nio.file.Files.delete(Files.java:1126)
at org.apache.kafka.common.utils.Utils$2.postVisitDirectory(Utils.java:740)
at org.apache.kafka.common.utils.Utils$2.postVisitDirectory(Utils.java:723)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.apache.kafka.common.utils.Utils.delete(Utils.java:723)
at org.apache.kafka.streams.processor.internals.StateDirectory.cleanRemovedTasks(StateDirectory.java:287)
at org.apache.kafka.streams.processor.internals.StateDirectory.clean(StateDirectory.java:228)
at org.apache.kafka.streams.TopologyTestDriver.close(TopologyTestDriver.java:679)
at com.dvsts.avaya.processing.topology.TopologyKafkaStreamTest.tearDown(TopologyKafkaStreamTest.java:235)