From 8ad13b6d0aa1f4c57934bb18c2c478bd496beb64 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 17:22:16 +0530 Subject: [PATCH] Implement DAO unit tests --- .../org/wso2/carbon/device/mgt/common/Device.java | 13 ++++++------- .../org.wso2.carbon.device.mgt.core/pom.xml | 13 +++++++++++++ .../mgt/core/dao/DeviceManagementDAOFactory.java | 7 +++++++ .../org/wso2/carbon/device/mgt/core/dto/Device.java | 13 ++++++------- components/device-mgt/pom.xml | 9 ++++++++- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java index 8675c8af8..4d747f354 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java @@ -15,7 +15,6 @@ */ package org.wso2.carbon.device.mgt.common; -import java.util.Date; import java.util.List; public class Device { @@ -28,9 +27,9 @@ public class Device { private String name; - private Date dateOfEnrolment; + private Long dateOfEnrolment; - private Date dateOfLastUpdate; + private Long dateOfLastUpdate; private String ownership; @@ -70,19 +69,19 @@ public class Device { this.name = name; } - public Date getDateOfEnrolment() { + public Long getDateOfEnrolment() { return dateOfEnrolment; } - public void setDateOfEnrolment(Date dateOfEnrolment) { + public void setDateOfEnrolment(Long dateOfEnrolment) { this.dateOfEnrolment = dateOfEnrolment; } - public Date getDateOfLastUpdate() { + public Long getDateOfLastUpdate() { return dateOfLastUpdate; } - public void setDateOfLastUpdate(Date dateOfLastUpdate) { + public void setDateOfLastUpdate(Long dateOfLastUpdate) { this.dateOfLastUpdate = dateOfLastUpdate; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 00ee94cd1..76a49c871 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -119,6 +119,19 @@ org.jboss.spec.javax.transaction jboss-transaction-api_1.1_spec + + commons-dbcp + commons-dbcp + 1.2.2 + test + + + + com.h2database.wso2 + h2-database-engine + test + + org.testng testng diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java index 90255603c..bc1ab0255 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -44,6 +44,10 @@ public class DeviceManagementDAOFactory { dataSource = resolveDataSource(config); } + public static void init(DataSource dtSource) { + dataSource = dtSource; + } + /** * Resolve data source from the data source definition * @@ -78,4 +82,7 @@ public class DeviceManagementDAOFactory { return dataSource; } + public static DataSource getDataSource() { + return dataSource; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java index 44c9d3e57..8adbd5ff7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java @@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.core.dto; import java.io.Serializable; -import java.util.Date; public class Device implements Serializable { @@ -27,8 +26,8 @@ public class Device implements Serializable { private String id; private String description; private String name; - private Date dateOfEnrollment; - private Date dateOfLastUpdate; + private Long dateOfEnrollment; + private Long dateOfLastUpdate; private String deviceIdentificationId; private Status status; private String ownerId; @@ -68,19 +67,19 @@ public class Device implements Serializable { this.name = name; } - public Date getDateOfEnrollment() { + public Long getDateOfEnrollment() { return dateOfEnrollment; } - public void setDateOfEnrollment(Date dateOfEnrollment) { + public void setDateOfEnrollment(Long dateOfEnrollment) { this.dateOfEnrollment = dateOfEnrollment; } - public Date getDateOfLastUpdate() { + public Long getDateOfLastUpdate() { return dateOfLastUpdate; } - public void setDateOfLastUpdate(Date dateOfLastUpdate) { + public void setDateOfLastUpdate(Long dateOfLastUpdate) { this.dateOfLastUpdate = dateOfLastUpdate; } diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index bcfbf8edf..a154b9ef3 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -69,6 +69,11 @@ org.eclipse.osgi.services 3.3.100.v20120522-1822 + + com.h2database.wso2 + h2-database-engine + ${orbit.version.h2.engine} + @@ -91,5 +96,7 @@ - + + 1.2.140.wso2v3 +