- From: Hiep Duong via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 11 Feb 2008 09:10:24 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/tests In directory hutz:/tmp/cvs-serv4968/org/w3c/unicorn/tests Modified Files: UnicornClient.java Log Message: with DirectInput, version incomplet!!! Index: UnicornClient.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tests/UnicornClient.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- UnicornClient.java 16 Jan 2008 17:33:50 -0000 1.4 +++ UnicornClient.java 11 Feb 2008 09:10:22 -0000 1.5 @@ -1,5 +1,6 @@ package org.w3c.unicorn.tests; +import java.io.File; import java.io.PrintWriter; import java.util.LinkedHashMap; import java.util.Map; @@ -12,42 +13,51 @@ public class UnicornClient { + public static void print_help() { + System.out.println("[Usage] UnicornClient task inputType=[mimetype=]pageToValid templateLanguage outputTemplate [otherParameters]"); + System.out.println(""); + System.out.println("* tasks = one of task in tasklist.xml (eg: markup, css...)"); + System.out.println("* inputType : uri|file"); + System.out.println("* mimetype : text/html|text/css|... (required only if inputType='file')"); + System.out.println("* pageToValid : an uri or a path to a file (depend on inputType)"); + System.out.println("* otherParameters : param1=val1,param2=val2..."); + System.out.println(""); + System.out.println("[Example] UnicornClient markup uri=http://w3.org en xhtml10"); + System.out.println("[Example] UnicornClient calculator uri=http://flyingman.sophia.w3.org/test en text10 x2=on,ptoto=titi"); + System.out.println("[Example] UnicornClient css file=text/css=./style/base.css fr text10 profile=css2,usermedium=screen,warning=2,lang=en"); + } + public static void main(String[] args) { UnicornCall aUnicornCall = new UnicornCall(); + /* String task = "css"; - String pageToValid = "http://w3.org"; + String pageToValid = "file=text/css=D:/stageW3C/unicorn/style/base_result.css"; String language = "en"; String outputTemplate = "text10"; String pParams=""; */ - /* + String task = "calculator"; - String pageToValid = "http://flyingman.sophia.w3.org/test"; + String pageToValid = "uri=http://flyingman.sophia.w3.org/test"; String language = "fr"; String outputTemplate = "text10"; - String pParams = "x2=on"; - */ + String pParams = "x2=on,ucn_lang=vn"; + /* // read parameters - if (args.length<4) { - System.out.println("[Usage] UnicornClient task pageToValid templateLanguage outputTemplate [otherParameters]"); - System.out.println("[Example] UnicornClient calculator http://flyingman.sophia.w3.org/test en text10 x2=on,ptoto=titi"); - System.out.println("[Example] UnicornClient markup http://w3.org en xhtml10"); - System.out.println("[Example] UnicornClient markup http://w3.org en xhtml10"); - System.out.println("[Example] UnicornClient css http://w3.org en text10"); - } String task = args[0]; String pageToValid = args[1]; String language = args[2]; String outputTemplate = args[3]; - String pParams = ""; //pParam = "x2=on,toto=tata" - if (args.length>4) { - pParams = args[4]; + String pParams = ""; + if (args.length>4) { //this argument is optional + pParams = args[4]; } - - // simple parser des param�tres - if (pParams!=null && !"".equals(pParams)) { + */ + + //parse other parameters: "x2=on,toto=titi" to a map<String,String[]> + if (pParams.length()!=0) { Map<String, String[]> mapOfParameter = new LinkedHashMap<String, String[]>(); String[] couples = pParams.split(","); for (int i=0; i<couples.length; i++) { @@ -60,13 +70,35 @@ System.err.println("Error parameter!"); } aUnicornCall.setMapOfStringParameter(mapOfParameter); - - aUnicornCall.setTask(task); //task id + } + + //parse input type: "uri=http://flyingman.sophia.w3.org/test" or "file=text/css=./style/base.css" + String[] pInput = pageToValid.split("="); + if (pInput[0].equals("uri")) { aUnicornCall.setEnumInputMethod(EnumInputMethod.URI); - aUnicornCall.setDocumentName(pageToValid); - aUnicornCall.setInputParameterValue(pageToValid); - aUnicornCall.setLang(language); + aUnicornCall.setDocumentName(pInput[1]); + aUnicornCall.setInputParameterValue(pInput[1]); + } else { + aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT); + File f = new File(pInput[2]); + //TODO: read content in the file couple[2] + String content=".h1{color:#FA0012}"; + + //TODO: ajouter mime type dans map of parameter + + Map<String, String[]> mapOfParameter = aUnicornCall.getMapOfStringParameter(); + if (mapOfParameter==null) { + mapOfParameter = new LinkedHashMap<String, String[]>(); + aUnicornCall.setMapOfStringParameter(mapOfParameter); + } + String[] tmp = {pInput[1]}; + mapOfParameter.put("ucn_mime", tmp); + + aUnicornCall.setInputParameterValue(content); } + + aUnicornCall.setTask(task); //task id + aUnicornCall.setLang(language); /* // lang par defaut @@ -76,7 +108,6 @@ aUnicornCall.setMapOfStringParameter(mapOfParameter); */ - long before = System.currentTimeMillis() ; try { aUnicornCall.doTask(); @@ -94,7 +125,6 @@ } catch (Exception e) { e.printStackTrace(); } - long after = System.currentTimeMillis() ; System.out.println("Elapsed time (s): "+(double)(after - before)/1000); }
Received on Monday, 11 February 2008 09:10:41 UTC