|
|
|
@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.analytics.data.publisher.config.InvalidConfigu
|
|
|
|
|
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -33,12 +34,16 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest {
|
|
|
|
|
|
|
|
|
|
@Test(description = "Validating the behaviour od getInstance of the config before calling the init",
|
|
|
|
|
expectedExceptions = InvalidConfigurationStateException.class)
|
|
|
|
|
public void testGetInstanceWithoutInit() {
|
|
|
|
|
public void testGetInstanceWithoutInit() throws NoSuchFieldException, IllegalAccessException {
|
|
|
|
|
Field configField = AnalyticsConfiguration.class.getDeclaredField("config");
|
|
|
|
|
configField.setAccessible(true);
|
|
|
|
|
configField.set(configField, null);
|
|
|
|
|
AnalyticsConfiguration.getInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test(description = "Validating the behaviour od getInstance of the config before calling the init",
|
|
|
|
|
expectedExceptions = DataPublisherConfigurationException.class)
|
|
|
|
|
expectedExceptions = DataPublisherConfigurationException.class,
|
|
|
|
|
dependsOnMethods = "testGetInstanceWithoutInit")
|
|
|
|
|
public void testInitWithInvalidConfig() throws DataPublisherConfigurationException {
|
|
|
|
|
ClassLoader classLoader = this.getClass().getClassLoader();
|
|
|
|
|
URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" +
|
|
|
|
@ -51,7 +56,8 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Validating the behaviour od getInstance of the config before calling the init",
|
|
|
|
|
expectedExceptions = DataPublisherConfigurationException.class)
|
|
|
|
|
expectedExceptions = DataPublisherConfigurationException.class,
|
|
|
|
|
dependsOnMethods = "testInitWithInvalidConfig")
|
|
|
|
|
public void testInitWithInvalidXML() throws DataPublisherConfigurationException {
|
|
|
|
|
ClassLoader classLoader = this.getClass().getClassLoader();
|
|
|
|
|
URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" +
|
|
|
|
@ -63,7 +69,8 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Validating the init method with all required params", dependsOnMethods = "testInitWithInvalidXML")
|
|
|
|
|
@Test(description = "Validating the init method with all required params",
|
|
|
|
|
dependsOnMethods = "testInitWithInvalidXML")
|
|
|
|
|
public void testInitWithValidConfig() throws DataPublisherConfigurationException {
|
|
|
|
|
AnalyticsConfiguration.init();
|
|
|
|
|
AnalyticsConfiguration analyticsConfiguration = AnalyticsConfiguration.getInstance();
|
|
|
|
|