1 package org.apache.maven.index;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.lucene.store.Directory;
25 import org.apache.lucene.store.FSDirectory;
26 import org.apache.maven.index.context.IndexingContext;
27
28 public class FSDirectoryDeleteTest
29 extends AbstractIndexCreatorHelper
30 {
31 protected NexusIndexer nexusIndexer;
32
33 protected File repo = new File( getBasedir(), "src/test/nexus-13" );
34
35 protected IndexingContext context;
36
37 protected File indexDirFile = super.getDirectory( "fsdirectorytest/one" );
38
39 protected Directory indexDir;
40
41 protected IndexingContext otherContext;
42
43 protected File otherIndexDirFile = super.getDirectory( "fsdirectorytest/other" );
44
45 protected Directory otherIndexDir;
46
47 @Override
48 protected void setUp()
49 throws Exception
50 {
51 super.setUp();
52
53 nexusIndexer = lookup( NexusIndexer.class );
54
55 indexDir = FSDirectory.open( indexDirFile );
56
57 context = nexusIndexer.addIndexingContext( "one", "nexus-13", repo, indexDir, null, null, DEFAULT_CREATORS );
58
59 nexusIndexer.scan( context );
60
61 otherIndexDir = FSDirectory.open( otherIndexDirFile );
62
63 otherContext =
64 nexusIndexer.addIndexingContext( "other", "nexus-13", repo, otherIndexDir, null, null, DEFAULT_CREATORS );
65
66 nexusIndexer.scan( otherContext );
67 }
68
69 @Override
70 protected void tearDown()
71 throws Exception
72 {
73 super.tearDown();
74
75 nexusIndexer.removeIndexingContext( context, true );
76
77 nexusIndexer.removeIndexingContext( otherContext, true );
78
79 super.deleteDirectory( indexDirFile );
80
81 super.deleteDirectory( otherIndexDirFile );
82 }
83
84 public void testIndexAndDelete()
85 throws Exception
86 {
87 context.getIndexReader().maxDoc();
88
89 otherContext.getIndexReader().maxDoc();
90
91 context.replace( otherIndexDir );
92
93 context.merge( otherIndexDir );
94 }
95 }