Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.AbstractMojo


        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );

        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            assertTrue( "dav server port not available: " + simpleDavServerHandler.getPort(),
                        simpleDavServerHandler.getPort() > 0 );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://localhost:" + simpleDavServerHandler.getPort() + "/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            setVariableValueToObject( mojo, "settings", settings );
            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();
            assertFalse( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );
        }
        finally


        FileUtils.cleanDirectory( siteTargetPath );
        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );
            // olamy, Note : toto is something like foo or bar for french folks :-)
            String siteUrl = "dav:http://toto.com/site/";
            siteMavenProjectStub.getDistributionManagement().getSite().setUrl( siteUrl );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "http" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();

            assertTrue( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );


        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( servlet );       
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://toto.com/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "dav" );
            proxy.setUsername( "foo" );
            proxy.setPassword( "titi" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            // test which mojo we are using
            if ( ReflectionUtils.getFieldByNameIncludingSuperclasses( "inputDirectory", mojo.getClass() ) != null )
            {
                setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            }
            else
            {
                ArtifactRepositoryFactory artifactRepositoryFactory = getContainer().lookup( ArtifactRepositoryFactory.class );

                setVariableValueToObject( mojo, "stagingDirectory", inputDirectory );
                setVariableValueToObject( mojo, "reactorProjects", Collections.emptyList() );
                setVariableValueToObject( mojo, "localRepository",
                                          artifactRepositoryFactory.createArtifactRepository( "local", "foo", "default",
                                                                                              null, null ) );
                setVariableValueToObject( mojo, "siteTool", getContainer().lookup( SiteTool.class ) );
                setVariableValueToObject( mojo, "siteDirectory", new File("foo") );
                setVariableValueToObject( mojo, "repositories", Collections.emptyList() );
            }
            mojo.execute();

            assertContentInFiles();
            assertTrue( requestsContainsProxyUse( servlet.httpRequests ) );
            assertAtLeastOneRequestContainsHeader( servlet.httpRequests, "Proxy-Authorization" );
            for ( HttpRequest rq : servlet.httpRequests )

        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );

        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            assertTrue( "dav server port not available: " + simpleDavServerHandler.getPort(),
                        simpleDavServerHandler.getPort() > 0 );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://localhost:" + simpleDavServerHandler.getPort() + "/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            setVariableValueToObject( mojo, "settings", settings );
            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();
            assertFalse( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );
        }
        finally

        FileUtils.cleanDirectory( siteTargetPath );
        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );
            // olamy, Note : toto is something like foo or bar for french folks :-)
            String siteUrl = "dav:http://toto.com/site/";
            siteMavenProjectStub.getDistributionManagement().getSite().setUrl( siteUrl );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "http" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();

            assertTrue( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );


        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( servlet );       
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://toto.com/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "dav" );
            proxy.setUsername( "foo" );
            proxy.setPassword( "titi" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            // test which mojo we are using
            if ( ReflectionUtils.getFieldByNameIncludingSuperclasses( "inputDirectory", mojo.getClass() ) != null )
            {
                setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            }
            else
            {
                ArtifactRepositoryFactory artifactRepositoryFactory = getContainer().lookup( ArtifactRepositoryFactory.class );

                setVariableValueToObject( mojo, "stagingDirectory", inputDirectory );
                setVariableValueToObject( mojo, "reactorProjects", Collections.emptyList() );
                setVariableValueToObject( mojo, "localRepository",
                                          artifactRepositoryFactory.createArtifactRepository( "local", "foo", "default",
                                                                                              null, null ) );
                setVariableValueToObject( mojo, "siteTool", getContainer().lookup( SiteTool.class ) );
                setVariableValueToObject( mojo, "siteDirectory", new File("foo") );
                setVariableValueToObject( mojo, "repositories", Collections.emptyList() );
            }
            mojo.execute();

            assertContentInFiles();
            assertTrue( requestsContainsProxyUse( servlet.httpRequests ) );
            assertAtLeastOneRequestContainsHeader( servlet.httpRequests, "Proxy-Authorization" );
            for ( HttpRequest rq : servlet.httpRequests )

        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );

        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            assertTrue( "dav server port not available: " + simpleDavServerHandler.getPort(),
                        simpleDavServerHandler.getPort() > 0 );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://localhost:" + simpleDavServerHandler.getPort() + "/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            setVariableValueToObject( mojo, "settings", settings );
            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();
            assertFalse( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );
        }
        finally

        FileUtils.cleanDirectory( siteTargetPath );
        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );
            // olamy, Note : toto is something like foo or bar for french folks :-)
            String siteUrl = "dav:http://toto.com/site/";
            siteMavenProjectStub.getDistributionManagement().getSite().setUrl( siteUrl );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "http" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();

            assertContentInFiles();

            assertTrue( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );


        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( servlet );       
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );

            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://toto.com/site/" );

            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            Proxy proxy = new Proxy();

            //dummy proxy
            proxy.setActive( true );
            proxy.setHost( "localhost" );
            proxy.setPort( simpleDavServerHandler.getPort() );
            proxy.setProtocol( "dav" );
            proxy.setUsername( "foo" );
            proxy.setPassword( "titi" );
            proxy.setNonProxyHosts( "www.google.com|*.somewhere.com" );
            settings.addProxy( proxy );

            setVariableValueToObject( mojo, "settings", settings );

            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setProxies( Arrays.asList( proxy ) );
            MavenSession mavenSession = new MavenSession( getContainer(), null, request, null );

            setVariableValueToObject( mojo, "mavenSession", mavenSession );

            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );

            // test which mojo we are using
            if ( ReflectionUtils.getFieldByNameIncludingSuperclasses( "inputDirectory", mojo.getClass() ) != null )
            {
                setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            }
            else
            {
                ArtifactRepositoryFactory artifactRepositoryFactory = getContainer().lookup( ArtifactRepositoryFactory.class );

                setVariableValueToObject( mojo, "stagingDirectory", inputDirectory );
                setVariableValueToObject( mojo, "reactorProjects", Collections.emptyList() );
                setVariableValueToObject( mojo, "localRepository",
                                          artifactRepositoryFactory.createArtifactRepository( "local", "foo", "default",
                                                                                              null, null ) );
                setVariableValueToObject( mojo, "siteTool", getContainer().lookup( SiteTool.class ) );
                setVariableValueToObject( mojo, "siteDirectory", new File("foo") );
                setVariableValueToObject( mojo, "repositories", Collections.emptyList() );
            }
            mojo.execute();

            assertContentInFiles();
            assertTrue( requestsContainsProxyUse( servlet.httpRequests ) );
            assertAtLeastOneRequestContainsHeader( servlet.httpRequests, "Proxy-Authorization" );
            for ( HttpRequest rq : servlet.httpRequests )

        FileUtils.cleanDirectory( siteTargetPath );
        SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
        try
        {
            File pluginXmlFile = getTestFile( "src/test/resources/unit/deploy-dav/pom.xml" );
            AbstractMojo mojo = getMojo( pluginXmlFile );
            assertNotNull( mojo );
            SiteMavenProjectStub siteMavenProjectStub =
                new SiteMavenProjectStub( "src/test/resources/unit/deploy-dav/pom.xml" );
           
            siteMavenProjectStub.getDistributionManagement().getSite()
                .setUrl( "dav:http://localhost:" + simpleDavServerHandler.getPort() + "/site/" );
           
            setVariableValueToObject( mojo, "project", siteMavenProjectStub );
            Settings settings = new Settings();
            setVariableValueToObject( mojo, "settings", settings );
            File inputDirectory = new File( "src/test/resources/unit/deploy-dav/target/site" );
           
            setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
            mojo.execute();
           
            assertContentInFiles();
            assertFalse( requestsContainsProxyUse( simpleDavServerHandler.httpRequests ) );
        }
        finally

TOP

Related Classes of org.apache.maven.plugin.AbstractMojo

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.