Package org.apache.maven.scm.manager

Examples of org.apache.maven.scm.manager.ScmManager


        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org" ), repository );

        // src/main/java/org/Foo.java
        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository );

        ScmManager scmManager = getScmManager();

        // ----------------------------------------------------------------------
        // Check status the project
        // src/main/java/org/Foo.java is added
        // /pom.xml is modified
        // check that readme and project.xml are not updated/created
        // ----------------------------------------------------------------------

        StatusScmResult result = scmManager.getProviderByUrl( getScmUrl() )
            .status( repository, new ScmFileSet( getUpdatingCopy() ) );

        assertNotNull( "The command returned a null result.", result );

        assertResultIsSuccess( result );
View Full Code Here


    public void testBlameCommand()
        throws Exception
    {
        ScmRepository repository = getScmRepository();
        ScmManager manager = getScmManager();
        ScmProvider provider = manager.getProviderByRepository( getScmRepository() );
        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );

        BlameScmResult result;
        BlameLine line;

        // === readme.txt ===
        result = manager.blame( repository, fileSet, "readme.txt" );
        assertNotNull( "The command returned a null result.", result );
        assertResultIsSuccess( result );
        assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
        line = result.getLines().get( 0 );
        String initialRevision = line.getRevision();

        //Make a timestamp that we know are after initial revision but before the second
        Date timeBeforeSecond = new Date(); // Current time
        // pause a couple seconds...
        Thread.sleep( 2000 );
        //Make a change to the readme.txt and commit the change
        ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
        CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG );
        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );

        result = manager.blame( repository, fileSet, "readme.txt" );

        // pause a couple seconds...
        Thread.sleep( 2000 );
        Date timeAfterSecond = new Date(); // Current time

        assertNotNull( "The command returned a null result.", result );
        assertResultIsSuccess( result );

        assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
        line = result.getLines().get( 0 );

        assertNotNull( "Expected not null author", line.getAuthor() );
        assertNotNull( "Expected not null revision", line.getRevision() );
        assertNotNull( "Expected not null date", line.getDate() );

        assertTrue( "Expected another revision", !initialRevision.equals( line.getRevision() ) );
        if ( isTestDateTime() )
        {
            assertDateBetween( timeBeforeSecond, timeAfterSecond, line.getDate() );
        }

        // === pom.xml ===
        result = manager.blame( repository, fileSet, "pom.xml" );

        assertNotNull( "The command returned a null result.", result );

        assertResultIsSuccess( result );
View Full Code Here

        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org" ), repository );

        // src/main/java/org/Foo.java
        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository );

        ScmManager scmManager = getScmManager();

        // ----------------------------------------------------------------------
        // Check status the project
        // src/main/java/org/Foo.java is added
        // /pom.xml is modified
        // check that readme and project.xml are not updated/created
        // ----------------------------------------------------------------------

        StatusScmResult result = scmManager.getProviderByUrl( getScmUrl() )
            .status( repository, new ScmFileSet( getUpdatingCopy() ) );

        assertNotNull( "The command returned a null result.", result );

        assertResultIsSuccess( result );
View Full Code Here

        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org" ), repository );

        // src/main/java/org/Foo.java
        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository );

        ScmManager scmManager = getScmManager();

        Date lastUpdate = new Date( System.currentTimeMillis() - 1000000 );

        commit( getWorkingCopy(), repository );

        Thread.sleep( 5000 );
       
        // ----------------------------------------------------------------------
        // Update the project
        // ----------------------------------------------------------------------
      
        UpdateScmResult result = scmManager.update( repository, new ScmFileSet( getUpdatingCopy() ), lastUpdate );

        assertNotNull( "The command returned a null result.", result );

        assertResultIsSuccess( result );
View Full Code Here

                System.err.println(
                    "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored " + getName() + "." );
                return;
            }

            ScmManager scmManager = getScmManager();

            String scmUrl = CvsScmTestUtils.getScmUrl( repository, getModule() );

            // Check out the repo to a working directory where files will be modified and committed
            String arguments =
                "-f -d " + repository.getAbsolutePath() + " " + "co -d " + workingDirectory.getName() + " "
                    + getModule();

            CvsScmTestUtils.executeCVS( workingDirectory.getParentFile(), arguments );

            // Check out the repo to a assertion directory where the command will be used
            arguments = "-f -d " + repository.getAbsolutePath() + " " + "co -d " + assertionDirectory.getName() + " "
                + getModule();

            CvsScmTestUtils.executeCVS( assertionDirectory.getParentFile(), arguments );

            // A new check out should return 0 updated files.
            ScmRepository scmRepository = scmManager.makeScmRepository( scmUrl );

            UpdateScmResult result = scmManager.update( scmRepository, new ScmFileSet( assertionDirectory ) );

            assertNotNull( result );

            if ( !result.isSuccess() )
            {
                System.out.println( "result.providerMessage: " + result.getProviderMessage() );

                System.out.println( "result.commandOutput: " + result.getCommandOutput() );

                fail( "Command failed" );
            }

            assertNull( result.getProviderMessage() );

            assertNull( result.getCommandOutput() );

            assertNotNull( result.getUpdatedFiles() );

            assertEquals( 0, result.getUpdatedFiles().size() );

            // Modifing a file
            File fooJava = new File( workingDirectory, "Foo.java" );

            String content = FileUtils.fileRead( fooJava );

            writer = new FileWriter( fooJava );

            writer.write( content + System.getProperty( "line.separator" ) );
            writer.write( "extra line" );

            writer.close();

            // Adding a new file
            writer = new FileWriter( new File( workingDirectory, "New.txt" ) );

            writer.write( "new file" );

            writer.close();

            arguments = "-f -d " + repository.getAbsolutePath() + " add New.txt";

            CvsScmTestUtils.executeCVS( workingDirectory, arguments );

            // Committing
            arguments = "-f -d " + repository.getAbsolutePath() + " commit -m .";

            CvsScmTestUtils.executeCVS( workingDirectory, arguments );

            // Check the updated files
            result = scmManager.update( scmRepository, new ScmFileSet( assertionDirectory ) );

            assertNotNull( result );

            if ( !result.isSuccess() )
            {
View Full Code Here

    {
        // prepare
        List<MavenProject> reactorProjects = createReactorProjects();
        ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();

        ScmManager scmManagerMock = mock( ScmManager.class );
        when( scmManagerMock.makeScmRepository( "scm-url" ) ).thenThrow( new NoSuchScmProviderException( "..." ) );

        DefaultScmRepositoryConfigurator configurator =
            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
        configurator.setScmManager( scmManagerMock );
View Full Code Here

    {
        // prepare
        List<MavenProject> reactorProjects = createReactorProjects();
        ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();

        ScmManager scmManagerMock = mock( ScmManager.class );
        when( scmManagerMock.makeScmRepository( "scm-url" ) ).thenThrow( new ScmRepositoryException( "..." ) );
        DefaultScmRepositoryConfigurator configurator =
            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
        configurator.setScmManager( scmManagerMock );

        // execute
View Full Code Here

        throws Exception
    {
        List<MavenProject> reactorProjects = createReactorProjects();
        ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();

        ScmManager scmManager = (ScmManager) lookup( ScmManager.ROLE );
        ScmProviderStub providerStub =
            (ScmProviderStub) scmManager.getProviderByUrl( releaseDescriptor.getScmSourceUrl() );

        providerStub.setBranchScmResult( new BranchScmResult( "", "", "", false ) );

        try
        {
View Full Code Here

    {
        // prepare
        List<MavenProject> reactorProjects = createReactorProjects();
        ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();

        ScmManager scmManagerMock = mock( ScmManager.class );
        when( scmManagerMock.makeScmRepository( "scm-url" ) ).thenThrow( new NoSuchScmProviderException( "..." ) );

        DefaultScmRepositoryConfigurator configurator =
            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
        configurator.setScmManager( scmManagerMock );
View Full Code Here

    {
        // prepare
        List<MavenProject> reactorProjects = createReactorProjects();
        ReleaseDescriptor releaseDescriptor = createReleaseDescriptor();

        ScmManager scmManagerMock = mock( ScmManager.class );
        when( scmManagerMock.makeScmRepository( "scm-url" ) ).thenThrow( new ScmRepositoryException( "..." ) );
        DefaultScmRepositoryConfigurator configurator =
            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
        configurator.setScmManager( scmManagerMock );

        // execute
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.manager.ScmManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.