PerformanceMonitorFactory { public synchronized PerformanceMonitor createPerformanceMonitor(String name) { PerformanceMonitor performanceMonitor = findPerformanceMonitor(name); if (performanceMonitor == null) { performanceMonitor = new PerformanceMonitor(); addPerformanceMonitorToMap(name, performanceMonitor); } return performanceMonitor; } PerformanceMonitorFactory(); synchronized PerformanceMonitor createPerformanceMonitor(String name); PerformanceMonitor findPerformanceMonitor(String name); Set<String> getPerformanceMonitorNames();  }
@Test public void testCreatePerformanceMonitor() { PerformanceMonitor createdMonitor = factory.createPerformanceMonitor("testCreate"); assertNotNull(createdMonitor); }
@Test public void testCreateDuplicatePerformanceMonitor() { String name = "testCreate"; PerformanceMonitor createdMonitor = factory.createPerformanceMonitor(name); PerformanceMonitor secondMonitor = factory.createPerformanceMonitor(name); assertSame(createdMonitor, secondMonitor); }