List of usage examples for junit.framework TestSuite TestSuite
TestSuite
From source file:org.apache.ddlutils.TestAgainstLiveDatabaseBase.java
/** * Creates the test suite for the given test class which must be a sub class of * {@link RoundtripTestBase}. If the platform supports it, it will be tested * with both delimited and undelimited identifiers. * /* ww w .j av a 2s .com*/ * @param testedClass The tested class * @return The tests */ protected static TestSuite getTests(Class testedClass) { if (!TestAgainstLiveDatabaseBase.class.isAssignableFrom(testedClass) || Modifier.isAbstract(testedClass.getModifiers())) { throw new DdlUtilsException("Cannot create parameterized tests for class " + testedClass.getName()); } TestSuite suite = new TestSuite(); Properties props = readTestProperties(); if (props == null) { return suite; } DataSource dataSource = initDataSourceFromProperties(props); String databaseName = determineDatabaseName(props, dataSource); try { Method[] methods = testedClass.getMethods(); PlatformInfo info = null; TestAgainstLiveDatabaseBase newTest; for (int idx = 0; (methods != null) && (idx < methods.length); idx++) { if (methods[idx].getName().startsWith("test") && ((methods[idx].getParameterTypes() == null) || (methods[idx].getParameterTypes().length == 0))) { newTest = (TestAgainstLiveDatabaseBase) testedClass.newInstance(); newTest.setName(methods[idx].getName()); newTest.setTestProperties(props); newTest.setDataSource(dataSource); newTest.setDatabaseName(databaseName); newTest.setUseDelimitedIdentifiers(false); suite.addTest(newTest); if (info == null) { info = PlatformFactory.createNewPlatformInstance(newTest.getDatabaseName()) .getPlatformInfo(); } if (info.isDelimitedIdentifiersSupported()) { newTest = (TestAgainstLiveDatabaseBase) testedClass.newInstance(); newTest.setName(methods[idx].getName()); newTest.setTestProperties(props); newTest.setDataSource(dataSource); newTest.setDatabaseName(databaseName); newTest.setUseDelimitedIdentifiers(true); suite.addTest(newTest); } } } } catch (Exception ex) { throw new DdlUtilsException(ex); } return suite; }
From source file:org.apache.directory.fortress.core.impl.AccelMgrImplTest.java
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new AccelMgrImplTest("testCreateSession")); suite.addTest(new AccelMgrImplTest("testCreateSessionWithRole")); suite.addTest(new AccelMgrImplTest("testCheckAccess")); suite.addTest(new AccelMgrImplTest("testAddActiveRole")); suite.addTest(new AccelMgrImplTest("testDropActiveRole")); return suite; }
From source file:org.apache.directory.fortress.core.impl.AccessMgrImplTest.java
public static Test suite() { TestSuite suite = new TestSuite(); //suite.addTest(new AccessMgrImplTest("testDropActiveRole")); /*/*from w w w .j a v a 2 s . c o m*/ suite.addTest( new AdminMgrImplTest( "testResetPassword" ) ); suite.addTest( new AccessMgrImplTest( "testAuthenticateReset" ) ); suite.addTest( new AdminMgrImplTest( "testChangePassword" ) ); suite.addTest( new AccessMgrImplTest( "testAuthenticate" ) ); suite.addTest( new AdminMgrImplTest( "testLockUserAccount" ) ); suite.addTest( new AccessMgrImplTest( "testAuthenticateLocked" ) ); suite.addTest( new AdminMgrImplTest( "testUnlockUserAccount" ) ); */ suite.addTest(new AccessMgrImplTest("testCheckAccess")); return suite; }
From source file:org.apache.fop.fotreetest.FOTreeTestSuite.java
/** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem *///from w ww . j a va 2 s. co m public static Test suite() throws IOException { TestSuite suite = new TestSuite(); addXMLTestCases(suite); addUnitTestCases(suite); return suite; }
From source file:org.apache.fop.intermediate.AreaTreeXMLFormatTestSuite.java
/** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem *///from ww w .j av a2 s . c o m public static Test suite() throws IOException { TestSuite suite = new TestSuite(); Collection files = LayoutEngineTestSuite.getTestFiles(); Iterator i = files.iterator(); while (i.hasNext()) { File f = (File) i.next(); addATTestCase(suite, f); } return suite; }
From source file:org.apache.fop.intermediate.IntermediateFormatTestSuite.java
/** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem */// w ww. j a v a 2 s. c o m public static Test suite() throws IOException { TestSuite suite = new TestSuite(); Collection files = LayoutEngineTestSuite.getTestFiles(); Iterator i = files.iterator(); while (i.hasNext()) { File f = (File) i.next(); addIFTestCase(suite, f); } return suite; }
From source file:org.apache.fop.layoutengine.LayoutEngineTestSuite.java
/** * @return the test suite with all the tests (one for each XML file) * @throws IOException in case of an I/O problem *//* w w w . j a v a 2 s .co m*/ public static Test suite() throws IOException { TestSuite suite = new TestSuite(); File backupDir = new File("build/test-results/layoutengine"); backupDir.mkdirs(); Collection files = getTestFiles(); final LayoutEngineTester tester = new LayoutEngineTester(backupDir); Iterator i = files.iterator(); while (i.hasNext()) { File f = (File) i.next(); addTestCase(suite, tester, f); } return suite; }
From source file:org.apache.ofbiz.testtools.ModelTestSuite.java
private void parseTestElement(String caseName, Element testElement) { String nodeName = testElement.getNodeName(); if ("junit-test-suite".equals(nodeName)) { String className = testElement.getAttribute("class-name"); try {/*from w w w.ja va2 s . c om*/ @SuppressWarnings("unchecked") Class<? extends TestCase> clz = (Class<? extends TestCase>) ObjectType.loadClass(className); TestSuite suite = new TestSuite(); suite.addTestSuite(clz); Enumeration<?> testEnum = suite.tests(); int testsAdded = 0; int casesAdded = 0; while (testEnum.hasMoreElements()) { Test tst = (Test) testEnum.nextElement(); this.testList.add(tst); casesAdded += tst.countTestCases(); testsAdded++; } Debug.logInfo( "Added " + testsAdded + " tests [" + casesAdded + " cases] from the class: " + className, module); } catch (Exception e) { String errMsg = "Unable to load test suite class : " + className; Debug.logError(e, errMsg, module); } } else if ("service-test".equals(nodeName)) { this.testList.add(new ServiceTest(caseName, testElement)); } else if ("simple-method-test".equals(nodeName)) { if (UtilValidate.isNotEmpty(testElement.getAttribute("name"))) { this.testList.add(new SimpleMethodTest(caseName, testElement)); } else { String methodLocation = testElement.getAttribute("location"); List<SimpleMethod> simpleMethods; try { simpleMethods = SimpleMethod.getSimpleMethodsList(methodLocation, null); for (SimpleMethod simpleMethod : simpleMethods) { String methodName = simpleMethod.getMethodName(); if (methodName.startsWith("test")) { this.testList.add( new SimpleMethodTest(caseName + "." + methodName, methodLocation, methodName)); } } } catch (MiniLangException e) { Debug.logError(e, module); } } } else if ("webdriver-test".equals(nodeName)) { try { String className = "org.apache.ofbiz.testtools.WebDriverTest"; Class<?> cl; cl = Class.forName(className); Constructor<?> con = cl.getConstructor(String.class, Element.class); this.testList.add((Test) con.newInstance(caseName, testElement)); } catch (Exception e) { Debug.logError(e, module); } } else if ("entity-xml".equals(nodeName)) { this.testList.add(new EntityXmlAssertTest(caseName, testElement)); } else if ("entity-xml-assert".equals(nodeName)) { // this is the old, deprecated name for the element, changed because it now does assert or load this.testList.add(new EntityXmlAssertTest(caseName, testElement)); } }
From source file:org.apache.ofbiz.testtools.ModelTestSuite.java
public TestSuite makeTestSuite() { TestSuite suite = new TestSuite(); suite.setName(this.getSuiteName()); for (Test tst : this.getTestList()) { prepareTest(tst);//from w w w .jav a 2 s . c om suite.addTest(tst); } return suite; }
From source file:org.apache.synapse.samples.framework.TestSamplesHandlerSuite.java
public static TestSuite suite() { //Adding all samples available populateSamplesMap();/*w ww. j av a 2 s . c om*/ ArrayList<Class> suiteClassesList = new ArrayList<Class>(); TestSuite suite = new TestSuite(); String inputSuiteName = System.getProperty("suite"); String tests = System.getProperty("tests"); String suiteName = "SamplesSuite"; //preparing suites, if specified if (inputSuiteName != null) { if (inputSuiteName.equalsIgnoreCase("message")) { suiteName = "MessageMediationSamplesSuite"; for (int i = 0; i <= 15; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("endpoint")) { suiteName = "EndpointSamplesSuite"; for (int i = 50; i <= 60; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("qos")) { suiteName = "QoSSamplesSuite"; for (int i = 100; i <= 110; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("proxy")) { suiteName = "ProxySamplesSuite"; for (int i = 150; i <= 170; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("transport")) { suiteName = "TransportSamplesSuite"; for (int i = 250; i <= 280; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("tasks")) { suiteName = "TasksSamplesSuite"; for (int i = 300; i <= 310; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("advanced")) { suiteName = "AdvancedSamplesSuite"; for (int i = 350; i <= 490; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } if (inputSuiteName.equalsIgnoreCase("eventing")) { suiteName = "EventingSamplesSuite"; for (int i = 500; i <= 510; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } } else if (tests != null) { String[] testArray = tests.split(","); suiteName = "SelectedSamplesSuite"; for (String testNum : testArray) { Class testClass = (Class) sampleClassRepo.get(testNum); if (testClass != null) { suiteClassesList.add(testClass); } } } else { suiteName = "AllSamplesSuite"; for (int i = 0; i <= 20000; i++) { Class testClass = (Class) sampleClassRepo.get(Integer.toString(i)); if (testClass != null) { suiteClassesList.add(testClass); } } } for (Class testClass : suiteClassesList) { suite.addTestSuite(testClass); log.info("Adding Sample:" + testClass); } suite.setName(suiteName); return suite; }