Skip to content

Commit

Permalink
refactor: minor remove of deprecated use in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Sep 8, 2023
1 parent 6c62e41 commit a56338d
Show file tree
Hide file tree
Showing 32 changed files with 177 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.orientechnologies;

import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import java.util.Locale;
import org.junit.After;
Expand All @@ -10,7 +11,7 @@
* @since 7/16/14
*/
public abstract class DatabaseAbstractTest {
protected ODatabaseDocumentTx database;
protected ODatabaseDocument database;

public static ENV getEnvironment() {
String envName = System.getProperty("orientdb.test.env", "dev").toUpperCase(Locale.ENGLISH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertTrue;

import com.orientechnologies.orient.core.db.ODatabase;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.exception.ODatabaseException;
import com.orientechnologies.orient.core.exception.OSchemaException;
Expand All @@ -29,7 +30,7 @@

public class ODatabaseDocumentTxTest {

private ODatabaseDocumentTx db;
private ODatabaseDocument db;

@Before
public void setUp() throws Exception {
Expand Down Expand Up @@ -282,7 +283,7 @@ public void testExecuteWithRetry() throws InterruptedException {
new Thread() {
@Override
public void run() {
ODatabaseDocumentTx dbCopy = db.copy();
ODatabaseDocument dbCopy = ((ODatabaseDocumentInternal) db).copy();
dbCopy.activateOnCurrentThread();
dbCopy.executeWithRetry(
10,
Expand Down Expand Up @@ -324,7 +325,7 @@ public void testExecuteWithRetryTx() throws InterruptedException {
new Thread() {
@Override
public void run() {
ODatabaseDocumentTx dbCopy = db.copy();
ODatabaseDocument dbCopy = ((ODatabaseDocumentInternal) db).copy();
dbCopy.activateOnCurrentThread();
dbCopy.begin();
dbCopy.executeWithRetry(
Expand Down Expand Up @@ -465,7 +466,7 @@ public void testLinkDuplicate() {

@Test
public void selectDescTest() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:foo");
ODatabaseDocument db = new ODatabaseDocumentTx("memory:foo");
db.create();
String className = "bar";
OSchema schema = db.getMetadata().getSchema();
Expand All @@ -475,7 +476,8 @@ public void selectDescTest() {
ODocument document = new ODocument(className);
document.save();
ORecordIteratorClassDescendentOrder<ODocument> reverseIterator =
new ORecordIteratorClassDescendentOrder<ODocument>(db, db, className, true);
new ORecordIteratorClassDescendentOrder<ODocument>(
(ODatabaseDocumentInternal) db, (ODatabaseDocumentInternal) db, className, true);
Assert.assertTrue(reverseIterator.hasNext());
Assert.assertEquals(document, reverseIterator.next());
db.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/** @author Sergey Sitnikov */
public class VersionedDeleteTest {

private ODatabaseDocumentTx db;
private ODatabaseDocument db;

@Before
public void before() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;

import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.hook.ORecordHook;
import com.orientechnologies.orient.core.record.ORecord;
Expand All @@ -14,7 +15,7 @@ public class HookRegisterRemoveTest {
@Test
public void addAndRemoveHookTest() {

ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + HookRegisterRemoveTest.class.getSimpleName());
db.create();
final AtomicInteger integer = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.orientechnologies.orient.core.db.tool;

import com.orientechnologies.orient.core.command.OCommandOutputListener;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OProperty;
Expand All @@ -15,26 +17,29 @@ public class TestSchemaImportExport {

@Test
public void testExportImportCustomData() throws IOException {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + TestSchemaImportExport.class.getSimpleName());
db.create();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
OClass clazz = db.getMetadata().getSchema().createClass("Test");
clazz.createProperty("some", OType.STRING);
clazz.setCustom("testcustom", "test");
ODatabaseExport exp = new ODatabaseExport(db, output, new MockOutputListener());
ODatabaseExport exp =
new ODatabaseExport((ODatabaseDocumentInternal) db, output, new MockOutputListener());
exp.exportDatabase();
} finally {
db.drop();
}
ODatabaseDocumentTx db1 =
ODatabaseDocument db1 =
new ODatabaseDocumentTx("memory:imp_" + TestSchemaImportExport.class.getSimpleName());
db1.create();
try {
ODatabaseImport imp =
new ODatabaseImport(
db1, new ByteArrayInputStream(output.toByteArray()), new MockOutputListener());
(ODatabaseDocumentInternal) db1,
new ByteArrayInputStream(output.toByteArray()),
new MockOutputListener());
imp.importDatabase();
db1.close();
db1.open("admin", "admin");
Expand All @@ -48,26 +53,29 @@ public void testExportImportCustomData() throws IOException {

@Test
public void testExportImportDefaultValue() throws IOException {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + TestSchemaImportExport.class.getSimpleName());
db.create();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
OClass clazz = db.getMetadata().getSchema().createClass("Test");
clazz.createProperty("bla", OType.STRING).setDefaultValue("something");
ODatabaseExport exp = new ODatabaseExport(db, output, new MockOutputListener());
ODatabaseExport exp =
new ODatabaseExport((ODatabaseDocumentInternal) db, output, new MockOutputListener());
exp.exportDatabase();
} finally {
db.drop();
}

ODatabaseDocumentTx db1 =
ODatabaseDocument db1 =
new ODatabaseDocumentTx("memory:imp_" + TestSchemaImportExport.class.getSimpleName());
db1.create();
try {
ODatabaseImport imp =
new ODatabaseImport(
db1, new ByteArrayInputStream(output.toByteArray()), new MockOutputListener());
(ODatabaseDocumentInternal) db1,
new ByteArrayInputStream(output.toByteArray()),
new MockOutputListener());
imp.importDatabase();
db1.close();
db1.open("admin", "admin");
Expand All @@ -83,7 +91,7 @@ public void testExportImportDefaultValue() throws IOException {

@Test
public void testExportImportMultipleInheritance() throws IOException {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx(
"memory:" + TestSchemaImportExport.class.getSimpleName() + "MultipleInheritance");
db.create();
Expand All @@ -93,20 +101,23 @@ public void testExportImportMultipleInheritance() throws IOException {
clazz.addSuperClass(db.getMetadata().getSchema().getClass("ORestricted"));
clazz.addSuperClass(db.getMetadata().getSchema().getClass("OIdentity"));

ODatabaseExport exp = new ODatabaseExport(db, output, new MockOutputListener());
ODatabaseExport exp =
new ODatabaseExport((ODatabaseDocumentInternal) db, output, new MockOutputListener());
exp.exportDatabase();
} finally {
db.drop();
}

ODatabaseDocumentTx db1 =
ODatabaseDocument db1 =
new ODatabaseDocumentTx(
"memory:imp_" + TestSchemaImportExport.class.getSimpleName() + "MultipleInheritance");
db1.create();
try {
ODatabaseImport imp =
new ODatabaseImport(
db1, new ByteArrayInputStream(output.toByteArray()), new MockOutputListener());
(ODatabaseDocumentInternal) db1,
new ByteArrayInputStream(output.toByteArray()),
new MockOutputListener());
imp.importDatabase();
db1.close();
db1.open("admin", "admin");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.orientechnologies.orient.core.index;

import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
Expand Down Expand Up @@ -135,7 +136,7 @@ public void testGetKeyTypesOneType() {

@Test
public void testReload() {
final ODatabaseDocumentTx databaseDocumentTx =
final ODatabaseDocument databaseDocumentTx =
new ODatabaseDocumentTx("memory:osimplekeyindexdefinitiontest");
databaseDocumentTx.create();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.orientechnologies.orient.core.iterator;

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OSchema;
Expand All @@ -16,7 +18,7 @@
/** @author Artem Loginov */
public class ClassIteratorTest {
private static final boolean RECREATE_DATABASE = true;
private static ODatabaseDocumentTx db = null;
private static ODatabaseDocument db = null;
private Set<String> names;

private static void initializeDatabase() {
Expand Down Expand Up @@ -138,7 +140,8 @@ public void testDescendentOrderIteratorWithMultipleClusters() throws Exception {

// Use descending class iterator.
final ORecordIteratorClass<ODocument> personIter =
new ORecordIteratorClassDescendentOrder<ODocument>(db, db, "Person", true);
new ORecordIteratorClassDescendentOrder<ODocument>(
(ODatabaseDocumentInternal) db, (ODatabaseDocumentInternal) db, "Person", true);

personIter.setRange(null, null); // open range

Expand All @@ -163,7 +166,8 @@ public void testMultipleClusters() throws Exception {
}

final ORecordIteratorClass<ODocument> personIter =
new ORecordIteratorClass<ODocument>(db, "PersonMultipleClusters", true);
new ORecordIteratorClass<ODocument>(
(ODatabaseDocumentInternal) db, "PersonMultipleClusters", true);

int docNum = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
Expand Down Expand Up @@ -33,7 +35,7 @@ public void after() {
@Test
public void testSimpleDocumentDebug() {

ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + ORecordSerializerBinaryDebugTest.class.getSimpleName());
db.create();
try {
Expand All @@ -45,7 +47,8 @@ public void testSimpleDocumentDebug() {
byte[] bytes = doc.toStream();

ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
ORecordSerializationDebug debug = debugger.deserializeDebug(bytes, db);
ORecordSerializationDebug debug =
debugger.deserializeDebug(bytes, (ODatabaseDocumentInternal) db);

assertEquals(debug.properties.size(), 3);
assertEquals(debug.properties.get(0).name, "test");
Expand All @@ -66,7 +69,7 @@ public void testSimpleDocumentDebug() {

@Test
public void testSchemaFullDocumentDebug() {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + ORecordSerializerBinaryDebugTest.class.getSimpleName());
db.create();
try {
Expand All @@ -81,7 +84,8 @@ public void testSchemaFullDocumentDebug() {
byte[] bytes = doc.toStream();

ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
ORecordSerializationDebug debug = debugger.deserializeDebug(bytes, db);
ORecordSerializationDebug debug =
debugger.deserializeDebug(bytes, (ODatabaseDocumentInternal) db);

assertEquals(debug.properties.size(), 3);
assertEquals(debug.properties.get(0).name, "testP");
Expand All @@ -102,7 +106,7 @@ public void testSchemaFullDocumentDebug() {

@Test
public void testSimpleBrokenDocumentDebug() {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + ORecordSerializerBinaryDebugTest.class.getSimpleName());
db.create();
try {
Expand All @@ -116,7 +120,8 @@ public void testSimpleBrokenDocumentDebug() {
System.arraycopy(bytes, 0, brokenBytes, 0, bytes.length - 10);

ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
ORecordSerializationDebug debug = debugger.deserializeDebug(brokenBytes, db);
ORecordSerializationDebug debug =
debugger.deserializeDebug(brokenBytes, (ODatabaseDocumentInternal) db);

assertEquals(debug.properties.size(), 3);
assertEquals(debug.properties.get(0).name, "test");
Expand All @@ -140,7 +145,7 @@ public void testSimpleBrokenDocumentDebug() {

@Test
public void testBrokenSchemaFullDocumentDebug() {
ODatabaseDocumentTx db =
ODatabaseDocument db =
new ODatabaseDocumentTx("memory:" + ORecordSerializerBinaryDebugTest.class.getSimpleName());
db.create();
try {
Expand All @@ -157,7 +162,8 @@ public void testBrokenSchemaFullDocumentDebug() {
System.arraycopy(bytes, 0, brokenBytes, 0, bytes.length - 10);

ORecordSerializerBinaryDebug debugger = new ORecordSerializerBinaryDebug();
ORecordSerializationDebug debug = debugger.deserializeDebug(brokenBytes, db);
ORecordSerializationDebug debug =
debugger.deserializeDebug(brokenBytes, (ODatabaseDocumentInternal) db);

assertEquals(debug.properties.size(), 3);
assertEquals(debug.properties.get(0).name, "testP");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void beforeMethod() throws Exception {
"localSBTreeCompositeKeyTest",
".sbt",
".nbt",
(OAbstractPaginatedStorage) database.getStorage());
(OAbstractPaginatedStorage) ((ODatabaseDocumentInternal) database).getStorage());

atomicOperationsManager.executeInsideAtomicOperation(
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void beforeMethod() throws Exception {
"localSBTreeCompositeKeyTest",
".sbt",
".nbt",
(OAbstractPaginatedStorage) database.getStorage());
(OAbstractPaginatedStorage) ((ODatabaseDocumentInternal) database).getStorage());
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
Expand Down
Loading

0 comments on commit a56338d

Please sign in to comment.