AutonomicClusterManagementHeuristicService { @SuppressWarnings("unchecked") protected Class<? extends ClusterAdministrationHeuristicAlgorithm> loadAlgorithmClass(String algorithmName) throws ClassNotFoundException { logger.info(String.format("Loading heuristics from algorithm [algorithm class name=%s]", algorithmName)); Class<? extends ClusterAdministrationHeuristicAlgorithm> algorithmClass = (Class<? extends ClusterAdministrationHeuristicAlgorithm>)Class.forName(algorithmName.trim()); algorithmsMap.put(algorithmName, algorithmClass); return algorithmClass; }  ClusterAdministrationHeuristicAlgorithm getAdministrationAlgorithm(); final static String CLUSTER_ADMINISTRATION_ALGORITHMS_IN_CONFIGURATION_KEY; }
@Test public void loadAlgorithmClassTest() throws ClassNotFoundException { spy.loadAlgorithmClass("br.com.autonomiccs.autonomic.administration.algorithms.impl.ClusterManagementDummyAlgorithm"); Assert.assertEquals(1, spy.algorithmsMap.size()); Assert.assertTrue(spy.algorithmsMap.containsKey("br.com.autonomiccs.autonomic.administration.algorithms.impl.ClusterManagementDummyAlgorithm")); }
@Test(expected = ClassNotFoundException.class) public void loadAlgorithmClassTestExpectClassNotFoundException() throws ClassNotFoundException { spy.loadAlgorithmClass("this.class.does.not.exist"); }