示例#1
0
  public void testWriteClean() throws Exception {
    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Creating resource");
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    msg("Creating supplier");
    Supplier supplier = getModel1Factory().createSupplier();

    msg("Setting name");
    supplier.setName("Stepper");

    msg("Adding supplier");
    resource.getContents().add(supplier);

    msg("Committing");
    transaction.commit();

    msg("Getting supplier");
    Supplier s = (Supplier) resource.getContents().get(0);

    msg("Setting name");
    s.setName("Eike");
    assertEquals("Eike", s.getName());
    assertEquals(CDOState.DIRTY, CDOUtil.getCDOObject(supplier).cdoState());
    assertEquals(CDOState.CLEAN, resource.cdoState());
  }
示例#2
0
  public void testReadResourceClean() throws Exception {
    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Creating resource");
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    msg("Creating supplier");
    Supplier supplier = getModel1Factory().createSupplier();

    msg("Setting name");
    supplier.setName("Stepper");

    msg("Adding supplier");
    resource.getContents().add(supplier);

    msg("Committing");
    long commitTime = transaction.commit().getTimeStamp();

    msg("Getting supplier");
    EList<EObject> contents = resource.getContents();
    Supplier s = (Supplier) contents.get(0);
    assertEquals(1, CDOUtil.getCDOObject(s).cdoRevision().getVersion());
    assertEquals(supplier, s);
    assertCreatedTime(s, commitTime);
  }
  public void testAddNewObjectInResource() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Create a new element");
      Supplier supplier = getModel1Factory().createSupplier();
      supplier.setName("supplier" + System.currentTimeMillis());
      resource.getContents().add(supplier);
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Reload previous local session");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
      assertEquals(true, transaction.isDirty());
      assertEquals(1, transaction.getRevisionDeltas().size());
      CDORevisionDelta delta = transaction.getRevisionDeltas().values().iterator().next();
      assertNotNull(delta);
      push(transaction, pushTransaction);
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    assertEquals(3, resource.getContents().size());
  }
  public void testGetResourceClearedCache() throws Exception {
    Supplier supplier = getModel1Factory().createSupplier();
    supplier.setName("Stepper");

    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));
    resource.getContents().add(supplier);
    transaction.commit();

    clearCache(getRepository().getRevisionManager());

    // query(new BasicDBObject(Commits.REVISIONS, new BasicDBObject("$elemMatch", new BasicDBObject(
    // Commits.REVISIONS_RESOURCE, 1))));
    transaction = session.openTransaction();

    msg("Getting resource");
    resource = transaction.getResource(getResourcePath("/test1"), true);
    assertNotNull(resource);
    assertEquals(
        URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
        resource.getURI());
    assertEquals(transaction.getResourceSet(), resource.getResourceSet());
    assertEquals(1, transaction.getResourceSet().getResources().size());
    assertEquals(CDOState.CLEAN, resource.cdoState());
    assertEquals(transaction, resource.cdoView());
    assertNotNull(resource.cdoRevision());
  }
示例#5
0
  public void testCommitNew() throws Exception {
    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Creating resource");
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    msg("Creating supplier");
    Supplier supplier = getModel1Factory().createSupplier();

    msg("Setting name");
    supplier.setName("Stepper");

    msg("Adding supplier");
    resource.getContents().add(supplier);

    msg("Committing");
    CDOCommitInfo commit = transaction.commit();
    assertEquals(CDOState.CLEAN, resource.cdoState());
    assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
    assertEquals(1, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
    assertCreatedTime(resource, commit.getTimeStamp());
    assertCreatedTime(supplier, commit.getTimeStamp());
  }
示例#6
0
  public void testResourceAccessor() throws Exception {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    Supplier supplier = getModel1Factory().createSupplier();
    supplier.setName("Stepper");

    resource.getContents().add(supplier);

    URI supplierTempURI = EcoreUtil.getURI(supplier);

    // Retrieving supplier from URI before commit
    EObject supplier1 = transaction.getResourceSet().getEObject(supplierTempURI, true);
    assertEquals(supplier, CDOUtil.getEObject(supplier1));

    transaction.commit();

    URI supplierURI = EcoreUtil.getURI(supplier);

    // Retrieving supplier from URI after commit
    EObject supplierFromURI = transaction.getResourceSet().getEObject(supplierURI, true);
    assertEquals(supplier, CDOUtil.getEObject(supplierFromURI));

    EObject supplierAfterCommit2 = transaction.getResourceSet().getEObject(supplierTempURI, true);
    if (session.getRepositoryInfo().getIDGenerationLocation() == IDGenerationLocation.STORE) {
      assertEquals(null, supplierAfterCommit2);
    } else {
      assertEquals(supplier, supplierAfterCommit2);
    }
  }
示例#7
0
  public void testTransientResource() throws Exception {
    final URI uri = URI.createURI("cdo:/test1");

    msg("Creating resourceSet");
    ResourceSet resourceSet = new ResourceSetImpl();
    SessionUtil.prepareResourceSet(resourceSet);

    msg("Creating resource");
    CDOResource resource = (CDOResource) resourceSet.createResource(uri);
    assertTransient(resource);

    msg("Creating supplier");
    Supplier supplier = getModel1Factory().createSupplier();
    assertTransient(supplier);
    assertEquals(null, supplier.eContainer());

    msg("Verifying contents");
    EList<EObject> contents = resource.getContents();
    assertNotNull(contents);
    assertEquals(true, contents.isEmpty());
    assertEquals(0, contents.size());
    assertTransient(resource);

    msg("Adding supplier");
    contents.add(supplier);
    assertTransient(resource);
    assertTransient(supplier);
    assertContent(resource, supplier);

    assertEquals(true, resourceSet.getResources().contains(resource));
    resource.delete(null);
    assertEquals(false, resourceSet.getResources().contains(resource));
    assertTransient(supplier);
  }
示例#8
0
  public void testLoadObject() throws Exception {
    {
      // disableConsole();
      msg("Opening session");
      CDOSession session = openSession();

      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Creating resource");
      CDOResource resource = transaction.createResource(getResourcePath("/test1"));

      msg("Creating supplier");
      Supplier supplier = getModel1Factory().createSupplier();

      msg("Setting name");
      supplier.setName("Stepper");

      msg("Adding supplier");
      resource.getContents().add(supplier);

      msg("Committing");
      transaction.commit();
      // XXX session.close();
      enableConsole();
    }

    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Getting resource");
    CDOResource resource = transaction.getResource(getResourcePath("/test1"));

    msg("Getting contents");
    EList<EObject> contents = resource.getContents();

    msg("Getting supplier");
    Supplier s = (Supplier) contents.get(0);
    assertNotNull(s);

    msg("Verifying name");
    assertEquals("Stepper", s.getName());
  }
示例#9
0
  public void testLoadResource() throws Exception {
    {
      // disableConsole();
      msg("Opening session");
      CDOSession session = openSession();

      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Creating resource");
      CDOResource resource = transaction.createResource(getResourcePath("/test1"));

      msg("Creating supplier");
      Supplier supplier = getModel1Factory().createSupplier();

      msg("Setting name");
      supplier.setName("Stepper");

      msg("Adding supplier");
      resource.getContents().add(supplier);

      msg("Committing");
      transaction.commit();
      // XXX session.close();
      // enableConsole();
    }

    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Getting resource");
    CDOResource resource = transaction.getResource(getResourcePath("/test1"));
    assertNotNull(resource);

    URI uri =
        URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1"));
    URI resourceURI = resource.getURI();
    assertEquals(uri, resourceURI);
    assertEquals(transaction.getResourceSet(), resource.getResourceSet());
    assertEquals(CDOState.CLEAN, resource.cdoState());
    assertEquals(transaction, resource.cdoView());
    assertNotNull(resource.cdoRevision());
  }
示例#10
0
  public void testAttachObject() throws Exception {
    Supplier supplier = getModel1Factory().createSupplier();
    supplier.setName("Stepper");

    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    EList<EObject> contents = resource.getContents();
    contents.add(supplier);
    assertNew(supplier, transaction);
    assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
    assertEquals(resource, CDOUtil.getCDOObject(supplier).cdoDirectResource());
    assertEquals(0, CDOUtil.getCDOObject(supplier).cdoRevision().getVersion());
    assertEquals(resource, supplier.eResource());
    assertEquals(null, supplier.eContainer());
  }
  public void testGetContentsClearedCache() throws Exception {
    {
      msg("Opening session");
      CDOSession session = openSession();

      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Creating resource");
      CDOResource resource = transaction.createResource(getResourcePath("/test1"));

      msg("Creating supplier");
      Supplier supplier = getModel1Factory().createSupplier();

      msg("Setting name");
      supplier.setName("Stepper");

      msg("Adding supplier");
      resource.getContents().add(supplier);

      msg("Committing");
      transaction.commit();
      session.close();
    }

    clearCache(getRepository().getRevisionManager());

    msg("Opening session");
    CDOSession session = openSession();

    msg("Opening transaction");
    CDOTransaction transaction = session.openTransaction();

    msg("Getting resource");
    CDOResource resource = transaction.getResource(getResourcePath("/test1"));

    msg("Getting contents");
    EList<EObject> contents = resource.getContents();
    assertNotNull(contents);

    Supplier supplier = (Supplier) contents.get(0);
    String name = supplier.getName();
    assertEquals("Stepper", name);
  }
  public void testUnsetValueWithoutPushTX() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName(null);
      msg("Commit");
      transaction.commit();
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    Supplier supplier = (Supplier) resource.getContents().get(0);
    assertNull(supplier.getName());
  }
  public void testAddNewHierarchy() throws Exception {
    final String currentSupplierName = "supplier" + System.currentTimeMillis();
    final Date orderDate = new Date();
    final Float orderDetailPrice = 10.5F;

    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Create a new element");
      Supplier supplier = getModel1Factory().createSupplier();
      supplier.setName(currentSupplierName);
      resource.getContents().add(supplier);
      msg("Create a new child");
      PurchaseOrder order = getModel1Factory().createPurchaseOrder();
      order.setDate(orderDate);
      supplier.getPurchaseOrders().add(order);
      resource.getContents().add(order);
      OrderDetail detail = getModel1Factory().createOrderDetail();
      detail.setPrice(orderDetailPrice);
      order.getOrderDetails().add(detail);
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Reload previous local session");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
      assertEquals(true, transaction.isDirty());
      assertEquals(1, transaction.getRevisionDeltas().size());
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      assertEquals(4, resource.getContents().size());
      push(transaction, pushTransaction);
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    assertEquals(4, resource.getContents().size());
    Supplier supplier = (Supplier) resource.getContents().get(2);
    assertEquals(currentSupplierName, supplier.getName());
    assertEquals(1, supplier.getPurchaseOrders().size());
    PurchaseOrder order = supplier.getPurchaseOrders().get(0);
    assertNotNull(order);
    assertEquals(orderDate, order.getDate());
    assertEquals(1, order.getOrderDetails().size());
    OrderDetail detail = order.getOrderDetails().get(0);
    assertNotNull(detail);
    assertEquals(orderDetailPrice, detail.getPrice());
  }
  public void testUnsetValue() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName(null);
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Reload previous local session");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
      assertEquals(true, transaction.isDirty());
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      Supplier supplier = (Supplier) resource.getContents().get(0);
      assertNull(supplier.getName());
      push(transaction, pushTransaction);
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    Supplier supplier = (Supplier) resource.getContents().get(0);
    assertNull(supplier.getName());
  }
  public void testConflictWithModifiedObject() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Make a diff in existing element");
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName("" + System.currentTimeMillis());
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Open transaction & commit changes to repo");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName("" + System.currentTimeMillis());
      transaction.commit();
      session.close();
    }

    msg("Reload previous local session");
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
    assertEquals(true, transaction.hasConflict());

    try {
      pushTransaction.push();
      fail("CommitException expected");
    } catch (CommitException expected) {
      // SUCCESS
    }
  }
示例#16
0
  public void testCommitDirty() throws Exception {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/test1"));

    Supplier supplier = getModel1Factory().createSupplier();
    supplier.setName("Stepper");

    resource.getContents().add(supplier);

    CDOCommitInfo commit = transaction.commit();
    long commitTime1 = commit.getTimeStamp();
    assertCreatedTime(supplier, commitTime1);

    supplier.setName("Eike");

    long commitTime2 = transaction.commit().getTimeStamp();
    assertEquals(true, commitTime1 < commitTime2);
    assertEquals(CDOState.CLEAN, resource.cdoState());
    assertEquals(CDOState.CLEAN, CDOUtil.getCDOObject(supplier).cdoState());
    assertCreatedTime(supplier, commitTime2);
  }
  public void testMoveObject() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Create a new elements");
      Supplier supplier2 = getModel1Factory().createSupplier();
      supplier2.setName("supplier" + System.currentTimeMillis());
      resource.getContents().add(supplier2);
      msg("Move first supplier");
      Supplier supplier1 = (Supplier) resource.getContents().get(0);
      resource.getContents().move(1, supplier1);
      assertEquals(supplierName, ((Supplier) resource.getContents().get(1)).getName());
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Reload previous local session");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
      assertEquals(true, transaction.isDirty());
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      assertEquals(supplierName, ((Supplier) resource.getContents().get(1)).getName());
      push(transaction, pushTransaction);
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    assertEquals(supplierName, ((Supplier) resource.getContents().get(1)).getName());
  }
  private void populateRepository() {
    msg("Populate the repository the classic way");
    msg("Create resource");
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath(resourcePath));

    msg("Populate resource");
    Supplier supplier0 = getModel1Factory().createSupplier();
    supplier0.setName(supplierName);
    resource.getContents().add(supplier0);
    Company company0 = getModel1Factory().createCompany();
    resource.getContents().add(company0);

    try {
      msg("Commit");
      transaction.commit();
    } catch (CommitException ex) {
      throw WrappedException.wrap(ex);
    }

    session.close();
  }
示例#19
0
  public void testTransientObject() throws Exception {
    final Date date = new Date();

    msg("Creating supplier");
    Supplier supplier = getModel1Factory().createSupplier();
    assertTransient(supplier);

    msg("Setting name");
    supplier.setName("Stepper");
    assertTransient(supplier);

    msg("Verifying name");
    assertEquals("Stepper", supplier.getName());
    assertTransient(supplier);

    msg("Creating purchaseOrder");
    PurchaseOrder purchaseOrder = getModel1Factory().createPurchaseOrder();
    assertTransient(purchaseOrder);

    msg("Setting date");
    purchaseOrder.setDate(date);
    assertTransient(purchaseOrder);

    msg("Verifying date");
    assertEquals(date, purchaseOrder.getDate());
    assertTransient(purchaseOrder);

    msg("Setting supplier");
    purchaseOrder.setSupplier(supplier);
    assertTransient(supplier);
    assertTransient(purchaseOrder);

    msg("Verifying supplier");
    assertEquals(supplier, purchaseOrder.getSupplier());
    assertTransient(supplier);
    assertTransient(purchaseOrder);
  }
  public void testUpdateExistingObject() throws Exception {
    String newName = "supplier" + System.currentTimeMillis();

    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Make a diff in existing element");
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName(newName);
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Reload previous local session");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction, file);
      assertEquals(true, transaction.isDirty());
      assertEquals(1, transaction.getRevisionDeltas().size());
      push(transaction, pushTransaction);
      session.close();
    }

    CDOSession session = openSession();
    CDOView view = session.openView();
    CDOResource resource = view.getResource(getResourcePath(resourcePath));
    assertEquals(2, resource.getContents().size());
    Supplier supplier = (Supplier) resource.getContents().get(0);
    assertNotNull(supplier);
    assertEquals(newName, supplier.getName());
  }
  public void testConflictWithRemovedObject() throws Exception {
    {
      msg("Open session & local transaction");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOPushTransaction pushTransaction = openPushTransaction(transaction);
      file = pushTransaction.getFile();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      msg("Make a diff in existing element");
      Supplier supplier = (Supplier) resource.getContents().get(0);
      supplier.setName(null);
      msg("Commit");
      pushTransaction.commit();
      session.close();
    }

    {
      msg("Open transaction & commit changes to repo");
      CDOSession session = openSession();
      CDOTransaction transaction = session.openTransaction();
      CDOResource resource = transaction.getOrCreateResource(getResourcePath(resourcePath));
      resource.getContents().remove(0);
      transaction.commit();
      session.close();
    }

    msg("Reload previous local session");
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();

    try {
      openPushTransaction(transaction, file);
      fail("ObjectNotFoundException expected");
    } catch (ObjectNotFoundException expected) {
      // SUCCESS
    }
  }
示例#22
0
  public void testGetResource() throws Exception {
    msg("Opening session");
    CDOSession session = openSession();

    {
      disableConsole();
      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Creating resource");
      CDOResource resource = transaction.createResource(getResourcePath("/test1"));

      msg("Creating supplier");
      Supplier supplier = getModel1Factory().createSupplier();

      msg("Setting name");
      supplier.setName("Stepper");

      msg("Adding supplier");
      resource.getContents().add(supplier);

      msg("Committing");
      transaction.commit();
      enableConsole();
    }

    {
      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Getting resource");
      CDOResource resource = transaction.getResource(getResourcePath("/test1"), true);
      assertNotNull(resource);
      assertEquals(
          URI.createURI(
              "cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
          resource.getURI());
      assertEquals(transaction.getResourceSet(), resource.getResourceSet());
      assertEquals(1, transaction.getResourceSet().getResources().size());
      assertEquals(CDOState.CLEAN, resource.cdoState());
      assertEquals(transaction, resource.cdoView());
      assertNotNull(resource.cdoRevision());
    }

    {
      msg("Opening transaction");
      CDOTransaction transaction = session.openTransaction();

      msg("Getting resource");
      CDOResource resource =
          (CDOResource)
              transaction
                  .getResourceSet()
                  .getResource(
                      CDOURIUtil.createResourceURI(transaction, getResourcePath("/test1")), true);
      assertNotNull(resource);
      assertEquals(
          URI.createURI(
              "cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
          resource.getURI());
      assertEquals(transaction.getResourceSet(), resource.getResourceSet());
      assertEquals(1, transaction.getResourceSet().getResources().size());
      assertEquals(CDOState.CLEAN, resource.cdoState());
      assertEquals(transaction, resource.cdoView());
      assertNotNull(resource.cdoRevision());
    }
  }