From d46c60f4574624a7b5b2881780d12e06b2876140 Mon Sep 17 00:00:00 2001 From: Balaji Seshadri Date: Sat, 4 Oct 2014 23:39:05 -0600 Subject: [PATCH] KAFKA-328 Write unit test for kafka server startup and shutdown API --- .../test/scala/unit/kafka/server/ServerShutdownTest.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala index 3804a11..a140ebe 100644 --- a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala +++ b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala @@ -140,7 +140,20 @@ class ServerShutdownTest extends JUnit3Suite with ZooKeeperTestHarness { Utils.rm(server.config.logDirs) verifyNonDaemonThreadsStatus } - + @Test + def testServerStartupConsecutively() { + var server = new KafkaServer(config) + server.startup() + try { + server.startup() + } + catch { + case ex => { + assertTrue(ex.getMessage().contains("This scheduler has already been started!")) + } + } + server.shutdown() + } def verifyNonDaemonThreadsStatus() { assertEquals(0, Thread.getAllStackTraces.keySet().toArray .map(_.asInstanceOf[Thread]) -- 1.8.5.2 (Apple Git-48)