package org.opennms.netmgt.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/*
@RunWith(OpenNMSJUnit4ClassRunner.class)
@ContextConfiguration(locations={
        "classpath:/emptyContext.xml"
})
@TestExecutionListeners({
    OpenNMSConfigurationExecutionListener.class
})
*/
public class JMXDataCollectionConfigFactoryTest {
    @Before
    public void setUp() {
        System.setProperty("opennms.home", new File("target/test-classes").getAbsolutePath());
    }

    @Test
    // Tests that the JmxDataCollectionConfigFactory also supports/implements the split config feature.
    public void shouldSupportSplitConfig() throws FileNotFoundException {
        File jmxCollectionConfig = new File("src/test/resources/etc/jmx-datacollection-split.xml");
        Assert.assertTrue("JMX configuration file is not readable", jmxCollectionConfig.canRead());
        FileInputStream configFileStream = new FileInputStream(jmxCollectionConfig);

        JMXDataCollectionConfigFactory factory = new JMXDataCollectionConfigFactory(configFileStream);

        Assert.assertNotNull(factory.getJmxCollection("jboss"));
        Assert.assertNotNull(factory.getJmxCollection("jsr160"));
        Assert.assertEquals(8, factory.getJmxCollection("jboss").getMbeanCount());
        Assert.assertEquals(4, factory.getJmxCollection("jsr160").getMbeanCount());

    }
}

@@ -29,16 +29,65 @@
 onfig;%0A%0A
+import org.junit.Assert;%0Aimport org.junit.Test;%0A%0A
 import j
@@ -99,16 +99,16 @@
 o.File;%0A
-
 import j
@@ -174,469 +174,57 @@
 n;%0A%0A
-import org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/*%0A@RunWith(OpenNMSJUnit4ClassRunner.class)%0A@ContextConfiguration(locations=%7B%0A        %22classpath:/emptyContext.xml%22%0A%7D)%0A@TestExecutionListeners(%7B%0A    OpenNMSConfigurationExecutionListener.class%0A%7D)%0A*/%0Apublic class JMXDataCollectionConfigFactoryTest %7B%0A    @Before%0A    public void setUp() %7B%0A        System.setProperty(%22opennms.home%22, new File(%22target/test-classes%22).getAbsolutePath());%0A    %7D
+public class JMXDataCollectionConfigFactoryTest %7B
 %0A%0A  

Revert "set opennms home for JMXDataCollectionConfigFactory"