Package com.mathieucarbou.mojo.license.test

Source Code of com.mathieucarbou.mojo.license.test.LicenseFormatMojoTest

/**
* Copyright (C) 2008 Mathieu Carbou
*
* 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.
*/

package com.mathieucarbou.mojo.license.test;

import com.mathieucarbou.mojo.license.LicenseCheckMojo;
import com.mathieucarbou.mojo.license.LicenseFormatMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.FileUtils;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

import java.io.File;
import java.util.HashMap;

/**
* <b>Date:</b> 16-Feb-2008<br>
* <b>Author:</b> Mathieu Carbou (mathieu.carbou@gmail.com)
*/
public class LicenseFormatMojoTest
{
    @BeforeSuite
    public void copyFiles() throws Exception
    {
        FileUtils.copyDirectory(new File("src/test/project/documents"), new File("target/documents"));
    }

    @Test(expectedExceptions = MojoFailureException.class)
    public void test_check_before() throws Exception
    {
        LicenseCheckMojo mojo = new LicenseCheckMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2008");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }

    @Test(dependsOnMethods = "test_check_before")
    public void test_add() throws Exception
    {
        LicenseFormatMojo mojo = new LicenseFormatMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2008");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }

    @Test(dependsOnMethods = "test_add")
    public void test_check_after() throws Exception
    {
        LicenseCheckMojo mojo = new LicenseCheckMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2008");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }

    @Test(dependsOnMethods = "test_check_after", expectedExceptions = MojoFailureException.class)
    public void test_check_before_update() throws Exception
    {
        LicenseCheckMojo mojo = new LicenseCheckMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2010");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }

    @Test(dependsOnMethods = "test_check_before_update")
    public void test_update() throws Exception
    {
        LicenseFormatMojo mojo = new LicenseFormatMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2010");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }

    @Test(dependsOnMethods = "test_update")
    public void test_check_after_update() throws Exception
    {
        LicenseCheckMojo mojo = new LicenseCheckMojo()
        {
            {
                super.basedir = new File("target/documents");
                super.header = new File("target/documents/header.txt");
                super.excludes = new String[] {"*.svn-base"};
                super.properties = new HashMap<String, String>()
                {
                    {
                        put("year", "2010");
                        put("email", "mathieu.carbou@gmail.com");
                    }

                };
                super.mapping = new HashMap<String, String>()
                {
                    {
                        put("toto", "xml");
                    }
                };
            }
        };
        mojo.execute();
    }
}
TOP

Related Classes of com.mathieucarbou.mojo.license.test.LicenseFormatMojoTest

TOP
Copyright © 2018 www.massapi.com. 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.