/*-
 * Copyright (c) 2013 Red Hat, Inc.
 *
 * Licensed 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.
 */
package org.fedoraproject.maven.resolver;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.codehaus.plexus.PlexusTestCase;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.fedoraproject.maven.config.Configuration;
import org.fedoraproject.maven.config.Configurator;
import org.fedoraproject.maven.config.Repository;
import org.fedoraproject.maven.utils.AtomicFileCounter;

/**
 * @author Michael Simacek
 */
public class BisectResolverTest
    extends PlexusTestCase
{
    @Override
    public void setUp()
        throws IOException
    {
        Path counterPath = Paths.get( "target/test-work/bisect-counter" );
        Files.createDirectories( counterPath.getParent() );
        System.setProperty( "xmvn.bisect.counter", counterPath.toString() );
        AtomicFileCounter counter = new AtomicFileCounter( counterPath.toString(), 1000 );
    }

    @Override
    public void tearDown()
    {
        System.clearProperty( "xmvn.bisect.counter" );
    }

    /**
     * Test bisection resolution of artifact with no corresponding file
     * 
     * @throws Exception
     */
    public void testBisectResolverNoFile()
        throws Exception
    {
        Configurator configurator = lookup( Configurator.class );
        Configuration configuration = configurator.getConfiguration();

        Repository repository = new Repository();
        repository.setId( "bisect" );
        repository.setType( "flat" );
        configuration.addRepository( repository );

        Artifact artifact = new DefaultArtifact( "foo:bar:1.2" );

        Resolver resolver = lookup( Resolver.class );
        ResolutionRequest request = new ResolutionRequest( artifact );
        ResolutionResult result = resolver.resolve( request );

        assertNotNull( result );
        assertNull( result.getArtifactFile() );
    }
}

@@ -1198,16 +1198,56 @@
 tCase%0A%7B%0A
+    private AtomicFileCounter counter;%0A%0A
     @Ove
@@ -1244,32 +1244,32 @@
 %0A%0A    @Override%0A
-
     public void 
@@ -1529,34 +1529,16 @@
         
-AtomicFileCounter 
 counter 
@@ -1718,16 +1718,16 @@
     /**%0A
-
      * T
@@ -1789,16 +1789,17 @@
 ing file
+.
 %0A     * 
@@ -2555,20 +2555,69 @@
 ctFile() );%0A
+        assertEquals( 999, counter.getValue() );%0A
     %7D%0A%7D%0A

Check bisect counter value after failed resolution