incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r834545 - in /incubator/kato/trunk/org.apache.kato/kato.anttasks: ./ src/main/java/org/apache/kato/anttasks/tck/ src/main/resources/org/apache/kato/anttasks/ src/test/ant/ src/test/java/test/ src/test/java/test/org/ src/test/java/test/org/a...
Date Tue, 10 Nov 2009 16:59:05 GMT
Author: spoole
Date: Tue Nov 10 16:59:05 2009
New Revision: 834545

URL: http://svn.apache.org/viewvc?rev=834545&view=rev
Log:
added new ant task to setup tck scenarios

Added:
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/Scenario.java
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/DummySetupClass.java
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/TestTCKSetupTask.java
Modified:
    incubator/kato/trunk/org.apache.kato/kato.anttasks/   (props changed)
    incubator/kato/trunk/org.apache.kato/kato.anttasks/pom.xml
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/resources/org/apache/kato/anttasks/anttasks.properties

Propchange: incubator/kato/trunk/org.apache.kato/kato.anttasks/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 10 16:59:05 2009
@@ -0,0 +1 @@
+target

Modified: incubator/kato/trunk/org.apache.kato/kato.anttasks/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/pom.xml?rev=834545&r1=834544&r2=834545&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/pom.xml (original)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/pom.xml Tue Nov 10 16:59:05 2009
@@ -40,11 +40,16 @@
 		<dependency>
 			<groupId>com.sun</groupId>
 			<artifactId>tools</artifactId>
-			<version>1.6</version>
+			<version>1.4</version>
 			<scope>system</scope>
 			<systemPath>${java.home}/../lib/tools.jar</systemPath>
 		</dependency>
-		
+		<dependency>
+		<groupId>junit</groupId>
+		<artifactId>junit</artifactId>
+		<version>3.8.1</version>
+		<scope>test</scope>
+	</dependency>
 		<dependency>
 		 
     <groupId>net.sourceforge.nekohtml</groupId>
@@ -59,8 +64,8 @@
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-compiler-plugin</artifactId>
 				<configuration>
-					<source>1.6</source>
-					<target>1.6</target>
+					<source>1.4</source>
+					<target>1.4</target>
 				</configuration>
 				<dependencies>
       <dependency>
@@ -71,6 +76,39 @@
       			
    </dependencies>
 			</plugin>
+			
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<version>1.3</version>
+				<executions>
+					<execution>
+						<id>compile</id>
+						<phase>test</phase>
+						<configuration>
+							<tasks>
+								<ant antfile="testtags.xml" dir="src/test/ant">
+									<property name="target" location="${project.build.directory}/classes" />
+									<property name="tests" location="${project.build.directory}/testclasses" />
+									<property name="path" refid="maven.runtime.classpath" />
+								</ant>
+							</tasks>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
+				</executions>
+				<dependencies>
+					<dependency>
+            			<groupId>ant</groupId>
+            			<artifactId>ant-trax</artifactId>
+            			<version>1.6.5</version>
+          			</dependency>    
+        			 
+				
+				</dependencies>
+				</plugin>
 		</plugins>
 	</build>
 </project>

Added: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/Scenario.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/Scenario.java?rev=834545&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/Scenario.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/Scenario.java
Tue Nov 10 16:59:05 2009
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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 org.apache.kato.anttasks.tck;
+
+import org.apache.tools.ant.BuildException;
+
+public class Scenario {
+
+	 String scenerio=null;
+	 String classname=null;
+	
+	public void setName(String name) {
+		if(classname!=null) throw new BuildException("cannot have name and classname attributes
on scenerio tag");
+		this.scenerio=name;
+	}
+	public void setClass(String name) {
+		if(scenerio!=null) throw new BuildException("cannot have name and classname attributes
on scenerio tag");
+		this.classname=name;
+	}
+}
+

Added: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java?rev=834545&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
Tue Nov 10 16:59:05 2009
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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 org.apache.kato.anttasks.tck;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.types.Commandline.Argument;
+import org.apache.tools.ant.types.Environment.Variable;
+
+/**
+ * Convinience wrapper to drive the TCK setup class
+ * Takes the provided config and extracts from the setup classes
+ * any further configuration.  These are added after those provided
+ * by the caller
+ *  
+ */
+public class TCKSetupTask extends Java {
+
+	private boolean validateOnly=false;
+	
+	private List envvars=new LinkedList();
+	private List scenerios=new LinkedList();
+	
+	public TCKSetupTask() {
+		super.setFork(true);
+		super.setFailonerror(true);
+		super.setClassname("org.apache.kato.tck.harness.ScenarioLauncher");
+	}
+
+	@Override
+	public void setFork(boolean s) {
+		throw new BuildException("cannot set fork on setup task");
+	}
+
+	@Override
+	public void setFailonerror(boolean s) {
+		throw new BuildException("cannot set fail on error on setup task");
+	}
+	@Override
+	public void execute() throws BuildException {
+		
+		configureScenerios();
+		
+		
+		if(validateOnly) {
+			validate();
+			return;
+		}
+		// get env details etc
+		super.execute();
+	}
+
+	/**
+	 * 
+	 */
+	private void configureScenerios() {
+		
+		// add scenerios defs to arguments
+		if(scenerios.isEmpty()) {
+			
+			Argument arg=createArg();
+			arg.setValue("-scenario");
+			arg=createArg();
+			arg.setValue("142");
+		}
+		else {
+			Iterator i=scenerios.iterator();
+			while(i.hasNext()) {
+				Scenario scenerio=(Scenario) i.next();
+				if(scenerio.classname==null && scenerio.scenerio==null) {
+					throw new BuildException("scenario tag must have a name or classname attribute");
+				}
+				if(scenerio.scenerio==null) {
+					Argument arg=createArg();
+					arg.setValue("-class");
+					arg=createArg();
+					arg.setValue(scenerio.classname);
+				} else {
+					Argument arg=createArg();
+					arg.setValue("-scenario");
+					arg=createArg();
+					arg.setValue(scenerio.scenerio);
+				}
+			}
+		}
+		
+		
+	}
+
+	/**
+	 * Lists out validation details
+	 */
+	private void validate() {
+		
+		
+		// report execution environment
+		System.out.println(getCommandLine().toString());
+		Iterator vars=envvars.iterator();
+		while(vars.hasNext()) {
+			Variable v=(Variable) vars.next();
+			System.out.println("envvar key="+v.getKey()+" value="+v.getValue());
+		}
+	
+		
+	}
+
+	
+	@Override
+	public void setClassname(String s) throws BuildException {
+		throw new BuildException("cannot set classname on setup task");
+		
+	}
+	
+	public void setValidateonly(boolean value) {
+		validateOnly=value;
+	}
+
+	/**
+	 * @return
+	 */
+	public boolean isValidateOnly() {
+		return validateOnly;
+	}
+
+	@Override
+	public void addEnv(Variable var) {
+		
+		super.addEnv(var);
+		envvars.add(var); // keep a copy for us
+	}
+	 
+	public void addConfiguredScenario(Scenario s) {
+		scenerios.add(s);
+	}
+
+}

Modified: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/resources/org/apache/kato/anttasks/anttasks.properties
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/resources/org/apache/kato/anttasks/anttasks.properties?rev=834545&r1=834544&r2=834545&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/resources/org/apache/kato/anttasks/anttasks.properties
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/resources/org/apache/kato/anttasks/anttasks.properties
Tue Nov 10 16:59:05 2009
@@ -13,4 +13,5 @@
 #-------------------------------------------------------------------------------
 sitebuilder=org.apache.kato.anttasks.sitebuilder.SiteBuilder
 tcklistbuilder=org.apache.kato.anttasks.tcklistbuilder.TCKListBuilder
-xmljavadoc=org.apache.kato.anttasks.xmlgen.XMLJavaDocGenerator
\ No newline at end of file
+xmljavadoc=org.apache.kato.anttasks.xmlgen.XMLJavaDocGenerator
+tcksetup=org.apache.kato.anttasks.tck.TCKSetupTask
\ No newline at end of file

Added: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml?rev=834545&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml (added)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml Tue Nov 10
16:59:05 2009
@@ -0,0 +1,72 @@
+<project default="all">
+
+	<taskdef resource="org/apache/kato/anttasks/anttasks.properties">
+		<classpath path="${target}" />
+	</taskdef>
+
+	<target name="all" depends="tcksetup" />
+
+
+	<target name="tcksetup">
+
+		<antcall target="tcksetup1" />
+		<antcall target="tcksetup2" />
+		<antcall target="tcksetup3" />
+		<antcall target="tcksetup4" />
+		<antcall target="tcksetup5" />
+		<antcall target="tcksetup6" />
+	</target>
+
+
+	<target name="tcksetup1">
+
+		<tcksetup validateonly="true">
+			<classpath path="${tests}" />
+		</tcksetup>
+
+	</target>
+
+	<target name="tcksetup2">
+
+		<tcksetup validateonly="true">
+			<classpath path="${tests}" />
+			<jvmarg value="-showversion" />
+		</tcksetup>
+
+	</target>
+	
+	<target name="tcksetup3">
+
+		<tcksetup validateonly="true">
+			<classpath path="${tests}" />
+			<sysproperty key="foo" value="bar" />
+		</tcksetup>
+
+	</target>
+	<target name="tcksetup4">
+
+		<tcksetup validateonly="true">
+			<classpath path="${tests}" />
+			<env key="foo" value="bar" />
+		</tcksetup>
+
+	</target>
+	<target name="tcksetup5">
+
+		<tcksetup validateonly="true" >
+			<classpath path="${tests}" />
+			<scenario name="142" />
+		</tcksetup>
+
+	</target>
+	
+	<target name="tcksetup6">
+
+			<tcksetup validateonly="true" >
+				<classpath path="${tests}" />
+				<scenario class="org.wibble.foo" />
+			</tcksetup>
+
+		</target>
+
+</project>
\ No newline at end of file

Added: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/DummySetupClass.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/DummySetupClass.java?rev=834545&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/DummySetupClass.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/DummySetupClass.java
Tue Nov 10 16:59:05 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 test.org.apache.kato.anttasks.tck;
+
+/**
+ * 
+ */
+public class DummySetupClass {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		
+
+	}
+
+}

Added: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/TestTCKSetupTask.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/TestTCKSetupTask.java?rev=834545&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/TestTCKSetupTask.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/java/test/org/apache/kato/anttasks/tck/TestTCKSetupTask.java
Tue Nov 10 16:59:05 2009
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.org.apache.kato.anttasks.tck;
+
+import org.apache.kato.anttasks.tck.TCKSetupTask;
+import org.apache.tools.ant.BuildException;
+
+import junit.framework.TestCase;
+
+
+public class TestTCKSetupTask extends TestCase {
+
+	
+	public void testNew() {
+		new TCKSetupTask();
+	}
+	public void testSetForkTrue() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setFork(true);
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	public void testSetForkFalse() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setFork(false);
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	public void testSetFailOnerrorTrue() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setFailonerror(true);
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	public void testSetFailOnerrorFalse() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setFailonerror(false);
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	public void testSetClassnameNull() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setClassname(null);
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	public void testSetClassnameSomething() {
+		TCKSetupTask task=new TCKSetupTask();
+		try {
+		task.setClassname("xxx");
+		fail("expected BuildException");
+		} catch(BuildException e) {
+			; // expected
+		}
+	}
+	
+	public void testSetValidateOnlyTrue() {
+		TCKSetupTask task=new TCKSetupTask();
+		task.setValidateonly(true);
+		assertTrue(task.isValidateOnly());
+	}
+	public void testSetValidateOnlyFalse() {
+		TCKSetupTask task=new TCKSetupTask();
+		task.setValidateonly(false);
+		assertFalse(task.isValidateOnly());
+	}
+	
+	public void testAddEnvVar() {
+		TCKSetupTask task=new TCKSetupTask();
+		task.addEnv(null);
+	}
+	
+}



Mime
View raw message