001: /*
002: * Author: Chris Seguin
003: *
004: * This software has been developed under the copyleft
005: * rules of the GNU General Public License. Please
006: * consult the GNU General Public License for more
007: * details about use and distribution of this software.
008: */
009: package org.acm.seguin.pretty;
010:
011: import org.acm.seguin.tools.builder.PrettyPrinter;
012: import java.io.File;
013: import org.acm.seguin.io.FileCopy;
014: import org.acm.seguin.junit.DirSourceTestCase;
015: import org.acm.seguin.junit.FileCompare;
016: import org.acm.seguin.pretty.sort.MultipleOrdering;
017: import org.acm.seguin.tools.RefactoryInstaller;
018: import junit.framework.*;
019:
020: /**
021: * Unit tests for the pretty printer
022: *
023: *@author Mike Atkinson
024: *@created June 17, 2003
025: */
026: public class TestPrettyPrinterJDK1_5 extends DirSourceTestCase {
027: private File checkDir;
028: private File cleanDir;
029: private File destDir;
030:
031: /**
032: * Constructor for the TestPrettyPrinter object
033: *
034: *@param name Description of Parameter
035: */
036: public TestPrettyPrinterJDK1_5(String name) {
037: super (name);
038: }
039:
040: /**
041: * A unit test for JUnit
042: */
043: public void test01() {
044: File dest = new File(destDir, "Enums.java");
045: (new FileCopy(new File(cleanDir, "Enums.java"), dest, false))
046: .run();
047:
048: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
049: tppf.setAsk(false);
050: tppf.isApplicable(dest);
051: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
052: tppf.apply(dest);
053:
054: FileCompare.assertEquals("Enums.java in error", new File(
055: checkDir, "Enums.java"), dest);
056: }
057:
058: /**
059: * A unit test for JUnit
060: */
061: public void test02() {
062: File dest = new File(destDir, "Generics.java");
063: (new FileCopy(new File(cleanDir, "Generics.java"), dest, false))
064: .run();
065:
066: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
067: tppf.setAsk(false);
068: tppf.isApplicable(dest);
069: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
070: tppf.apply(dest);
071:
072: FileCompare.assertEquals("Generics.java in error", new File(
073: checkDir, "Generics.java"), dest);
074: }
075:
076: /**
077: * A unit test for JUnit
078: */
079: public void test03() {
080: File dest = new File(destDir, "Card.java");
081: (new FileCopy(new File(cleanDir, "Card.java"), dest, false))
082: .run();
083:
084: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
085: tppf.setAsk(false);
086: tppf.isApplicable(dest);
087: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
088: tppf.apply(dest);
089:
090: FileCompare.assertEquals("Card.java in error", new File(
091: checkDir, "Card.java"), dest);
092: }
093:
094: /**
095: * A unit test for JUnit
096: */
097: public void test04() {
098: File dest = new File(destDir, "GenericCollections.java");
099: (new FileCopy(new File(cleanDir, "GenericCollections.java"),
100: dest, false)).run();
101:
102: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
103: tppf.setAsk(false);
104: tppf.isApplicable(dest);
105: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
106: tppf.apply(dest);
107:
108: FileCompare.assertEquals("GenericCollections.java in error",
109: new File(checkDir, "GenericCollections.java"), dest);
110: }
111:
112: /**
113: * A unit test for JUnit
114: */
115: public void test05() {
116: File dest = new File(destDir, "Wildcard.java");
117: (new FileCopy(new File(cleanDir, "Wildcard.java"), dest, false))
118: .run();
119:
120: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
121: tppf.setAsk(false);
122: tppf.isApplicable(dest);
123: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
124: tppf.apply(dest);
125:
126: FileCompare.assertEquals("Wildcard.java in error", new File(
127: checkDir, "Wildcard.java"), dest);
128: }
129:
130: /**
131: * A unit test for JUnit
132: */
133: public void test06() {
134: File dest = new File(destDir, "MoreTests.java");
135: (new FileCopy(new File(cleanDir, "MoreTests.java"), dest, false))
136: .run();
137:
138: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
139: tppf.setAsk(false);
140: tppf.isApplicable(dest);
141: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
142: tppf.apply(dest);
143:
144: FileCompare.assertEquals("MoreTests.java in error", new File(
145: checkDir, "MoreTests.java"), dest);
146: }
147:
148: /**
149: * A unit test for JUnit
150: */
151: public void test07() {
152: File dest = new File(destDir, "Annotations.java");
153: (new FileCopy(new File(cleanDir, "Annotations.java"), dest,
154: false)).run();
155:
156: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
157: tppf.setAsk(false);
158: tppf.isApplicable(dest);
159: tppf.setSingleLineCommentOwnline(false);
160: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
161: tppf.apply(dest);
162:
163: FileCompare.assertEquals("Annotations.java in error", new File(
164: checkDir, "Annotations.java"), dest);
165: }
166:
167: /**
168: * A unit test for JUnit
169: */
170: public void test08() {
171: File dest = new File(destDir, "Reviewer.java");
172: (new FileCopy(new File(cleanDir, "Reviewer.java"), dest, false))
173: .run();
174:
175: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
176: tppf.setAsk(false);
177: tppf.isApplicable(dest);
178: tppf.setSingleLineCommentOwnline(false);
179: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
180: tppf.apply(dest);
181:
182: FileCompare.assertEquals("Reviewer.java in error", new File(
183: checkDir, "Reviewer.java"), dest);
184: }
185:
186: /**
187: * A unit test for JUnit
188: */
189: public void test09() {
190: File dest = new File(destDir, "Author.java");
191: (new FileCopy(new File(cleanDir, "Author.java"), dest, false))
192: .run();
193:
194: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
195: tppf.setAsk(false);
196: tppf.isApplicable(dest);
197: tppf.setSingleLineCommentOwnline(false);
198: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
199: tppf.apply(dest);
200:
201: FileCompare.assertEquals("Author.java in error", new File(
202: checkDir, "Author.java"), dest);
203: }
204:
205: /**
206: * A unit test for JUnit
207: */
208: public void test10() {
209: File dest = new File(destDir, "Copyright.java");
210: (new FileCopy(new File(cleanDir, "Copyright.java"), dest, false))
211: .run();
212:
213: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
214: tppf.setAsk(false);
215: tppf.isApplicable(dest);
216: tppf.setSingleLineCommentOwnline(false);
217: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
218: tppf.apply(dest);
219:
220: FileCompare.assertEquals("Copyright.java in error", new File(
221: checkDir, "Copyright.java"), dest);
222: }
223:
224: /**
225: * A unit test for JUnit
226: */
227: public void test11() {
228: File dest = new File(destDir, "Endorsers.java");
229: (new FileCopy(new File(cleanDir, "Endorsers.java"), dest, false))
230: .run();
231:
232: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
233: tppf.setAsk(false);
234: tppf.isApplicable(dest);
235: tppf.setSingleLineCommentOwnline(false);
236: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
237: tppf.apply(dest);
238:
239: FileCompare.assertEquals("Endorsers.java in error", new File(
240: checkDir, "Endorsers.java"), dest);
241: }
242:
243: /**
244: * A unit test for JUnit
245: */
246: public void test12() {
247: File dest = new File(destDir, "Formatter.java");
248: (new FileCopy(new File(cleanDir, "Formatter.java"), dest, false))
249: .run();
250:
251: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
252: tppf.setAsk(false);
253: tppf.isApplicable(dest);
254: tppf.setSingleLineCommentOwnline(false);
255: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
256: tppf.apply(dest);
257:
258: FileCompare.assertEquals("Formatter.java in error", new File(
259: checkDir, "Formatter.java"), dest);
260: }
261:
262: /**
263: * A unit test for JUnit
264: */
265: public void test13() {
266: File dest = new File(destDir, "Name.java");
267: (new FileCopy(new File(cleanDir, "Name.java"), dest, false))
268: .run();
269:
270: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
271: tppf.setAsk(false);
272: tppf.isApplicable(dest);
273: tppf.setSingleLineCommentOwnline(false);
274: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
275: tppf.apply(dest);
276:
277: FileCompare.assertEquals("Name.java in error", new File(
278: checkDir, "Name.java"), dest);
279: }
280:
281: /**
282: * A unit test for JUnit
283: */
284: public void test14() {
285: File dest = new File(destDir, "Preliminary.java");
286: (new FileCopy(new File(cleanDir, "Preliminary.java"), dest,
287: false)).run();
288:
289: TestPrettyPrintFile tppf = new TestPrettyPrintFile();
290: tppf.setAsk(false);
291: tppf.isApplicable(dest);
292: tppf.setSingleLineCommentOwnline(false);
293: tppf.setCStyle(PrintData.CSC_LEAVE_UNTOUCHED);
294: tppf.apply(dest);
295:
296: FileCompare.assertEquals("Preliminary.java in error", new File(
297: checkDir, "Preliminary.java"), dest);
298: }
299:
300: /**
301: * The JUnit setup method
302: */
303: protected void setUp() {
304: cleanDir = new File("test/clean/pretty/jdk1_5");
305: //try {
306: // System.out.println("file="+cleanDir.getCanonicalFile());
307: //} catch (java.io.IOException e) {
308: // e.printStackTrace();
309: //}
310: destDir = new File("test/temp");
311: checkDir = new File("test/check/pretty/jdk1_5");
312: (new RefactoryInstaller(false)).run();
313: }
314:
315: public static TestSuite suite() {
316: TestSuite result = new TestSuite();
317: result.addTest(new TestPrettyPrinterJDK1_5("test01"));
318: result.addTest(new TestPrettyPrinterJDK1_5("test02"));
319: result.addTest(new TestPrettyPrinterJDK1_5("test03"));
320: result.addTest(new TestPrettyPrinterJDK1_5("test04"));
321: result.addTest(new TestPrettyPrinterJDK1_5("test05"));
322: result.addTest(new TestPrettyPrinterJDK1_5("test06"));
323: result.addTest(new TestPrettyPrinterJDK1_5("test07"));
324: result.addTest(new TestPrettyPrinterJDK1_5("test08"));
325: result.addTest(new TestPrettyPrinterJDK1_5("test09"));
326: result.addTest(new TestPrettyPrinterJDK1_5("test10"));
327: result.addTest(new TestPrettyPrinterJDK1_5("test11"));
328: result.addTest(new TestPrettyPrinterJDK1_5("test12"));
329: result.addTest(new TestPrettyPrinterJDK1_5("test13"));
330: result.addTest(new TestPrettyPrinterJDK1_5("test14"));
331: return result;
332: }
333:
334: }
|