Package com.orientechnologies.orient.core.db.record

Examples of com.orientechnologies.orient.core.db.record.ODatabaseFlat


    database.close();
  }

  @Test(dependsOnMethods = "createSchema")
  public void checkTotalRecords() {
    database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    Assert.assertTrue(database.getStorage().countRecords() > 0);

    database.close();
View Full Code Here


    database.close();
  }

  @Test(expectedExceptions = OValidationException.class)
  public void checkErrorOnUserNoPasswd() {
    database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    database.getMetadata().getSecurity().createUser("error", null, null);

    database.close();
View Full Code Here

    url = iURL;
  }

  @Test
  public void testTransactionAtomic() throws IOException {
    ODatabaseFlat db1 = new ODatabaseFlat(url);
    db1.open("admin", "admin");

    ODatabaseFlat db2 = new ODatabaseFlat(url);
    db2.open("admin", "admin");

    ORecordFlat record1 = new ORecordFlat(db1);
    record1.value("This is the first version").save();

    // RE-READ THE RECORD
    record1.reload();
    ORecordFlat record2 = db2.load(record1.getIdentity());

    record2.value("This is the second version").save();
    record2.value("This is the third version").save();

    record1.reload(null, true);

    Assert.assertTrue(record1.value().equals("This is the third version"));

    db1.close();
    db2.close();
  }
View Full Code Here

    db.close();
  }

  @Test(expectedExceptions = OTransactionException.class)
  public void testTransactionPreListenerRollback() throws IOException {
    ODatabaseFlat db = new ODatabaseFlat(url);
    db.open("admin", "admin");

    ORecordFlat record1 = new ORecordFlat(db);
    record1.value("This is the first version").save();

    db.registerListener(new ODatabaseListener() {

      public void onAfterTxCommit(ODatabase iDatabase) {
      }

      public void onAfterTxRollback(ODatabase iDatabase) {
      }

      public void onBeforeTxBegin(ODatabase iDatabase) {
      }

      public void onBeforeTxCommit(ODatabase iDatabase) {
        throw new RuntimeException("Rollback test");
      }

      public void onBeforeTxRollback(ODatabase iDatabase) {
      }

      public void onClose(ODatabase iDatabase) {
      }

      public void onCreate(ODatabase iDatabase) {
      }

      public void onDelete(ODatabase iDatabase) {
      }

      public void onOpen(ODatabase iDatabase) {
      }
    });

    db.commit();

    db.close();
  }
View Full Code Here

  private ODatabaseFlat  database;
  private ORecordFlat    record;

  @Parameters(value = "url")
  public DictionaryTest(String iURL) {
    database = new ODatabaseFlat(iURL);
    record = database.newInstance();
  }
View Full Code Here

  public DictionaryTest(@Optional String url) {
    super(url);
  }

  public void testDictionaryCreate() throws IOException {
    ODatabaseFlat database = new ODatabaseFlat(url);
    database.open("admin", "admin");
    ORecordFlat record = database.newInstance();

    database.getDictionary().put("key1", record.value("Dictionary test!"));

    database.close();
  }
View Full Code Here

    database.close();
  }

  @Test(dependsOnMethods = "testDictionaryCreate")
  public void testDictionaryLookup() throws IOException {
    ODatabaseFlat database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    Assert.assertNotNull(database.getDictionary().get("key1"));
    Assert.assertTrue(((ORecordFlat) database.getDictionary().get("key1")).value().equals("Dictionary test!"));

    database.close();
  }
View Full Code Here

    database.close();
  }

  @Test(dependsOnMethods = "testDictionaryLookup")
  public void testDictionaryUpdate() throws IOException {
    ODatabaseFlat database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    final long originalSize = database.getDictionary().size();

    database.getDictionary().put("key1", database.newInstance().value("Text changed"));

    database.close();
    database.open("admin", "admin");

    Assert.assertEquals(((ORecordFlat) database.getDictionary().get("key1")).value(), "Text changed");
    Assert.assertEquals(database.getDictionary().size(), originalSize);

    database.close();
  }
View Full Code Here

    database.close();
  }

  @Test(dependsOnMethods = "testDictionaryUpdate")
  public void testDictionaryDelete() throws IOException {
    ODatabaseFlat database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    final long originalSize = database.getDictionary().size();
    Assert.assertNotNull(database.getDictionary().remove("key1"));

    database.close();
    database.open("admin", "admin");

    Assert.assertEquals(database.getDictionary().size(), originalSize - 1);

    database.close();
  }
View Full Code Here

    database.close();
  }

  @Test(dependsOnMethods = "testDictionaryDelete")
  public void testDictionaryMassiveCreate() throws IOException {
    ODatabaseFlat database = new ODatabaseFlat(url);
    database.open("admin", "admin");

    final long originalSize = database.getDictionary().size();

    // ASSURE TO STORE THE PAGE-SIZE + 3 FORCING THE CREATION OF LEFT AND RIGHT
    final int total = 1000;

    for (int i = total; i > 0; --i) {
      database.getDictionary().put("key-" + (originalSize + i), database.newInstance().value("test-dictionary-" + i));
    }

    for (int i = total; i > 0; --i) {
      ORecord record = database.getDictionary().get("key-" + (originalSize + i));
      record.toString().equals("test-dictionary-" + i);
    }

    Assert.assertEquals(database.getDictionary().size(), originalSize + total);

    database.close();
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.record.ODatabaseFlat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.