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); }
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()); }