1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.index; 20 21 import java.io.File; 22 23 import org.apache.lucene.document.Document; 24 import org.apache.lucene.index.IndexReader; 25 import org.apache.lucene.index.MultiBits; 26 import org.apache.lucene.util.Bits; 27 import org.junit.Test; 28 29 import static org.junit.Assert.assertEquals; 30 31 /** http://issues.sonatype.org/browse/NEXUS-737 */ 32 public class Nexus737NexusIndexerTest extends AbstractNexusIndexerTest { 33 protected File repo = new File(getBasedir(), "src/test/nexus-658"); 34 35 @Override 36 protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception { 37 context = 38 nexusIndexer.addIndexingContext("nexus-658", "nexus-658", repo, indexDir, null, null, DEFAULT_CREATORS); 39 nexusIndexer.scan(context); 40 } 41 42 @Test 43 public void testValidateUINFOs() throws Exception { 44 IndexReader reader = context.acquireIndexSearcher().getIndexReader(); 45 Bits liveDocs = MultiBits.getLiveDocs(reader); 46 47 int foundCount = 0; 48 49 for (int i = 0; i < reader.maxDoc(); i++) { 50 if (liveDocs == null || liveDocs.get(i)) { 51 Document document = reader.document(i); 52 53 String uinfo = document.get(ArtifactInfo.UINFO); 54 55 if ("org.sonatype.nexus|nexus-webapp|1.0.0-SNAPSHOT|NA|jar".equals(uinfo) 56 || "org.sonatype.nexus|nexus-webapp|1.0.0-SNAPSHOT|bundle|zip".equals(uinfo) 57 || "org.sonatype.nexus|nexus-webapp|1.0.0-SNAPSHOT|bundle|tar.gz".equals(uinfo)) { 58 foundCount++; 59 } 60 } 61 } 62 63 assertEquals(foundCount, 3); 64 } 65 }