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.

LstBuildConfigManagerTest.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * Helen Hawkins Converted to new interface (bug 148190)
  12. * ******************************************************************/
  13. package org.aspectj.ajde.internal;
  14. import java.io.File;
  15. import java.io.IOException;
  16. import java.util.List;
  17. import org.aspectj.ajde.AjdeTestCase;
  18. import org.aspectj.ajde.ui.BuildConfigModel;
  19. import org.aspectj.ajde.ui.utils.TestMessageHandler.TestMessage;
  20. import junit.framework.TestSuite;
  21. public class LstBuildConfigManagerTest extends AjdeTestCase {
  22. private BuildConfigManager buildConfigManager = new LstBuildConfigManager();
  23. public static void main(String[] args) {
  24. junit.swingui.TestRunner.run(LstBuildConfigManagerTest.class);
  25. }
  26. public static TestSuite suite() {
  27. TestSuite result = new TestSuite();
  28. result.addTestSuite(LstBuildConfigManagerTest.class);
  29. return result;
  30. }
  31. protected void setUp() throws Exception {
  32. super.setUp();
  33. initialiseProject("LstBuildConfigManagerTest");
  34. }
  35. public void testConfigParserErrorMessages() {
  36. doBuild("dir-entry.lst");
  37. List messages = getMessages("dir-entry.lst");
  38. TestMessage message = (TestMessage)messages.get(0);
  39. assertEquals(message.getContainedMessage().getSourceLocation().getSourceFile().getAbsolutePath(), openFile("dir-entry.lst").getAbsolutePath());
  40. doBuild("bad-injar.lst");
  41. messages = getMessages("bad-injar.lst");
  42. message = (TestMessage)messages.get(0);
  43. assertTrue(message.getContainedMessage().getMessage().contains("skipping missing, empty or corrupt inpath entry"));
  44. }
  45. public void testErrorMessages() throws IOException {
  46. doBuild("invalid-entry.lst");
  47. assertFalse("expected there to be error messages because the build failed but didn't" +
  48. " find any", getErrorMessages("invalid-entry.lst").isEmpty());
  49. List messages = getMessages("invalid-entry.lst");
  50. TestMessage message = (TestMessage)messages.get(0);
  51. assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().contains("aaa.bbb"));
  52. }
  53. public void testNonExistentConfigFile() throws IOException {
  54. File file = openFile("mumbleDoesNotExist.lst");
  55. assertTrue("valid non-existing file", !file.exists());
  56. BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath());
  57. assertTrue("root: " + model.getRoot(), model.getRoot() != null);
  58. }
  59. public void testFileRelativePathSameDir() throws IOException {
  60. File file = openFile("file-relPath-sameDir.lst");
  61. buildConfigManager.buildModel(file.getCanonicalPath());
  62. assertTrue("single file", true);
  63. }
  64. }