Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 997869c88b86145fa65608133b930ce3ae516a5c (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/**
 * 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:
 *    Stefan Winkler - initial API and implementation
 */
package org.eclipse.emf.cdo.tests.store.verifier;

import static junit.framework.Assert.assertTrue;

import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;

/**
 * @author Stefan Winkler
 */
public abstract class NonAuditDBStoreIntegrityVerifier extends AbstractDBStoreVerifier
{
  public NonAuditDBStoreIntegrityVerifier(IRepository repo)
  {
    super(repo);

    // this is a verifier for non-auditing mode
    assertTrue(getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
    // ... and for horizontal class mapping
    // assertTrue(getStore().getMappingStrategy() instanceof HorizontalMappingStrategy);
  }

  // @Override
  // protected void doVerify() throws Exception
  // {
  // for (IClassMapping mapping : getClassMappings())
  // {
  // if (mapping != null && mapping.getTable() != null)
  // {
  // verifyClassMapping(mapping);
  // }
  // }
  // }
  //
  // private void verifyClassMapping(IClassMapping mapping) throws Exception
  // {
  // verifyNoUnrevisedRevisions(mapping);
  // verifyUniqueId(mapping);
  // verifyReferences(mapping);
  // }
  //
  // /**
  // * Verify that there is no row with cdo_revised == 0.
  // */
  // private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
  // {
  // String tableName = mapping.getTable().getName();
  // String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
  // ResultSet resultSet = getStatement().executeQuery(sql);
  // try
  // {
  // assertTrue(resultSet.next());
  // assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
  // }
  // finally
  // {
  // resultSet.close();
  // }
  // }
  //
  // /**
  // * Verify that the id is unique.
  // */
  // private void verifyUniqueId(IClassMapping mapping) throws Exception
  // {
  // String tableName = mapping.getTable().getName();
  // String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
  // + CDODBSchema.ATTRIBUTES_ID;
  //
  // ResultSet resultSet = getStatement().executeQuery(sql);
  //
  // try
  // {
  // while (resultSet.next())
  // {
  // assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
  // }
  // }
  // finally
  // {
  // resultSet.close();
  // }
  // }
  //
  // private void verifyReferences(IClassMapping mapping) throws Exception
  // {
  // List<IManyMapping> referenceMappings = mapping.getReferenceMappings();
  // if (referenceMappings == null)
  // {
  // return;
  // }
  //
  // String tableName = mapping.getTable().getName();
  // String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
  //
  // ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
  //
  // ResultSet resultSet = getStatement().executeQuery(sql);
  // try
  // {
  // while (resultSet.next())
  // {
  // idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
  // }
  // }
  // finally
  // {
  // resultSet.close();
  // }
  //
  // for (IManyMapping refMapping : referenceMappings)
  // {
  // for (Pair<Long, Integer> idVersion : idVersions)
  // {
  // verifyOnlyLatestReferences(refMapping, idVersion.getElement1(), idVersion.getElement2());
  // verifyCorrectIndices(refMapping, idVersion.getElement1());
  // }
  // }
  // }
  //
  // /**
  // * Verify that no reference with sourceId == ID exist which have another version
  // */
  // private void verifyOnlyLatestReferences(IManyMapping refMapping, long id, int version) throws Exception
  // {
  // String tableName = refMapping.getTable().getName();
  // String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.FEATURE_REVISION_ID + "=" + id + " AND "
  // + CDODBSchema.FEATURE_REVISION_VERSION + "<>" + version;
  //
  // ResultSet resultSet = getStatement().executeQuery(sql);
  // try
  // {
  // assertTrue(resultSet.next());
  // assertEquals("Table " + tableName + " contains old references for id " + id + "(version should be " + version
  // + ")", 0, resultSet.getInt(1));
  // }
  // finally
  // {
  // resultSet.close();
  // }
  // }
  //
  // private void verifyCorrectIndices(IManyMapping refMapping, long id) throws Exception
  // {
  // String tableName = refMapping.getTable().getName();
  // String sql = "SELECT " + CDODBSchema.FEATURE_IDX + " FROM " + tableName + " WHERE "
  // + CDODBSchema.FEATURE_REVISION_ID + "=" + id + " ORDER BY " + CDODBSchema.FEATURE_IDX;
  //
  // ResultSet resultSet = getStatement().executeQuery(sql);
  // int indexShouldBe = 0;
  // try
  // {
  // while (resultSet.next())
  // {
  // assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
  // }
  // }
  // finally
  // {
  // resultSet.close();
  // }
  // }
}

Back to the top