Moving the device-type and sql file folder as constants

4.x.x
megala21 7 years ago
parent 42a08a209c
commit 16ab9dac3b

@ -51,7 +51,7 @@ public class BaseExtensionsTest {
@BeforeSuite @BeforeSuite
public void init() throws RegistryException, IOException { public void init() throws RegistryException, IOException {
ClassLoader classLoader = getClass().getClassLoader(); 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; String rxt = null;
File carbonHome; File carbonHome;
if (resourceUrl != null) { if (resourceUrl != null) {

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

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

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

@ -154,7 +154,7 @@ public class HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest {
throws SAXException, JAXBException, ParserConfigurationException, DeviceTypeConfigurationException, throws SAXException, JAXBException, ParserConfigurationException, DeviceTypeConfigurationException,
IOException { IOException {
ClassLoader classLoader = getClass().getClassLoader(); 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; File androidSenseConfiguration = null;
if (resourceUrl != null) { if (resourceUrl != null) {

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.extensions.utils;
import org.h2.jdbcx.JdbcDataSource; import org.h2.jdbcx.JdbcDataSource;
import org.w3c.dom.Document; 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.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.DeviceDetails;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration;
@ -56,9 +55,11 @@ import java.util.List;
* This class handles the test utility tasks. * This class handles the test utility tasks.
*/ */
public class Utils { 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 * To get the device type configuration based on the configuration file
*
* @param configurationFile Relevant configuration file of a device type * @param configurationFile Relevant configuration file of a device type
* @return the DeviceTypeConfiguration object of the relevant Device Type * @return the DeviceTypeConfiguration object of the relevant Device Type
* @throws DeviceTypeConfigurationException DeviceType Configuration Exception * @throws DeviceTypeConfigurationException DeviceType Configuration Exception

Loading…
Cancel
Save