Package com.orientechnologies.orient.core

Source Code of com.orientechnologies.orient.core.TestExceptionNotOpen

package com.orientechnologies.orient.core;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.exception.ODatabaseException;
import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.tx.OTransaction;

public class TestExceptionNotOpen {

  @Test
  public void testExceptionNotOpenMemory() {

    ODatabaseDocument db = new ODatabaseDocumentTx("memory:test");
    try {
      db.save(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.delete(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.hide(new ORecordId());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin(OTransaction.TXTYPE.NOTX);
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.rollback();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.commit();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.getMetadata();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }

  }

  @Test
  public void testExceptionNotOpenRemote() {

    ODatabaseDocument db = new ODatabaseDocumentTx("remote:127.0.0.1:00");
    try {
      db.save(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.delete(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.hide(new ORecordId());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin(OTransaction.TXTYPE.NOTX);
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.rollback();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.commit();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.getMetadata();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
  }

  @Test
  public void testExceptionNotOpenPlocal() {

    ODatabaseDocument db = new ODatabaseDocumentTx("plocal:./target/databaseCheck");
    try {
      db.save(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.delete(new ODocument());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.hide(new ORecordId());
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.begin(OTransaction.TXTYPE.NOTX);
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.rollback();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.commit();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
    try {
      db.getMetadata();
      Assert.fail();
    } catch (ODatabaseException ex) {
    }
  }

}
TOP

Related Classes of com.orientechnologies.orient.core.TestExceptionNotOpen

TOP
Copyright © 2018 www.massapi.com. 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.