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.

MainTest.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* *******************************************************************
  2. * Copyright (c) 2004 Contributors.
  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. * Wes Isberg initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.tools.ajc;
  13. import java.util.ArrayList;
  14. import java.util.ResourceBundle;
  15. import org.aspectj.bridge.AbortException;
  16. /**
  17. *
  18. */
  19. public class MainTest extends AjcTestCase {
  20. public void testMainbare() {
  21. ArrayList<String> list = new ArrayList<String>();
  22. // Usage now printed by Eclipse compiler so doesn't appear here in our message list
  23. // Main.bareMain(new String[] {"-help"}, false, list, null, null, null);
  24. // assertTrue(1 == list.size());
  25. Main.bareMain(new String[] {"-X"}, false, list, null, null, null);
  26. assertTrue(1 == list.size()); Object o = list.get(0);
  27. assertTrue(o instanceof String);
  28. // assertTrue(-1 != ((String)o).indexOf("-aspectpath"));
  29. // assertTrue(-1 != ((String)o).indexOf("-incremental"));
  30. }
  31. public void testDashX() {
  32. String xoptionText = ResourceBundle.getBundle("org.aspectj.ajdt.ajc.messages").getString("xoption.usage");
  33. xoptionText = "non-standard options:"; //xoptionText.substring("{0}".length());
  34. CompilationResult result = ajc(null,new String[] {"-X"});
  35. assertMessages(result,"Expecting xoptions usage message",
  36. new MessageSpec(null,null,null,newMessageList(new Message(xoptionText)),null));
  37. }
  38. public void testDashMessageHolder() {
  39. try {
  40. new Main().runMain(new String[] {"-messageHolder","org.xyz.abc"},false);
  41. fail ("Should have thrown abort exception");
  42. } catch (AbortException ex) {
  43. // good
  44. }
  45. }
  46. public void testDashMessageHolderOk() {
  47. Main main = new Main();
  48. main.runMain(new String[] {"-messageHolder","org.aspectj.tools.ajc.TestMessageHolder"},false);
  49. assertSame("ajc should be using our message handler",TestMessageHolder.class,main.getHolder().getClass());
  50. }
  51. }