package org.jboss.loom.migrators._ext;

import java.io.File;
import org.apache.commons.io.FileUtils;
import org.jboss.loom.conf.GlobalConfiguration;
import org.jboss.loom.utils.Utils;
import org.junit.Test;

/**
 *
 * @author Ondrej Zizka, ozizka at redhat.com
 */
public class ExternalMigratorsLoaderTest {
    
    public ExternalMigratorsLoaderTest() {
    }


    @Test
    public void testLoadMigrators() throws Exception {
        System.out.println( "loadMigrators" );
        
        File workDir = new File("target/extMigrators/");
        FileUtils.forceMkdir( workDir );
        Utils.copyResourceToDir( ExternalMigratorsLoader.class, "TestMigrator.mig.xml", workDir );
        Utils.copyResourceToDir( ExternalMigratorsLoader.class, "TestJaxbBean.groovy",  workDir );
        
        new ExternalMigratorsLoader().loadMigrators( workDir, new GlobalConfiguration() );
    }


}// class
@@ -54,16 +54,38 @@
 o.File;%0A
+import java.util.Map;%0A
 import o
@@ -817,90 +817,565 @@
     
-new ExternalMigratorsLoader().loadMigrators( workDir, new GlobalConfiguration() );
+Map%3CClass%3C? extends DefinitionBasedMigrator%3E, DefinitionBasedMigrator%3E migs%0A                = new ExternalMigratorsLoader().loadMigrators( workDir, new GlobalConfiguration() );%0A        %0A        for( Map.Entry%3CClass%3C? extends DefinitionBasedMigrator%3E, DefinitionBasedMigrator%3E entry : migs.entrySet() ) %7B%0A            Class%3C? extends DefinitionBasedMigrator%3E cls = entry.getKey();%0A            DefinitionBasedMigrator mig = entry.getValue();%0A            System.out.println( String.format(%22  Loaded migrator %25s: %25s%22, cls.getName(), mig.toString() ) );%0A        %7D
 %0A   

Improve ext migr loading test