Path: blob/master/test/functional/Jsr292/src/com/ibm/j9/jsr292/JSR292TestSuite.java
6007 views
/*******************************************************************************1* Copyright (c) 2001, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21package com.ibm.j9.jsr292;2223import java.util.Enumeration;24import junit.framework.TestResult;2526/**27* @author mesbaha28* This class extends the default junit.framework.TestSuite class and redefines the run() method29* in order to run only the test cases that are not in a given exclude list for this test suite.30*/31public class JSR292TestSuite extends junit.framework.TestSuite {3233private String excludeList;3435/**36* Default constructor37* @param name - Name of the test suite38* @param ignoreTestCaseList - A comma separated list of test cases to ignore39*/40public JSR292TestSuite( String name, String excludeList ) {41super( name );42this.excludeList = excludeList;43}4445/* ( non-Javadoc )46* @see junit.framework.TestSuite#run( junit.framework.TestResult )47* Overridden version of TestSuite.run() method which invokes the new run( TestSuite, TestResult ) method48* in order to ensure we use test filtering.49* @param result - This TestResult object to use for result reporting50*/51public void run( TestResult result ) {52run( this, result );53}5455/**56* This method runs all test cases from this test suite but the ones found in the given ignore list57* @param suite - This TestSuite object58* @param result - The TestResult object to use59*/60public void run( junit.framework.TestSuite suite, TestResult result ) {61@SuppressWarnings( "rawtypes" )62Enumeration en = suite.tests();63while ( en.hasMoreElements() ) {64junit.framework.Test test = ( junit.framework.Test )en.nextElement();65if ( test instanceof junit.framework.TestSuite ) {66run( ( junit.framework.TestSuite )test, result );67} else {68junit.framework.TestCase testCase = ( junit.framework.TestCase )test;69//Ignore test cases from the exclude list70if ( excludeList == null || excludeList.contains( testCase.getName() ) == false ) {71super.runTest( testCase, result );72}73}74}75}76}777879