From: <ble...@us...> - 2010-10-12 19:31:17
|
Revision: 3775 http://bigdata.svn.sourceforge.net/bigdata/?rev=3775&view=rev Author: blevine218 Date: 2010-10-12 19:31:09 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Re-whack @IngoreIf to take a class that executes the test. Move all classes into new com.bigdata.test.conditional sub-package. Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalParameterized.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalRunner.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/FalseCondition.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/IgnoreIf.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/LongTestsExcluded.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIf.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnIgnoredClass.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnNotIgnoredClass.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TrueCondition.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalParameterized.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalRunner.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/IgnoreIf.java Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalParameterized.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalParameterized.java 2010-10-12 17:53:12 UTC (rev 3774) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalParameterized.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -1,127 +0,0 @@ -package com.bigdata.test; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.junit.runner.Runner; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.Suite; -import org.junit.runners.Parameterized.Parameters; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; -import org.junit.runners.model.TestClass; - -/** - * Similar to the Parameterized runner but uses a ConditionalRunner rather than the default - * runner when generating the parameterized test instances. - * - * @author blevine - * - */ -public class ConditionalParameterized extends Suite -{ - - private final ArrayList<Runner> runners = new ArrayList<Runner>(); - - /** - * Constructor - * - * @param klass - * @throws Throwable - */ - public ConditionalParameterized(Class<?> klass) throws Throwable - { - super(klass, Collections.<Runner> emptyList()); - List<Object[]> parametersList = getParametersList(getTestClass()); - - for (int i = 0; i < parametersList.size(); i++) - { - runners.add(new TestClassRunnerForParameters(getTestClass().getJavaClass(), parametersList, i)); - } - } - - @Override - protected List<Runner> getChildren() - { - return runners; - } - - @SuppressWarnings("unchecked") - private List<Object[]> getParametersList(TestClass klass) throws Throwable - { - return (List<Object[]>) getParametersMethod(klass).invokeExplosively(null); - } - - private FrameworkMethod getParametersMethod(TestClass testClass) throws Exception - { - List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class); - for (FrameworkMethod each : methods) - { - int modifiers = each.getMethod().getModifiers(); - if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) - return each; - } - - throw new Exception("No public static parameters method on class " + testClass.getName()); - } - - - private class TestClassRunnerForParameters extends ConditionalRunner - { - private final int parmSetNumber; - private final List<Object[]> parmList; - - TestClassRunnerForParameters(Class<?> type, List<Object[]> parameterList, int i) throws InitializationError - { - super(type); - parmList = parameterList; - parmSetNumber = i; - } - - @Override - public Object createTest() throws Exception - { - return getTestClass().getOnlyConstructor().newInstance(computeParams()); - } - - private Object[] computeParams() throws Exception - { - try - { - return parmList.get(parmSetNumber); - } - catch (ClassCastException e) - { - throw new Exception(String.format("%s.%s() must return a Collection of arrays.", getTestClass().getName(), getParametersMethod(getTestClass()).getName())); - } - } - - @Override - protected String getName() - { - return String.format("[%s]", parmSetNumber); - } - - @Override - protected String testName(final FrameworkMethod method) - { - return String.format("%s[%s]", method.getName(), parmSetNumber); - } - - @Override - protected void validateConstructor(List<Throwable> errors) - { - validateOnlyOneConstructor(errors); - } - - @Override - protected Statement classBlock(RunNotifier notifier) - { - return childrenInvoker(notifier); - } - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalRunner.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalRunner.java 2010-10-12 17:53:12 UTC (rev 3774) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalRunner.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -1,100 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.bigdata.test; - -import org.junit.internal.runners.model.EachTestNotifier; -import org.junit.runner.Description; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; - -/** - * A subclass of the default JUnit runner that checks for and process the @IgnoreIf conditional annotation - * - * @author blevine - * - */ -public class ConditionalRunner extends BlockJUnit4ClassRunner -{ - - /** - * Constructor - * - * @param klass - * @throws InitializationError - */ - public ConditionalRunner(Class<?> klass) throws InitializationError - { - super(klass); - } - - /* (non-Javadoc) - * @see org.junit.runners.BlockJUnit4ClassRunner#runChild(org.junit.runners.model.FrameworkMethod, org.junit.runner.notification.RunNotifier) - */ - @Override - protected void runChild(FrameworkMethod method, RunNotifier notifier) - { - // Is the annotation on the method? - IgnoreIf ann = method.getAnnotation(IgnoreIf.class); - - // Is the annotation on the class? - if (ann == null) - { - ann = method.getMethod().getDeclaringClass().getAnnotation(IgnoreIf.class); - } - - // If we found the annotation on the method or it's declaring class, check the condition - // and if true, skip this method (test case). - if (ann != null) - { - boolean condition = ann.value(); - - if (condition) - { - EachTestNotifier eachNotifier = makeNotifier(method, notifier); - eachNotifier.fireTestIgnored(); - return; - } - } - - // If we didn't find the annotation or if the annotation's condition evaluated to false process - // the test case normally. - - super.runChild(method, notifier); - } - - /** - * Unfortunately declared private in super-class. Cloned from there - * - * @param method - * @param notifier - * @return - */ - private EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) - { - Description description = describeChild(method); - return new EachTestNotifier(notifier, description); - } -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/IgnoreIf.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/IgnoreIf.java 2010-10-12 17:53:12 UTC (rev 3774) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/IgnoreIf.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -1,41 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package com.bigdata.test; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A conditional implementation of Junit's @Ignore annotation - * @author blevine - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface IgnoreIf { - boolean value() default true; -} - Copied: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalParameterized.java (from rev 3772, branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalParameterized.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalParameterized.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalParameterized.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,150 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.test.conditional; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.junit.runner.Runner; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.Suite; +import org.junit.runners.Parameterized.Parameters; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; +import org.junit.runners.model.TestClass; + +/** + * Similar to the standard JUnit Parameterized runner but uses a ConditionalRunner rather than the default + * runner when generating the parameterized test proxies. + * + * @author blevine + * + */ +public class ConditionalParameterized extends Suite +{ + + private final ArrayList<Runner> runners = new ArrayList<Runner>(); + + /** + * Constructor + * + * @param klass + * @throws Throwable + */ + public ConditionalParameterized(Class<?> klass) throws Throwable + { + super(klass, Collections.<Runner> emptyList()); + List<Object[]> parametersList = getParametersList(getTestClass()); + + for (int i = 0; i < parametersList.size(); i++) + { + runners.add(new TestClassRunnerForParameters(getTestClass().getJavaClass(), parametersList, i)); + } + } + + @Override + protected List<Runner> getChildren() + { + return runners; + } + + @SuppressWarnings("unchecked") + private List<Object[]> getParametersList(TestClass klass) throws Throwable + { + return (List<Object[]>) getParametersMethod(klass).invokeExplosively(null); + } + + private FrameworkMethod getParametersMethod(TestClass testClass) throws Exception + { + List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class); + for (FrameworkMethod each : methods) + { + int modifiers = each.getMethod().getModifiers(); + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) + return each; + } + + throw new Exception("No public static parameters method on class " + testClass.getName()); + } + + + private class TestClassRunnerForParameters extends ConditionalRunner + { + private final int parmSetNumber; + private final List<Object[]> parmList; + + TestClassRunnerForParameters(Class<?> type, List<Object[]> parameterList, int i) throws InitializationError + { + super(type); + parmList = parameterList; + parmSetNumber = i; + } + + @Override + public Object createTest() throws Exception + { + return getTestClass().getOnlyConstructor().newInstance(computeParams()); + } + + private Object[] computeParams() throws Exception + { + try + { + return parmList.get(parmSetNumber); + } + catch (ClassCastException e) + { + throw new Exception(String.format("%s.%s() must return a Collection of arrays.", getTestClass().getName(), getParametersMethod(getTestClass()).getName())); + } + } + + @Override + protected String getName() + { + return String.format("[%s]", parmSetNumber); + } + + @Override + protected String testName(final FrameworkMethod method) + { + return String.format("%s[%s]", method.getName(), parmSetNumber); + } + + @Override + protected void validateConstructor(List<Throwable> errors) + { + validateOnlyOneConstructor(errors); + } + + @Override + protected Statement classBlock(RunNotifier notifier) + { + return childrenInvoker(notifier); + } + } + +} Copied: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalRunner.java (from rev 3772, branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/ConditionalRunner.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalRunner.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/ConditionalRunner.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,132 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.bigdata.test.conditional; + +import java.lang.reflect.Method; + +import org.junit.internal.runners.model.EachTestNotifier; +import org.junit.runner.Description; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; + +/** + * A subclass of the default JUnit standard runner that checks for and processes the @IgnoreIf + * conditional annotation + * + * @author blevine + * + */ +public class ConditionalRunner extends BlockJUnit4ClassRunner +{ + + /** + * Constructor + * + * @param klass + * @throws InitializationError + */ + public ConditionalRunner(Class<?> klass) throws InitializationError + { + super(klass); + } + + /* (non-Javadoc) + * @see org.junit.runners.BlockJUnit4ClassRunner#runChild(org.junit.runners.model.FrameworkMethod, org.junit.runner.notification.RunNotifier) + */ + @Override + protected void runChild(FrameworkMethod method, RunNotifier notifier) + { + // Is the annotation on the method? + IgnoreIf ann = method.getAnnotation(IgnoreIf.class); + + // Is the annotation on the class? + if (ann == null) + { + ann = method.getMethod().getDeclaringClass().getAnnotation(IgnoreIf.class); + } + + // If we found the annotation on the method or it's declaring class, check the condition + // and if true, skip this method (test case). + if (ann != null) + { + Class<?> conditionalClass = ann.value(); + + if (conditionalClass != null) + { + String conditionalClassName = conditionalClass.getName(); + // Does the conditional class have a public static boolean test() method? If so, invoke it. + // If not, it's an error. + try + { + Method testMethod = conditionalClass.getMethod("test"); + Class<?> returnType = testMethod.getReturnType(); + + if ((returnType) == null || (returnType != Boolean.TYPE)) + { + throw new IllegalArgumentException("@IgnoreIf conditional class, " + conditionalClassName + + " must have a static no arg 'test' method that returns boolean"); + } + + Boolean result = (Boolean)testMethod.invoke(null); + + if (result) + { + EachTestNotifier eachNotifier = makeNotifier(method, notifier); + eachNotifier.fireTestIgnored(); + return; + } + } + catch (Exception e) + { + throw new IllegalArgumentException("@IgnoreIf conditional class, " + conditionalClassName + + " must have a static no arg 'test' method that returns boolean"); + } + } + else + { + throw new IllegalArgumentException("No class specified for @IgnoreIf annotation."); + } + } + + // If we didn't find the annotation or if the annotation's condition evaluated to false process + // the test case normally. + + super.runChild(method, notifier); + } + + /** + * Unfortunately declared private in super-class. Cloned from there + * + * @param method + * @param notifier + * @return + */ + private EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) + { + Description description = describeChild(method); + return new EachTestNotifier(notifier, description); + } +} Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/FalseCondition.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/FalseCondition.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/FalseCondition.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,36 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.test.conditional; + +/** + * @author blevine + * + */ +public class FalseCondition +{ + public static boolean test() + { + return false; + } +} Copied: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/IgnoreIf.java (from rev 3772, branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/IgnoreIf.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/IgnoreIf.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/IgnoreIf.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,41 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.test.conditional; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A conditional implementation of Junit's @Ignore annotation + * @author blevine + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +public @interface IgnoreIf { + Class<?> value(); +} + Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/LongTestsExcluded.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/LongTestsExcluded.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/LongTestsExcluded.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,40 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.test.conditional; + +/** + * Tests whether long-running unit tests should be included in the set of executed tests. + * Used in conjunction with the @IgnoreIf annotation. + * + * @author blevine + * + */ +public class LongTestsExcluded +{ + private final static String INCLUDE_LONG_TESTS_PROP = "com.bigdata.test.includeLongTests"; + public final static boolean test() + { + return !Boolean.getBoolean(INCLUDE_LONG_TESTS_PROP); + } +} Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIf.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIf.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIf.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,57 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.bigdata.test.conditional; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * @author blevine + * + */ +@RunWith(ConditionalRunner.class) +public class TestIgnoreIf +{ + @Test + public void includedTest() + { + System.out.println("Included test!"); + } + + @Test + @IgnoreIf(FalseCondition.class) + public void includedTest2() + { + System.out.println("Included test 2!"); + } + + @Test + @IgnoreIf(TrueCondition.class) + public void excludedTest() + { + Assert.fail("This test should have been excluded!"); + } +} Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnIgnoredClass.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnIgnoredClass.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnIgnoredClass.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,58 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.bigdata.test.conditional; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * @author blevine + * + */ +@RunWith(ConditionalRunner.class) +@IgnoreIf(TrueCondition.class) +public class TestIgnoreIfOnIgnoredClass +{ + @Test + public void test1() + { + Assert.fail("Test should have been ignored"); + } + + @Test + public void test2() + { + Assert.fail("Test should have been ignored");; + } + + @Test + @IgnoreIf(FalseCondition.class) + public void test3() + { + System.out.println("Test3!!"); + } + +} Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnNotIgnoredClass.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnNotIgnoredClass.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TestIgnoreIfOnNotIgnoredClass.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,58 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.bigdata.test.conditional; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * @author blevine + * + */ +@RunWith(ConditionalRunner.class) +@IgnoreIf(FalseCondition.class) +public class TestIgnoreIfOnNotIgnoredClass +{ + @Test + public void test1() + { + System.out.println("Test1!"); + } + + @Test + public void test2() + { + System.out.println("Test2!"); + } + + @Test + @IgnoreIf(TrueCondition.class) + public void test3() + { + Assert.fail("This test should have been ignored."); + } + +} Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TrueCondition.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TrueCondition.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/test/conditional/TrueCondition.java 2010-10-12 19:31:09 UTC (rev 3775) @@ -0,0 +1,36 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.test.conditional; + +/** + * @author blevine + * + */ +public class TrueCondition +{ + public static boolean test() + { + return true; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |