Author: hboutemy
Date: Fri Feb 13 21:03:26 2009
New Revision: 744243

URL: http://svn.apache.org/viewvc?rev=744243&view=rev
Log:
fixed coding style

Modified:
    
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
    
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java

Modified: 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
URL: 
http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java?rev=744243&r1=744242&r2=744243&view=diff
==============================================================================
--- 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
 (original)
+++ 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/main/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReader.java
 Fri Feb 13 21:03:26 2009
@@ -6,9 +6,9 @@
  *  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
@@ -24,10 +24,8 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.maven.mercury.artifact.Artifact;
@@ -67,7 +65,7 @@
 /**
  * this helper class hides the necessity to talk to localRepo and a bunch of 
remoteRepos. It also adds discrete
  * convenience methods, hiding batch nature of RepositoryReader
- * 
+ *
  * @author Oleg Gusakov
  * @version $Id$
  */
@@ -126,31 +124,41 @@
         throws RepositoryException
     {
         if ( !Util.isEmpty( repositories ) )
+        {
             this._repositories.addAll( repositories );
+        }
     }
 
     // 
----------------------------------------------------------------------------------------------------------------------------
     public VirtualRepositoryReader( LocalRepository localRepository, 
Collection<RemoteRepository> remoteRepositories )
-    throws RepositoryException
+        throws RepositoryException
     {
         if ( _localRepository == null )
+        {
             throw new RepositoryException( "null local repo" );
+        }
 
         this._localRepository = localRepository;
 
         this._repositories.add( localRepository );
 
         if ( remoteRepositories != null && remoteRepositories.size() > 0 )
+        {
             this._repositories.addAll( remoteRepositories );
+        }
     }
 
     // 
----------------------------------------------------------------------------------------------------------------------------
     public VirtualRepositoryReader( Repository... repositories )
-    throws RepositoryException
+        throws RepositoryException
     {
         if ( repositories != null && repositories.length > 0 )
+        {
             for ( Repository r : repositories )
+            {
                 this._repositories.add( r );
+            }
+        }
     }
 
     // 
----------------------------------------------------------------------------------------------------------------------------
@@ -167,7 +175,9 @@
         throws RepositoryException
     {
         if ( _initialized )
+        {
             throw new RepositoryException( "cannot add repositories after 
VirtualReader has been initialized" );
+        }
 
         _repositories.add( repo );
     }
@@ -186,7 +196,9 @@
         throws RepositoryException
     {
         if ( _initialized )
+        {
             return;
+        }
 
         _repositoryReaders = new RepositoryReader[_repositories.size()];
 
@@ -195,7 +207,9 @@
         for ( Repository r : _repositories )
         {
             if ( !r.isLocal() || !r.isReadable() )
+            {
                 continue;
+            }
 
             RepositoryReader rr = r.getReader();
 
@@ -207,7 +221,9 @@
             {
                 // we select the first writable repo in the list
                 if ( _localRepository != null )
+                {
                     continue;
+                }
 
                 _localRepository = (LocalRepository) 
r.getReader().getRepository();
                 _localRepositoryWriter = _localRepository.getWriter();
@@ -219,7 +235,9 @@
                         _mdCache = getCache( _localRepository.getDirectory() );
 
                         if ( _eventManager != null )
+                        {
                             _mdCache.setEventManager( _eventManager );
+                        }
                     }
                     catch ( IOException e )
                     {
@@ -233,12 +251,16 @@
         for ( Repository r : _repositories )
         {
             if ( r.isLocal() || !r.isReadable() )
+            {
                 continue;
+            }
 
             RepositoryReader rr = r.getReader();
 
             if ( _mdCache != null )
+            {
                 rr.setMetadataCache( _mdCache );
+            }
 
             rr.setMetadataReader( this );
 
@@ -249,10 +271,12 @@
 
     // 
----------------------------------------------------------------------------------------------------------------------------
     public ArtifactBasicResults readVersions( 
Collection<ArtifactBasicMetadata> query )
-    throws IllegalArgumentException, RepositoryException
+        throws IllegalArgumentException, RepositoryException
     {
         if ( query == null )
+        {
             throw new IllegalArgumentException( "null bmd supplied" );
+        }
 
         init();
 
@@ -262,7 +286,9 @@
         {
 
             if ( _eventManager != null )
+            {
                 event = new GenericEvent( 
EventTypeEnum.virtualRepositoryReader, EVENT_READ_VERSIONS );
+            }
 
             ArtifactBasicResults res = null;
             ArtifactListProcessor tp = _processors == null ? null : 
_processors.get( ArtifactListProcessor.FUNCTION_TP );
@@ -273,23 +299,30 @@
             qList.addAll( query );
 
             for ( RepositoryReader rr : _repositoryReaders )
+            {
                 try
                 {
                     // all found
                     if ( qList.isEmpty() )
+                    {
                         break;
+                    }
 
                     if ( _eventManager != null )
+                    {
                         eventRead =
                             new GenericEvent( 
EventTypeEnum.virtualRepositoryReader, EVENT_READ_VERSIONS_FROM_REPO,
                                               rr.getRepository().getId() );
+                    }
 
                     ArtifactBasicResults repoRes = rr.readVersions( qList );
-                    
-                    if( repoRes != null && repoRes.hasExceptions() )
+
+                    if ( repoRes != null && repoRes.hasExceptions() )
                     {
-                        if( LOG.isWarnEnabled() )
+                        if ( LOG.isWarnEnabled() )
+                        {
                             LOG.warn( repoRes.getExceptions().toString() );
+                        }
                     }
 
                     if ( repoRes != null && repoRes.hasResults() )
@@ -318,12 +351,18 @@
                             }
 
                             for ( ArtifactBasicMetadata bmd : rorRes )
+                            {
                                 bmd.setTracker( rr );
+                            }
 
                             if ( res == null )
+                            {
                                 res = new ArtifactBasicResults( key, rorRes );
-                            else 
+                            }
+                            else
+                            {
                                 res.add( key, rorRes );
+                            }
 
                             String keyVersion = key.getVersion();
                             VersionRange keyVersionRange = null;
@@ -340,15 +379,19 @@
                             if ( keyVersionRange.isSingleton() )
                             {
                                 Quality keyQuality = new Quality( keyVersion );
-                                if( keyQuality.compareTo( 
Quality.RELEASE_QUALITY ) == 0 )
+                                if ( keyQuality.compareTo( 
Quality.RELEASE_QUALITY ) == 0 )
+                                {
                                     // fixed release is found - no more 
scanning
                                     qList.remove( key );
+                                }
                             }
                         }
                     }
 
                     if ( _eventManager != null )
+                    {
                         eventRead.setResult( "repo done" );
+                    }
                 }
                 finally
                 {
@@ -358,9 +401,12 @@
                         _eventManager.fireEvent( eventRead );
                     }
                 }
-                
-            if( res != null && res.hasResults() )
+            }
+
+            if ( res != null && res.hasResults() )
+            {
                 processSingletons( res );
+            }
 
             return res;
         }
@@ -376,20 +422,26 @@
 
     private void processSingletons( ArtifactBasicResults res )
     {
-        if( ! res.hasResults() )
+        if ( !res.hasResults() )
+        {
             return;
-        
+        }
+
         Map<ArtifactBasicMetadata, List<ArtifactBasicMetadata> > m = 
res.getResults();
-        
-        for( ArtifactBasicMetadata key : m.keySet() )
+
+        for ( ArtifactBasicMetadata key : m.keySet() )
+        {
             processSingletons( key, res.getResult( key ) );
+        }
     }
-    
+
     private void processSingletons( ArtifactBasicMetadata key, 
List<ArtifactBasicMetadata> res )
     {
-        if( Util.isEmpty( res ) || !DefaultArtifactVersion.isVirtual( 
key.getVersion() ) )
+        if ( Util.isEmpty( res ) || !DefaultArtifactVersion.isVirtual( 
key.getVersion() ) )
+        {
             return;
-        
+        }
+
         TreeSet<ArtifactBasicMetadata> ts = new TreeSet<ArtifactBasicMetadata>(
                         new Comparator<ArtifactBasicMetadata>()
                         {
@@ -400,15 +452,15 @@
 
                                   return av1.compareTo( av2 );
                             }
-                            
+
                         }
                                                                               
);
         ts.addAll( res );
-        
+
         ArtifactBasicMetadata single = ts.last();
-        
+
         res.clear();
-        
+
         res.add( single );
     }
 
@@ -417,7 +469,9 @@
         throws IllegalArgumentException, RepositoryException
     {
         if ( bmd == null )
+        {
             throw new IllegalArgumentException( "null bmd supplied" );
+        }
 
         GenericEvent event = null;
 
@@ -425,8 +479,10 @@
         {
 
             if ( _eventManager != null )
+            {
                 event =
                     new GenericEvent( EventTypeEnum.virtualRepositoryReader, 
EVENT_READ_DEPENDENCIES, bmd.toString() );
+            }
 
             init();
 
@@ -448,13 +504,16 @@
             GenericEvent eventRead = null;
 
             for ( RepositoryReader rr : repos )
+            {
                 try
                 {
 
                     if ( _eventManager != null )
+                    {
                         eventRead =
                             new GenericEvent( 
EventTypeEnum.virtualRepositoryReader, EVENT_READ_DEPENDENCIES_FROM_REPO,
                                               rr.getRepository().getId() );
+                    }
 
                     ArtifactBasicResults res = rr.readDependencies( query );
 
@@ -464,10 +523,14 @@
                         md.setTracker( rr );
 
                         if ( _eventManager != null )
+                        {
                             eventRead.setInfo( eventRead.getInfo() + ", found: 
" + md.getDependencies() );
-                        
-                        if( LOG.isDebugEnabled() )
-                            LOG.debug( bmd+" dependecies found : " + 
md.getDependencies() );
+                        }
+
+                        if ( LOG.isDebugEnabled() )
+                        {
+                            LOG.debug( bmd + " dependecies found : " + 
md.getDependencies() );
+                        }
 
                         return md;
                     }
@@ -480,9 +543,12 @@
                         _eventManager.fireEvent( eventRead );
                     }
                 }
+            }
 
             if ( _eventManager != null )
+            {
                 event.setResult( "not found" );
+            }
 
             return md;
         }
@@ -534,7 +600,9 @@
             else
             {
                 if ( rejects == null )
+                {
                     rejects = new ArrayList<ArtifactBasicMetadata>();
+                }
 
                 rejects.add( bmd );
             }
@@ -543,7 +611,9 @@
         if ( rejects != null )
         {
             if ( res == null )
+            {
                 res = new HashMap<RepositoryReader, 
List<ArtifactBasicMetadata>>();
+            }
 
             res.put( RepositoryReader.NULL_READER, rejects );
         }
@@ -553,7 +623,7 @@
 
     // 
----------------------------------------------------------------------------------------------------------------------------
     public ArtifactResults readArtifacts( Collection<? extends 
ArtifactBasicMetadata> query )
-    throws RepositoryException
+        throws RepositoryException
     {
         GenericEvent event = null;
 
@@ -562,27 +632,35 @@
             ArtifactResults res = null;
 
             if ( _eventManager != null )
+            {
                 event = new GenericEvent( 
EventTypeEnum.virtualRepositoryReader, EVENT_READ_ARTIFACTS, "" );
+            }
 
             if ( Util.isEmpty( query ) )
+            {
                 return res;
+            }
 
             Map<RepositoryReader, List<ArtifactBasicMetadata>> buckets = 
sortByRepo( query );
 
             List<ArtifactBasicMetadata> leftovers = buckets == null ? null : 
buckets.get( RepositoryReader.NULL_READER );
 
             if ( buckets == null )
+            {
                 throw new RepositoryException( LANG.getMessage( 
"internal.error.sorting.query", query.toString() ) );
+            }
 
             init();
 
             res = new ArtifactResults();
-                
+
             // first read repository-qualified Artifacts
             for ( RepositoryReader rr : buckets.keySet() )
             {
                 if ( RepositoryReader.NULL_READER.equals( rr ) )
+                {
                     continue;
+                }
 
                 String repoId = rr.getRepository().getId();
 
@@ -591,20 +669,25 @@
                 try
                 {
                     if ( _eventManager != null )
+                    {
                         eventRead =
                             new GenericEvent( 
EventTypeEnum.virtualRepositoryReader,
                                               
EVENT_READ_ARTIFACTS_FROM_REPO_QUALIFIED, repoId );
+                    }
 
                     List<ArtifactBasicMetadata> rrQuery = buckets.get( rr );
 
                     ArtifactResults rrRes = rr.readArtifacts( rrQuery );
 
                     if ( rrRes.hasExceptions() )
+                    {
                         throw new RepositoryException( LANG.getMessage( 
"error.reading.existing.artifact",
                                                                          
rrRes.getExceptions().toString(),
                                                                          
rr.getRepository().getId() ) );
+                    }
 
                     if ( rrRes.hasResults() )
+                    {
                         for ( ArtifactBasicMetadata bm : 
rrRes.getResults().keySet() )
                         {
                             List<Artifact> al = rrRes.getResults( bm );
@@ -613,11 +696,16 @@
 
                             // don't write local artifacts back to the same 
repo
                             if ( _localRepository != null && repoId.equals( 
_localRepository.getId() ) )
+                            {
                                 continue;
+                            }
 
                             if ( _localRepositoryWriter != null )
+                            {
                                 _localRepositoryWriter.writeArtifacts( al );
+                            }
                         }
+                    }
                 }
                 finally
                 {
@@ -628,69 +716,81 @@
                     }
                 }
             }
-            
+
             // then process unqualified virtuals
             if ( !Util.isEmpty( leftovers ) )
             {
                 List<ArtifactBasicMetadata> virtuals = null;
-                
-                for( ArtifactBasicMetadata md : leftovers )
-                    if( DefaultArtifactVersion.isVirtual( md.getVersion() ) )
+
+                for ( ArtifactBasicMetadata md : leftovers )
+                {
+                    if ( DefaultArtifactVersion.isVirtual( md.getVersion() ) )
                     {
-                        if( virtuals == null )
+                        if ( virtuals == null )
+                        {
                             virtuals = new ArrayList<ArtifactBasicMetadata>();
-                        
+                        }
+
                         virtuals.add( md );
                     }
-                
-                
-                if( virtuals != null )
+                }
+
+
+                if ( virtuals != null )
                 {
                     ArtifactBasicResults virtRes = readVersions( virtuals );
-                    
+
                     leftovers.removeAll( virtuals );
-                    
+
                     virtuals.clear();
-                    
-                    if( virtRes != null )
+
+                    if ( virtRes != null )
                     {
-                        if( virtRes.hasResults() )
+                        if ( virtRes.hasResults() )
                         {
                             Map<ArtifactBasicMetadata, ArtifactBasicMetadata> 
sMap = new HashMap<ArtifactBasicMetadata, ArtifactBasicMetadata>();
-                            
-                            for( ArtifactBasicMetadata md : 
virtRes.getResults().keySet() )
+
+                            for ( ArtifactBasicMetadata md : 
virtRes.getResults().keySet() )
                             {
-                                ArtifactBasicMetadata v = virtRes.getResult( 
md ).get( 0 ); 
+                                ArtifactBasicMetadata v = virtRes.getResult( 
md ).get( 0 );
                                 virtuals.add( v );
                                 sMap.put( v, md );
                             }
-                            
+
                             ArtifactResults ares = readArtifacts( virtuals );
-                            
-                            if( ares != null )
+
+                            if ( ares != null )
                             {
-                                if( ares.hasResults() )
+                                if ( ares.hasResults() )
                                 {
                                     Map<ArtifactBasicMetadata, List<Artifact>> 
aresMap = ares.getResults();
-                                    
+
                                     // remap
-                                    for( ArtifactBasicMetadata md : 
aresMap.keySet() )
+                                    for ( ArtifactBasicMetadata md : 
aresMap.keySet() )
+                                    {
                                         res.add( sMap.get( md ), aresMap.get( 
md ).get( 0 ) );
+                                    }
                                 }
-                                
-                                if( ares.hasExceptions() )
+
+                                if ( ares.hasExceptions() )
+                                {
                                     res.getExceptions().putAll( 
ares.getExceptions() );
+                                }
                             }
-                            
-                            if( virtRes.hasExceptions() )
+
+                            if ( virtRes.hasExceptions() )
+                            {
                                 res.addError( virtRes.getExceptions() );
+                            }
                         }
-                        
-                        if( virtRes.hasExceptions() )
+
+                        if ( virtRes.hasExceptions() )
+                        {
                             res.addError( virtRes.getExceptions() );
+                        }
                     }
                 }
-                
+
             }
 
             // then search all repos for unqualified Artifacts
@@ -699,7 +799,9 @@
                 for ( RepositoryReader rr : _repositoryReaders )
                 {
                     if ( leftovers.isEmpty() )
+                    {
                         break;
+                    }
 
                     String repoId = rr.getRepository().getId();
 
@@ -708,9 +810,11 @@
                     try
                     {
                         if ( _eventManager != null )
+                        {
                             eventRead =
                                 new GenericEvent( 
EventTypeEnum.virtualRepositoryReader,
                                                   
EVENT_READ_ARTIFACTS_FROM_REPO_UNQUALIFIED, repoId );
+                        }
 
                         ArtifactResults rrRes = rr.readArtifacts( leftovers );
 
@@ -730,10 +834,14 @@
 
                                 // don't write local artifacts back to the 
same repo
                                 if ( _localRepository != null && 
repoId.equals( _localRepository.getId() ) )
+                                {
                                     continue;
+                                }
 
                                 if ( _localRepositoryWriter != null )
+                                {
                                     _localRepositoryWriter.writeArtifacts( al 
);
+                                }
 
                             }
                         }
@@ -765,15 +873,18 @@
     // MetadataReader implementation
     // 
----------------------------------------------------------------------------------------------------------------------------
     public byte[] readMetadata( ArtifactBasicMetadata bmd )
-    throws MetadataReaderException
+        throws MetadataReaderException
     {
         return readMetadata( bmd, false );
     }
+
     public byte[] readMetadata( ArtifactBasicMetadata bmd, boolean exempt  )
-    throws MetadataReaderException
+        throws MetadataReaderException
     {
         if ( LOG.isDebugEnabled() )
+        {
             LOG.debug( "Asking for pom: " + bmd );
+        }
 
         return readRawData( bmd, "", "pom", exempt );
     }
@@ -782,22 +893,27 @@
     // MetadataReader implementation
     // 
----------------------------------------------------------------------------------------------------------------------------
     public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, 
String type )
-    throws MetadataReaderException
+        throws MetadataReaderException
     {
         return readRawData( bmd, classifier, type, false );
     }
-    public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, 
String type, boolean exempt  )
-    throws MetadataReaderException
+
+    public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, 
String type, boolean exempt )
+        throws MetadataReaderException
     {
 
         GenericEvent event = null;
         String eventTag = null;
 
         if ( LOG.isDebugEnabled() )
+        {
             LOG.debug( "request for " + bmd + ", classifier=" + classifier + 
", type=" + type );
+        }
 
         if ( bmd == null )
+        {
             throw new IllegalArgumentException( "null bmd supplied" );
+        }
 
         try
         {
@@ -824,7 +940,9 @@
             Quality vq = new Quality( bmd.getVersion() );
 
             if ( LOG.isDebugEnabled() )
+            {
                 LOG.debug( "quality calculated as " + vq.getQuality() == null 
? "null" : vq.getQuality().name() );
+            }
 
             if ( Quality.SNAPSHOT_QUALITY.equals( vq ) )
             {
@@ -837,7 +955,9 @@
                     if ( Util.isEmpty( vRes ) )
                     {
                         if ( LOG.isDebugEnabled() )
+                        {
                             LOG.debug( "no snapshots found - throw exception" 
);
+                        }
 
                         throw new MetadataReaderException( LANG.getMessage( 
"no.snapshots", bmd.toString(),
                                                                              
classifier, type ) );
@@ -856,7 +976,9 @@
                     else
                     {
                         if ( LOG.isDebugEnabled() )
+                        {
                             LOG.debug( "no snapshots found - throw exception" 
);
+                        }
 
                         throw new MetadataReaderException( LANG.getMessage( 
"no.snapshots", bmd.toString(),
                                                                              
classifier, type ) );
@@ -875,24 +997,32 @@
                 try
                 {
                     if ( _eventManager != null )
+                    {
                         eventRead =
                             new GenericEvent( 
EventTypeEnum.virtualRepositoryReader, EVENT_READ_RAW_FROM_REPO,
                                               rr.getRepository().getId() + ": 
" + eventTag );
+                    }
 
                     res = rr.readRawData( bmdQuery, classifier, type, false );
                     if ( res != null )
                     {
                         if ( LOG.isDebugEnabled() )
+                        {
                             LOG.debug( bmdQuery + " found in " + 
rr.getRepository().getServer() );
+                        }
 
                         if ( _eventManager != null )
+                        {
                             eventRead.setInfo( eventRead.getInfo() );
+                        }
 
                         return res;
                     }
 
                     if ( _eventManager != null )
+                    {
                         eventRead.setResult( "not found" );
+                    }
                 }
                 finally
                 {
@@ -905,7 +1035,9 @@
             }
 
             if ( LOG.isDebugEnabled() )
+            {
                 LOG.debug( "no data found, returning null" );
+            }
 
             return null;
         }
@@ -923,7 +1055,9 @@
     public void register( MercuryEventListener listener )
     {
         if ( _eventManager == null )
+        {
             _eventManager = new EventManager();
+        }
 
         _eventManager.register( listener );
     }
@@ -936,7 +1070,9 @@
     public void unRegister( MercuryEventListener listener )
     {
         if ( _eventManager != null )
+        {
             _eventManager.unRegister( listener );
+        }
     }
     // 
----------------------------------------------------------------------------------------------------------------------------
     // 
----------------------------------------------------------------------------------------------------------------------------

Modified: 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java
URL: 
http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java?rev=744243&r1=744242&r2=744243&view=diff
==============================================================================
--- 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java
 (original)
+++ 
maven/mercury/trunk/mercury-repo/mercury-repo-virtual/src/test/java/org/apache/maven/mercury/repository/virtual/VirtualRepositoryReaderTest.java
 Fri Feb 13 21:03:26 2009
@@ -6,9 +6,9 @@
  *  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
@@ -46,203 +46,220 @@
 import org.apache.maven.mercury.util.Util;
 
 /**
- *
- *
  * @author Oleg Gusakov
  * @version $Id$
- *
  */
 public class VirtualRepositoryReaderTest
-extends TestCase
+    extends TestCase
 {
-  File             _testBase;
-  LocalRepository  _localRepo;
-  RemoteRepository _remoteRepo;
-  VirtualRepositoryReader _vr;
-  
-//  String _remoteUrl; // = "http://people.apache.org/~ogusakov/repos/test";;
-  String _artifactCoordSn = 
"org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-SNAPSHOT";
-  String _artifactCoordLatest = 
"org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-LATEST";
-  String _artifactCoordRelease = "ant:ant:1.6.5";
-  
-  String _localRepoId = "localRepo";
-  String _remoteRepoId = "remoteRepo";
-  
-  HttpTestServer _jetty;
-  String _port;
-  File _remoteRepoBase = new File("./target/test-classes/remoteRepo");
-  
-  @Override
-  protected void setUp()
-  throws Exception
-  {
-    
-      if( Util.isWindows() )
-          Thread.sleep( 2000L );
-
-    _testBase = new File( "./target/repo" );
-    FileUtil.delete( _testBase );
-
-// windows does not like it     
-    if( ! Util.isWindows() && _testBase.exists() )
-        throw new Exception( "cannot clean folder " + 
_testBase.getAbsolutePath() );
-    
-    _testBase.mkdirs();
-    FileUtil.copy( new File("./src/test/resources/repo"), _testBase, false );
-    
-    if( !_testBase.exists() || !_testBase.isDirectory() )
-      throw new Exception( "cannot create clean folder " + 
_testBase.getAbsolutePath() );
-    
-    _localRepo = new LocalRepositoryM2( _localRepoId, _testBase, new 
MetadataProcessorMock() );
-    
-    
-    _jetty = new HttpTestServer( _remoteRepoBase, "/repo" );
-    _jetty.start();
-    _port = String.valueOf( _jetty.getPort() );
-    Server server = new Server( _remoteRepoId, new 
URL("http://localhost:"+_port+"/repo";) );
-    
-    _remoteRepo = new RemoteRepositoryM2( server.getId(), server, new 
MetadataProcessorMock() );
+    File _testBase;
+
+    LocalRepository _localRepo;
+
+    RemoteRepository _remoteRepo;
+
+    VirtualRepositoryReader _vr;
+
+    // String _remoteUrl; // = "http://people.apache.org/~ogusakov/repos/test";;
+    String _artifactCoordSn = 
"org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-SNAPSHOT";
+
+    String _artifactCoordLatest = 
"org.apache.maven.mercury:mercury-repo-virtual:1.0.0-alpha-2-LATEST";
+
+    String _artifactCoordRelease = "ant:ant:1.6.5";
+
+    String _localRepoId = "localRepo";
+
+    String _remoteRepoId = "remoteRepo";
+
+    HttpTestServer _jetty;
+
+    String _port;
+
+    File _remoteRepoBase = new File( "./target/test-classes/remoteRepo" );
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+
+        if ( Util.isWindows() )
+        {
+            Thread.sleep( 2000L );
+        }
+
+        _testBase = new File( "./target/repo" );
+        FileUtil.delete( _testBase );
+
+        // windows does not like it
+        if ( !Util.isWindows() && _testBase.exists() )
+        {
+            throw new Exception( "cannot clean folder " + 
_testBase.getAbsolutePath() );
+        }
+
+        _testBase.mkdirs();
+        FileUtil.copy( new File( "./src/test/resources/repo" ), _testBase, 
false );
+
+        if ( !_testBase.exists() || !_testBase.isDirectory() )
+        {
+            throw new Exception( "cannot create clean folder " + 
_testBase.getAbsolutePath() );
+        }
+
+        _localRepo = new LocalRepositoryM2( _localRepoId, _testBase, new 
MetadataProcessorMock() );
+
+        _jetty = new HttpTestServer( _remoteRepoBase, "/repo" );
+        _jetty.start();
+        _port = String.valueOf( _jetty.getPort() );
+        Server server = new Server( _remoteRepoId, new URL( 
"http://localhost:"; + _port + "/repo" ) );
+
+        _remoteRepo = new RemoteRepositoryM2( server.getId(), server, new 
MetadataProcessorMock() );
+
+        if ( Util.isWindows() )
+        {
+            Thread.sleep( 2000L );
+        }
+
+        List<Repository> rl = new ArrayList<Repository>();
+        rl.add( _localRepo );
+        rl.add( _remoteRepo );
+
+        _vr = new VirtualRepositoryReader( rl );
+    }
 
-    if( Util.isWindows() )
-        Thread.sleep( 2000L );
-    
-    List<Repository> rl = new ArrayList<Repository>();
-    rl.add( _localRepo );
-    rl.add( _remoteRepo );
-     
-    _vr = new VirtualRepositoryReader( rl );
-  }
-  
     @Override
     protected void tearDown()
         throws Exception
     {
         super.tearDown();
-        if( _jetty != null )
+        if ( _jetty != null )
         {
         }
     }
-  
-  public void testReadSnapshot()
-  throws Exception
-  {
-    ArtifactBasicMetadata bmd = new ArtifactBasicMetadata(_artifactCoordSn);
-    List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>();
-    q.add( bmd );
-    
-    ArtifactResults res = _vr.readArtifacts( q );
-    
-    assertNotNull( res );
-    
-    assertFalse( res.hasExceptions() );
-    
-    assertTrue( res.hasResults() );
-    
-    assertTrue( res.hasResults( bmd ) );
-    
-    Map<ArtifactBasicMetadata, List<Artifact>> m = res.getResults();
-    
-    List<Artifact> al = m.get( bmd );
-    
-    Artifact a = al.get( 0 );
-    
-    assertTrue( bmd.getGroupId().equals( a.getGroupId() ) );
-    assertTrue( bmd.getArtifactId().equals( a.getArtifactId() ) );
-    
-    assertTrue( a.getVersion().matches( Artifact.SNAPSHOT_TS_REGEX ) );
-    
-    byte [] pomBytes = a.getPomBlob(); 
-    
-    assertTrue( pomBytes != null );
-    
-    assertEquals( 795, pomBytes.length );
-    
-    File ab = a.getFile();
-    
-    assertNotNull( ab );
-    
-    assertTrue( ab.exists() );
-    
-    assertEquals( 6162, ab.length() );
-  }
-  
-  public void testWrite()
-  throws Exception
-  {
-    Artifact a = new DefaultArtifact( new 
ArtifactBasicMetadata("a:a:1.0:text:txt") );
-    File bin = File.createTempFile( "vr-", "-test.txt" );
-    bin.deleteOnExit();
-    FileUtil.writeRawData( bin, "test" );
-    a.setFile( bin );
-    
-    List<Artifact> arts = new ArrayList<Artifact>();
-    arts.add( a );
-    
-    _localRepo.getWriter().writeArtifacts( arts );
-    
-    File af = new File( _testBase, "a/a/1.0/a-1.0-text.txt");
-    
-    assertTrue( af.exists() );
-    
-    assertEquals( 4, af.length() );
-    
-  }
-  
-  public void testReadRelease()
-  throws Exception
-  {
-    ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( 
_artifactCoordRelease );
-    List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>();
-    q.add( bmd );
-    
-    Listener l = new Listener();
-    _vr.register( l );
-    
-    ArtifactBasicResults res = _vr.readVersions( q );
-    
-    assertNotNull( res );
-    
-    assertFalse( res.hasExceptions() );
-    
-    assertTrue( res.hasResults() );
-    
-    assertTrue( res.hasResults( bmd ) );
-    
-    // let events propagate
-    Thread.sleep( 2000L );
-    
-    assertTrue( l.localEventCount > 0 );
-    
-    assertEquals( 0, l.remoteEventCount );
-    
-  }
-  //========================================================================
-  class Listener
-  implements MercuryEventListener
-  {
-
-    int localEventCount = 0;
-    int remoteEventCount = 0;
-      
-    public void fire( MercuryEvent event )
-    {
-      String tag = event.getInfo();
-      
-      if( _localRepoId.equals( tag ) )
-        ++localEventCount;
-      else if( _remoteRepoId.equals( tag ) )
-        ++remoteEventCount;
-      
-//      System.out.println(EventManager.toString( event ));
-//      System.out.flush();
-    }
-
-    public EventMask getMask()
-    {
-      return null;
-    }
-    
-  }
-  
-}
 
+    public void testReadSnapshot()
+        throws Exception
+    {
+        ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( 
_artifactCoordSn );
+        List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>();
+        q.add( bmd );
+
+        ArtifactResults res = _vr.readArtifacts( q );
+
+        assertNotNull( res );
+
+        assertFalse( res.hasExceptions() );
+
+        assertTrue( res.hasResults() );
+
+        assertTrue( res.hasResults( bmd ) );
+
+        Map<ArtifactBasicMetadata, List<Artifact>> m = res.getResults();
+
+        List<Artifact> al = m.get( bmd );
+
+        Artifact a = al.get( 0 );
+
+        assertTrue( bmd.getGroupId().equals( a.getGroupId() ) );
+        assertTrue( bmd.getArtifactId().equals( a.getArtifactId() ) );
+
+        assertTrue( a.getVersion().matches( Artifact.SNAPSHOT_TS_REGEX ) );
+
+        byte[] pomBytes = a.getPomBlob();
+
+        assertTrue( pomBytes != null );
+
+        assertEquals( 795, pomBytes.length );
+
+        File ab = a.getFile();
+
+        assertNotNull( ab );
+
+        assertTrue( ab.exists() );
+
+        assertEquals( 6162, ab.length() );
+    }
+
+    public void testWrite()
+        throws Exception
+    {
+        Artifact a = new DefaultArtifact( new ArtifactBasicMetadata( 
"a:a:1.0:text:txt" ) );
+        File bin = File.createTempFile( "vr-", "-test.txt" );
+        bin.deleteOnExit();
+        FileUtil.writeRawData( bin, "test" );
+        a.setFile( bin );
+
+        List<Artifact> arts = new ArrayList<Artifact>();
+        arts.add( a );
+
+        _localRepo.getWriter().writeArtifacts( arts );
+
+        File af = new File( _testBase, "a/a/1.0/a-1.0-text.txt" );
+
+        assertTrue( af.exists() );
+
+        assertEquals( 4, af.length() );
+
+    }
+
+    public void testReadRelease()
+        throws Exception
+    {
+        ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( 
_artifactCoordRelease );
+        List<ArtifactBasicMetadata> q = new ArrayList<ArtifactBasicMetadata>();
+        q.add( bmd );
+
+        Listener l = new Listener();
+        _vr.register( l );
+
+        ArtifactBasicResults res = _vr.readVersions( q );
+
+        assertNotNull( res );
+
+        assertFalse( res.hasExceptions() );
+
+        assertTrue( res.hasResults() );
+
+        assertTrue( res.hasResults( bmd ) );
+
+        // let events propagate
+        Thread.sleep( 2000L );
+
+        assertTrue( l.localEventCount > 0 );
+
+        assertEquals( 0, l.remoteEventCount );
+
+    }
+
+    // ========================================================================
+    class Listener
+        implements MercuryEventListener
+    {
+
+        int localEventCount = 0;
+
+        int remoteEventCount = 0;
+
+        public void fire( MercuryEvent event )
+        {
+            String tag = event.getInfo();
+
+            if ( _localRepoId.equals( tag ) )
+            {
+                ++localEventCount;
+            }
+            else if ( _remoteRepoId.equals( tag ) )
+            {
+                ++remoteEventCount;
+            }
+
+            // System.out.println(EventManager.toString( event ));
+            // System.out.flush();
+        }
+
+        public EventMask getMask()
+        {
+            return null;
+        }
+
+    }
+
+}


Reply via email to