1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.index;
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.util.concurrent.atomic.AtomicInteger;
24
25 import org.apache.lucene.search.IndexSearcher;
26 import org.apache.maven.index.context.IndexingContext;
27 import org.apache.maven.index.packer.IndexPacker;
28 import org.apache.maven.index.packer.IndexPackingRequest;
29
30
31
32
33
34
35
36 public class ConcurrentUseWithMergedContextPublishingTest extends ConcurrentUseWithMergedContextTest {
37 protected IndexPacker packer;
38
39 protected File repoPublish = new File(getBasedir(), "target/repo-publish");
40
41 protected final AtomicInteger counter = new AtomicInteger();
42
43 @Override
44 public void setUp() throws Exception {
45 super.setUp();
46
47 packer = lookup(IndexPacker.class);
48 }
49
50 @Override
51 public void tearDown() throws Exception {
52 File props = new File(IndexingContext.INDEX_PACKER_PROPERTIES_FILE);
53 if (props.exists()) {
54 props.delete();
55 }
56 super.tearDown();
57 }
58
59 @Override
60 protected int readIndex(final NexusIndexer nexusIndexer, final IndexingContext indexingContext) throws IOException {
61
62
63
64
65 final File publish = new File(repoPublish, "publish-" + counter.getAndIncrement());
66
67 final IndexSearcher indexSearcher = context.acquireIndexSearcher();
68 try {
69 final IndexPackingRequest request =
70 new IndexPackingRequest(context, indexSearcher.getIndexReader(), publish);
71 request.setCreateIncrementalChunks(false);
72 packer.packIndex(request);
73 } finally {
74 context.releaseIndexSearcher(indexSearcher);
75 }
76
77 return 1;
78 }
79 }