blob: 917fa144cf7a9acfa4176e4070245c695ba2f2db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/**
* Copyright (c) 2004 - 2009 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.revision.CDORevision;
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.CDOAudit;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import java.util.Map;
/**
* NPE when calling audit.setTimeStamp()
* <p>
* See https://bugs.eclipse.org/252214
*
* @author Simon McDuff
*/
public class Bugzilla_252214_Test extends AbstractCDOTest
{
@Override
public 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 = openModel1Session();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource("/res1");
Company company = getModel1Factory().createCompany();
company.setName("ESC");
resource.getContents().add(company);
transaction.commit();
commitTime1 = transaction.getLastCommitTime();
assertTrue(session.getRepositoryInfo().getCreationTime() < commitTime1);
assertEquals("ESC", company.getName());
company.setName("Sympedia");
transaction.commit();
commitTime2 = transaction.getLastCommitTime();
assertTrue(commitTime1 < commitTime2);
assertTrue(session.getRepositoryInfo().getCreationTime() < commitTime2);
assertEquals("Sympedia", company.getName());
}
CDOSession session = openModel1Session();
CDOAudit audit = session.openAudit(commitTime1);
{
CDOResource auditResource = audit.getResource("/res1");
Company auditCompany = (Company)auditResource.getContents().get(0);
CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany);
CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, CDORevision.UNSPECIFIED_VERSION);
}
audit.setTimeStamp(commitTime2);
{
CDOResource auditResource = audit.getResource("/res1");
Company auditCompany = (Company)auditResource.getContents().get(0);
assertEquals("Sympedia", auditCompany.getName());
}
session.close();
}
}
|