You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MessageListXmlReaderTest.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.testing.xml;
  14. import java.io.File;
  15. import java.util.ArrayList;
  16. import java.util.Iterator;
  17. import org.aspectj.bridge.IMessage;
  18. import org.aspectj.util.LangUtil;
  19. import junit.framework.TestCase;
  20. /**
  21. *
  22. */
  23. public class MessageListXmlReaderTest extends TestCase {
  24. ArrayList tempFiles = new ArrayList();
  25. public MessageListXmlReaderTest(String name) {
  26. super(name);
  27. }
  28. public void setUp() {
  29. tempFiles.clear();
  30. }
  31. public void tearDown() {
  32. if (!LangUtil.isEmpty(tempFiles)) {
  33. for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
  34. File file = (File) iter.next();
  35. if (file.canRead()) {
  36. file.delete();
  37. }
  38. }
  39. }
  40. }
  41. public void testNothingOthersSkipped() {}
  42. public void skiptestMessageReading() throws Exception {
  43. //assertTrue("XXX need better XML wrapping - has < character", false);
  44. //checkXmlRoundTrip("testdata/dirChangesTestDir/diff/expectedMessages");
  45. //checkXmlRoundTrip("testdata/dirChangesTestDir/same/expectedMessages");
  46. }
  47. void checkXmlRoundTrip(String path) throws Exception {
  48. String xmlPath = path + ".xml";
  49. String xml2Path = path + ".tmp.xml";
  50. final File file1 = new File(xmlPath);
  51. assertTrue("" + file1, file1.canRead());
  52. MessageListXmlReader reader = new MessageListXmlReader();
  53. IMessage[] messages = reader.readMessages(file1);
  54. assertNotNull(messages);
  55. assertTrue("empty messages", 0 != messages.length);
  56. File file2 = new File(xml2Path);
  57. String warning = reader.writeMessages(file2, messages);
  58. assertTrue(warning, null == warning);
  59. tempFiles.add(file2);
  60. IMessage[] messages2 = reader.readMessages(file2);
  61. assertEquals(LangUtil.arrayAsList(messages).toString(),
  62. LangUtil.arrayAsList(messages2).toString());
  63. }
  64. }