diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java index 9df91f2551..b70a457f8d 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java @@ -1,92 +1,92 @@ -/*
- * 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.bugzilla;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.util.Map;
-
-/**
- * NPE when calling audit.setTimeStamp()
- * <p>
- * See bug 252214
- *
- * @author Simon McDuff
- */
-public class Bugzilla_252214_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> testProperties = super.getTestProperties();
- testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "true");
- return testProperties;
- }
-
- public void testBugzilla_252214() throws Exception
- {
- long commitTime1 = 0;
- long commitTime2 = 0;
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
-
- Company company = getModel1Factory().createCompany();
- company.setName("ESC");
- resource.getContents().add(company);
- commitTime1 = transaction.commit().getTimeStamp();
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1);
- assertEquals("ESC", company.getName());
-
- company.setName("Sympedia");
- commitTime2 = transaction.commit().getTimeStamp();
- assertEquals(true, commitTime1 < commitTime2);
- assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2);
- assertEquals("Sympedia", company.getName());
- }
-
- CDOSession session = openSession();
- CDOView audit = session.openView(commitTime1);
-
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany);
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE);
- }
-
- audit.setTimeStamp(commitTime2);
-
- {
- CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
- Company auditCompany = (Company)auditResource.getContents().get(0);
- assertEquals("Sympedia", auditCompany.getName());
- }
-
- session.close();
- }
-}
+/* + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.model1.Company; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.internal.cdo.view.CDOStateMachine; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +import java.util.Map; + +/** + * NPE when calling audit.setTimeStamp() + * <p> + * See bug 252214 + * + * @author Simon McDuff + */ +public class Bugzilla_252214_Test extends AbstractCDOTest +{ + @Override + public synchronized Map<String, Object> getTestProperties() + { + Map<String, Object> testProperties = super.getTestProperties(); + testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "true"); + return testProperties; + } + + public void testBugzilla_252214() throws Exception + { + long commitTime1 = 0; + long commitTime2 = 0; + + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("/res1")); + + Company company = getModel1Factory().createCompany(); + company.setName("ESC"); + resource.getContents().add(company); + commitTime1 = transaction.commit().getTimeStamp(); + assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime1); + assertEquals("ESC", company.getName()); + + company.setName("Sympedia"); + commitTime2 = transaction.commit().getTimeStamp(); + assertEquals(true, commitTime1 < commitTime2); + assertEquals(true, session.getRepositoryInfo().getCreationTime() < commitTime2); + assertEquals("Sympedia", company.getName()); + } + + CDOSession session = openSession(); + CDOView audit = session.openView(commitTime1); + + { + CDOResource auditResource = audit.getResource(getResourcePath("/res1")); + Company auditCompany = (Company)auditResource.getContents().get(0); + CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany); + CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE); + } + + audit.setTimeStamp(commitTime2); + + { + CDOResource auditResource = audit.getResource(getResourcePath("/res1")); + Company auditCompany = (Company)auditResource.getContents().get(0); + assertEquals("Sympedia", auditCompany.getName()); + } + + session.close(); + } +} |