I have a problem with spring embedded kafka which I want to use to test my kafka sender/receiver.
When I try to run my tests using:
@RunWith(MockitoJUnitRunner.class)
@SpringBootTest
@DirtiesContext
public class myTestClass {
@ClassRule
public static EmbeddedKafkaRule embeddedKafka =
new EmbeddedKafkaRule(1, true, RECEIVER_TOPIC);
@Test public void test() {
System.out.println("@Test");
}
}
I get an error:
java.io.IOException: Failed to load C:\Users\username\AppData\Local\Temp\kafka-8251150311475880576 during broker startup
...
15:29:33.135 [main] ERROR kafka.log.LogManager - Shutdown broker because none of the specified log dirs from C:\Users\username\AppData\Local\Temp\kafka-8251150311475880576 can be created or validated
Im sure that as a user I have access to this directory and when I'm running tests I can see that kafka is creating this kind of diretories (empty) on temp folder but still not working.
This is my pom configuration:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.2.0.RC1</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.2.0.RC1</version>
<scope>test</scope>
</dependency>
appliacation.properties:
kafka.bootstrap-servers= ${spring.embedded.kafka.brokers}
The interesting thing is that I have an example of kafka embedded used for testing purposes cloned from the internet and it just works fine but when I apply it to my project it just crushes as above.
Any suggestions what am I doing wrong?