incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccris...@apache.org
Subject svn commit: r754938 [2/2] - in /incubator/kato/trunk/import/org.apache.kato.anttasks: ./ .settings/ META-INF/ lib/ src/ src/com/ src/com/ibm/ src/com/ibm/dtfj/ src/com/ibm/dtfj/anttasks/ src/com/ibm/dtfj/anttasks/sitebuilder/ src/com/ibm/dtfj/anttasks/...
Date Mon, 16 Mar 2009 16:40:57 GMT
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionParser.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionParser.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionParser.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionParser.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,585 @@
+/*******************************************************************************
+ * 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpression.AndExpression;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpression.OrExpression;
+
+
+
+public class TCKSelectionExpressionParser {
+
+	private static final String delims="=!<>&| ";
+	
+	private static Map keywords=new HashMap();
+	
+	static {
+		keywords.put("vm", new String[]{}); // TODO: add vm types to the array
+		keywords.put("os",new String[]{"aix","linux","windows","os390"});
+		keywords.put("dumptype", new String[]{}); //TODO: add dump formats to the array
+		keywords.put("arch",new String[]{"x86","ppc","s390"});
+		keywords.put("testsuite", new String[]{"javaruntime","process","javaheap"});
+		keywords.put("vmbuild", Date.class);
+		keywords.put("vmvendor", new String[]{"ibm","sun"});
+	}
+	/**
+	 * Supported TCK tag syntax examples
+	 * 
+	 * ( keyword=value || keyword
+	 * 
+	 *          
+	 *       
+	 * @param expression
+	 * 
+	 */
+	public static TCKSelectionExpression parse(String command) {
+		
+		
+		List data=tokenize(command);
+		return buildExpresion(data);
+		
+	}
+	
+	
+	public static abstract class Token {
+		
+		private String value=null;
+		private  Token() {
+			
+		}
+		public Token(char start) {
+			value=""+start;
+		}
+		
+		public Token(String start) {
+			value=start;
+		}
+		public abstract boolean isValid();
+		
+		public Token getFinalForm() {
+			return this;
+		}
+		
+		public abstract Token starts(char c);
+		public abstract boolean append(char c);
+		
+		public void add(char c) {
+			value=value+c;
+		}
+		
+		public String possibleToken(char c) {
+			return value+c;
+		}
+		public String toString() {
+			
+			return value;
+		}
+		public String getValue() {
+			return value;
+		}
+	}
+	
+	public static class OpenBracket extends Token{
+
+		private OpenBracket() {
+			
+		}
+		public OpenBracket(char start) {
+			super(start);
+			
+		}
+		public Token starts(char c) {
+			
+			if(c=='(') return new OpenBracket(c);
+			return null;
+		}
+		
+		public boolean append(char c) {
+			
+			return false;
+		}
+		public boolean isValid() {
+			
+			return true;
+		}
+		
+		
+	}
+	
+	public static class CloseBracket extends Token{
+
+		private CloseBracket() {
+			
+		}
+		public CloseBracket(char start) {
+			super(start);
+			
+		}
+		public Token starts(char c) {
+			
+			if(c==')') return new CloseBracket(c);
+			return null;
+		}
+		
+		public boolean append(char c) {
+			
+			return false;
+		}
+		public boolean isValid() {
+		
+			return true;
+		}
+		
+		
+	}
+	
+	
+	
+	public static class Operator extends Token{
+
+		
+		public static final int EQ=1;
+		public static final int NE=2;
+		public static final int GT=3;
+		public static final int LT=4;
+		public static final int LE=5;
+		public static final int GE=6;
+		public static final int AND=7;
+		public static final int OR=8;
+		
+		private static String[] names=new String[]{"unrecognised","=","!=",">","<",">=","<=","&&","||"};
+		
+		private Operator() {
+			
+		}
+		public static String getOperatorValue(int v) {
+			if(v<0 || v>=names.length) return "?";
+			return names[v];
+		}
+		
+		public Operator(char start) {
+			super(start);
+			
+		}
+
+		public boolean append(char c) {
+			
+			if( isOperator(c) ==false) return false;
+			String possibleToken=possibleToken(c);
+			int tokenID=getOperatorID(possibleToken);
+			return tokenID>0;
+			
+		}
+
+		public static int getOperatorID(String op) {
+			
+			for(int i=1;i<names.length;i++) {
+				if(names[i].equals(op)) return i;
+			}
+			return 0;
+		}
+
+		public Token starts(char c) {
+			
+			if(isOperator(c)) return new Operator(c);
+			return null;
+		}
+
+		public static boolean isOperator(char c) {
+			return "=<>!|&".indexOf(c)>=0;
+		}
+		public int getOperator() {
+			
+			return getOperatorID(toString());
+		}
+		public boolean isValid() {
+			return true;
+		}
+	
+		
+	}
+	
+	public static class Numeric extends Token {
+
+		
+		private Numeric() {
+			
+		}
+		public Numeric(char start) {
+			super(start);
+		
+		}
+
+		public boolean append(char c) {
+			if(c=='/') return true;
+			return Character.isDigit(c);
+		}
+
+		public Token starts(char c) {
+			if (Character.isDigit(c)) {
+				return new Numeric(c);
+			}
+			return null;
+		}
+		
+		public Token getFinalForm() {
+				if( isValid()) {
+					return this;
+				}
+				return new Word(getValue());
+		}
+		public boolean isValid() {
+		
+			// can we parse the string as a number?
+			try {
+			Integer.parseInt(getValue());
+			return true;
+			} catch(NumberFormatException nfe) {
+				;
+			}
+			return false;
+		}
+		public int intValue() {
+			return Integer.parseInt(getValue());
+		}
+		
+		
+		
+	}
+	public static class Word extends Token {
+
+		private Word() {
+			
+		}
+		public Word(char start) {
+			super(start);
+			
+		}
+		public Word(String start) {
+			super(start);
+			
+		}
+
+		public boolean append(char c) {
+			
+			if(Operator.isOperator(c)) return false;
+			if(c=='(' || c==')') return false;
+			
+			return true;
+		}
+
+		public Token starts(char c) {
+			
+			if(Operator.isOperator(c)) return null;
+			if(c=='(' || c==')') return null;
+			if(Character.isDigit(c)) return null;
+			
+			return new Word(c);
+		
+		}
+		public boolean isValid() {
+			return true;
+		}
+		
+	}
+	/**
+	 * Tokenizes the command and returns a list
+	 * consisting of java.lang.String and java.lang.Number objects..
+	 * 
+	 * @param command
+	 * @return list of objects
+	 */
+	public static List tokenizeToValues(String command) {
+		
+		List tokens=tokenize(command);
+		List values=new LinkedList();
+		Iterator i=tokens.iterator();
+		while(i.hasNext()) {
+			Object o=i.next();
+			if(o instanceof Numeric) {
+				Numeric n=(Numeric) o;
+				int v=n.intValue();
+				
+				values.add(new Integer(v));
+			}
+			else {
+				Token t=(Token) o;
+				values.add(t.getValue());
+			}
+		}
+		
+		return values;
+	}
+	/*
+	 * Returns a list of tokens that represent the contents of the command
+	 * 
+	 */
+	public static List tokenize(String command) {
+	
+		Token[] builders=new Token[]{new OpenBracket(),new CloseBracket(),new Operator(),new Numeric(),new Word()};
+		
+		List results=new LinkedList();
+		
+		Token currentWord=null;
+		
+		
+		for(int i=0;i<command.length();i++) {
+			char c=command.charAt(i);
+			if(Character.isWhitespace(c)) {
+				if(currentWord==null) {
+					// not in a word - so skip
+					
+				}
+				else {
+					// end of a word
+					results.add(currentWord.getFinalForm());
+					currentWord=null;
+				}
+			}
+			else {
+				if(currentWord!=null) {
+					
+					// in word . so we determine if current char is compatable
+					// with word. If so we add it, else we end the current word and start a new 
+					// one
+					if(currentWord.append(c)) {
+						currentWord.add(c);
+					}
+					else {
+						// validate current word
+						currentWord=currentWord.getFinalForm();
+						results.add(currentWord);
+						currentWord=null;
+						for(int j=0;j<builders.length;j++) {
+							currentWord=builders[j].starts(c);
+							if(currentWord!=null) break;
+						}
+						if(currentWord==null) {
+							throw new TCKSelectionEvaluationException("character ["+c+"] at offset "+i+" is invalid");
+						}
+					}
+					 
+			 	}
+				else {
+					for(int j=0;j<builders.length;j++) {
+						currentWord=builders[j].starts(c);
+						if(currentWord!=null) break;
+					}
+					if(currentWord==null) {
+						throw new TCKSelectionEvaluationException("character ["+c+"] at offset "+i+" is invalid");
+					}
+				}
+		}
+		}
+		if(currentWord!=null)  results.add(currentWord.getFinalForm());
+		
+		
+		return results;
+	}
+	
+	
+	
+	private static TCKSelectionExpression buildExpresion(List data) {
+		
+		if(data==null) return null;
+		if(data.isEmpty()) return null;
+	
+		Object first=data.get(0);
+		
+		if(first instanceof OpenBracket) {
+			
+			List subExpression=extractSubExpressionList(data);
+			
+			if(data.isEmpty()) {
+				// subexpression was all of the expression so all we've done
+				// is remove the brackets..
+				return buildExpresion(subExpression);
+			}
+			else {
+				// more to do - expect next token to be a logical statement
+				return buildExpression(data, subExpression);
+			}
+		}
+		else {
+			//not a bracketed expression - so should take the starting form of
+			//  key op value
+			if(data.size()<3) {
+				throw new TCKSelectionEvaluationException("Expected keyword comparision expression: found "+data+" instead");
+				
+			}
+			Object key=data.remove(0);
+			if(key instanceof Word ==false) {
+				throw new TCKSelectionEvaluationException("keyword comparision expression cannot start with "+key.toString());
+			}
+			// check key
+			if(keywords.containsKey(key.toString())==false) {
+				throw new TCKSelectionEvaluationException("keyword ["+key+"] not valid");
+			}
+			Object options=keywords.get(key);
+			
+			
+			Object op=data.remove(0);
+			if(op instanceof Operator ==false) {
+				throw new TCKSelectionEvaluationException("expected keyword comparision operator: "+op+" not understood");
+			}
+			
+			// reject logical operators..
+			int operator=((Operator)op).getOperator();
+			switch(operator) {
+				case TCKSelectionExpression.AND:
+				case TCKSelectionExpression.OR:
+				throw new TCKSelectionEvaluationException("Cannot use logical operator "+op+" in keyword comparision");
+				
+			}
+			
+			Object value=data.remove(0);
+			// if the options of this keyword is a string array
+			// then we can check the value now
+			
+			if(options instanceof String[]) {
+				if(value instanceof Word==false) {
+					throw new TCKSelectionEvaluationException("value in  "+key+op+value+" is invalid type");
+				}
+				String stringValue=value.toString();
+				String[] validOptions=(String[]) options;
+				// any matched?
+				boolean matched=false;
+				for(int i=0;i<validOptions.length;i++) {
+					if(validOptions[i].equals(stringValue)) {
+						matched=true;
+					}
+				}
+				// if we did not match any value then regardless of operator type this is not
+				// a valid comparision
+				if(!matched) {
+					throw new TCKSelectionEvaluationException("value "+stringValue+" used with key "+key+" is not valid");
+				}
+				
+				
+			}
+			 
+			 
+			
+		
+			
+			// build an expression with this data
+			TCKSelectionEnvironmentExpression eval=new TCKSelectionEnvironmentExpression(key.toString(),operator,value);
+		
+			if(data.isEmpty()==false) {
+				return buildExpression(data, eval);
+			}
+			else {
+				// no more data - eval expression is it
+				return eval;
+			}
+		}
+		
+		
+	}
+
+	private static TCKSelectionExpression buildExpression(List data,
+			List subExpression) {
+		Operator op=(Operator) data.remove(0);
+		int logicalOp=op.getOperator();
+		switch(logicalOp) {
+		case TCKSelectionExpression.OR :
+			// valid operator - get right expression
+			TCKSelectionExpression leftExpression=buildExpresion(subExpression);
+			TCKSelectionExpression rightExpression=buildExpresion(data);
+			if(leftExpression==null || rightExpression==null) return null;
+			return new OrExpression(leftExpression,rightExpression); 
+		case TCKSelectionExpression.AND :
+			// valid operator - get right expression
+			 leftExpression=buildExpresion(subExpression);
+			 rightExpression=buildExpresion(data);
+			if(leftExpression==null || rightExpression==null) return null;
+			return new AndExpression(leftExpression,rightExpression); 
+			
+		default:  throw new TCKSelectionEvaluationException("logical operator "+op+" is not understood");
+		}
+	}
+	private static TCKSelectionExpression buildExpression(List data,
+			TCKSelectionExpression leftExpression) {
+		Operator op=(Operator) data.remove(0);
+		int logicalOp=op.getOperator();
+		switch(logicalOp) {
+		case TCKSelectionExpression.OR :
+			// valid operator - get right expression
+			TCKSelectionExpression rightExpression=buildExpresion(data);
+			return new OrExpression(leftExpression,rightExpression);
+		case TCKSelectionExpression.AND :
+			// valid operator - get right expression
+			rightExpression=buildExpresion(data);
+			return new AndExpression(leftExpression,rightExpression); 
+			
+		default:  throw new TCKSelectionEvaluationException("logical operator "+op+" is not understood");
+		}
+	}
+
+	
+
+	/**
+	 * Returns a list that contains the elements between the first opening bracket
+	 * and its corresponding closing bracket.
+	 * 
+	 * The original list is shortened by the sub expression elements
+	 *  
+	 * @param data
+	 * 
+	 */
+	private static List extractSubExpressionList(List data) {
+		
+		List results=new LinkedList();
+		
+		Iterator i=data.iterator();
+		int bracketDepth=0;
+		i.next(); // skip initial opening bracket
+		i.remove();
+		
+		while(i.hasNext()) {
+			Object element=i.next();
+			if(element.toString().equals(")")) {
+			
+				if(bracketDepth==0) {
+					i.remove();
+					break; // done
+				}
+				else {
+					bracketDepth--; // reduce depth
+				}
+			}
+			if(element.toString().equals("(")) {
+				bracketDepth++;
+			}
+			i.remove();
+			results.add(element);
+			
+		}
+		if(bracketDepth!=0) throw new TCKSelectionEvaluationException("mismatched brackets in expression");
+		
+		return results;
+	}
+
+	private static boolean isDelimiter(String token) {
+		if(token.length()>1) return false;
+		return delims.indexOf(token.charAt(0))>=0;
+	}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagFactory.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagFactory.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagFactory.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+
+
+public class TCKTagFactory {
+
+
+	public class TCKSelectionTag extends TCKTestTag {
+
+		
+		public TCKSelectionTag(String value) throws TCKDefinitionException {
+			super("tck",value);
+		}
+
+		public boolean validate(String value) {
+			
+			TCKSelectionExpression expression=TCKSelectionExpressionParser.parse(value);
+			return expression!=null;
+		}
+
+	}
+
+
+	private static TCKTagFactory defaultFactory=new TCKTagFactory();
+	
+	
+	public static final String OS = "os";
+	public static final String OS_OS390 = "os390";
+	public static final String OS_AIX = "aix";
+	public static final String OS_LINUX = "linux";
+	public static final String OS_WINDOWS = "windows";	
+	
+	public static final String ARCH = "arch";
+	public static final String ARCH_PPC = "ppc";
+	public static final String ARCH_X86 = "x86";	
+
+	public static final String VMTYPE = "vmtype";
+	//TODO: add constants for valid VM types
+
+	public static final String DUMPTYPE = "dumptype";
+	//TODO: add constants for valid dump types
+	
+	public static final String VMVENDOR = "vmvendor";
+	public static final String VENDOR_SUN = "sun";
+	public static final String VENDOR_IBM = "ibm";
+	
+	public static final String TESTSUITE = "testsuite";
+	public static final String TESTSUITE_JAVARUNTIME = "javaruntime";
+	public static final String TESTSUITE_PROCESS = "process";
+	public static final String TESTSUITE_JAVAHEAP = "javaheap";
+	
+	public static final String VMBUILD = "vmbuild";
+	public static final String TCK = "tck";
+	
+	static final String[] tagnames=new String[]{OS,ARCH,VMVENDOR,VMTYPE,VMBUILD,DUMPTYPE,TESTSUITE,TCK};
+	/** 
+	 * Converts string into a correct TCK tag type.
+	 * Valid tags are 
+	 * @throws TCKDefinitionException 
+	* @os : operating system
+    * @arch : platform architectures supported e.g. x86
+    * @vmvendor : VM vendor
+    * @vmversion : VM version expressed as major.minor.service e.g. for Java 6.0 SR 2 it would be 1.60.2
+    * @dumpType : type of dump
+    * @testgroup : the suite in which this test belongs e.g. Process
+    * @vmbuild : VM build date 
+	*/
+
+	public static  TCKTestTag create(String tagName, String value) throws TCKDefinitionException {
+		
+		if(tagName.equals(OS)) return defaultFactory.new TCKOSTag(value);
+		if(tagName.equals(ARCH)) return defaultFactory.new TCKArchTag(value);
+		if(tagName.equals(VMVENDOR)) return defaultFactory.new TCKVMVendorTag(value);
+		if(tagName.equals(VMTYPE)) return defaultFactory.new TCKVMTypeTag(value);
+		if(tagName.equals(DUMPTYPE)) return defaultFactory.new TCKDumpTypeTag(value);
+		if(tagName.equals(TESTSUITE)) return defaultFactory.new TCKTestSuiteTag(value);
+		if(tagName.equals(VMBUILD)) return defaultFactory.new TCKVMBuildTag(value);
+		if(tagName.equals(TCK)) return defaultFactory.new TCKSelectionTag(value);
+		throw new TCKDefinitionException("tagname ["+tagName+"] is invalid");
+		
+	}
+
+	
+
+
+public class TCKOSTag extends TCKTestTag {
+	
+	
+
+	private TCKOSTag(String value) throws TCKDefinitionException {
+		super(OS,value);
+	}
+
+	public boolean validate(String value) {
+		
+		if(value.equals(OS_WINDOWS)) return true;
+		if(value.equals(OS_LINUX)) return true;
+		if(value.equals(OS_AIX)) return true;
+		if(value.equals(OS_OS390)) return true;
+		return false;
+	}
+}
+
+
+
+public class TCKArchTag extends TCKTestTag {
+	
+	
+	
+
+	private TCKArchTag(String value) throws TCKDefinitionException {
+		super(ARCH,value);
+	}
+
+	public boolean validate(String value) {
+		
+		if(value.equals(ARCH_X86)) return true;
+		if(value.equals(ARCH_PPC)) return true;
+		
+		
+		return false;
+	}
+	
+}
+
+public class TCKVMTypeTag extends TCKTestTag {
+	
+	
+	private TCKVMTypeTag(String value) throws TCKDefinitionException {
+		super(VMTYPE,value);
+	}
+
+	public boolean validate(String value) {
+		
+		//TODO: return true for valid VM types
+		return false;
+	}
+	
+}
+public class TCKDumpTypeTag extends TCKTestTag {
+	
+	
+	private TCKDumpTypeTag(String value) throws TCKDefinitionException {
+		super(DUMPTYPE,value);
+	}
+
+	public boolean validate(String value) {
+		
+		//TODO: return true for valid dump types
+		return false;
+	}
+	
+}
+public class TCKTestSuiteTag extends TCKTestTag {
+	
+	
+	private TCKTestSuiteTag(String value) throws TCKDefinitionException {
+		super(TESTSUITE,value);
+	}
+
+	public boolean validate(String value) {
+		
+		if(value.equals(TESTSUITE_JAVAHEAP)) return true;
+		if(value.equals(TESTSUITE_PROCESS)) return true;
+		if(value.equals(TESTSUITE_JAVARUNTIME)) return true;
+		
+		return false;
+	}
+	
+}
+public class TCKVMVendorTag extends TCKTestTag {
+	
+	
+
+	private TCKVMVendorTag(String value) throws TCKDefinitionException {
+		super(VMVENDOR,value);
+	}
+
+	public boolean validate(String value) {
+		
+		if(value.equals(VENDOR_IBM)) return true;
+		if(value.equals(VENDOR_SUN)) return true;
+		
+		
+		return false;
+	}
+	
+}
+
+public class TCKVMBuildTag extends TCKTestTag {
+
+	private TCKVMBuildTag(String value) throws TCKDefinitionException {
+		super(VMBUILD,value);
+	}
+
+	public boolean validate(String value) {
+		
+		DateFormat df = new SimpleDateFormat("yyyyMMdd");
+		
+		try {
+			df.parse(value);
+			return true;
+		} catch (ParseException e) {
+			return false;
+		}
+	}
+}
+
+
+public boolean isValidTagName(String tagName) {
+	
+	if(tagName==null) return false;
+	
+	for(int i=0;i<tagnames.length;i++) {
+		if(tagnames[i].equals(tagName)) return true;
+	}
+	
+	return false;
+	
+	
+}
+
+
+}
+

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagGroup.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagGroup.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagGroup.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagGroup.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.TreeMap;
+
+public class TCKTagGroup {
+
+	private TreeMap tags=null;
+	public TCKTagGroup(TreeMap tags) {
+		this.tags=tags;
+	}
+	
+	public boolean expectedResult(String osName, String arch, String vmVendor,String dumpType,String vmType,String testSuite, String vmBuild) {
+		
+		if(check(TCKTagFactory.OS,osName)==false) return false; // failed os check
+		if(check(TCKTagFactory.ARCH,arch)==false) return false; // failed arch check
+		if(check(TCKTagFactory.VMVENDOR,vmVendor)==false) return false; // failed arch check
+		if(check(TCKTagFactory.DUMPTYPE,dumpType)==false) return false; // failed arch check
+		if(check(TCKTagFactory.VMTYPE,vmType)==false) return false; // failed arch check
+		if(check(TCKTagFactory.VMBUILD,vmBuild)==false) return false; // failed build check
+		if(check(TCKTagFactory.TESTSUITE,testSuite)==false) return false; // failed arch check
+		
+		return true;
+	}
+
+	private boolean check(String tagName, String requiredValue) {
+		
+		TCKTestTag tag=(TCKTestTag) tags.get(tagName);
+
+		// if the tag exists then we check it
+		if(tag!=null) {
+			String value=tag.getValue();
+			if(value.equals(requiredValue)==false) return false; 
+			
+		}
+		return true;
+
+	}
+
+	
+	
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTestTag.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTestTag.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTestTag.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTestTag.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+
+public abstract class TCKTestTag {
+	
+	private String value=null;
+	private String tagName=null;
+	
+	TCKTestTag(String tagName,String value) throws TCKDefinitionException {
+		if(tagName==null) throw new TCKDefinitionException("missing tagName");
+		this.tagName=tagName;
+		if(value==null) throw new TCKDefinitionException("missing value");
+		if(validate(value)==false) throw new TCKDefinitionException("value ["+value+"] is invalid");
+		this.value=value;
+	}
+	/**
+	 * Called by constructor to validate tag value. 
+	 * @param value (never null)
+	 * @return true or false 
+	 */
+	public abstract boolean validate(String value);
+	public String getValue() {
+		return value;
+	}
+	public String getTagName() {
+		return tagName;
+	}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test1.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test1.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test1.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test1.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.tests.foo;
+
+import junit.framework.TestCase;
+
+/**
+ * os windows
+ *
+ */
+public class Test1 extends TestCase{
+
+	/**
+	 *  @vmvendor ibm
+	 */
+	public void test1() {
+		
+	}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test2.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test2.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test2.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test2.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.tests.foo;
+
+import junit.framework.TestCase;
+
+/**
+ * os windows
+ *
+ */
+public class Test2 extends TestCase{
+
+	/**
+	 *  @tck arch=ppc
+	 */
+	public void test2() {
+		
+	}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/site.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/site.xml?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/site.xml (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/site.xml Mon Mar 16 16:40:55 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- AUTO GENERATED SITE FILE using com.ibm.dtfj.anttasks.sitebuilder.SiteBuilder -->
+<site mirrorsURL="http://mirror.url.wibble" >
+<description url="vvv" >
+This is my site file
+</description>
+<category-def name="com.ibm.group1" label="Group Name 1">
+<description>
+This is my category
+</description>
+</category-def>
+	<feature url="features/feature.a.b.c.1_123456.jar" id="123456.jar" version="feature.a.b.c.1">
+		<category name="com.ibm.group1"/>
+	</feature>
+<category-def name="com.ibm.group2" label="Group Name 2"/>
+	<feature url="features/feature.z.z.z.1_999.jar" id="999.jar" version="feature.z.z.z.1">
+		<category name="com.ibm.group2"/>
+	</feature>
+	<feature url="features/feature2.z.z.z.z_999.jar" id="999.jar" version="feature2.z.z.z.z">
+		<category name="com.ibm.group2"/>
+	</feature>
+<archive path="frompath" url="tomath"/>
+</site>

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/test.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/test.xml?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/test.xml (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/test.xml Mon Mar 16 16:40:55 2009
@@ -0,0 +1,48 @@
+<!--
+  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.
+-->
+<project default="default">
+	
+	<taskdef resource="com/ibm/dtfj/anttasks/anttasks.properties">
+		<classpath>
+			<pathelement location="${dtfjantjar}" />
+		</classpath>
+	</taskdef>
+
+	<target name="default">
+		
+		
+		
+		<sitebuilder file="${sitefile}" mirrorsURL="http://mirror.url.wibble">
+			<description url="vvv">
+			This is my site file
+			</description>
+			
+					<category name="Group Name 1" label="com.ibm.group1" urlprefix="features/">
+						<fileset dir="testdata/features">
+							<include name="*.a.*"/>
+						</fileset>
+						<description>
+							This is my category
+						</description>
+					</category>
+					
+					<category name="Group Name 2" label="com.ibm.group2" urlprefix="features/">
+						<fileset dir="testdata/features">
+								<include name="*.z.*"/>
+						</fileset>
+					</category>
+			 <archive path="frompath" url="tomath"/>
+				</sitebuilder>
+	</target>
+</project>

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/test.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/test.xml?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/test.xml (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/test.xml Mon Mar 16 16:40:55 2009
@@ -0,0 +1,41 @@
+<!--
+  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.
+-->
+<project default="default">
+	
+	<property file="../../build.properties"/>
+	
+	<taskdef resource="com/ibm/dtfj/anttasks/anttasks.properties">
+		<classpath>
+			<pathelement location="${dtfjantjar}" />
+		</classpath>
+	</taskdef>
+
+	<target name="default">
+		<antcall target="test1" />
+
+	</target>
+
+
+	<target name="test1">
+		
+		<tcklistbuilder packagenames="com.tests.*" output="/tmp/wibble"
+			sourcepath="${testdata.src}"
+			classpath="${junit.path}"
+			failonerror="true" docletpath="${dtfjantjar}"/>
+		
+		
+
+	</target>
+
+</project>

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionParser.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionParser.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionParser.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionParser.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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 test.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionEvaluator;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpression;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionParser;
+
+public class TestExpressionParser extends TestCase {
+
+	
+	
+	public void testNoExpression() {
+		
+		try {
+			TCKSelectionExpressionParser.parse((String)null);
+			fail("expected NPE");
+		} catch(NullPointerException npe) {
+			
+		}
+		
+	}
+	
+	public void testSimpleExpression() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("arch=ppc");
+		assertNotNull(expression);
+		
+	}
+	public void testSimpleJVMExpression() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("arch=ppc");
+		
+		Map environment=new HashMap();
+		environment.put("arch","ppc");
+		
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		assertTrue(eval.evaluate(expression,environment));
+		
+	}
+	
+	public void testComplexJVMExpression() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("arch=ppc || arch=x86");
+		
+		Map environment=new HashMap();
+		environment.put("arch","x86");
+		
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		assertFalse(eval.evaluate(expression,environment));
+		
+	}
+	
+	public void testBracketedExpression() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("()");
+		assertNull(expression);
+		
+	}
+	public void testLargeBracketedExpression() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("() && ()");
+		assertNull(expression);
+		
+	}
+	
+	public void testDateExpressionLT() {
+		
+		String date="2008/01/01";
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("vmbuild<2009/01/01");
+		
+		Map environment=new HashMap();
+		environment.put("vmbuild",date);
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		
+		assertTrue(eval.evaluate(expression,environment));
+	}
+	
+		public void testDateExpressionGE() {
+		
+		String date="2008/01";
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("vmbuild>=2008/01");
+		
+		Map environment=new HashMap();
+		environment.put("vmbuild",date);
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		
+		assertTrue(eval.evaluate(expression,environment));
+	}
+	public void testDateExpressionLE() {
+			
+			String date="2008/10/10";
+			
+			TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("vmbuild<=2008/10/10");
+			
+			Map environment=new HashMap();
+			environment.put("vmbuild",date);
+			TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		
+			assertTrue(eval.evaluate(expression,environment));
+		}
+	public void testDateExpressionNE() {
+		
+		String date="2008/10/11";
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("vmbuild !=  2008/10/10");
+		
+		Map environment=new HashMap();
+		environment.put("vmbuild",date);
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+	
+		assertTrue(eval.evaluate(expression,environment));
+	}
+	public void testDateExpressionGT() {
+		
+		String date="2008/10/11";
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("vmbuild >  2001/10/10");
+		
+		Map environment=new HashMap();
+		environment.put("vmbuild",date);
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+	
+		assertTrue(eval.evaluate(expression,environment));
+	}
+	public void testValuedBracketedExpression2() {
+		
+		TCKSelectionExpression expression=TCKSelectionExpressionParser.parse("((arch=ppc) || arch = x86)  && ( os=aix || os=linux )");
+		Map environment=new HashMap();
+		environment.put("arch","x86");
+		environment.put("os","linux");
+		environment.put("e",new Double(1.6));
+		
+		TCKSelectionExpressionEvaluator eval=new TCKSelectionExpressionEvaluator();
+		assertTrue(eval.evaluate(expression,environment));
+	}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionTokenizer.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionTokenizer.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionTokenizer.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionTokenizer.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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 test.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionParser;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionParser.OpenBracket;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionParser.Token;
+
+public class TestExpressionTokenizer extends TestCase {
+
+	
+	
+	
+	public void testEmptyValue() {
+		
+		List results=TCKSelectionExpressionParser.tokenize("");
+		assertNotNull(results);
+	}
+public void testWhiteSpaceValue() {
+		
+		List results=TCKSelectionExpressionParser.tokenize("  ");
+		assertEquals(0, results.size());
+	}
+
+public void testBracketedValue() {
+	
+	List results=TCKSelectionExpressionParser.tokenize("()");
+	assertEquals(2, results.size());
+}
+
+public void testBracketedValueContents() {
+	
+	
+	Token[] results=(Token[]) TCKSelectionExpressionParser.tokenize("((").toArray(new Token[0]);
+	
+	assertEquals(OpenBracket.class, results[0].getClass());
+	assertEquals(OpenBracket.class, results[1].getClass());
+	
+}
+
+public void testDelimiterSymbolSet() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenize(" ! = < > & | ").toArray();
+	assertEquals(6,results.length);
+	
+}
+
+public void testNumbers() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenize("100").toArray();
+	assertEquals("100",results[0].toString());
+	
+}
+public void testWord() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenize("abcdefg").toArray();
+	assertEquals("abcdefg",results[0].toString());
+	
+}
+
+public void testDate() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenize("2008/01/01").toArray();
+	assertEquals("2008/01/01",results[0].toString());
+	
+}
+public void testKeyValue() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenize("abc!= 123").toArray();
+	assertEquals("abc",results[0].toString());
+	assertEquals("!=",results[1].toString());
+	assertEquals("123",results[2].toString());
+	
+}
+public void testComplexValue() {
+	
+	Object[] results=TCKSelectionExpressionParser.tokenizeToValues("a!=b && ccc!=100 || ( ( d>=qwerty && q<199) || ( d<=qwerty && q>200))").toArray();
+	
+	assertEquals("a",results[0]);
+	assertEquals("!=",results[1]);
+	assertEquals("b",results[2]);
+	assertEquals("&&",results[3]);
+	assertEquals("ccc",results[4]);
+	assertEquals("!=",results[5]);
+	assertEquals(new Integer(100),results[6]);
+	assertEquals("||",results[7]);
+	assertEquals("(",results[8]);
+	assertEquals("(",results[9]);
+	assertEquals("d",results[10]);
+	assertEquals(">=",results[11]);
+	assertEquals("qwerty",results[12]);
+	assertEquals("&&",results[13]);
+	assertEquals("q",results[14]);
+	assertEquals("<",results[15]);
+	assertEquals(new Integer(199),results[16]);
+	assertEquals(")",results[17]);
+	assertEquals("||",results[18]);
+	assertEquals("(",results[19]);
+	assertEquals("d",results[20]);
+	assertEquals("<=",results[21]);
+	assertEquals("qwerty",results[22]);
+	assertEquals("&&",results[23]);
+	assertEquals("q",results[24]);
+	assertEquals(">",results[25]);
+	assertEquals(new Integer(200),results[26]);
+	assertEquals(")",results[27]);
+	assertEquals(")",results[28]);
+}
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKDefinitionWriter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKDefinitionWriter.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKDefinitionWriter.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKDefinitionWriter.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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 test.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinitionXMLReader;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinitionXMLWriter;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKTestTag;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKMethodDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKPackageDefinition;
+
+public class TestTCKDefinitionWriter extends TestCase {
+
+	/**
+	 * Test to show what a simple tck definition can
+	 * be written with out errors
+	 * @throws IOException
+	 */
+	public void testSimpleSave() throws IOException {
+		
+		TCKDefinition def=new TCKDefinition();
+		TCKPackageDefinition a1=def.createPackage("a1");
+		TCKClassDefinition c1=a1.createClass("c1");
+		TCKMethodDefinition m1=c1.createMethod("m1");
+		
+		
+		TCKDefinitionXMLWriter writer=new TCKDefinitionXMLWriter(def);
+		
+			File out=File.createTempFile("dtfj", ".xml");
+		
+			writer.write(out);
+				
+	}
+	/**
+	 * Test to write a simple TCK definition to an XML file
+	 * and retrieve it again.
+	 * 
+	 * @throws Exception
+	 */
+	public void testBasicSaveAndLoad() throws Exception {
+		
+		// create a definition
+		
+		TCKDefinition def=new TCKDefinition();
+		TCKPackageDefinition a1=def.createPackage("a1");
+		TCKClassDefinition c1=a1.createClass("c1");
+		TCKMethodDefinition m1=c1.createMethod("m1");
+		TCKTestTag osTag=def.getTag("os","windows");
+		m1.addTag(osTag);
+		
+		// write it out
+		
+		TCKDefinitionXMLWriter writer=new TCKDefinitionXMLWriter(def);
+		
+			File out=File.createTempFile("dtfj", ".xml");
+			writer.write(out);
+		
+		// load it back
+			
+		FileInputStream fis=new FileInputStream(out);
+		TCKDefinition loaded=TCKDefinitionXMLReader.load(fis);
+		fis.close();
+			
+		// check its the same by retrieveing the method m1
+		
+		TCKMethodDefinition mLoaded=loaded.getMethod("a1","c1","m1");
+		
+		// check it matches...
+		assertEquals("Invalid method name","m1",mLoaded.getName());
+		
+		
+	}
+	
+	/**
+	 * Test to show that the writers text escape method works
+	 * correctly
+	 * 
+	 */
+	public void testEscapeProcess1() {
+		
+		String in="hello<its>me I l&ive <<here";
+		String out=TCKDefinitionXMLWriter.escape(in);
+		
+		assertEquals("hello&lt;its&gt;me I l&amp;ive &lt;&lt;here", out);
+		
+	}
+	
+}

Added: incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKTagDefinitions.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKTagDefinitions.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKTagDefinitions.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKTagDefinitions.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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 test.ibm.dtfj.anttasks.tcklistbuilder;
+
+import junit.framework.TestCase;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinitionException;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKTagFactory;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKTestTag;
+
+public class TestTCKTagDefinitions extends TestCase {
+
+	
+	public void testOSTag() throws TCKDefinitionException {
+		
+		TCKTagFactory def=new TCKTagFactory();
+		
+		TCKTestTag tag=def.create("os", "windows");
+		assertNotNull(tag); 
+		
+		tag=def.create("os", "linux");
+		assertNotNull(tag);
+		
+		tag=def.create("os", "aix");
+		assertNotNull(tag);
+		
+		try {
+		tag=def.create("os", "Foo");
+		fail("expected TCKDefinitionException");
+		} catch(TCKDefinitionException te) {
+			
+		}
+		
+	}
+	public void testArchTag() throws TCKDefinitionException {
+		
+		TCKTagFactory def=new TCKTagFactory();
+		
+		TCKTestTag tag=def.create("arch", "x86");
+		assertNotNull(tag);
+		
+		tag=def.create("arch", "ppc");
+		assertNotNull(tag);
+		
+		try {
+		tag=def.create("arch", "Foo");
+		fail("expected TCKDefinitionException");
+		} catch(TCKDefinitionException te) {
+			
+		}
+		
+	}
+	public void testVMVendorTag() throws TCKDefinitionException {
+		
+		TCKTagFactory def=new TCKTagFactory();
+		
+		TCKTestTag tag=def.create("vmvendor", "ibm");
+		assertNotNull(tag);
+		
+		tag=def.create("vmvendor", "sun");
+		assertNotNull(tag);
+		
+		try {
+		tag=def.create("vmvendor", "Foo");
+		fail("expected TCKDefinitionException");
+		} catch(TCKDefinitionException te) {
+			
+		}
+		
+	}
+}



Mime
View raw message