CPD Results

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

Duplications

File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 780
org/apache/maven/wagon/http/HttpWagonTestCase.java 960
    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", HttpServletResponse.SC_SEE_OTHER, 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 );
File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 868
org/apache/maven/wagon/http/HttpWagonTestCase.java 1038
    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", HttpServletResponse.SC_SEE_OTHER, "/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 );
File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 653
org/apache/maven/wagon/http/HttpWagonTestCase.java 718
    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", HttpServletResponse.SC_SEE_OTHER, redirectUrl, null );

        redirectServer.setHandler( redirectHandler );

        redirectServer.start();

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

        File tmpResult = File.createTempFile( "foo", "get" );
File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 829
org/apache/maven/wagon/http/HttpWagonTestCase.java 1820
            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() ) );
File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 829
org/apache/maven/wagon/http/HttpWagonTestCase.java 901
org/apache/maven/wagon/http/HttpWagonTestCase.java 1820
            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() ) );
File Line
org/apache/maven/wagon/http/HttpWagonTestCase.java 158
org/apache/maven/wagon/http/HttpWagonTestCase.java 190
        setHttpHeaders( wagon, properties );

        Server server = new Server( 0 );
        TestHeaderHandler handler = new TestHeaderHandler();
        server.setHandler( handler );
        addConnectors( server );
        server.start();

        wagon.connect(
            new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );

        wagon.getToStream( "resource", new ByteArrayOutputStream() );

        wagon.disconnect();

        server.stop();

        assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
    }

    /**
     * test set of User-Agent as it's done by aether wagon connector with using setHttpHeaders
     */
    public void testHttpHeadersWithCommonMethods()