Moving the device-type and sql file folder as constants

revert-70aa11f8
megala21 7 years ago
parent 42a08a209c
commit 16ab9dac3b

@ -51,7 +51,7 @@ public class BaseExtensionsTest {
@BeforeSuite
public void init() throws RegistryException, IOException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("device-types/license.rxt");
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "license.rxt");
String rxt = null;
File carbonHome;
if (resourceUrl != null) {

@ -50,7 +50,7 @@ public class DeviceTypeManagerNegativeTest {
throws SAXException, JAXBException, ParserConfigurationException, DeviceTypeConfigurationException,
IOException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("device-types/defective-devicetype.xml");
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "defective-devicetype.xml");
File configurationFile = null;
if (resourceUrl != null) {
configurationFile = new File(resourceUrl.getFile());
@ -58,10 +58,10 @@ public class DeviceTypeManagerNegativeTest {
if (configurationFile != null) {
defectiveDeviceTypeConfiguration1 = Utils.getDeviceTypeConfiguration(configurationFile.getAbsoluteFile());
}
deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier(DEFECTIVE_DEVICE_TYPE,MultitenantConstants
.SUPER_TENANT_DOMAIN_NAME);
deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier(DEFECTIVE_DEVICE_TYPE,
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
resourceUrl = classLoader.getResource("device-types/defective-devicetype2.xml");
resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "defective-devicetype2.xml");
if (resourceUrl != null) {
configurationFile = new File(resourceUrl.getFile());
}
@ -69,7 +69,7 @@ public class DeviceTypeManagerNegativeTest {
defectiveDeviceTypeConfiguration2 = Utils.getDeviceTypeConfiguration(configurationFile.getAbsoluteFile());
}
resourceUrl = classLoader.getResource("device-types/android.xml");
resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "android.xml");
if (resourceUrl != null) {
configurationFile = new File(resourceUrl.getFile());
}

@ -124,7 +124,7 @@ public class DeviceTypeManagerServiceTest {
operationMonitoringConfigs.set(rasberrypiDeviceTypeManagerService, new OperationMonitoringTaskConfig());
initialOperationConfig.set(rasberrypiDeviceTypeManagerService, new InitialOperationConfig());
URL resourceUrl = classLoader.getResource("device-types/android.xml");
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "android.xml");
File androidConfiguration = null;
if (resourceUrl != null) {
@ -132,7 +132,7 @@ public class DeviceTypeManagerServiceTest {
}
androidDeviceConfiguration = Utils.getDeviceTypeConfiguration(androidConfiguration);
resourceUrl = classLoader.getResource("device-types/raspberrypi.xml");
resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "raspberrypi.xml");
File raspberrypiConfiguration = null;
if (resourceUrl != null) {
raspberrypiConfiguration = new File(resourceUrl.getFile());
@ -304,7 +304,7 @@ public class DeviceTypeManagerServiceTest {
throws RegistryException, IOException, SAXException, ParserConfigurationException,
DeviceTypeConfigurationException, JAXBException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("device-types/arduino.xml");
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "arduino.xml");
File arduinoConfiguration = null;
if (resourceUrl != null) {
arduinoConfiguration = new File(resourceUrl.getFile());

@ -71,12 +71,13 @@ public class DeviceTypeManagerTest {
private Field deviceTypePluginDAOField;
private Field deviceTypeDAOHandlerField;
private String[] customDeviceTypeProperties = {"custom_property", "custom_property2"};
private final String SQL_FOLDER = "sql-files" + File.separator;
@BeforeTest(description = "Mocking the classes for testing")
public void setup() throws NoSuchFieldException, IllegalAccessException, IOException, SQLException, SAXException,
ParserConfigurationException, DeviceTypeConfigurationException, JAXBException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("sql-files/android_h2.sql");
URL resourceUrl = classLoader.getResource(SQL_FOLDER + "android_h2.sql");
androidDeviceType = "android";
File androidDatabaseScript = null;
javax.sql.DataSource dataSource = null;
@ -85,7 +86,7 @@ public class DeviceTypeManagerTest {
if (resourceUrl != null) {
androidDatabaseScript = new File(resourceUrl.getFile());
}
resourceUrl = classLoader.getResource("device-types/android.xml");
resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "android.xml");
if (resourceUrl != null) {
androidConfiguration = new File(resourceUrl.getFile());
@ -295,7 +296,7 @@ public class DeviceTypeManagerTest {
private DeviceTypePluginDAOManager createPluginBasedDeviceTypeManager()
throws IOException, SQLException, NoSuchFieldException, IllegalAccessException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("sql-files/h2.sql");
URL resourceUrl = classLoader.getResource(SQL_FOLDER + "h2.sql");
File cdmDataScript = null;
javax.sql.DataSource dataSource = null;
if (resourceUrl != null) {

@ -154,7 +154,7 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
throws SAXException, JAXBException, ParserConfigurationException, DeviceTypeConfigurationException,
IOException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("device-types/android_sense.xml");
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "android_sense.xml");
File androidSenseConfiguration = null;
if (resourceUrl != null) {

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.extensions.utils;
import org.h2.jdbcx.JdbcDataSource;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration;
@ -56,16 +55,18 @@ import java.util.List;
* This class handles the test utility tasks.
*/
public class Utils {
public static final String DEVICE_TYPE_FOLDER = "device-types" + File.separator;
/**
* To get the device type configuration based on the configuration file
*
* @param configurationFile Relevant configuration file of a device type
* @return the DeviceTypeConfiguration object of the relevant Device Type
* @throws DeviceTypeConfigurationException DeviceType Configuration Exception
* @throws IOException IO Exception
* @throws SAXException SAX Exception
* @throws ParserConfigurationException Parser Configuration Exception
* @throws JAXBException JAXB Exception
* @throws IOException IO Exception
* @throws SAXException SAX Exception
* @throws ParserConfigurationException Parser Configuration Exception
* @throws JAXBException JAXB Exception
*/
public static DeviceTypeConfiguration getDeviceTypeConfiguration(File configurationFile)
throws DeviceTypeConfigurationException, IOException, SAXException, ParserConfigurationException,

Loading…
Cancel
Save