Merge JavaDoc modification and refactor.
diff --git a/src/test/java/net/onrc/onos/registry/controller/ZookeeperRegistryTest.java b/src/test/java/net/onrc/onos/registry/controller/ZookeeperRegistryTest.java
index f557663..3314ad2 100644
--- a/src/test/java/net/onrc/onos/registry/controller/ZookeeperRegistryTest.java
+++ b/src/test/java/net/onrc/onos/registry/controller/ZookeeperRegistryTest.java
@@ -41,8 +41,8 @@
 import com.netflix.curator.x.discovery.ServiceInstance;
 
 /**
- * Unit test for ZookeeperRegistry.
- * NOTE: FloodlightTestCase conflicts with PowerMock. If FloodLight-related methods need to be tested,
+ * Unit test for {@link ZookeeperRegistry}.
+ * NOTE: {@link FloodlightTestCase} conflicts with PowerMock. If FloodLight-related methods need to be tested,
  *       implement another test class to test them.
  * @author Naoki Shiota
  *
@@ -61,8 +61,8 @@
 	protected final String CONTROLLER_ID = "controller2013";
 
 	/**
-	 * Initialize ZookeeperRegistry Object and inject initial value with init() method.
-	 * This setup code also tests init() method itself.
+	 * Initialize {@link ZookeeperRegistry} Object and inject initial value with {@link ZookeeperRegistry#init(FloodlightModuleContext)} method.
+	 * This setup code also tests {@link ZookeeperRegistry#init(FloodlightModuleContext)} method itself.
 	 */
 	@Before
 	public void setUp() throws Exception {
@@ -97,8 +97,8 @@
 	}
 
 	/**
-	 * Test if registerController() method can go through without exception.
-	 * (Exceptions are usually out of test target, but registerController() throws an exception in case of invalid registration.)
+	 * Test if {@link ZookeeperRegistry#registerController(String)} method can go through without exception.
+	 * (Exceptions are usually out of test target, but {@link ZookeeperRegistry#registerController(String)} throws an exception in case of invalid registration.)
 	 */
 	@Test
 	public void testRegisterController() {
@@ -113,7 +113,7 @@
 	}
 
 	/**
-	 * Test if getControllerId() correctly returns registered ID.
+	 * Test if {@link ZookeeperRegistry#getControllerId()} correctly returns registered ID.
 	 * @throws Exception
 	 */
 	@Test
@@ -134,9 +134,9 @@
 	}
 
 	/**
-	 * Test if getAllControllers() returns all controllers.
-	 * Controllers are injected while setup. See createCuratorFrameworkMock() to what controllers
-	 * are injected using ServiceCache Mock.
+	 * Test if {@link ZookeeperRegistry#getAllControllers()} returns all controllers.
+	 * Controllers to be returned are injected while setup. See {@link ZookeeperRegistryTest#createCuratorFrameworkMock()}
+	 * to what controllers are injected using mock {@link ServiceCache}.
 	 * @throws Exception
 	 */
 	@Test
@@ -144,7 +144,6 @@
 		String controllerIdRegistered = "controller1";
 		String controllerIdNotRegistered = "controller2013";
 
-		// Test registered controller
 		try {
 			Collection<String> ctrls = registry.getAllControllers();
 			assertTrue(ctrls.contains(controllerIdRegistered));
@@ -156,13 +155,14 @@
 	}
 
 	/**
-	 * Test if requestControl() correctly take control of specific switch.
-	 * Because requestControl() doesn't return values, inject mock LeaderLatch object and verify latch is correctly set up.
+	 * Test if {@link ZookeeperRegistry#requestControl(long, net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback)}
+	 * correctly take control of specific switch. Because {@link ZookeeperRegistry#requestControl(long, net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback)}
+	 * doesn't return values, inject mock {@link LeaderLatch} object and verify latch is correctly set up.
 	 * @throws Exception
 	 */
 	@Test
 	public void testRequestControl() throws Exception {
-		// Mock of LeaderLatch
+		// Mock LeaderLatch
 		LeaderLatch latch = EasyMock.createMock(LeaderLatch.class);
 		latch.addListener(EasyMock.anyObject(SwitchLeaderListener.class));
 		EasyMock.expectLastCall().once();
@@ -172,7 +172,7 @@
 		
 		PowerMock.expectNew(LeaderLatch.class,
 				EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))
-				.andReturn(latch);
+				.andReturn(latch).once();
 		PowerMock.replay(LeaderLatch.class);
 		
 		String controllerId = "controller2013";
@@ -192,8 +192,9 @@
 	}
 
 	/**
-	 * Test if releaseControl() correctly release control of specific switch.
-	 * Because releaseControl() doesn't return values, inject mock LeaderLatch object and verify latch is correctly set up.
+	 * Test if {@link ZookeeperRegistry#releaseControl(long)} correctly release control of specific switch.
+	 * Because {@link ZookeeperRegistry#releaseControl(long)} doesn't return values, inject mock
+	 * {@link LeaderLatch} object and verify latch is correctly set up.
 	 * @throws Exception
 	 */
 	@Test
@@ -212,25 +213,23 @@
 		
 		PowerMock.expectNew(LeaderLatch.class,
 				EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))
-				.andReturn(latch);
+				.andReturn(latch).once();
 		PowerMock.replay(LeaderLatch.class);
 		
 		String controllerId = "controller2013";
 		registry.registerController(controllerId);
 		
-		long dpidToRequest = 1000L;
+		long dpidToRequest = 2000L;
 		LoggingCallback callback = new LoggingCallback(1);
 		
-		// to request and wait to take control
 		registry.requestControl(dpidToRequest, callback);
 		registry.releaseControl(dpidToRequest);
 		
-		// verify
 		EasyMock.verify(latch);
 	}
 
 	/**
-	 * Test if hasControl() returns correct status whether controller has control of specific switch.
+	 * Test if {@link ZookeeperRegistry#hasControl(long)} returns correct status whether controller has control of specific switch.
 	 * @throws Exception
 	 */
 	@Test
@@ -276,8 +275,8 @@
 	}
 
 	/**
-	 * Test if getControllerForSwitch() correctly returns controller ID of specific switch.
-	 * Relation between controllers and switches are defined by setPathChildrenCache() function.
+	 * Test if {@link ZookeeperRegistry#getControllerForSwitch(long)} correctly returns controller ID of specific switch.
+	 * Relation between controllers and switches are defined by {@link ZookeeperRegistryTest#setPathChildrenCache()} function.
 	 * @throws Throwable
 	 */
 	@Test
@@ -295,11 +294,11 @@
 	}
 
 	/**
-	 * Test if getSwitchesControlledByController() returns correct list of switches controlled by
-	 * a controller.
+	 * Test if {@link ZookeeperRegistry#getSwitchesControlledByController(String)} returns correct list of
+	 * switches controlled by a controller.
 	 * @throws Exception
 	 */
-	// TODO: Test after implementation of getSwitch() is done.
+	// TODO: Test after getSwitchesControlledByController() is implemented.
 	@Ignore @Test
 	public void testGetSwitchesControlledByController() throws Exception {
 		String controllerIdRegistered = "controller1";
@@ -316,8 +315,8 @@
 	}
 
 	/**
-	 * Test if getAllSwitches() returns correct list of all switches.
-	 * Switches are injected in setPathChildrenCache() function.
+	 * Test if {@link ZookeeperRegistry#getAllSwitches()} returns correct list of all switches.
+	 * Switches are injected in {@link ZookeeperRegistryTest#setPathChildrenCache()} function.
 	 * @throws Exception
 	 */
 	@Test
@@ -339,7 +338,7 @@
 	}
 
 	/**
-	 * Test if allocateUniqueIdBlock() can assign IdBlock without duplication.
+	 * Test if {@link ZookeeperRegistry#allocateUniqueIdBlock()} can assign IdBlock without duplication.
 	 */
 	@Test
 	public void testAllocateUniqueIdBlock() {
@@ -374,20 +373,21 @@
 		}
 	}
 	
+	
+	//-------------------------- Creation of mock objects --------------------------
 	/**
-	 * Create mock CuratorFramework object with initial value below.
-	 *   [Ctrl ID]    : [DPID]
-	 * controller1    :  1000
-	 * controller2    :  1001
-	 * controller2    :  1002
+	 * Create mock {@link CuratorFramework} object with initial value below.<br>
+	 *   [Ctrl ID]    : [DPID]<br>
+	 * controller1    :  1000<br>
+	 * controller2    :  1001<br>
+	 * controller2    :  1002<br>
 	 * controller2013 : nothing
 	 * @return Created mock object
 	 * @throws Exception
 	 */
-	@SuppressWarnings("serial")
+	@SuppressWarnings({ "serial", "unchecked" })
 	private CuratorFramework createCuratorFrameworkMock() throws Exception {
 		// Mock of AtomicValue
-		@SuppressWarnings("unchecked")
 		AtomicValue<Long> atomicValue = EasyMock.createMock(AtomicValue.class);
 		EasyMock.expect(atomicValue.succeeded()).andReturn(true).anyTimes();
 		EasyMock.expect(atomicValue.preValue()).andAnswer(new IAnswer<Long>() {
@@ -408,7 +408,7 @@
 		}).anyTimes();
 		EasyMock.replay(atomicValue);
 		
-		// Mock of DistributedAtomicLong
+		// Mock DistributedAtomicLong
 		DistributedAtomicLong daLong = EasyMock.createMock(DistributedAtomicLong.class);
 		EasyMock.expect(daLong.add(EasyMock.anyLong())).andReturn(atomicValue).anyTimes();
 		EasyMock.replay(daLong);
@@ -418,8 +418,7 @@
 				andReturn(daLong).anyTimes();
 		PowerMock.replay(DistributedAtomicLong.class);
 		
-		// Mock of ListenerContainer
-		@SuppressWarnings("unchecked")
+		// Mock ListenerContainer
 		ListenerContainer<PathChildrenCacheListener> listenerContainer = EasyMock.createMock(ListenerContainer.class);
 		listenerContainer.addListener(EasyMock.anyObject(PathChildrenCacheListener.class));
 		EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@@ -431,13 +430,13 @@
 		}).once();
 		EasyMock.replay(listenerContainer);
 
-		// Mock of PathChildrenCache
+		// Mock PathChildrenCache
 		PathChildrenCache pathChildrenCacheMain = createPathChildrenCacheMock(CONTROLLER_ID, new String[] {"/switches"}, listenerContainer);
 		PathChildrenCache pathChildrenCache1 = createPathChildrenCacheMock("controller1", new String[] {HexString.toHexString(1000L)}, listenerContainer);
 		PathChildrenCache pathChildrenCache2 = createPathChildrenCacheMock("controller2", new String[] { 
 			HexString.toHexString(1001L), HexString.toHexString(1002L) },listenerContainer);
 		
-		// Mock of PathChildrenCache constructor
+		// Mock PathChildrenCache constructor
 		PowerMock.expectNew(PathChildrenCache.class,
 				EasyMock.anyObject(CuratorFramework.class), EasyMock.anyObject(String.class), EasyMock.anyBoolean()).
 				andReturn(pathChildrenCacheMain).once();
@@ -449,8 +448,7 @@
 				andReturn(pathChildrenCache2).anyTimes();
 		PowerMock.replay(PathChildrenCache.class);
 		
-		// Mock of ServiceCache
-		@SuppressWarnings("unchecked")
+		// Mock ServiceCache
 		ServiceCache<ControllerService> serviceCache = EasyMock.createMock(ServiceCache.class);
 		serviceCache.start();
 		EasyMock.expectLastCall().once();
@@ -460,15 +458,13 @@
 		}}).anyTimes();
 		EasyMock.replay(serviceCache);
 		
-		// Mock of ServiceCacheBuilder
-		@SuppressWarnings("unchecked")
+		// Mock ServiceCacheBuilder
 		ServiceCacheBuilder<ControllerService> serviceCacheBuilder = EasyMock.createMock(ServiceCacheBuilder.class);
 		EasyMock.expect(serviceCacheBuilder.name(EasyMock.anyObject(String.class))).andReturn(serviceCacheBuilder).once();
 		EasyMock.expect(serviceCacheBuilder.build()).andReturn(serviceCache).once();
 		EasyMock.replay(serviceCacheBuilder);
 
-		// Mock of ServiceDiscovery
-		@SuppressWarnings("unchecked")
+		// Mock ServiceDiscovery
 		ServiceDiscovery<ControllerService> serviceDiscovery = EasyMock.createMock(ServiceDiscovery.class);
 		serviceDiscovery.start();
 		EasyMock.expectLastCall().once();
@@ -477,15 +473,14 @@
 		EasyMock.expectLastCall().once();
 		EasyMock.replay(serviceDiscovery);
 		
-		// Mock of CuratorFramework
+		// Mock CuratorFramework
 		CuratorFramework client = EasyMock.createMock(CuratorFramework.class);
 		client.start();
 		EasyMock.expectLastCall().once();
 		EasyMock.expect(client.usingNamespace(EasyMock.anyObject(String.class))).andReturn(client);
 		EasyMock.replay(client);
 
-		// Mock of ServiceDiscoveryBuilder
-		@SuppressWarnings("unchecked")
+		// Mock ServiceDiscoveryBuilder
 		ServiceDiscoveryBuilder<ControllerService> builder = EasyMock.createMock(ServiceDiscoveryBuilder.class);
 		EasyMock.expect(builder.client(client)).andReturn(builder).once();
 		EasyMock.expect(builder.basePath(EasyMock.anyObject(String.class))).andReturn(builder);
@@ -500,9 +495,9 @@
 	}
 	
 	/**
-	 * Create mock ServiceInstance object using given controller ID.
-	 * @param controllerId Controller ID to represent instance's payload (ControllerSeervice).
-	 * @return
+	 * Create mock {@link ServiceInstance} object using given controller ID.
+	 * @param controllerId Controller ID to represent instance's payload (ControllerService).
+	 * @return Mock ServiceInstance object
 	 */
 	private ServiceInstance<ControllerService> createServiceInstanceMock(String controllerId) {
 		ControllerService controllerService = EasyMock.createMock(ControllerService.class);
@@ -518,11 +513,11 @@
 	}
 	
 	/**
-	 * Create mock PathChildrenCache using given controller ID and DPIDs.
+	 * Create mock {@link PathChildrenCache} using given controller ID and DPIDs.
 	 * @param controllerId Controller ID to represent current data.
 	 * @param paths List of HexString indicating switch's DPID.
 	 * @param listener Callback object to be set as Listenable.
-	 * @return
+	 * @return Mock PathChildrenCache object
 	 * @throws Exception
 	 */
 	private PathChildrenCache createPathChildrenCacheMock(final String controllerId, final String [] paths,
@@ -549,11 +544,11 @@
 	}
 	
 	/**
-	 * Create mock ChildData for {@link PathChildrenCache#getCurrentData()} return value.
+	 * Create mock {@link ChildData} for {@link PathChildrenCache#getCurrentData()} return value.
 	 * This object need to include 'sequence number' in tail of path string. ("-0" means 0th sequence)
 	 * @param controllerId Controller ID
 	 * @param path HexString indicating switch's DPID
-	 * @return
+	 * @return Mock ChildData object
 	 */
 	private ChildData createChildDataMockForCurrentData(String controllerId, String path) {
 		ChildData data = EasyMock.createMock(ChildData.class);
@@ -570,21 +565,21 @@
 	 */
 	private void setPathChildrenCache() throws Exception {
 		pathChildrenCacheListener.childEvent(client,
-				createChildDataEventMock("controller1", HexString.toHexString(1000L), PathChildrenCacheEvent.Type.CHILD_ADDED));
+				createChildrenCacheEventMock("controller1", HexString.toHexString(1000L), PathChildrenCacheEvent.Type.CHILD_ADDED));
 		pathChildrenCacheListener.childEvent(client,
-				createChildDataEventMock("controller2", HexString.toHexString(1001L), PathChildrenCacheEvent.Type.CHILD_ADDED));
+				createChildrenCacheEventMock("controller2", HexString.toHexString(1001L), PathChildrenCacheEvent.Type.CHILD_ADDED));
 		pathChildrenCacheListener.childEvent(client,
-				createChildDataEventMock("controller2", HexString.toHexString(1002L), PathChildrenCacheEvent.Type.CHILD_ADDED));
+				createChildrenCacheEventMock("controller2", HexString.toHexString(1002L), PathChildrenCacheEvent.Type.CHILD_ADDED));
 	}
 
 	/**
-	 * Create mock ChildDataEvent object using given controller ID and DPID.
+	 * Create mock {@link PathChildrenCacheEvent} object using given controller ID and DPID.
 	 * @param controllerId Controller ID.
 	 * @param path HexString of DPID.
 	 * @param type Event type to be set to mock object.
-	 * @return
+	 * @return Mock PathChildrenCacheEvent object
 	 */
-	private PathChildrenCacheEvent createChildDataEventMock(String controllerId, String path,
+	private PathChildrenCacheEvent createChildrenCacheEventMock(String controllerId, String path,
 			PathChildrenCacheEvent.Type type) {
 		PathChildrenCacheEvent event = EasyMock.createMock(PathChildrenCacheEvent.class);
 		ChildData data = EasyMock.createMock(ChildData.class);