diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java index a83c11febe..a27c43bc87 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339908_Test.java @@ -1,96 +1,96 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model3.ClassWithIDAttribute;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_339908_Test extends AbstractCDOTest
-{
- public void testIDAttribute() throws Exception
- {
- String[] ids = new String[10];
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- for (int i = 0; i < ids.length; i++)
- {
- String id = java.util.UUID.randomUUID().toString();
- ids[i] = id;
-
- ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
- object.setId(id);
- resource.getContents().add(object);
- }
-
- transaction.commit();
-
- clearCache(getRepository().getRevisionManager());
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
-
- int i = 0;
- EList<EObject> contents = resource.getContents();
- for (EObject object : contents)
- {
- assertEquals(ids[i], ((ClassWithIDAttribute)object).getId());
- assertEquals(ids[i], EcoreUtil.getID(object));
- ++i;
- }
- }
-
- @SuppressWarnings("unused")
- private String createXMI() throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
- map.put("xmi", new XMIResourceFactoryImpl());
- Resource xmiResource = resourceSet.createResource(URI.createURI("test.xmi"));
-
- for (int i = 0; i < 10; i++)
- {
- ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute();
- object.setId(java.util.UUID.randomUUID().toString());
- xmiResource.getContents().add(object);
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmiResource.save(baos, null);
-
- String xmi = baos.toString();
- System.out.println(xmi);
- return xmi;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.model3.ClassWithIDAttribute; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +import java.io.ByteArrayOutputStream; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class Bugzilla_339908_Test extends AbstractCDOTest +{ + public void testIDAttribute() throws Exception + { + String[] ids = new String[10]; + + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("test")); + + for (int i = 0; i < ids.length; i++) + { + String id = java.util.UUID.randomUUID().toString(); + ids[i] = id; + + ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute(); + object.setId(id); + resource.getContents().add(object); + } + + transaction.commit(); + + clearCache(getRepository().getRevisionManager()); + } + + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(getResourcePath("test")); + + int i = 0; + EList<EObject> contents = resource.getContents(); + for (EObject object : contents) + { + assertEquals(ids[i], ((ClassWithIDAttribute)object).getId()); + assertEquals(ids[i], EcoreUtil.getID(object)); + ++i; + } + } + + @SuppressWarnings("unused") + private String createXMI() throws Exception + { + ResourceSet resourceSet = new ResourceSetImpl(); + Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap(); + map.put("xmi", new XMIResourceFactoryImpl()); + Resource xmiResource = resourceSet.createResource(URI.createURI("test.xmi")); + + for (int i = 0; i < 10; i++) + { + ClassWithIDAttribute object = getModel3Factory().createClassWithIDAttribute(); + object.setId(java.util.UUID.randomUUID().toString()); + xmiResource.getContents().add(object); + } + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmiResource.save(baos, null); + + String xmi = baos.toString(); + System.out.println(xmi); + return xmi; + } +} |