CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileLine
org/apache/maven/wagon/http/HttpWagonTestCase.java574
org/apache/maven/wagon/http/HttpWagonTestCase.java745
    public void testRedirectPutFromStreamWithFullUrl()
        throws Exception
    {
        Server realServer = new Server( 0 );

        addConnectors( realServer );

        File repositoryDirectory = getRepositoryDirectory();
        FileUtils.deleteDirectory( repositoryDirectory );
        repositoryDirectory.mkdirs();

        PutHandler putHandler = new PutHandler( repositoryDirectory );

        realServer.setHandler( putHandler );

        realServer.start();

        Server redirectServer = new Server( 0 );

        addConnectors( redirectServer );

        String protocol = getProtocol();

        // protocol is wagon protocol but in fact dav is http(s)
        if ( protocol.equals( "dav" ) )
        {
            protocol = "http";
        }

        if ( protocol.equals( "davs" ) )
        {
            protocol = "https";
        }

        String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();

        RedirectHandler redirectHandler = new RedirectHandler( "Found", 303, redirectUrl, repositoryDirectory );

        redirectServer.setHandler( redirectHandler );

        redirectServer.start();

        try
        {
            StreamingWagon wagon = (StreamingWagon) getWagon();
            Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
            wagon.connect( repository );

            File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
            sourceFile.delete();
            assertFalse( sourceFile.exists() );

            File tempFile = File.createTempFile( "wagon", "tmp" );
            tempFile.deleteOnExit();
            String content = "put top secret";
            FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
FileLine
org/apache/maven/wagon/http/HttpWagonTestCase.java666
org/apache/maven/wagon/http/HttpWagonTestCase.java822
    public void testRedirectPutFromStreamRelativeUrl()
        throws Exception
    {
        Server realServer = new Server( 0 );
        addConnectors( realServer );
        File repositoryDirectory = getRepositoryDirectory();
        FileUtils.deleteDirectory( repositoryDirectory );
        repositoryDirectory.mkdirs();

        PutHandler putHandler = new PutHandler( repositoryDirectory );

        realServer.setHandler( putHandler );

        realServer.start();

        Server redirectServer = new Server( 0 );

        addConnectors( redirectServer );

        RedirectHandler redirectHandler =
            new RedirectHandler( "Found", 303, "/redirectRequest/foo", repositoryDirectory );

        redirectServer.setHandler( redirectHandler );

        redirectServer.start();

        try
        {
            StreamingWagon wagon = (StreamingWagon) getWagon();
            Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
            wagon.connect( repository );

            File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
            sourceFile.delete();
            assertFalse( sourceFile.exists() );

            File tempFile = File.createTempFile( "wagon", "tmp" );
            tempFile.deleteOnExit();
            String content = "put top secret";
            FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
FileLine
org/apache/maven/wagon/http/HttpWagonTestCase.java445
org/apache/maven/wagon/http/HttpWagonTestCase.java511
    public void testRedirectGetToStream()
        throws Exception
    {
        StreamingWagon wagon = (StreamingWagon) getWagon();

        Server server = new Server( 0 );
        TestHeaderHandler handler = new TestHeaderHandler();

        server.setHandler( handler );
        addConnectors( server );
        server.start();

        Server redirectServer = new Server( 0 );

        addConnectors( redirectServer );

        String protocol = getProtocol();

        // protocol is wagon protocol but in fact dav is http(s)
        if ( protocol.equals( "dav" ) )
        {
            protocol = "http";
        }

        if ( protocol.equals( "davs" ) )
        {
            protocol = "https";
        }

        String redirectUrl = protocol + "://localhost:" + server.getConnectors()[0].getLocalPort();

        RedirectHandler redirectHandler = new RedirectHandler( "Found", 303, redirectUrl, null );

        redirectServer.setHandler( redirectHandler );

        redirectServer.start();

        wagon.connect( new Repository( "id", getRepositoryUrl( redirectServer ) ) );

        File tmpResult = File.createTempFile( "foo", "get" );
FileLine
org/apache/maven/wagon/http/HttpWagonTestCase.java622
org/apache/maven/wagon/http/HttpWagonTestCase.java1478
            File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
            sourceFile.delete();
            assertFalse( sourceFile.exists() );

            File tempFile = File.createTempFile( "wagon", "tmp" );
            tempFile.deleteOnExit();
            String content = "put top secret";
            FileUtils.fileWrite( tempFile.getAbsolutePath(), content );

            FileInputStream fileInputStream = new FileInputStream( tempFile );
            try
            {
                wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
            }
            finally
            {
                fileInputStream.close();
                tempFile.delete();

            }

            assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
FileLine
org/apache/maven/wagon/http/HttpWagonTestCase.java622
org/apache/maven/wagon/http/HttpWagonTestCase.java698
org/apache/maven/wagon/http/HttpWagonTestCase.java1478
            File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
            sourceFile.delete();
            assertFalse( sourceFile.exists() );

            File tempFile = File.createTempFile( "wagon", "tmp" );
            tempFile.deleteOnExit();
            String content = "put top secret";
            FileUtils.fileWrite( tempFile.getAbsolutePath(), content );

            FileInputStream fileInputStream = new FileInputStream( tempFile );
            try
            {
                wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
            }
            finally
            {
                fileInputStream.close();
                tempFile.delete();

            }

            assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );