package com.redhat.ceylon.compiler.js;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;

import com.redhat.ceylon.common.tool.ArgumentParserFactory;
import com.redhat.ceylon.common.tool.ToolFactory;
import com.redhat.ceylon.common.tool.ToolLoader;
import com.redhat.ceylon.common.tool.ToolModel;

public class CompileJsToolTest {

    protected final ArgumentParserFactory apf = new ArgumentParserFactory();
    protected final ToolFactory pluginFactory = new ToolFactory(apf);
    protected final ToolLoader pluginLoader = new ToolLoader(apf){

        @Override
        protected String getToolName(String className) {
            return camelCaseToDashes(className.replaceAll("^(.*\\.)?Ceylon(.*)Tool$", "$2"));    
        }
    };

    private List<String> args(String... args) {
        return Arrays.asList(args);
    }
    
    @Test
    public void testLoad() {
        ToolModel<CeylonCompileJsTool> tool = pluginLoader.loadToolModel("compile-js");
        pluginFactory.bindArguments(tool, args());
    }
    
}

@@ -78,24 +78,49 @@
 util.List;%0A%0A
+import org.junit.Assert;%0A
 import org.j
@@ -168,37 +168,76 @@
 on.tool.
-ArgumentParserFactory
+ServiceToolLoader;%0Aimport com.redhat.ceylon.common.tool.Tool
 ;%0Aimport
@@ -416,85 +416,8 @@
  %7B%0A%0A
-    protected final ArgumentParserFactory apf = new ArgumentParserFactory();%0A
     
@@ -476,19 +476,16 @@
 Factory(
-apf
 );%0A    p
@@ -525,24 +525,31 @@
 oader = new 
+Service
 ToolLoader(a
@@ -551,14 +551,30 @@
 der(
-apf)%7B%0A
+Tool.class) %7B%0A        
 %0A   
@@ -597,24 +597,21 @@
        p
-rotected
+ublic
  String 
@@ -735,20 +735,16 @@
  %22$2%22));
-    
 %0A       
@@ -976,16 +976,52 @@
 e-js%22);%0A
+        Assert.assertNotNull(tool);%0A
         

Fix CompileJsToolTest due to changes in the tool API