### Question:
DataCollectionConfigFactory { public static synchronized DataCollectionConfigDao getInstance() { if (m_singleton == null) throw new IllegalStateException("The factory has not been initialized"); return m_singleton; }  static void setInstance(DataCollectionConfigDao instance); static synchronized void init(); static synchronized void reload(); static synchronized DataCollectionConfigDao getInstance(); static void main(String[] args);  }### Answer:
@Test public void testNms6186() throws MarshalException, ValidationException, IOException { initDataCollectionFactory(m_xml_nms6186); assertEquals(0, DataCollectionConfigFactory.getInstance().getMibObjectList("default", ".1.9.9.9.9", "127.0.0.1", 0).size()); }
@Test public void testNms6186_2() throws MarshalException, ValidationException, IOException { String modifiedXml = m_xml_nms6186.replaceFirst("</snmp-collection>", m_systemsXmlFragment+"</snmp-collection>"); initDataCollectionFactory(modifiedXml); assertEquals(12, DataCollectionConfigFactory.getInstance().getMibObjectList("default", ".1.3.6.1.4.1.200", "127.0.0.1", 0).size()); }
@Test public void testValidResourceType() throws MarshalException, ValidationException, IOException { String modifiedXml = m_xml.replaceFirst("ifIndex", "brocadeIndex").replaceFirst("<groups", m_brocadeXmlFragment + "<groups"); initDataCollectionFactory(modifiedXml); assertEquals(m_rrdRepository.getAbsolutePath(), DataCollectionConfigFactory.getInstance().getRrdPath()); assertEquals(0, DataCollectionConfigFactory.getInstance().getMibObjectList("default", ".1.9.9.9.9", "127.0.0.1", 0).size()); List<MibObject> mibObjects = DataCollectionConfigFactory.getInstance().getMibObjectList("default", ".1.3.6.1.4.1.200", "127.0.0.1", 0); MibObject first = mibObjects.remove(0); assertEquals("Invalid MibObject: " + first, "brocadeIndex", first.getInstance()); for (MibObject object : mibObjects) { assertEquals("Invalid MibObject: " + object, "ifIndex", object.getInstance()); } assertArrayEquals(new String[] {"brocadeIndex"}, DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes().keySet().toArray(new String[0])); }
@Test public void testInvalidResourceType() throws MarshalException, ValidationException, IOException { String modifiedXml = m_xml.replaceFirst("ifIndex", "brocadeIndex"); ThrowableAnticipator ta = new ThrowableAnticipator(); ta.anticipate(new IllegalArgumentException("instance 'brocadeIndex' invalid in mibObj definition for OID '.1.3.6.1.2.1.2.2.1.10' in collection 'default' for group 'mib2-interfaces'. Allowable instance values: any positive number, 'ifIndex', or any of the configured resourceTypes: (none)")); try { initDataCollectionFactory(modifiedXml); assertArrayEquals(new String[0], DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes().keySet().toArray(new String[0])); DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes(); } catch (Throwable t) { ta.throwableReceived(t); } ta.verifyAnticipated(); }