@@ -50,9 +50,6 @@ public class FileHistoryCacheTest extends TestCase {
50
50
51
51
cache = new FileHistoryCache ();
52
52
cache .initialize ();
53
-
54
- // The tests expect support for renamed files.
55
- System .setProperty ("org.opensolaris.opengrok.history.RenamedHandlingEnabled" , "1" );
56
53
}
57
54
58
55
/**
@@ -119,11 +116,37 @@ private void assertSameEntry(HistoryEntry expected, HistoryEntry actual, boolean
119
116
}
120
117
}
121
118
119
+ /**
120
+ * Basic tests for the {@code store()} method on cache with disabled
121
+ * handling of renamed files.
122
+ */
123
+ public void testStoreAndGetNotRenamed () throws Exception {
124
+ File reposRoot = new File (repositories .getSourceRoot (), "mercurial" );
125
+ Repository repo = RepositoryFactory .getRepository (reposRoot );
126
+ History historyToStore = repo .getHistory (reposRoot );
127
+
128
+ cache .store (historyToStore , repo );
129
+
130
+ // This makes sure that the file which contains the latest revision
131
+ // has indeed been created.
132
+ assertEquals ("9:8b340409b3a8" , cache .getLatestCachedRevision (repo ));
133
+
134
+ // test reindex
135
+ History historyNull = new History ();
136
+ cache .store (historyNull , repo );
137
+
138
+ assertEquals ("9:8b340409b3a8" , cache .getLatestCachedRevision (repo ));
139
+ }
140
+
122
141
/**
123
142
* Basic tests for the {@code store()} and {@code get()} methods.
124
143
*/
125
144
public void testStoreAndGet () throws Exception {
126
145
File reposRoot = new File (repositories .getSourceRoot (), "mercurial" );
146
+
147
+ // The test expects support for renamed files.
148
+ System .setProperty ("org.opensolaris.opengrok.history.RenamedHandlingEnabled" , "1" );
149
+
127
150
Repository repo = RepositoryFactory .getRepository (reposRoot );
128
151
History historyToStore = repo .getHistory (reposRoot );
129
152
@@ -234,6 +257,10 @@ public void testStoreAndGet() throws Exception {
234
257
public void testRenamedFile () throws Exception {
235
258
File reposRoot = new File (repositories .getSourceRoot (), "mercurial" );
236
259
Repository repo = RepositoryFactory .getRepository (reposRoot );
260
+
261
+ // The test expects support for renamed files.
262
+ System .setProperty ("org.opensolaris.opengrok.history.RenamedHandlingEnabled" , "1" );
263
+
237
264
History historyToStore = repo .getHistory (reposRoot );
238
265
239
266
cache .store (historyToStore , repo );
0 commit comments