1 19 package org.netbeans.modules.xsl.settings; 20 21 import java.util.*; 22 import java.io.*; 23 import java.rmi.MarshalledObject ; 24 25 import junit.framework.*; 26 import org.netbeans.junit.*; 27 28 import org.openide.filesystems.FileObject; 29 30 import org.netbeans.modules.xsl.utils.TransformUtil; 31 32 36 public class TransformHistoryTest extends NbTestCase { 37 38 public TransformHistoryTest(java.lang.String testName) { 39 super(testName); 40 } 41 42 public static void main(java.lang.String [] args) { 43 junit.textui.TestRunner.run(suite()); 44 } 45 46 public static Test suite() { 47 TestSuite suite = new NbTestSuite(TransformHistoryTest.class); 48 49 return suite; 50 } 51 52 53 public void testIt () { 54 System.out.println("testIt"); 55 56 TransformHistory history = new TransformHistory(); 57 58 assertTrue ("[1/5][1/5] OK!", checkHistory (history, 1, 1, "in.xml", "trans.xsl", "out.put")); 60 assertTrue ("[1/5][1/5] OK!", checkHistory (history, 1, 1, "in.xml", null, null)); 61 assertTrue ("[2/5][1/5] OK!", checkHistory (history, 2, 1, "in2.xml", null, "out2.put")); 62 assertTrue ("[3/5][1/5] OK!", checkHistory (history, 3, 1, "in3.xml", null, "out3.put")); 63 assertTrue ("[4/5][1/5] OK!", checkHistory (history, 4, 1, "in4.xml", null, "out4.put")); 64 assertTrue ("[5/5][1/5] OK!", checkHistory (history, 5, 1, "in5.xml", null, "out5.put")); 65 assertTrue ("[6/5][1/5] OK!", checkHistory (history, 5, 1, "in6.xml", null, "out6.put")); 66 assertTrue ("Output for in6.xml is out6.put!", "out6.put".equals (history.getXMLOutput("in6.xml"))); 67 assertTrue ("Output for in.xml is null!", (history.getXMLOutput("in.xml") == null)); 68 } 69 70 71 private boolean checkHistory (TransformHistory history, int xi, int ti, String xml, String xsl, String output) { 72 history.setOverwriteOutput (!history.isOverwriteOutput()); history.setProcessOutput ((history.getProcessOutput()+1)%3); if ( xml != null ) { 76 history.addXML (xml, output); 77 } 78 if ( xsl != null ) { 79 history.addXSL (xsl, output); 80 } 81 82 if ( history.getXMLs().length != xi ) { 84 System.out.println(" history.getXMLs().length: " + history.getXMLs().length); 85 return false; 86 } 87 if ( history.getXSLs().length != ti ) { 89 System.out.println(" history.getXSLs().length: " + history.getXSLs().length); 90 return false; 91 } 92 93 TransformHistory newHistory = null; 95 try { 96 MarshalledObject marshalled = new MarshalledObject (history); 97 newHistory = (TransformHistory) marshalled.get(); 98 } catch (Exception exc) { 99 System.err.println("!!! " + exc); 100 return false; 101 } 102 103 return (history.equals (newHistory)); 105 } 106 107 } 108 | Popular Tags |