Multiple fixes: MINDEXER-84 updater bug MINDEXER-85 POM reading MINDEXER-86 legacy transport format removed MINDEXER-41 unique by GAVCE from now on
Project: http://git-wip-us.apache.org/repos/asf/maven-indexer/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-indexer/commit/22fbfe07 Tree: http://git-wip-us.apache.org/repos/asf/maven-indexer/tree/22fbfe07 Diff: http://git-wip-us.apache.org/repos/asf/maven-indexer/diff/22fbfe07 Branch: refs/heads/master Commit: 22fbfe07ae012e1c2c115dc9ebed1dc3dae14b8a Parents: b071123 Author: Tamas Cservenak <[email protected]> Authored: Sun Jun 29 19:28:03 2014 +0200 Committer: Tamas Cservenak <[email protected]> Committed: Sun Jun 29 19:28:03 2014 +0200 ---------------------------------------------------------------------- .../apache/maven/index/cli/NexusIndexerCli.java | 26 +- indexer-core/pom.xml | 2 +- .../org/apache/maven/index/ArtifactContext.java | 92 +----- .../org/apache/maven/index/ArtifactInfo.java | 38 +-- .../MinimalArtifactInfoIndexCreator.java | 21 +- .../incremental/DefaultIncrementalHandler.java | 74 ++--- .../index/incremental/IncrementalHandler.java | 6 +- .../maven/index/locator/ArtifactLocator.java | 11 +- .../maven/index/packer/DefaultIndexPacker.java | 301 ++----------------- .../maven/index/packer/IndexPackingRequest.java | 32 +- .../index/updater/DefaultIndexUpdater.java | 122 -------- .../maven/index/updater/IndexDataReader.java | 18 ++ .../maven/index/updater/IndexDataWriter.java | 13 +- .../index/AbstractRepoNexusIndexerTest.java | 2 +- ...rrentUseWithMergedContextPublishingTest.java | 15 +- .../index/DefaultIndexNexusIndexerTest.java | 33 +- .../maven/index/FullIndexNexusIndexerTest.java | 34 ++- .../index/Index20081108RegressionTest.java | 288 ------------------ .../maven/index/Nexus1179NexusIndexerTest.java | 6 +- .../maven/index/Nexus13NexusIndexerTest.java | 29 +- .../Nexus1911IncrementalMergedCtxTest.java | 1 + .../maven/index/Nexus1911IncrementalTest.java | 121 ++++++-- .../maven/index/Nexus687NexusIndexerTest.java | 2 +- .../maven/index/Nexus737NexusIndexerTest.java | 2 +- .../apache/maven/index/NexusIndexerTest.java | 42 ++- .../maven/index/SearchWithAnEmptyIndexTest.java | 13 +- .../DefaultIncrementalHandlerTest.java | 58 ++-- .../packer/NEXUS4149TransferFormatTest.java | 15 +- .../index/updater/AbstractIndexUpdaterTest.java | 14 +- .../maven/index/updater/IndexDataTest.java | 19 +- .../nexus-maven-repository-index.20081108.zip | Bin 22383 -> 0 bytes .../testQueryCreatorNGSearch/case05.txt | 2 +- .../testQueryCreatorNGSearch/case06.txt | 2 +- pom.xml | 27 +- 34 files changed, 462 insertions(+), 1019 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java ---------------------------------------------------------------------- diff --git a/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java b/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java index 1f5e061..5f09659 100644 --- a/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java +++ b/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java @@ -33,6 +33,7 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.FSDirectory; import org.apache.maven.index.ArtifactContext; import org.apache.maven.index.ArtifactInfo; @@ -95,8 +96,6 @@ public class NexusIndexerCli public static final char INCREMENTAL_CHUNK_KEEP_COUNT = 'k'; - public static final char LEGACY = 'l'; - public static final char UNPACK = 'u'; private static final long MB = 1024 * 1024; @@ -206,9 +205,6 @@ public class NexusIndexerCli options.addOption( OptionBuilder.withLongOpt( "type" ).hasArg() // .withDescription( "Indexer type (default, min, full or coma separated list of custom types)." ).create( TYPE ) ); - options.addOption( OptionBuilder.withLongOpt( "legacy" ) // - .withDescription( "Build legacy .zip index file" ).create( LEGACY ) ); - options.addOption( OptionBuilder.withLongOpt( "unpack" ) // .withDescription( "Unpack an index file" ).create( UNPACK ) ); @@ -297,8 +293,6 @@ public class NexusIndexerCli boolean createIncrementalChunks = cli.hasOption( CREATE_INCREMENTAL_CHUNKS ); - boolean createLegacyIndex = cli.hasOption( LEGACY ); - boolean debug = cli.hasOption( DEBUG ); boolean quiet = cli.hasOption( QUIET ); @@ -332,11 +326,6 @@ public class NexusIndexerCli { System.err.printf( "Will create baseline file.\n" ); } - - if ( createLegacyIndex ) - { - System.err.printf( "Will also create legacy .zip index file.\n" ); - } } NexusIndexer indexer = plexus.lookup( NexusIndexer.class ); @@ -352,6 +341,7 @@ public class NexusIndexerCli null, // index update url indexers ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); try { IndexPacker packer = plexus.lookup( IndexPacker.class ); @@ -360,20 +350,13 @@ public class NexusIndexerCli indexer.scan( context, listener, true ); - IndexPackingRequest request = new IndexPackingRequest( context, outputFolder ); + IndexPackingRequest request = new IndexPackingRequest( context, indexSearcher.getIndexReader(), outputFolder ); request.setCreateChecksumFiles( createChecksums ); request.setCreateIncrementalChunks( createIncrementalChunks ); - if ( createLegacyIndex ) - { - request.setFormats( Arrays.asList( IndexFormat.FORMAT_LEGACY, IndexFormat.FORMAT_V1 ) ); - } - else - { - request.setFormats( Arrays.asList( IndexFormat.FORMAT_V1 ) ); - } + request.setFormats( Arrays.asList( IndexFormat.FORMAT_V1 ) ); if ( chunkCount != null ) { @@ -389,6 +372,7 @@ public class NexusIndexerCli } finally { + context.releaseIndexSearcher( indexSearcher ); indexer.removeIndexingContext( context, false ); } } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/pom.xml ---------------------------------------------------------------------- diff --git a/indexer-core/pom.xml b/indexer-core/pom.xml index 6343faa..ca90740 100644 --- a/indexer-core/pom.xml +++ b/indexer-core/pom.xml @@ -45,7 +45,7 @@ under the License. <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> - + <!-- DI --> <dependency> <groupId>javax.inject</groupId> http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java index 33323ac..c911406 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java +++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java @@ -21,11 +21,7 @@ package org.apache.maven.index; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; import java.util.ArrayList; import java.util.List; @@ -39,8 +35,7 @@ import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.util.zip.ZipFacade; import org.apache.maven.index.util.zip.ZipHandle; import org.apache.maven.model.Model; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** @@ -93,10 +88,15 @@ public class ArtifactContext { try { - return new ModelReader().readModel( new FileInputStream( getPom() ) ); + return new MavenXpp3Reader().read( new FileInputStream( getPom() ), false ); } - catch ( FileNotFoundException e ) + catch ( IOException e ) + { + e.printStackTrace(); + } + catch ( XmlPullParserException e ) { + e.printStackTrace(); } } // Otherwise, check for pom contained in maven generated artifact @@ -113,11 +113,16 @@ public class ArtifactContext if ( handle.hasEntry( embeddedPomPath ) ) { - return new ModelReader().readModel( handle.getEntryContent( embeddedPomPath ) ); + return new MavenXpp3Reader().read( handle.getEntryContent( embeddedPomPath ), false ); } } catch ( IOException e ) { + e.printStackTrace(); + } + catch ( XmlPullParserException e ) + { + e.printStackTrace(); } finally { @@ -197,73 +202,4 @@ public class ArtifactContext return doc; } - - public static class ModelReader - { - public Model readModel( InputStream pom ) - { - if ( pom == null ) - { - return null; - } - - Model model = new Model(); - - Xpp3Dom dom = readPomInputStream( pom ); - - if ( dom == null ) - { - return null; - } - - if ( dom.getChild( "packaging" ) != null ) - { - model.setPackaging( dom.getChild( "packaging" ).getValue() ); - } - // Special case, packaging should be null instead of default .jar if not set in pom - else - { - model.setPackaging( null ); - } - - if ( dom.getChild( "name" ) != null ) - { - model.setName( dom.getChild( "name" ).getValue() ); - } - - if ( dom.getChild( "description" ) != null ) - { - model.setDescription( dom.getChild( "description" ).getValue() ); - } - - return model; - } - - private Xpp3Dom readPomInputStream( InputStream is ) - { - Reader r = new InputStreamReader( is ); - try - { - return Xpp3DomBuilder.build( r ); - } - catch ( XmlPullParserException e ) - { - } - catch ( IOException e ) - { - } - finally - { - try - { - r.close(); - } - catch ( IOException e ) - { - } - } - - return null; - } - } } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java index ba321af..d9011ec 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java +++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.common.base.Strings; import org.apache.maven.index.artifact.Gav; import org.apache.maven.index.creator.JarFileContentsIndexCreator; import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator; @@ -282,8 +283,6 @@ public class ArtifactInfo */ private String bundleRequireBundle; - private String uinfo = null; - private final Map<String, String> attributes = new HashMap<String, String>(); private final List<MatchHighlight> matchHighlights = new ArrayList<MatchHighlight>(); @@ -336,18 +335,14 @@ public class ArtifactInfo public String getUinfo() { - if ( uinfo == null ) - { - uinfo = new StringBuilder() // - .append( groupId ).append( FS ) // - .append( artifactId ).append( FS ) // - .append( version ).append( FS ) // - .append( nvl( classifier ) ) // - .append( StringUtils.isEmpty( classifier ) || StringUtils.isEmpty( packaging ) ? "" : FS + packaging ) // - .toString(); // extension is stored in the packaging field when classifier is not used - } - - return uinfo; + return new StringBuilder() // + .append( groupId ).append( FS ) // + .append( artifactId ).append( FS ) // + .append( version ).append( FS ) // + .append( nvl( classifier ) ).append( FS ) // + .append( fileExtension ) + // .append( StringUtils.isEmpty( classifier ) || StringUtils.isEmpty( packaging ) ? "" : FS + packaging ) // + .toString(); // extension is stored in the packaging field when classifier is not used } public String getRootGroup() @@ -384,10 +379,12 @@ public class ArtifactInfo @Override public String toString() { - return new StringBuilder( groupId ).append( ':' ).append( artifactId ) // - .append( ':' ).append( version ) // - .append( ':' ).append( classifier ) // - .append( ':' ).append( packaging ).toString(); + final StringBuilder result = new StringBuilder( getUinfo() ); + if ( !Strings.isNullOrEmpty( getPackaging() ) ) + { + result.append( "[" ).append( getPackaging() ).append( "]" ); + } + return result.toString(); } private static final List<Field> DEFAULT_FIELDS = new ArrayList<Field>(); @@ -1005,11 +1002,6 @@ public class ArtifactInfo this.bundleRequireBundle = bundleRequireBundle; } - public void setUinfo( String uinfo ) - { - this.uinfo = uinfo; - } - public VersionScheme getVersionScheme( ) { return versionScheme; http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java b/indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java index f8543d3..316e4c8 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java +++ b/indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java @@ -120,7 +120,7 @@ public class MinimalArtifactInfoIndexCreator ArtifactInfo ai = ac.getArtifactInfo(); - if ( pom != null ) + if ( pom != null && pom.isFile() ) { ai.setLastModified( pom.lastModified() ); @@ -128,7 +128,7 @@ public class MinimalArtifactInfoIndexCreator } // TODO handle artifacts without poms - if ( pom != null ) + if ( pom != null && pom.isFile() ) { if ( ai.getClassifier() != null ) { @@ -181,7 +181,7 @@ public class MinimalArtifactInfoIndexCreator { // default it, since POM is present, is read, but does not contain explicit packaging // TODO: this change breaks junit tests, but not sure why is "null" expected value? - // ai.packaging = "jar"; + ai.setPackaging( "jar" ); } } } @@ -217,11 +217,6 @@ public class MinimalArtifactInfoIndexCreator ai.setSize( artifact.length() ); ai.setFileExtension( getExtension( artifact, ac.getGav() ) ); - - if ( ai.getPackaging() == null ) - { - ai.setPackaging( ai.getFileExtension() ); - } } } @@ -252,7 +247,7 @@ public class MinimalArtifactInfoIndexCreator public void updateDocument( ArtifactInfo ai, Document doc ) { String info = - new StringBuilder().append( ai.getPackaging() ).append( ArtifactInfo.FS ).append( + new StringBuilder().append( ArtifactInfo.nvl( ai.getPackaging() )).append( ArtifactInfo.FS ).append( Long.toString( ai.getLastModified() ) ).append( ArtifactInfo.FS ).append( Long.toString( ai.getSize() ) ).append( ArtifactInfo.FS ).append( ai.getSourcesExists().toString() ).append( ArtifactInfo.FS ).append( ai.getJavadocExists().toString() ).append( ArtifactInfo.FS ).append( ai.getSignatureExists().toString() ).append( @@ -331,9 +326,11 @@ public class MinimalArtifactInfoIndexCreator ai.setVersion( r[2] ); - if ( r.length > 3 ) + ai.setClassifier( ArtifactInfo.renvl( r[3] ) ); + + if ( r.length > 4 ) { - ai.setClassifier( ArtifactInfo.renvl( r[3] ) ); + ai.setFileExtension( r[4] ); } res = true; @@ -345,7 +342,7 @@ public class MinimalArtifactInfoIndexCreator { String[] r = ArtifactInfo.FS_PATTERN.split( info ); - ai.setPackaging( r[0] ); + ai.setPackaging( ArtifactInfo.renvl( r[0] )); ai.setLastModified( Long.parseLong( r[1] ) ); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java b/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java index 4ddb1aa..75c50dc 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java +++ b/indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java @@ -19,6 +19,18 @@ package org.apache.maven.index.incremental; * under the License. */ +import org.apache.lucene.document.Document; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.MultiFields; +import org.apache.lucene.util.Bits; +import org.apache.maven.index.ArtifactInfo; +import org.apache.maven.index.context.IndexingContext; +import org.apache.maven.index.packer.IndexPackingRequest; +import org.apache.maven.index.updater.IndexUpdateRequest; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.util.StringUtils; + import java.io.File; import java.io.FilenameFilter; import java.io.IOException; @@ -35,20 +47,7 @@ import java.util.Set; import java.util.TimeZone; import java.util.TreeMap; -import org.apache.lucene.document.Document; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.MultiFields; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.util.Bits; -import org.apache.maven.index.ArtifactInfo; -import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.index.packer.IndexPackingRequest; -import org.apache.maven.index.updater.IndexUpdateRequest; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.StringUtils; - -@Component( role = IncrementalHandler.class ) +@Component(role = IncrementalHandler.class) public class DefaultIncrementalHandler extends AbstractLogEnabled implements IncrementalHandler @@ -143,43 +142,34 @@ public class DefaultIncrementalHandler } } - // Note Toni: private List<Integer> getIndexChunk( IndexPackingRequest request, Date timestamp ) throws IOException { final List<Integer> chunk = new ArrayList<Integer>(); - final IndexSearcher indexSearcher = request.getContext().acquireIndexSearcher(); - try + final IndexReader r = request.getIndexReader(); + Bits liveDocs = MultiFields.getLiveDocs( r ); + for ( int i = 0; i < r.maxDoc(); i++ ) { - final IndexReader r = indexSearcher.getIndexReader(); - Bits liveDocs = MultiFields.getLiveDocs(r); - for ( int i = 0; i < r.maxDoc(); i++ ) + if ( liveDocs == null || liveDocs.get( i ) ) { - if (liveDocs == null || liveDocs.get(i) ) - { - Document d = r.document( i ); + Document d = r.document( i ); - String lastModified = d.get( ArtifactInfo.LAST_MODIFIED ); + String lastModified = d.get( ArtifactInfo.LAST_MODIFIED ); - if ( lastModified != null ) - { - Date t = new Date( Long.parseLong( lastModified ) ); + if ( lastModified != null ) + { + Date t = new Date( Long.parseLong( lastModified ) ); - // Only add documents that were added after the last time we indexed - if ( t.after( timestamp ) ) - { - chunk.add( i ); - } + // Only add documents that were added after the last time we indexed + if ( t.after( timestamp ) ) + { + chunk.add( i ); } } } - - return chunk; - } - finally - { - request.getContext().releaseIndexSearcher( indexSearcher ); } + + return chunk; } private void updateProperties( Properties properties, IndexPackingRequest request ) @@ -236,8 +226,8 @@ public class DefaultIncrementalHandler { String[] parts = name.split( "\\." ); - if ( parts.length == 3 && parts[0].equals( IndexingContext.INDEX_FILE_PREFIX ) - && parts[2].equals( "gz" ) ) + if ( parts.length == 3 && parts[0].equals( IndexingContext.INDEX_FILE_PREFIX ) && parts[2].equals( + "gz" ) ) { return true; } @@ -321,8 +311,8 @@ public class DefaultIncrementalHandler String value = remoteProps.getProperty( sKey ); // If we have the current counter, or the next counter, we are good to go - if ( Integer.toString( currentLocalCounter ).equals( value ) - || Integer.toString( currentLocalCounter + 1 ).equals( value ) ) + if ( Integer.toString( currentLocalCounter ).equals( value ) || Integer.toString( + currentLocalCounter + 1 ).equals( value ) ) { return true; } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/incremental/IncrementalHandler.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/incremental/IncrementalHandler.java b/indexer-core/src/main/java/org/apache/maven/index/incremental/IncrementalHandler.java index ef1efdf..45f63c7 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/incremental/IncrementalHandler.java +++ b/indexer-core/src/main/java/org/apache/maven/index/incremental/IncrementalHandler.java @@ -19,13 +19,13 @@ package org.apache.maven.index.incremental; * under the License. */ +import org.apache.maven.index.packer.IndexPackingRequest; +import org.apache.maven.index.updater.IndexUpdateRequest; + import java.io.IOException; import java.util.List; import java.util.Properties; -import org.apache.maven.index.packer.IndexPackingRequest; -import org.apache.maven.index.updater.IndexUpdateRequest; - public interface IncrementalHandler { List<Integer> getIncrementalUpdates( IndexPackingRequest request, Properties properties ) http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java b/indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java index b0f6cef..d27d2a6 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java +++ b/indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java @@ -23,11 +23,12 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import org.apache.maven.index.ArtifactContext.ModelReader; import org.apache.maven.index.artifact.ArtifactPackagingMapper; import org.apache.maven.index.artifact.Gav; import org.apache.maven.index.artifact.GavCalculator; import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** * Artifact locator. @@ -56,7 +57,7 @@ public class ArtifactLocator try { // need to read the pom model to get packaging - Model model = new ModelReader().readModel( new FileInputStream( source ) ); + final Model model = new MavenXpp3Reader().read( new FileInputStream( source ), false ); if ( model == null ) { @@ -79,6 +80,12 @@ public class ArtifactLocator } catch ( IOException e ) { + e.printStackTrace(); + return null; + } + catch ( XmlPullParserException e ) + { + e.printStackTrace(); return null; } } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java b/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java index e028cb1..ba15396 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java +++ b/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java @@ -19,46 +19,18 @@ package org.apache.maven.index.packer; * under the License. */ -import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.TimeZone; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.StoredField; -import org.apache.lucene.document.StringField; -import org.apache.lucene.document.TextField; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.MultiFields; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.store.IOContext; -import org.apache.lucene.store.IndexInput; -import org.apache.lucene.store.LockObtainFailedException; -import org.apache.lucene.util.Bits; -import org.apache.maven.index.ArtifactInfo; -import org.apache.maven.index.context.DefaultIndexingContext; -import org.apache.maven.index.context.IndexCreator; -import org.apache.maven.index.context.IndexUtils; + import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.index.context.NexusIndexWriter; -import org.apache.maven.index.context.NexusLegacyAnalyzer; -import org.apache.maven.index.creator.LegacyDocumentUpdater; import org.apache.maven.index.incremental.IncrementalHandler; import org.apache.maven.index.updater.IndexDataWriter; import org.codehaus.plexus.component.annotations.Component; @@ -69,7 +41,7 @@ import org.codehaus.plexus.util.IOUtil; /** * A default {@link IndexPacker} implementation. Creates the properties, legacy index zip and new gz files. - * + * * @author Tamas Cservenak * @author Eugene Kuleshov */ @@ -94,13 +66,13 @@ public class DefaultIndexPacker if ( !request.getTargetDir().isDirectory() ) { throw new IllegalArgumentException( // - String.format( "Specified target path %s is not a directory", - request.getTargetDir().getAbsolutePath() ) ); + String.format( "Specified target path %s is not a directory", + request.getTargetDir().getAbsolutePath() ) ); } if ( !request.getTargetDir().canWrite() ) { throw new IllegalArgumentException( String.format( "Specified target path %s is not writtable", - request.getTargetDir().getAbsolutePath() ) ); + request.getTargetDir().getAbsolutePath() ) ); } } else @@ -138,13 +110,11 @@ public class DefaultIndexPacker } else { - File file = - new File( request.getTargetDir(), // - IndexingContext.INDEX_FILE_PREFIX + "." - + info.getProperty( IndexingContext.INDEX_CHUNK_COUNTER ) + ".gz" ); + File file = new File( request.getTargetDir(), // + IndexingContext.INDEX_FILE_PREFIX + "." + info.getProperty( + IndexingContext.INDEX_CHUNK_COUNTER ) + ".gz" ); - writeIndexData( request.getContext(), // - chunk, file ); + writeIndexData( request, chunk, file ); if ( request.isCreateChecksumFiles() ) { @@ -173,37 +143,19 @@ public class DefaultIndexPacker timestamp = new Date( 0 ); // never updated } - if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_LEGACY ) ) - { - info.setProperty( IndexingContext.INDEX_LEGACY_TIMESTAMP, format( timestamp ) ); - - writeIndexArchive( request.getContext(), legacyFile, request.getMaxIndexChunks() ); - - if ( request.isCreateChecksumFiles() ) - { - FileUtils.fileWrite( - new File( legacyFile.getParentFile(), legacyFile.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( legacyFile ) ); - - FileUtils.fileWrite( - new File( legacyFile.getParentFile(), legacyFile.getName() + ".md5" ).getAbsolutePath(), - DigesterUtils.getMd5Digest( legacyFile ) ); - } - } - if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_V1 ) ) { info.setProperty( IndexingContext.INDEX_TIMESTAMP, format( timestamp ) ); - writeIndexData( request.getContext(), null, v1File ); + writeIndexData( request, null, v1File ); if ( request.isCreateChecksumFiles() ) { FileUtils.fileWrite( new File( v1File.getParentFile(), v1File.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( v1File ) ); + DigesterUtils.getSha1Digest( v1File ) ); FileUtils.fileWrite( new File( v1File.getParentFile(), v1File.getName() + ".md5" ).getAbsolutePath(), - DigesterUtils.getMd5Digest( v1File ) ); + DigesterUtils.getMd5Digest( v1File ) ); } } @@ -245,226 +197,7 @@ public class DefaultIndexPacker return properties; } - void writeIndexArchive( IndexingContext context, File targetArchive ) - throws IOException - { - writeIndexArchive(context, targetArchive, IndexPackingRequest.MAX_CHUNKS); - } - - void writeIndexArchive( IndexingContext context, File targetArchive, int maxSegments ) - throws IOException - { - if ( targetArchive.exists() ) - { - targetArchive.delete(); - } - - OutputStream os = null; - - try - { - os = new BufferedOutputStream( new FileOutputStream( targetArchive ), 4096 ); - - packIndexArchive( context, os ); - } - finally - { - IOUtil.close( os ); - } - } - - /** - * Pack legacy index archive into a specified output stream - */ - public static void packIndexArchive( IndexingContext context, OutputStream os ) - throws IOException - { - packIndexArchive(context, os, IndexPackingRequest.MAX_CHUNKS); - } - - /** - * Pack legacy index archive into a specified output stream - */ - public static void packIndexArchive( IndexingContext context, OutputStream os, int maxSegments ) - throws IOException - { - File indexArchive = File.createTempFile( "nexus-index", "" ); - - File indexDir = new File( indexArchive.getAbsoluteFile().getParentFile(), indexArchive.getName() + ".dir" ); - - indexDir.mkdirs(); - - FSDirectory fdir = FSDirectory.open( indexDir ); - - try - { - // force the timestamp update - IndexUtils.updateTimestamp( context.getIndexDirectory(), context.getTimestamp() ); - IndexUtils.updateTimestamp( fdir, context.getTimestamp() ); - - final IndexSearcher indexSearcher = context.acquireIndexSearcher(); - try - { - copyLegacyDocuments( indexSearcher.getIndexReader(), fdir, context, maxSegments); - } - finally - { - context.releaseIndexSearcher( indexSearcher ); - } - packDirectory( fdir, os ); - } - finally - { - IndexUtils.close( fdir ); - indexArchive.delete(); - IndexUtils.delete( indexDir ); - } - } - - static void copyLegacyDocuments( IndexReader r, Directory targetdir, IndexingContext context ) - throws CorruptIndexException, LockObtainFailedException, IOException - { - copyLegacyDocuments(r, targetdir, context, IndexPackingRequest.MAX_CHUNKS); - } - - static void copyLegacyDocuments( IndexReader r, Directory targetdir, IndexingContext context, int maxSegments) - throws CorruptIndexException, LockObtainFailedException, IOException - { - IndexWriter w = null; - Bits liveDocs = MultiFields.getLiveDocs(r); - try - { - w = new NexusIndexWriter( targetdir, new NexusLegacyAnalyzer(), true ); - - for ( int i = 0; i < r.maxDoc(); i++ ) - { - if ( liveDocs == null || liveDocs.get(i) ) - { - Document legacyDocument = r.document( i ); - Document updatedLegacyDocument = updateLegacyDocument( legacyDocument, context ); - - //Lucene does not return metadata for stored documents, so we need to fix that - for (IndexableField indexableField : updatedLegacyDocument.getFields()) - { - if(indexableField.name().equals(DefaultIndexingContext.FLD_DESCRIPTOR)) - { - updatedLegacyDocument = new Document(); - updatedLegacyDocument.add(new StringField(DefaultIndexingContext.FLD_DESCRIPTOR, DefaultIndexingContext.FLD_DESCRIPTOR_CONTENTS, Field.Store.YES)); - updatedLegacyDocument.add( new StringField( DefaultIndexingContext.FLD_IDXINFO, DefaultIndexingContext.VERSION + ArtifactInfo.FS + context.getRepositoryId(), Field.Store.YES) ); - break; - } - } - - w.addDocument( updatedLegacyDocument ); - } - } - - w.forceMerge(maxSegments); - w.commit(); - } - finally - { - IndexUtils.close( w ); - } - } - - static Document updateLegacyDocument( Document doc, IndexingContext context ) - { - ArtifactInfo ai = IndexUtils.constructArtifactInfo( doc, context ); - if ( ai == null ) - { - return doc; - } - - Document document = new Document(); - document.add( new Field( ArtifactInfo.UINFO, ai.getUinfo(), Field.Store.YES, Field.Index.NOT_ANALYZED ) ); - - for ( IndexCreator ic : context.getIndexCreators() ) - { - if ( ic instanceof LegacyDocumentUpdater ) - { - ( (LegacyDocumentUpdater) ic ).updateLegacyDocument( ai, document ); - } - } - - return document; - } - - static void packDirectory( Directory directory, OutputStream os ) - throws IOException - { - ZipOutputStream zos = null; - try - { - zos = new ZipOutputStream( os ); - zos.setLevel( 9 ); - - String[] names = directory.listAll(); - - boolean savedTimestamp = false; - - byte[] buf = new byte[8192]; - - for ( int i = 0; i < names.length; i++ ) - { - String name = names[i]; - - writeFile( name, zos, directory, buf ); - - if ( name.equals( IndexUtils.TIMESTAMP_FILE ) ) - { - savedTimestamp = true; - } - } - - // FSDirectory filter out the foreign files - if ( !savedTimestamp && directory.fileExists( IndexUtils.TIMESTAMP_FILE ) ) - { - writeFile( IndexUtils.TIMESTAMP_FILE, zos, directory, buf ); - } - } - finally - { - IndexUtils.close( zos ); - } - } - - static void writeFile( String name, ZipOutputStream zos, Directory directory, byte[] buf ) - throws IOException - { - ZipEntry e = new ZipEntry( name ); - - zos.putNextEntry( e ); - - IndexInput in = directory.openInput( name, IOContext.DEFAULT ); - - try - { - int toRead = 0; - - int bytesLeft = (int) in.length(); - - while ( bytesLeft > 0 ) - { - toRead = ( bytesLeft >= buf.length ) ? buf.length : bytesLeft; - bytesLeft -= toRead; - - in.readBytes( buf, 0, toRead, false ); - - zos.write( buf, 0, toRead ); - } - } - finally - { - IndexUtils.close( in ); - } - - zos.flush(); - - zos.closeEntry(); - } - - void writeIndexData( IndexingContext context, List<Integer> docIndexes, File targetArchive ) + void writeIndexData( IndexPackingRequest request, List<Integer> docIndexes, File targetArchive ) throws IOException { if ( targetArchive.exists() ) @@ -479,7 +212,7 @@ public class DefaultIndexPacker os = new FileOutputStream( targetArchive ); IndexDataWriter dw = new IndexDataWriter( os ); - dw.write( context, docIndexes ); + dw.write( request.getContext(), request.getIndexReader(), docIndexes ); os.flush(); } @@ -524,9 +257,9 @@ public class DefaultIndexPacker if ( request.isCreateChecksumFiles() ) { - FileUtils.fileWrite( - new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( targetPropertyFile ) ); + FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), + targetPropertyFile.getName() + ".sha1" ).getAbsolutePath(), + DigesterUtils.getSha1Digest( targetPropertyFile ) ); FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".md5" ).getAbsolutePath(), http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/packer/IndexPackingRequest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/packer/IndexPackingRequest.java b/indexer-core/src/main/java/org/apache/maven/index/packer/IndexPackingRequest.java index 7debc23..0b74ea3 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/packer/IndexPackingRequest.java +++ b/indexer-core/src/main/java/org/apache/maven/index/packer/IndexPackingRequest.java @@ -23,8 +23,12 @@ import java.io.File; import java.util.Arrays; import java.util.Collection; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.IndexSearcher; import org.apache.maven.index.context.IndexingContext; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An index packing request. */ @@ -32,9 +36,11 @@ public class IndexPackingRequest { public static final int MAX_CHUNKS = 30; - private IndexingContext context; + private final IndexingContext context; + + private final IndexReader indexReader; - private File targetDir; + private final File targetDir; private boolean createIncrementalChunks; @@ -46,11 +52,13 @@ public class IndexPackingRequest private Collection<IndexFormat> formats; - public IndexPackingRequest( IndexingContext context, File targetDir ) + public IndexPackingRequest( final IndexingContext context, final IndexReader indexReader, final File targetDir ) { - this.context = context; + this.context = checkNotNull(context); - this.targetDir = targetDir; + this.indexReader = checkNotNull( indexReader ); + + this.targetDir = checkNotNull( targetDir ); this.createIncrementalChunks = true; @@ -60,7 +68,7 @@ public class IndexPackingRequest this.useTargetProperties = false; - this.formats = Arrays.asList( IndexFormat.FORMAT_LEGACY, IndexFormat.FORMAT_V1 ); + this.formats = Arrays.asList( IndexFormat.FORMAT_V1 ); } public IndexingContext getContext() @@ -68,10 +76,7 @@ public class IndexPackingRequest return context; } - public void setContext( IndexingContext context ) - { - this.context = context; - } + public IndexReader getIndexReader() { return indexReader; } /** * Sets index formats to be created @@ -94,11 +99,6 @@ public class IndexPackingRequest return targetDir; } - public void setTargetDir( File targetDir ) - { - this.targetDir = targetDir; - } - public boolean isCreateIncrementalChunks() { return createIncrementalChunks; @@ -144,6 +144,6 @@ public class IndexPackingRequest */ public static enum IndexFormat { - FORMAT_LEGACY, FORMAT_V1; + FORMAT_V1; } } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java b/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java index d8fd255..c5226f7 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java +++ b/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java @@ -262,128 +262,6 @@ public class DefaultIndexUpdater } } - /** - * Unpack legacy index archive into a specified Lucene <code>Directory</code> - * - * @param is a <code>ZipInputStream</code> with index data - * @param directory Lucene <code>Directory</code> to unpack index data to - * @return {@link Date} of the index update or null if it can't be read - */ - public static Date unpackIndexArchive( final InputStream is, final Directory directory, - final IndexingContext context ) - throws IOException - { - File indexArchive = File.createTempFile( "nexus-index", "" ); - - File indexDir = new File( indexArchive.getAbsoluteFile().getParentFile(), indexArchive.getName() + ".dir" ); - - indexDir.mkdirs(); - - FSDirectory fdir = FSDirectory.open( indexDir ); - - try - { - unpackDirectory( fdir, is ); - copyUpdatedDocuments( fdir, directory, context ); - - Date timestamp = IndexUtils.getTimestamp( fdir ); - IndexUtils.updateTimestamp( directory, timestamp ); - return timestamp; - } - finally - { - IndexUtils.close( fdir ); - indexArchive.delete(); - IndexUtils.delete( indexDir ); - } - } - - private static void unpackDirectory( final Directory directory, final InputStream is ) - throws IOException - { - byte[] buf = new byte[4096]; - - ZipEntry entry; - - ZipInputStream zis = null; - - try - { - zis = new ZipInputStream( is ); - - while ( ( entry = zis.getNextEntry() ) != null ) - { - if ( entry.isDirectory() || entry.getName().indexOf( '/' ) > -1 ) - { - continue; - } - - IndexOutput io = directory.createOutput( entry.getName(), IOContext.DEFAULT ); - try - { - int n = 0; - - while ( ( n = zis.read( buf ) ) != -1 ) - { - io.writeBytes( buf, n ); - } - } - finally - { - IndexUtils.close( io ); - } - } - } - finally - { - IndexUtils.close( zis ); - } - } - - private static void copyUpdatedDocuments( final Directory sourcedir, final Directory targetdir, - final IndexingContext context ) - throws CorruptIndexException, LockObtainFailedException, IOException - { - IndexWriter w = null; - IndexReader r = null; - try - { - r = IndexReader.open( sourcedir ); - w = new NexusIndexWriter( targetdir, new NexusAnalyzer(), true ); - Bits liveDocs = MultiFields.getLiveDocs(r); - - for ( int i = 0; i < r.maxDoc(); i++ ) - { - if (liveDocs == null || liveDocs.get(i) ) - { - Document sourceDocument = r.document( i ); - Document targetDocument = IndexUtils.updateDocument( sourceDocument, context ); - - //Lucene does not return metadata for stored documents, so we need to fix that - for (IndexableField indexableField : targetDocument.getFields()) - { - if(indexableField.name().equals(DefaultIndexingContext.FLD_DESCRIPTOR)) - { - targetDocument = new Document(); - targetDocument.add(new StringField(DefaultIndexingContext.FLD_DESCRIPTOR, DefaultIndexingContext.FLD_DESCRIPTOR_CONTENTS, Field.Store.YES)); - targetDocument.add( new StringField( DefaultIndexingContext.FLD_IDXINFO, DefaultIndexingContext.VERSION + ArtifactInfo.FS + context.getRepositoryId(), Field.Store.YES) ); - break; - } - } - w.addDocument( targetDocument ); - } - } - - w.forceMerge(1); - w.commit(); - } - finally - { - IndexUtils.close( w ); - IndexUtils.close( r ); - } - } - private static void filterDirectory( final Directory directory, final DocumentFilter filter ) throws IOException { http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java b/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java index d701347..f76200c 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java +++ b/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataReader.java @@ -28,11 +28,14 @@ import java.io.InputStream; import java.io.UTFDataFormatException; import java.util.Date; import java.util.zip.GZIPInputStream; + +import com.google.common.base.Strings; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Index; import org.apache.lucene.document.Field.Store; import org.apache.lucene.index.IndexWriter; +import org.apache.maven.index.ArtifactInfo; import org.apache.maven.index.context.IndexUtils; import org.apache.maven.index.context.IndexingContext; @@ -138,6 +141,21 @@ public class IndexDataReader doc.add( readField() ); } + // Fix up UINFO field wrt MINDEXER-41 + final Field uinfoField = (Field) doc.getField( ArtifactInfo.UINFO ); + final String info = doc.get( ArtifactInfo.INFO ); + if (uinfoField!= null && !Strings.isNullOrEmpty(info)) { + final String[] splitInfo = ArtifactInfo.FS_PATTERN.split( info ); + if ( splitInfo.length > 6 ) + { + final String extension = splitInfo[6]; + final String uinfoString = uinfoField.stringValue(); + if (uinfoString.endsWith( ArtifactInfo.FS + ArtifactInfo.NA )) { + uinfoField.setStringValue( uinfoString + ArtifactInfo.FS + ArtifactInfo.nvl( extension ) ); + } + } + } + return doc; } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java b/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java index 4c9e2bb..13ad7ce 100644 --- a/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java +++ b/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java @@ -84,21 +84,12 @@ public class IndexDataWriter this.descriptorWritten = false; } - public int write( IndexingContext context, List<Integer> docIndexes ) + public int write( IndexingContext context, IndexReader indexReader, List<Integer> docIndexes ) throws IOException { writeHeader( context ); - int n = 0; - final IndexSearcher indexSearcher = context.acquireIndexSearcher(); - try - { - n = writeDocuments( indexSearcher.getIndexReader(), docIndexes ); - } - finally - { - context.releaseIndexSearcher( indexSearcher ); - } + int n = writeDocuments( indexReader, docIndexes ); writeGroupFields(); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java index 6b1327d..7e2751e 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java @@ -535,7 +535,7 @@ public abstract class AbstractRepoNexusIndexerTest if ( uinfo != null ) { String info = document.get( ArtifactInfo.INFO ); - assertFalse( info.startsWith( "null" ) ); + assertFalse( "Bad:" + info, info.startsWith( "null" ) ); } } } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java index 4483f0f..e4c9908 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextPublishingTest.java @@ -19,6 +19,7 @@ package org.apache.maven.index; * under the License. */ +import org.apache.lucene.search.IndexSearcher; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.packer.IndexPacker; import org.apache.maven.index.packer.IndexPackingRequest; @@ -73,11 +74,15 @@ public class ConcurrentUseWithMergedContextPublishingTest // it was probably publish rubbish anyway. final File publish = new File( repoPublish, "publish-" + counter.getAndIncrement() ); - final IndexPackingRequest request = new IndexPackingRequest( context, publish ); - - request.setCreateIncrementalChunks( false ); - - packer.packIndex( request ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + final IndexPackingRequest request = new IndexPackingRequest( context, indexSearcher.getIndexReader(), publish ); + request.setCreateIncrementalChunks( false ); + packer.packIndex( request ); + } finally { + context.releaseIndexSearcher( indexSearcher ); + } return 1; } http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java index 83bf1e4..7d589a6 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/DefaultIndexNexusIndexerTest.java @@ -31,6 +31,7 @@ import java.util.Set; import org.apache.lucene.index.Term; import org.apache.lucene.search.FilteredQuery; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryWrapperFilter; @@ -43,7 +44,11 @@ import org.apache.maven.index.FlatSearchResponse; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.packer.DefaultIndexPacker; +import org.apache.maven.index.packer.IndexPacker; +import org.apache.maven.index.packer.IndexPackingRequest; import org.apache.maven.index.updater.DefaultIndexUpdater; +import org.apache.maven.index.updater.IndexUpdateRequest; +import org.apache.maven.index.updater.IndexUpdater; public class DefaultIndexNexusIndexerTest extends MinimalIndexNexusIndexerTest @@ -162,9 +167,22 @@ public class DefaultIndexNexusIndexerTest public void testIndexTimestamp() throws Exception { - ByteArrayOutputStream os = new ByteArrayOutputStream(); + final File targetDir = File.createTempFile( "testIndexTimestamp", "ut-tmp" ); + targetDir.delete(); + targetDir.mkdirs(); - DefaultIndexPacker.packIndexArchive( context, os ); + final IndexPacker indexPacker = lookup( IndexPacker.class ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + final IndexPackingRequest request = + new IndexPackingRequest( context, indexSearcher.getIndexReader(), targetDir ); + indexPacker.packIndex( request ); + } + finally + { + context.releaseIndexSearcher( indexSearcher ); + } Thread.sleep( 1000L ); @@ -172,11 +190,12 @@ public class DefaultIndexNexusIndexerTest Directory newIndexDir = FSDirectory.open( newIndex ); - DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context ); - IndexingContext newContext = nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS ); + final IndexUpdater indexUpdater = lookup( IndexUpdater.class ); + indexUpdater.fetchAndUpdateIndex( new IndexUpdateRequest( newContext, new DefaultIndexUpdater.FileFetcher( targetDir ) ) ); + assertEquals( context.getTimestamp().getTime(), newContext.getTimestamp().getTime() ); assertEquals( context.getTimestamp(), newContext.getTimestamp() ); @@ -189,6 +208,8 @@ public class DefaultIndexNexusIndexerTest FlatSearchResponse response = nexusIndexer.searchFlat( request ); Collection<ArtifactInfo> r = response.getResults(); + System.out.println(r); + assertEquals( 2, r.size() ); List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( r ); @@ -211,11 +232,11 @@ public class DefaultIndexNexusIndexerTest newIndexDir = FSDirectory.open( newIndex ); - DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context ); - newContext = nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS ); + indexUpdater.fetchAndUpdateIndex( new IndexUpdateRequest( newContext, new DefaultIndexUpdater.FileFetcher( targetDir ) ) ); + assertEquals( timestamp, newContext.getTimestamp() ); newContext.close( true ); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java index bce9143..dc07273 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/FullIndexNexusIndexerTest.java @@ -29,9 +29,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; + import org.apache.lucene.index.Term; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.FilteredQuery; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryWrapperFilter; @@ -40,9 +42,14 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.packer.DefaultIndexPacker; +import org.apache.maven.index.packer.IndexPacker; +import org.apache.maven.index.packer.IndexPackingRequest; import org.apache.maven.index.search.grouping.GAGrouping; import org.apache.maven.index.search.grouping.GGrouping; import org.apache.maven.index.updater.DefaultIndexUpdater; +import org.apache.maven.index.updater.IndexUpdateRequest; +import org.apache.maven.index.updater.IndexUpdater; + import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -328,9 +335,22 @@ public class FullIndexNexusIndexerTest public void testIndexTimestamp() throws Exception { - ByteArrayOutputStream os = new ByteArrayOutputStream(); + final File targetDir = File.createTempFile( "testIndexTimestamp", "ut-tmp" ); + targetDir.delete(); + targetDir.mkdirs(); - DefaultIndexPacker.packIndexArchive( context, os ); + final IndexPacker indexPacker = lookup( IndexPacker.class ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + final IndexPackingRequest request = + new IndexPackingRequest( context, indexSearcher.getIndexReader(), targetDir ); + indexPacker.packIndex( request ); + } + finally + { + context.releaseIndexSearcher( indexSearcher ); + } Thread.sleep( 1000L ); @@ -338,11 +358,13 @@ public class FullIndexNexusIndexerTest Directory newIndexDir = FSDirectory.open( newIndex ); - DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context ); - IndexingContext newContext = nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS ); + final IndexUpdater indexUpdater = lookup( IndexUpdater.class ); + indexUpdater.fetchAndUpdateIndex( new IndexUpdateRequest( newContext, new DefaultIndexUpdater.FileFetcher( targetDir ) ) ); + + assertEquals( context.getTimestamp().getTime(), newContext.getTimestamp().getTime() ); assertEquals( context.getTimestamp(), newContext.getTimestamp() ); @@ -377,11 +399,11 @@ public class FullIndexNexusIndexerTest newIndexDir = FSDirectory.open( newIndex ); - DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, context ); - newContext = nexusIndexer.addIndexingContext( "test-new", "test", null, newIndexDir, null, null, DEFAULT_CREATORS ); + indexUpdater.fetchAndUpdateIndex( new IndexUpdateRequest( newContext, new DefaultIndexUpdater.FileFetcher( targetDir ) ) ); + assertEquals( timestamp, newContext.getTimestamp() ); newContext.close( true ); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java b/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java deleted file mode 100644 index 027ecb2..0000000 --- a/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java +++ /dev/null @@ -1,288 +0,0 @@ -package org.apache.maven.index; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.lucene.index.Term; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.RAMDirectory; -import org.apache.maven.index.search.grouping.GAGrouping; -import org.apache.maven.index.updater.DefaultIndexUpdater; -import org.junit.Ignore; - -/** - * @author Eugene Kuleshov - */ -@Ignore("Index format too old for Lucene 4") -public class Index20081108RegressionTest - extends AbstractRepoNexusIndexerTest -{ - @Override - protected void prepareNexusIndexer( NexusIndexer nexusIndexer ) - throws Exception - { - context = nexusIndexer.addIndexingContextForced( "test", "test", null, indexDir, null, null, DEFAULT_CREATORS ); - - InputStream is = new FileInputStream( getBasedir() + // - File.separator + "src" + // - File.separator + "test" + // - File.separator + "nexus-maven-repository-index.20081108.zip" ); - - Directory tempDir = new RAMDirectory(); - DefaultIndexUpdater.unpackIndexArchive( is, tempDir, context ); - context.replace( tempDir ); - } - - public void testExtension() - throws Exception - { - assertEquals( 31, context.getSize() ); - - { - Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "qdox", SearchType.SCORED ); - FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q ) ); - assertEquals( response.getResults().toString(), 2, response.getTotalHits() ); - - List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( response.getResults() ); - assertEquals( 2, list.size() ); - - { - ArtifactInfo ai = list.get( 0 ); - assertEquals( "1.6.1", ai.getVersion() ); - assertEquals( "jar", ai.getFileExtension() ); - assertEquals( "jar", ai.getPackaging() ); - } - { - ArtifactInfo ai = list.get( 1 ); - assertEquals( "1.5", ai.getVersion() ); - assertEquals( "jar", ai.getFileExtension() ); - assertEquals( "jar", ai.getPackaging() ); - } - } - { - Query query = new TermQuery( new Term( ArtifactInfo.PACKAGING, "tar.gz" ) ); - FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( query ) ); - assertEquals( response.getResults().toString(), 1, response.getTotalHits() ); - - ArtifactInfo ai = response.getResults().iterator().next(); - assertEquals( "tar.gz", ai.getPackaging() ); - assertEquals( "tar.gz", ai.getFileExtension() ); - } - { - Query query = new TermQuery( new Term( ArtifactInfo.PACKAGING, "zip" ) ); - FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( query ) ); - assertEquals( response.getResults().toString(), 1, response.getTotalHits() ); - - ArtifactInfo ai = response.getResults().iterator().next(); - assertEquals( "zip", ai.getPackaging() ); - assertEquals( "zip", ai.getFileExtension() ); - } - } - - @Override - public void testRootGroups() - throws Exception - { - Set<String> rootGroups = context.getRootGroups(); - assertEquals( rootGroups.toString(), 8, rootGroups.size() ); - - assertGroup( 2, "qdox", context ); - - assertGroup( 1, "proptest", context ); - - assertGroup( 1, "junit", context ); - - assertGroup( 6, "commons-logging", context ); - - assertGroup( 1, "regexp", context ); - - assertGroup( 1, "commons-cli", context ); - - assertGroup( 15, "org", context ); - - assertGroup( 6, "org.slf4j", context ); - - assertGroup( 3, "org.testng", context ); - - assertGroup( 3, "org.apache", context ); - - assertGroup( 1, "org.apache.directory", context ); - assertGroup( 1, "org.apache.directory.server", context ); - - assertGroup( 1, "org.apache.maven", context ); - assertGroup( 1, "org.apache.maven.plugins", context ); - assertGroup( 0, "org.apache.maven.plugins.maven-core-it-plugin", context ); - } - - @Override - public void testSearchFlatPaged() - throws Exception - { - FlatSearchRequest request = new FlatSearchRequest( nexusIndexer.constructQuery( MAVEN.GROUP_ID, "org", SearchType.SCORED ) ); - - // See MINDEXER-22 - // Flat search is not pageable - // request.setStart( 0 ); - - request.setCount( 50 ); - - FlatSearchResponse response = nexusIndexer.searchFlat( request ); - - assertEquals( response.getResults().toString(), 15, response.getTotalHits() ); - } - - @Override - public void testSearchGroupedProblematicNames() - throws Exception - { - - // ---------------------------------------------------------------------------- - // Artifacts with "problematic" names - // ---------------------------------------------------------------------------- - { - // "-" in the name - Query q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, "commons-logg*", SearchType.SCORED ); - - GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() ); - - GroupedSearchResponse response = nexusIndexer.searchGrouped( request ); - - Map<String, ArtifactInfoGroup> r = response.getResults(); - - assertEquals( 1, r.size() ); - - ArtifactInfoGroup ig = r.values().iterator().next(); - - assertEquals( "commons-logging : commons-logging", ig.getGroupKey() ); - - assertEquals( ig.getArtifactInfos().toString(), 6, ig.getArtifactInfos().size() ); - } - - { - // numbers and "-" in the name - Query q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, "jcl104-over-slf4*", SearchType.SCORED ); - - GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() ); - - GroupedSearchResponse response = nexusIndexer.searchGrouped( request ); - Map<String, ArtifactInfoGroup> r = response.getResults(); - - assertEquals( 1, r.size() ); - - ArtifactInfoGroup ig = r.values().iterator().next(); - - assertEquals( ig.getArtifactInfos().toString(), 1, ig.getArtifactInfos().size() ); - - assertEquals( "org.slf4j : jcl104-over-slf4j", ig.getGroupKey() ); - } - } - - // See MINDEXER-22 - // Flat search is not pageable -// @Override -// public void donttestPaging() -// throws Exception -// { -// // we have 15 artifact for this search -// int total = 15; -// -// int pageSize = 4; -// -// Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "org", SearchType.SCORED ); -// -// FlatSearchRequest req = new FlatSearchRequest( q ); -// -// // have page size of 4, that will make us 4 pages -// req.setCount( pageSize ); -// -// List<ArtifactInfo> constructedPageList = new ArrayList<ArtifactInfo>(); -// -// int offset = 0; -// -// while ( true ) -// { -// req.setStart( offset ); -// -// FlatSearchResponse resp = nexusIndexer.searchFlat( req ); -// -// Collection<ArtifactInfo> p = resp.getResults(); -// -// assertEquals( p.toString(), total, resp.getTotalHits() ); -// -// assertEquals( Math.min( pageSize, total - offset ), p.size() ); -// -// constructedPageList.addAll( p ); -// -// offset += pageSize; -// -// if ( offset > total ) -// { -// break; -// } -// } -// -// // -// FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q ) ); -// Collection<ArtifactInfo> onePage = response.getResults(); -// -// List<ArtifactInfo> onePageList = new ArrayList<ArtifactInfo>( onePage ); -// -// // onePage and constructedPage should hold equal elems in the same order -// assertTrue( resultsAreEqual( onePageList, constructedPageList ) ); -// } - - @Override - public void testPurge() - throws Exception - { - // we have 14 artifact for this search - Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "org", SearchType.SCORED ); - FlatSearchRequest request = new FlatSearchRequest( q ); - - FlatSearchResponse response1 = nexusIndexer.searchFlat( request ); - Collection<ArtifactInfo> p1 = response1.getResults(); - - assertEquals( 15, p1.size() ); - - context.purge(); - - FlatSearchResponse response2 = nexusIndexer.searchFlat( request ); - Collection<ArtifactInfo> p2 = response2.getResults(); - - assertEquals( 0, p2.size() ); - } - - @Override - public void testIdentify() - { - // skip test (sha1 field wasn't stored in the old index format) - } - -} http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java index 8d2006c..fc23b79 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus1179NexusIndexerTest.java @@ -68,7 +68,7 @@ public class Nexus1179NexusIndexerTest assertEquals( "ant", ai.getGroupId() ); assertEquals( "ant", ai.getArtifactId() ); assertEquals( "1.6.5", ai.getVersion() ); - assertEquals( "jar", ai.getPackaging() ); + assertEquals( null, ai.getPackaging() ); // coz no POM present assertEquals( null, ai.getClassifier() ); assertEquals( "nexus-1179", ai.getRepository() ); assertEquals( "jar", ai.getFileExtension() ); @@ -79,7 +79,7 @@ public class Nexus1179NexusIndexerTest assertEquals( "ant", ai.getGroupId() ); assertEquals( "ant", ai.getArtifactId() ); assertEquals( "1.5.1", ai.getVersion() ); - assertEquals( null, ai.getPackaging() ); + assertEquals( "jar", ai.getPackaging() ); // coz POM is present and says so assertEquals( null, ai.getClassifier() ); assertEquals( "nexus-1179", ai.getRepository() ); assertEquals( "pom", ai.getFileExtension() ); @@ -101,7 +101,7 @@ public class Nexus1179NexusIndexerTest assertEquals( "org", ai.getGroupId() ); assertEquals( "test", ai.getArtifactId() ); assertEquals( "1.0", ai.getVersion() ); - assertEquals( null, ai.getPackaging() ); + assertEquals( "jar", ai.getPackaging() ); // coz POM is present and says so assertEquals( null, ai.getClassifier() ); assertEquals( "nexus-1179", ai.getRepository() ); assertEquals( "pom", ai.getFileExtension() ); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java index 21d01b7..c93e9f5 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus13NexusIndexerTest.java @@ -29,14 +29,19 @@ import java.util.Map; import java.util.Set; import org.apache.lucene.index.Term; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.packer.DefaultIndexPacker; +import org.apache.maven.index.packer.IndexPacker; +import org.apache.maven.index.packer.IndexPackingRequest; import org.apache.maven.index.search.grouping.GAGrouping; import org.apache.maven.index.updater.DefaultIndexUpdater; +import org.apache.maven.index.updater.IndexUpdateRequest; +import org.apache.maven.index.updater.IndexUpdater; /** http://issues.sonatype.org/browse/NEXUS-13 */ public class Nexus13NexusIndexerTest @@ -106,9 +111,22 @@ public class Nexus13NexusIndexerTest public void testIndexTimestamp() throws Exception { - ByteArrayOutputStream os = new ByteArrayOutputStream(); + final File targetDir = File.createTempFile( "testIndexTimestamp", "ut-tmp" ); + targetDir.delete(); + targetDir.mkdirs(); - DefaultIndexPacker.packIndexArchive( context, os ); + final IndexPacker indexPacker = lookup( IndexPacker.class ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + final IndexPackingRequest request = + new IndexPackingRequest( context, indexSearcher.getIndexReader(), targetDir ); + indexPacker.packIndex( request ); + } + finally + { + context.releaseIndexSearcher( indexSearcher ); + } Thread.sleep( 1000L ); @@ -117,10 +135,9 @@ public class Nexus13NexusIndexerTest IndexingContext newContext = nexusIndexer.addIndexingContext( "test-new", "nexus-13", null, indexDir, null, null, DEFAULT_CREATORS ); - Directory newIndexDir = new RAMDirectory(); - - DefaultIndexUpdater.unpackIndexArchive( new ByteArrayInputStream( os.toByteArray() ), newIndexDir, newContext ); - newContext.replace( newIndexDir ); + final IndexUpdater indexUpdater = lookup( IndexUpdater.class ); + final IndexUpdateRequest updateRequest = new IndexUpdateRequest( newContext, new DefaultIndexUpdater.FileFetcher( targetDir ) ); + indexUpdater.fetchAndUpdateIndex( updateRequest ); assertEquals( 0, newContext.getTimestamp().getTime() - context.getTimestamp().getTime() ); http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/22fbfe07/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java ---------------------------------------------------------------------- diff --git a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java index 3e72fb3..d52fc87 100644 --- a/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java +++ b/indexer-core/src/test/java/org/apache/maven/index/Nexus1911IncrementalMergedCtxTest.java @@ -40,6 +40,7 @@ public class Nexus1911IncrementalMergedCtxTest member = context; indexMergedDir = super.getDirectory( "index/nexus-1911-merged" ); + indexMergedDir.mkdirs(); context = indexer.addMergedIndexingContext( "merged", "merged", member.getRepository(), indexMergedDir, false,
