1 /* 2 * UnitTest.java 3 * 4 * Created on 08 October 2002, 16:17 5 * 6 * $Header: /cvsroot/ebxmlrr/ebxmlrr/test/com/sun/ebxml/registry/UnitTest.java,v 1.5 2002/12/27 13:29:53 ritzmann Exp $ 7 * 8 */ 9 10 package com.sun.ebxml.registry; 11 12 import junit.framework.*; 13 import com.sun.ebxml.registry.interfaces.soap.*; 14 import javax.xml.soap.*; 15 import java.io.*; 16 import com.sun.ebxml.registry.conformance.*; 17 import java.util.*; 18 /*** 19 * 20 * @author mzaremba 21 */ 22 23 public class UnitTest extends TestCase { 24 25 private SOAPSender sender; 26 private SOAPMessage reply; 27 private TestSupport supportMethods; 28 private static String url = null; 29 private static String sysSeparator; 30 private static String unitTestsDir; 31 32 private String fileName =""; 33 34 public UnitTest(String name){ 35 super(name); 36 sysSeparator = System.getProperty("file.separator"); 37 unitTestsDir = "misc" + sysSeparator + "samples" + 38 sysSeparator + "unitTest"; 39 String resultsDir = "misc" + sysSeparator + "samples" + 40 sysSeparator + "unitTest" + sysSeparator + "results"; 41 supportMethods = new TestSupport(unitTestsDir, resultsDir); 42 supportMethods.deleteRaport("raport.txt"); 43 try { 44 sender = supportMethods.connectRegistry(url); 45 } catch (Exception e) { 46 fail("Tests failed during Set up phase"); 47 e.printStackTrace(); 48 } 49 } 50 51 public void setUp() { 52 53 } 54 55 protected void tearDown() throws Exception { 56 System.gc(); 57 } 58 59 /*** 60 * 1.3. Predefined classification schemes 61 */ 62 public void testUnitTest() { 63 try { 64 supportMethods.printMessage("SUBMIT FILE: " + fileName); 65 supportMethods.submitFileToRegistry(sender, fileName); 66 } catch(Exception e) { 67 fail("Exception has been thrown during setting" + 68 " Pre-defined classification schemes by " + fileName); 69 e.printStackTrace(); 70 } 71 } 72 73 public void setTestName(String name){ 74 fileName = name; 75 } 76 77 /*** 78 * Add tests to the suite 79 */ 80 public static Test suite() { 81 TestSuite suite = new TestSuite(); 82 File unitFilesDir = new File(unitTestsDir); 83 String[] unitFiles = unitFilesDir.list(); 84 if (unitFiles.length !=0) { 85 Arrays.sort(unitFiles); 86 } 87 for (int i=0; i < unitFiles.length; i++) { 88 if (new File(unitTestsDir + sysSeparator + unitFiles[i]).isFile()) { 89 if (unitFiles[i].substring(unitFiles[i].lastIndexOf('.') + 1, 90 unitFiles[i].length()).equalsIgnoreCase("xml")) { 91 UnitTest test = new UnitTest("testUnitTest"); 92 test.setTestName(unitFiles[i]); 93 suite.addTest(test); 94 } 95 } 96 } 97 return suite; 98 } 99 100 public void runMyTests(boolean unpackTests) { 101 String[] filesList = null; 102 try { 103 TestSuite suite = new TestSuite(); 104 if(unpackTests) { 105 filesList = supportMethods.unZipAllFiles(); 106 } 107 suite.addTest(suite()); 108 TestResult result = new TestResult(); 109 suite.run(result); 110 supportMethods.processResults("", result); 111 supportMethods.printRaport("UNIT TESTS", false); 112 } finally { 113 if(unpackTests) { 114 supportMethods.removeFiles(filesList); 115 } 116 } 117 } 118 119 public static void main(String[] args) { 120 boolean condition = false; 121 if (args.length != 0 && args[0].startsWith("useZips")) { 122 condition = true; 123 } 124 url = TestSupport.getURL(args); 125 new UnitTest("testUnitTest").runMyTests(condition); 126 } 127 }

This page was automatically generated by Maven