59 lines
1.5 KiB
Java
59 lines
1.5 KiB
Java
package org.warp.jcwdb.tests;
|
|
|
|
import org.junit.After;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.warp.cowdb.Database;
|
|
import org.warp.cowdb.EnhancedObject;
|
|
import org.warp.cowdb.IDatabase;
|
|
import org.warp.jcwdb.ann.DBDataType;
|
|
import org.warp.jcwdb.ann.DBField;
|
|
import org.warp.jcwdb.ann.DBPropertyGetter;
|
|
import org.warp.jcwdb.ann.DBPropertySetter;
|
|
import org.warp.jcwdb.utils.NTestUtils;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
public class EnhancedClassUpdate {
|
|
|
|
private Path path1;
|
|
private Path path2;
|
|
private Path path3;
|
|
private Database db;
|
|
|
|
@Before
|
|
public void setUp() throws Exception {
|
|
path1 = Files.createTempFile("db-tests-", ".db");
|
|
path2 = Files.createTempFile("db-tests-", ".db");
|
|
path3 = Files.createTempFile("db-tests-", ".db");
|
|
db = new Database(path1, path2, path3);
|
|
OldClass root = db.loadRoot(OldClass.class, OldClass::new);
|
|
root.field1 = "Abc";
|
|
root.field2 = 12;
|
|
root.field4 = 13;
|
|
db.close();
|
|
}
|
|
|
|
@Test
|
|
public void shouldUpdateClass() throws IOException {
|
|
db = new Database(path1, path2, path3);
|
|
V2Class root = db.loadRoot(V2Class.class, V2Class::new);
|
|
assertEquals(root.field4, "Abc");
|
|
assertEquals(root.field2, 12);
|
|
assertEquals(root.field1, 13L);
|
|
db.close();
|
|
}
|
|
|
|
@After
|
|
public void tearDown() throws Exception {
|
|
Files.deleteIfExists(path1);
|
|
Files.deleteIfExists(path2);
|
|
Files.deleteIfExists(path3);
|
|
}
|
|
}
|