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.

AjStateTest.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * IBM Corporation - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.ajdt.internal.core.builder;
  12. import junit.framework.TestCase;
  13. import org.aspectj.ajdt.ajc.BuildArgParser;
  14. import org.aspectj.bridge.AbortException;
  15. import org.aspectj.bridge.IMessage;
  16. import org.aspectj.bridge.IMessageHandler;
  17. import java.io.File;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. public class AjStateTest extends TestCase {
  21. private AjState aRightState;
  22. private AjBuildConfig oldConfig;
  23. private AjBuildConfig newConfig;
  24. public void testNoChange() {
  25. aRightState.setCouldBeSubsequentIncrementalBuild(true);
  26. assertTrue("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  27. }
  28. public void testAddEntryToClasspath() {
  29. newConfig.getClasspath().add("anotherEntry");
  30. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  31. }
  32. public void testRemoveEntryFromClasspath() {
  33. newConfig.getClasspath().remove(0);
  34. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  35. }
  36. public void testReorderClasspath() {
  37. String o = newConfig.getClasspath().remove(0);
  38. newConfig.getClasspath().add(o);
  39. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  40. }
  41. public void testAddEntryToAspectpath() {
  42. newConfig.addToAspectpath(new File("anotherEntry.jar"));
  43. // newConfig.getAspectpath().add(new File("anotherEntry.jar"));
  44. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  45. }
  46. public void testRemoveEntryFromAspectpath() {
  47. newConfig.removeAspectPathEntry(0);
  48. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  49. }
  50. public void testReorderAspectpath() {
  51. String o = newConfig.removeClasspathEntry(0);
  52. newConfig.addToAspectpath(new File(o));
  53. // newConfig.getAspectpath().add(new File(o));
  54. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  55. }
  56. public void testAddEntryToInpath() {
  57. newConfig.addToInpath(new File("anotherEntry"));
  58. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  59. }
  60. public void testRemoveEntryFromInpath() {
  61. newConfig.removeInpathEntry(0);//getInpath().remove(0);
  62. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  63. }
  64. public void testReorderInpath() {
  65. String o = newConfig.removeClasspathEntry(0);//getClasspath().remove(0);
  66. newConfig.addToInpath(new File(o));//getInpath().add(new File(o));
  67. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  68. }
  69. public void testAddEntryToInjars() {
  70. newConfig.addToInjars(new File("anotherEntry.jar"));
  71. // newConfig.getInJars().add(new File("anotherEntry.jar"));
  72. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  73. }
  74. public void testRemoveEntryFromInjars() {
  75. newConfig.removeInjarsEntry(0);
  76. // newConfig.getInJars().remove(0);
  77. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  78. }
  79. public void testReorderInjars() {
  80. String o = newConfig.getClasspath().remove(0);
  81. newConfig.getInJars().add(new File(o));
  82. assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
  83. }
  84. protected void setUp() throws Exception {
  85. super.setUp();
  86. aRightState = new AjState(null);
  87. final BuildArgParser parser = new BuildArgParser(new IMessageHandler() {
  88. public boolean handleMessage(IMessage message) throws AbortException {
  89. return true;
  90. }
  91. public boolean isIgnoring(IMessage.Kind kind) {
  92. return false;
  93. }
  94. public void dontIgnore(IMessage.Kind kind) {
  95. }
  96. public void ignore(IMessage.Kind kind) {
  97. }
  98. });
  99. oldConfig = new AjBuildConfig(parser);
  100. newConfig = new AjBuildConfig(parser);
  101. List<String> cp = new ArrayList<String>();
  102. cp.add("adir");
  103. cp.add("ajar.jar");
  104. oldConfig.setClasspath(cp);
  105. newConfig.setClasspath(new ArrayList<String>(cp));
  106. List<File> ap = new ArrayList<File>();
  107. ap.add(new File("aLib.jar"));
  108. ap.add(new File("anotherLib.jar"));
  109. oldConfig.setAspectpath(ap);
  110. newConfig.setAspectpath(new ArrayList<File>(ap));
  111. List<File> ip = new ArrayList<File>();
  112. ip.add(new File("adir"));
  113. ip.add(new File("ajar.jar"));
  114. oldConfig.setInPath(ip);
  115. newConfig.setInPath(new ArrayList<File>(ip));
  116. List<File> ij = new ArrayList<File>();
  117. ij.add(new File("aLib.jar"));
  118. ij.add(new File("anotherLib.jar"));
  119. oldConfig.setInJars(ij);
  120. newConfig.setInJars(new ArrayList<File>(ij));
  121. aRightState.prepareForNextBuild(oldConfig);
  122. aRightState.successfulCompile(oldConfig, true);
  123. }
  124. }