title: java.lang.NoClassDefFoundError when running KafkaEmbedded for Unit test
body: <p>I have a Spring-Kafka project running Spring Boot 2.0.2. In the unit test I am trying to start a KafkaEmbedded server. I get this error.</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/apache/kafka/common/security/auth/SecurityProtocol
  
  at kafka.utils.TestUtils$.createBrokerConfig(TestUtils.scala:222)
  at kafka.utils.TestUtils.createBrokerConfig(TestUtils.scala)
  at org.springframework.kafka.test.rule.KafkaEmbedded.createBrokerProperties(KafkaEmbedded.java:278)
  at org.springframework.kafka.test.rule.KafkaEmbedded.before(KafkaEmbedded.java:224)
  at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
  at org.junit.rules.RunRules.evaluate(RunRules.java:20)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.security.auth.SecurityProtocol
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 13 more
  </code></pre>
  
  <p>I am aware that this is because of the dependencies mis-match. But I have added the latest versions spring-kafka-test &amp; kafka-clients. I am aware that this class "SecurityProtocol" is in the Kafka-clients jar but adding that dependency (old &amp; new versions) still does not solve the problem.</p>
  
  <p>The following is the dependencies in pom file.</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.0.2.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;spring-kafka&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;spring-kafka-test&lt;/artifactId&gt;
          &lt;version&gt;2.1.6.RELEASE&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;kafka-clients&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Here is the basic Unit test that uses the EmbeddedKafka.</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class KafkaDemoApplicationTests {
  
      @ClassRule
      public static KafkaEmbedded embeddedKafka = new KafkaEmbedded(1, true,
              Topology.DEMO_TOPIC);
  
      @Test
      public void contextLoads() {
      }
  
  }
  </code></pre>