* @author Kavoos
*/
public class FileDaoTest extends BaseTest {
-
+ private static int dataSize = 1024 * 512;
+
protected String bytesToHex(byte[] bytes) {
char[] hexArray = "0123456789ABCDEF".toCharArray();
char[] hexChars = new char[bytes.length * 2];
@Test
public void createChunkTest() throws Exception {
testName("createChunk");
- int dataSize = 1024 * 1024;
/* Create a new file */
Date date = new Date();
String fileName = "/home/kavoos/chunk" + date.getTime() + ".txt";
@Test
public void readChunkTest() throws Exception {
testName("readChunk");
- int dataSize = 1024 * 1024;
/* Create a new file */
Date date = new Date();
String fileName = "/home/kavoos/readchunk" + date.getTime() + ".txt";
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.config.CacheIsolationType;
/**
*
@NamedQuery(name = "Chunk.findById", query = "SELECT c FROM Chunk c WHERE c.id = :id"),
@NamedQuery(name = "Chunk.findByFileId", query = "SELECT c FROM Chunk c WHERE c.fileId = :fileId")
})
+@Cache(
+ size = 100,
+ isolation = CacheIsolationType.SHARED)
public class Chunk implements Serializable {
+
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "size")
private long size;
@Lob
- @Column(name = "data",nullable = false)
+ @Column(name = "data", nullable = false)
private byte[] data;
public Chunk() {
c.size = cto.getSize();
return c;
}
-
+
public ChunkTO toChunkTO() {
ChunkTO cto = new ChunkTO();
cto.setChecksum(this.checksum);
cto.setSize(this.size);
return cto;
}
-
+
@Override
public String toString() {
return "com.edf.gde.entities.Chunk[ id=" + id + " ]";
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.config.CacheIsolationType;
/**
*
*/
@Entity(name = "File")
@Table(name = "gde_file")
+@Cache(size = 100, isolation = CacheIsolationType.SHARED)
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.config.CacheIsolationType;
/**
*
* @author Kavoos
*/
-
-@Entity(name="User")
+@Entity(name = "User")
@Table(name = "USERS")
-@NamedQueries ({
+@NamedQueries({
@NamedQuery(name = "User.findById", query = "SELECT u FROM User u where u.id=:id"),
@NamedQuery(name = "User.findByName", query = "SELECT u FROM User u where u.name=:username")
})
+@Cache(
+ size = 100,
+ isolation = CacheIsolationType.SHARED)
public class User implements Serializable {
+
@Id
@Basic(optional = false)
@NotNull
@Size(max = 255)
@Column(name = "userPassword")
private String password;
-
+
public Long getId() {
return id;
}
public void setPassword(String password) {
this.password = password;
}
-
+
public static User fromUserTO(UserTO uto) {
User user = new User();
user.setId(uto.getId());
user.setPassword(uto.getPassword());
return user;
}
-
+
public UserTO toUserTO() {
UserTO uto = new UserTO();
uto.setId(id);
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.config.CacheIsolationType;
/**
*
*/
@Entity(name="UserGroup")
@Table(name = "USERGROUP")
+@Cache(size = 100, isolation = CacheIsolationType.SHARED)
@NamedQueries ({
@NamedQuery(name = "UserGroup.findById", query = "SELECT ug FROM UserGroup ug where ug.id = :id"),
@NamedQuery(name = "UserGroup.findByUserId", query = "SELECT ug FROM UserGroup ug where ug.userId=:userId"),