Implement DAO unit tests

4.x.x
manoj 10 years ago
parent c4e2722586
commit 8ad13b6d0a

@ -15,7 +15,6 @@
*/ */
package org.wso2.carbon.device.mgt.common; package org.wso2.carbon.device.mgt.common;
import java.util.Date;
import java.util.List; import java.util.List;
public class Device { public class Device {
@ -28,9 +27,9 @@ public class Device {
private String name; private String name;
private Date dateOfEnrolment; private Long dateOfEnrolment;
private Date dateOfLastUpdate; private Long dateOfLastUpdate;
private String ownership; private String ownership;
@ -70,19 +69,19 @@ public class Device {
this.name = name; this.name = name;
} }
public Date getDateOfEnrolment() { public Long getDateOfEnrolment() {
return dateOfEnrolment; return dateOfEnrolment;
} }
public void setDateOfEnrolment(Date dateOfEnrolment) { public void setDateOfEnrolment(Long dateOfEnrolment) {
this.dateOfEnrolment = dateOfEnrolment; this.dateOfEnrolment = dateOfEnrolment;
} }
public Date getDateOfLastUpdate() { public Long getDateOfLastUpdate() {
return dateOfLastUpdate; return dateOfLastUpdate;
} }
public void setDateOfLastUpdate(Date dateOfLastUpdate) { public void setDateOfLastUpdate(Long dateOfLastUpdate) {
this.dateOfLastUpdate = dateOfLastUpdate; this.dateOfLastUpdate = dateOfLastUpdate;
} }

@ -119,6 +119,19 @@
<groupId>org.jboss.spec.javax.transaction</groupId> <groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId> <artifactId>jboss-transaction-api_1.1_spec</artifactId>
</dependency> </dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>

@ -44,6 +44,10 @@ public class DeviceManagementDAOFactory {
dataSource = resolveDataSource(config); dataSource = resolveDataSource(config);
} }
public static void init(DataSource dtSource) {
dataSource = dtSource;
}
/** /**
* Resolve data source from the data source definition * Resolve data source from the data source definition
* *
@ -78,4 +82,7 @@ public class DeviceManagementDAOFactory {
return dataSource; return dataSource;
} }
public static DataSource getDataSource() {
return dataSource;
}
} }

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.core.dto; package org.wso2.carbon.device.mgt.core.dto;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
public class Device implements Serializable { public class Device implements Serializable {
@ -27,8 +26,8 @@ public class Device implements Serializable {
private String id; private String id;
private String description; private String description;
private String name; private String name;
private Date dateOfEnrollment; private Long dateOfEnrollment;
private Date dateOfLastUpdate; private Long dateOfLastUpdate;
private String deviceIdentificationId; private String deviceIdentificationId;
private Status status; private Status status;
private String ownerId; private String ownerId;
@ -68,19 +67,19 @@ public class Device implements Serializable {
this.name = name; this.name = name;
} }
public Date getDateOfEnrollment() { public Long getDateOfEnrollment() {
return dateOfEnrollment; return dateOfEnrollment;
} }
public void setDateOfEnrollment(Date dateOfEnrollment) { public void setDateOfEnrollment(Long dateOfEnrollment) {
this.dateOfEnrollment = dateOfEnrollment; this.dateOfEnrollment = dateOfEnrollment;
} }
public Date getDateOfLastUpdate() { public Long getDateOfLastUpdate() {
return dateOfLastUpdate; return dateOfLastUpdate;
} }
public void setDateOfLastUpdate(Date dateOfLastUpdate) { public void setDateOfLastUpdate(Long dateOfLastUpdate) {
this.dateOfLastUpdate = dateOfLastUpdate; this.dateOfLastUpdate = dateOfLastUpdate;
} }

@ -69,6 +69,11 @@
<artifactId>org.eclipse.osgi.services</artifactId> <artifactId>org.eclipse.osgi.services</artifactId>
<version>3.3.100.v20120522-1822</version> <version>3.3.100.v20120522-1822</version>
</dependency> </dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
<version>${orbit.version.h2.engine}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -91,5 +96,7 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<properties>
<orbit.version.h2.engine>1.2.140.wso2v3</orbit.version.h2.engine>
</properties>
</project> </project>

Loading…
Cancel
Save