@Test public void testInitNormal() throws Exception { ProductLineConfigManager manager = new MockProductLineConfigManager(); ((MockProductLineConfigManager) manager).setConfigDao(new MockConfigDao1()); manager.initialize(); ProductLine line1 = new ProductLine("Test1"); ProductLine line2 = new ProductLine("Test2"); String[] domains1 = {"domain1", "domain2"}; String[] domains2 = {"domain3", "domain4"}; manager.insertProductLine(line1, domains1); manager.insertProductLine(line2, domains2); Assert.assertEquals(2, s_storeCount); Assert.assertEquals("Default", manager.queryProductLineByDomain("domain")); Assert.assertEquals("Test1", manager.queryProductLineByDomain("domain1")); List<String> pDomains = manager.queryProductLineDomains("Test1"); Assert.assertEquals(2, pDomains.size()); Map<String, ProductLine> productLines = manager.queryProductLines(); Assert.assertEquals(3, productLines.size()); manager.enableLogging(new MockLog()); manager.refreshProductLineConfig(); productLines = manager.queryProductLines(); Assert.assertEquals(1, productLines.size()); }
@Test public void testInitThrowException() throws Exception { ProductLineConfigManager manager = new MockProductLineConfigManager(); ((MockProductLineConfigManager) manager).setConfigDao(new MockConfigDao2()); try { manager.initialize(); } catch (Exception e) { } Company config = manager.getCompany(); Assert.assertEquals(0, config.getProductLines().size()); }