package org.apache.maven.release;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   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.
 * ====================================================================
 */

import junit.framework.TestCase;

import java.io.File;

import java.util.List;

import org.dom4j.Node;

/**
 */
public class SnapshotResolverTest
    extends TestCase
{
    private static String TEST_CONF = System.getProperty( "basedir" )
        + "/src/test-data/test-pom.xml";

    /**
     * Constructor.
     *
     * @param name Name of the test.
     */
    public SnapshotResolverTest( String name )
    {
        super( name );
    }

    public void testBasic()
        throws Exception
    {
        DummySnapshotResolver sr = new DummySnapshotResolver();
        sr.setProject( new File( TEST_CONF ) );
        sr.transformNodes();
        sr.write();

        List nodes = sr.getDocument().selectNodes( "/project/dependencies/dependency" );

        assertEquals( 3, nodes.size() );

        assertEquals( "NON-SNAPSHOT", ((Node)nodes.get(0)).selectSingleNode( "version" ).getText() );
        assertEquals( "NON-SNAPSHOT", ((Node)nodes.get(1)).selectSingleNode( "version" ).getText() );
        assertEquals( "NON-SNAPSHOT", ((Node)nodes.get(2)).selectSingleNode( "version" ).getText() );
    }
}
