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.

BuildArgParserTestCase.java 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.ajc;
  13. import java.io.*;
  14. import java.util.*;
  15. import junit.framework.TestCase;
  16. import org.aspectj.ajdt.internal.core.builder.*;
  17. import org.aspectj.bridge.CountingMessageHandler;
  18. import org.aspectj.bridge.IMessage;
  19. import org.aspectj.bridge.IMessageHandler;
  20. import org.aspectj.bridge.IMessageHolder;
  21. import org.aspectj.bridge.MessageHandler;
  22. import org.aspectj.bridge.MessageWriter;
  23. import org.aspectj.testing.util.TestUtil;
  24. import org.aspectj.org.eclipse.jdt.core.compiler.InvalidInputException;
  25. import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
  26. /**
  27. * Some black-box test is happening here.
  28. */
  29. public class BuildArgParserTestCase extends TestCase {
  30. private static final String TEST_DIR = AjdtAjcTests.TESTDATA_PATH + File.separator + "ajc" + File.separator;
  31. private MessageWriter messageWriter = new MessageWriter(new PrintWriter(System.out), false);
  32. public BuildArgParserTestCase(String name) {
  33. super(name);
  34. }
  35. private AjBuildConfig genBuildConfig(String[] args, IMessageHandler handler) {
  36. return new BuildArgParser(handler).genBuildConfig(args);
  37. }
  38. public void testDefaultClasspathAndTargetCombo() throws Exception {
  39. String ENTRY = "1.jar" + File.pathSeparator + "2.jar";
  40. final String classpath = System.getProperty("java.class.path");
  41. try {
  42. System.setProperty("java.class.path", ENTRY); // see finally below
  43. BuildArgParser parser = new BuildArgParser(messageWriter);
  44. AjBuildConfig config = parser.genBuildConfig(new String[] { });
  45. /*String err = */parser.getOtherMessages(true);
  46. //!!!assertTrue(err, null == err);
  47. assertTrue(
  48. config.getClasspath().toString(),
  49. config.getClasspath().contains("1.jar"));
  50. assertTrue(
  51. config.getClasspath().toString(),
  52. config.getClasspath().contains("2.jar"));
  53. config = genBuildConfig(new String[] { "-1.3" }, messageWriter);
  54. // these errors are deffered to the compiler now
  55. //err = parser.getOtherMessages(true);
  56. //!!!assertTrue(err, null == err);
  57. assertTrue(
  58. config.getClasspath().toString(),
  59. config.getClasspath().contains("1.jar"));
  60. assertTrue(
  61. config.getClasspath().toString(),
  62. config.getClasspath().contains("2.jar"));
  63. parser = new BuildArgParser(messageWriter);
  64. config = parser.genBuildConfig(new String[] { "-1.3" });
  65. /*err = */parser.getOtherMessages(true);
  66. //!!!assertTrue(err, null == err);
  67. assertTrue(
  68. config.getClasspath().toString(),
  69. config.getClasspath().contains("1.jar"));
  70. assertTrue(
  71. config.getClasspath().toString(),
  72. config.getClasspath().contains("2.jar"));
  73. config = genBuildConfig(new String[] {
  74. "-classpath", ENTRY, "-1.4" }, messageWriter);
  75. // these errors are deffered to the compiler now
  76. //err = parser.getOtherMessages(true);
  77. //assertTrue("expected errors for missing jars", null != err);
  78. List cp = config.getClasspath();
  79. boolean jar1Found = false;
  80. boolean jar2Found = false;
  81. for (Iterator iter = cp.iterator(); iter.hasNext();) {
  82. String element = (String) iter.next();
  83. if (element.indexOf("1.jar") != -1) jar1Found = true;
  84. if (element.indexOf("2.jar") != -1) jar2Found = true;
  85. }
  86. assertTrue(
  87. config.getClasspath().toString(),
  88. jar1Found);
  89. assertTrue(
  90. config.getClasspath().toString(),
  91. jar2Found);
  92. } finally {
  93. // do finally to avoid messing up classpath for other tests
  94. System.setProperty("java.class.path", classpath);
  95. String setPath = System.getProperty("java.class.path");
  96. String m = "other tests will fail - classpath not reset";
  97. assertEquals(m, classpath, setPath);
  98. }
  99. }
  100. public void testPathResolutionFromConfigArgs() {
  101. String FILE_PATH = "@" + TEST_DIR + "configWithClasspathExtdirsBootCPArgs.lst";
  102. AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
  103. List classpath = config.getFullClasspath();
  104. // should have three entries, resolved relative to location of .lst file
  105. assertEquals("Three entries in classpath",3,classpath.size());
  106. Iterator cpIter = classpath.iterator();
  107. try {
  108. assertEquals("Should be relative to TESTDIR",new File(TEST_DIR+File.separator+"xyz").getCanonicalPath(),cpIter.next());
  109. assertEquals("Should be relative to TESTDIR",new File(TEST_DIR+File.separator+"myextdir" + File.separator + "dummy.jar").getCanonicalPath(),cpIter.next());
  110. assertEquals("Should be relative to TESTDIR",new File(TEST_DIR+File.separator+"abc.jar").getCanonicalPath(),cpIter.next());
  111. List files = config.getFiles();
  112. assertEquals("Two source files",2,files.size());
  113. Iterator fIter = files.iterator();
  114. assertEquals("Should be relative to TESTDIR",new File(TEST_DIR+File.separator+"Abc.java").getCanonicalFile(),fIter.next());
  115. assertEquals("Should be relative to TESTDIR",new File(TEST_DIR+File.separator+"xyz"+File.separator+"Def.aj").getCanonicalFile(),fIter.next());
  116. } catch (IOException ex) {
  117. fail("Test case failure attempting to create canonical path: " + ex);
  118. }
  119. }
  120. public void testAjOptions() throws InvalidInputException {
  121. AjBuildConfig config = genBuildConfig(new String[] { "-Xlint" }, messageWriter);
  122. assertTrue(
  123. "default options",
  124. config.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT));
  125. }
  126. public void testAspectpath() throws InvalidInputException {
  127. final String SOURCE_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
  128. final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator
  129. + "../weaver/testdata/tracing.jar" + File.pathSeparator
  130. + "../weaver/testdata/dummyAspect.jar";
  131. AjBuildConfig config = genBuildConfig(new String[] {
  132. "-aspectpath", SOURCE_JAR },
  133. messageWriter);
  134. assertTrue(((File)config.getAspectpath().get(0)).getName(), ((File)config.getAspectpath().get(0)).getName().equals("testclasses.jar"));
  135. config = genBuildConfig(new String[] {
  136. "-aspectpath", SOURCE_JARS },
  137. messageWriter);
  138. assertTrue("size", + config.getAspectpath().size() == 3);
  139. }
  140. public void testInJars() throws InvalidInputException {
  141. final String SOURCE_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
  142. final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator
  143. + "../weaver/testdata/tracing.jar" + File.pathSeparator
  144. + "../weaver/testdata/dummyAspect.jar";
  145. AjBuildConfig config = genBuildConfig(new String[] {
  146. "-injars", SOURCE_JAR },
  147. messageWriter);
  148. //XXX don't let this remain in both places in beta1
  149. // assertTrue(
  150. // "" + config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs),
  151. // config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs).equals(CompilerOptions.PRESERVE));
  152. assertTrue(((File)config.getInJars().get(0)).getName(), ((File)config.getInJars().get(0)).getName().equals("testclasses.jar"));
  153. config = genBuildConfig(new String[] {
  154. "-injars", SOURCE_JARS },
  155. messageWriter);
  156. assertTrue("size", + config.getInJars().size() == 3);
  157. }
  158. public void testBadInJars() throws InvalidInputException {
  159. final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator + "b.far" + File.pathSeparator + "c.jar";
  160. AjBuildConfig config = genBuildConfig(new String[] {
  161. "-injars", SOURCE_JARS },
  162. messageWriter);
  163. assertTrue("size: " + config.getInJars().size(), config.getInJars().size() == 1);
  164. }
  165. public void testBadPathToSourceFiles() {
  166. CountingMessageHandler countingHandler = new CountingMessageHandler(messageWriter);
  167. /*AjBuildConfig config = */genBuildConfig(new String[]{ "inventedDir/doesntexist/*.java"},countingHandler);
  168. assertTrue("Expected an error for the invalid path.",countingHandler.numMessages(IMessage.ERROR,false)==1);
  169. }
  170. public void testMultipleSourceRoots() throws InvalidInputException, IOException {
  171. final String SRCROOT_1 = AjdtAjcTests.TESTDATA_PATH + "/src1/p1";
  172. final String SRCROOT_2 = AjdtAjcTests.TESTDATA_PATH + "/ajc";
  173. AjBuildConfig config = genBuildConfig(new String[] {
  174. "-sourceroots", SRCROOT_1 + File.pathSeparator + SRCROOT_2 },
  175. messageWriter);
  176. assertEquals(getCanonicalPath(new File(SRCROOT_1)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
  177. Collection expectedFiles = Arrays.asList(new File[] {
  178. new File(SRCROOT_1+File.separator+"A.java").getCanonicalFile(),
  179. new File(SRCROOT_1+File.separator+"Foo.java").getCanonicalFile(),
  180. new File(SRCROOT_2+File.separator+"A.java").getCanonicalFile(),
  181. new File(SRCROOT_2+File.separator+"B.java").getCanonicalFile(),
  182. new File(SRCROOT_2+File.separator+"X.aj").getCanonicalFile(),
  183. new File(SRCROOT_2+File.separator+"Y.aj").getCanonicalFile(),
  184. new File(SRCROOT_2+File.separator+"pkg"+File.separator+"Hello.java").getCanonicalFile(),
  185. });
  186. //System.out.println(config.getFiles());
  187. TestUtil.assertSetEquals(expectedFiles, config.getFiles());
  188. }
  189. /**
  190. * @param file
  191. * @return String
  192. */
  193. private String getCanonicalPath(File file) {
  194. String ret = "";
  195. try {
  196. ret = file.getCanonicalPath();
  197. } catch (IOException ioEx) {
  198. fail("Unable to canonicalize " + file + " : " + ioEx);
  199. }
  200. return ret;
  201. }
  202. public void testSourceRootDir() throws InvalidInputException, IOException {
  203. final String SRCROOT = AjdtAjcTests.TESTDATA_PATH + "/ajc";
  204. AjBuildConfig config = genBuildConfig(new String[] {
  205. "-sourceroots", SRCROOT },
  206. messageWriter);
  207. assertEquals(getCanonicalPath(new File(SRCROOT)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
  208. Collection expectedFiles = Arrays.asList(new File[] {
  209. new File(SRCROOT+File.separator+"A.java").getCanonicalFile(),
  210. new File(SRCROOT+File.separator+"B.java").getCanonicalFile(),
  211. new File(SRCROOT+File.separator+"X.aj").getCanonicalFile(),
  212. new File(SRCROOT+File.separator+"Y.aj").getCanonicalFile(),
  213. new File(SRCROOT+File.separator+"pkg"+File.separator+"Hello.java").getCanonicalFile(),
  214. });
  215. //System.out.println(config.getFiles());
  216. TestUtil.assertSetEquals(expectedFiles, config.getFiles());
  217. }
  218. public void testBadSourceRootDir() throws InvalidInputException {
  219. AjBuildConfig config = genBuildConfig(new String[] {
  220. "-sourceroots",
  221. AjdtAjcTests.TESTDATA_PATH + "/mumbleDoesNotExist" + File.pathSeparator
  222. + AjdtAjcTests.TESTDATA_PATH + "/ajc" },
  223. messageWriter);
  224. assertTrue(config.getSourceRoots().toString(), config.getSourceRoots().size() == 1);
  225. config = genBuildConfig(new String[] {
  226. "-sourceroots" },
  227. messageWriter);
  228. assertTrue("" + config.getSourceRoots(), config.getSourceRoots().size() == 0);
  229. }
  230. //??? we've decided not to make this an error
  231. public void testSourceRootDirWithFiles() throws InvalidInputException, IOException {
  232. final String SRCROOT = AjdtAjcTests.TESTDATA_PATH + "/ajc/pkg";
  233. AjBuildConfig config = genBuildConfig(new String[] {
  234. "-sourceroots", SRCROOT, AjdtAjcTests.TESTDATA_PATH + "/src1/A.java"},
  235. messageWriter);
  236. assertEquals(getCanonicalPath(new File(SRCROOT)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
  237. Collection expectedFiles = Arrays.asList(new File[] {
  238. new File(SRCROOT+File.separator+"Hello.java").getCanonicalFile(),
  239. new File(AjdtAjcTests.TESTDATA_PATH +File.separator+"src1"+File.separator+"A.java").getCanonicalFile(),
  240. });
  241. TestUtil.assertSetEquals(expectedFiles, config.getFiles());
  242. }
  243. public void testExtDirs() throws Exception {
  244. final String DIR = AjdtAjcTests.TESTDATA_PATH;
  245. AjBuildConfig config = genBuildConfig(new String[] {
  246. "-extdirs", DIR },
  247. messageWriter);
  248. assertTrue(config.getClasspath().toString(), config.getClasspath().contains(
  249. new File(DIR + File.separator + "testclasses.jar").getCanonicalPath()
  250. ));
  251. }
  252. public void testBootclasspath() throws InvalidInputException {
  253. final String PATH = "mumble" + File.separator + "rt.jar";
  254. AjBuildConfig config = genBuildConfig(new String[] {
  255. "-bootclasspath", PATH },
  256. messageWriter);
  257. assertTrue("Should find '" + PATH + "' contained in the first entry of '" + config.getBootclasspath().toString(),
  258. ((String)config.getBootclasspath().get(0)).indexOf(PATH) != -1);
  259. config = genBuildConfig(new String[] {
  260. },
  261. messageWriter);
  262. assertTrue(config.getBootclasspath().toString(), !config.getBootclasspath().get(0).equals(PATH));
  263. }
  264. public void testOutputJar() throws InvalidInputException {
  265. final String OUT_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
  266. AjBuildConfig config = genBuildConfig(new String[] {
  267. "-outjar", OUT_JAR },
  268. messageWriter);
  269. //XXX don't let this remain in both places in beta1
  270. // assertTrue(
  271. // "will generate: " + config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR),
  272. // config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR).equals(CompilerOptions.GENERATE));
  273. assertEquals(
  274. getCanonicalPath(new File(OUT_JAR)),config.getOutputJar().getAbsolutePath());
  275. File nonExistingJar = new File(AjdtAjcTests.TESTDATA_PATH + "/mumbleDoesNotExist.jar");
  276. config = genBuildConfig(new String[] {
  277. "-outjar", nonExistingJar.getAbsolutePath() },
  278. messageWriter);
  279. assertEquals(
  280. getCanonicalPath(nonExistingJar),
  281. config.getOutputJar().getAbsolutePath());
  282. nonExistingJar.delete();
  283. }
  284. //XXX shouldn't need -1.4 to get this to pass
  285. public void testCombinedOptions() throws InvalidInputException {
  286. AjBuildConfig config = genBuildConfig(new String[] { "-Xlint:error", "-target", "1.4"}, messageWriter);
  287. assertTrue(
  288. "target set",
  289. config.getOptions().targetJDK == CompilerOptions.JDK1_4);
  290. assertTrue(
  291. "Xlint option set",
  292. config.getLintMode().equals(AjBuildConfig.AJLINT_ERROR));
  293. }
  294. public void testOutputDirectorySetting() throws InvalidInputException {
  295. AjBuildConfig config = genBuildConfig(new String[] { "-d", TEST_DIR }, messageWriter);
  296. assertTrue(
  297. new File(config.getOutputDir().getPath()).getAbsolutePath() + " ?= " +
  298. new File(TEST_DIR).getAbsolutePath(),
  299. config.getOutputDir().getAbsolutePath().equals((new File(TEST_DIR)).getAbsolutePath()));
  300. }
  301. public void testClasspathSetting() throws InvalidInputException {
  302. String ENTRY = "1.jar" + File.pathSeparator + "2.jar";
  303. AjBuildConfig config = genBuildConfig(new String[] { "-classpath", ENTRY }, messageWriter);
  304. List cp = config.getClasspath();
  305. boolean jar1Found = false;
  306. boolean jar2Found = false;
  307. for (Iterator iter = cp.iterator(); iter.hasNext();) {
  308. String element = (String) iter.next();
  309. if (element.indexOf("1.jar") != -1) jar1Found = true;
  310. if (element.indexOf("2.jar") != -1) jar2Found = true;
  311. }
  312. assertTrue(
  313. config.getClasspath().toString(),
  314. jar1Found);
  315. assertTrue(
  316. config.getClasspath().toString(),
  317. jar2Found);
  318. }
  319. public void testArgInConfigFile() throws InvalidInputException {
  320. String FILE_PATH = "@" + TEST_DIR + "configWithArgs.lst";
  321. String OUT_PATH = "bin";
  322. AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
  323. assertNotNull(config);
  324. File outputDir = config.getOutputDir();
  325. assertNotNull(outputDir);
  326. assertEquals(outputDir.getPath(), OUT_PATH);
  327. }
  328. public void testNonExistentConfigFile() throws IOException {
  329. String FILE_PATH = "@" + TEST_DIR + "../bug-40257/d1/test.lst";
  330. AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
  331. String a = new File(TEST_DIR + "../bug-40257/d1/A.java").getCanonicalPath();
  332. String b = new File(TEST_DIR + "../bug-40257/d1/d2/B.java").getCanonicalPath();
  333. String c = new File(TEST_DIR + "../bug-40257/d3/C.java").getCanonicalPath();
  334. List pathList = new ArrayList();
  335. for (Iterator it = config.getFiles().iterator(); it.hasNext(); ) {
  336. pathList.add(((File)it.next()).getCanonicalPath());
  337. }
  338. assertTrue(pathList.contains(a));
  339. assertTrue(pathList.contains(b));
  340. assertTrue(pathList.contains(c));
  341. }
  342. public void testXlint() throws InvalidInputException {
  343. // AjdtCommand command = new AjdtCommand();
  344. AjBuildConfig config = genBuildConfig(new String[] {"-Xlint"}, messageWriter);
  345. assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT));
  346. config = genBuildConfig(new String[] {"-Xlint:warn"}, messageWriter);
  347. assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_WARN));
  348. config = genBuildConfig(new String[] {"-Xlint:error"}, messageWriter);
  349. assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_ERROR));
  350. config = genBuildConfig(new String[] {"-Xlint:ignore"}, messageWriter);
  351. assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_IGNORE));
  352. }
  353. public void testXlintfile() throws InvalidInputException {
  354. String lintFile = AjdtAjcTests.TESTDATA_PATH + "/lintspec.properties";
  355. // String badLintFile = "lint.props";
  356. AjBuildConfig config = genBuildConfig(new String[] {"-Xlintfile", lintFile}, messageWriter);
  357. assertTrue(new File(lintFile).exists());
  358. assertEquals(getCanonicalPath(new File(lintFile)),config.getLintSpecFile().getAbsolutePath());
  359. }
  360. /**
  361. * The option '-1.5' are currently eaten by the AspectJ argument parser - since
  362. * the JDT compiler upon which we are based doesn't understand them - *this should change* when we
  363. * switch to a 1.5 compiler base. They are currently used to determine whether the weaver should
  364. * behave in a '1.5' way - for example autoboxing behaves differently when the 1.5 flag is specified.
  365. * Under 1.4 Integer != int
  366. * Under 1.5 Integer == int
  367. * (this applies to all primitive types)
  368. */
  369. public void testSource15() throws InvalidInputException {
  370. // AjBuildConfig config = genBuildConfig(new String[]{"-source","1.5"},messageWriter);
  371. // assertTrue("should be in 1.5 mode",config.getJave5Behaviour());
  372. AjBuildConfig config = genBuildConfig(new String[]{"-1.5"},messageWriter);
  373. assertTrue("should be in 1.5 mode",config.getBehaveInJava5Way());
  374. config = genBuildConfig(new String[]{"-source","1.4"},messageWriter);
  375. assertTrue("should not be in 1.5 mode",!config.getBehaveInJava5Way());
  376. assertTrue("should be in 1.4 mode",config.getOptions().sourceLevel == CompilerOptions.JDK1_4);
  377. config = genBuildConfig(new String[]{"-source","1.3"},messageWriter);
  378. assertTrue("should not be in 1.5 mode",!config.getBehaveInJava5Way());
  379. assertTrue("should be in 1.3 mode",config.getOptions().sourceLevel == CompilerOptions.JDK1_3);
  380. }
  381. public void testOptions() throws InvalidInputException {
  382. // AjdtCommand command = new AjdtCommand();
  383. String TARGET = "1.4";
  384. AjBuildConfig config = genBuildConfig(new String[] {"-target", TARGET, "-source", TARGET}, messageWriter);
  385. assertTrue(
  386. "target set",
  387. config.getOptions().targetJDK == CompilerOptions.JDK1_4);
  388. assertTrue(
  389. "source set",
  390. config.getOptions().sourceLevel == CompilerOptions.JDK1_4);
  391. }
  392. public void testLstFileExpansion() throws IOException, FileNotFoundException, InvalidInputException {
  393. String FILE_PATH = TEST_DIR + "config.lst";
  394. String SOURCE_PATH_1 = "A.java";
  395. String SOURCE_PATH_2 = "B.java";
  396. // File f = new File(FILE_PATH);
  397. AjBuildConfig config = genBuildConfig(new String[] { "@" + FILE_PATH }, messageWriter);
  398. List resultList = config.getFiles();
  399. assertTrue("correct number of files", resultList.size() == 2);
  400. assertTrue(resultList.toString() + new File(TEST_DIR + SOURCE_PATH_1).getCanonicalFile(),
  401. resultList.contains(new File(TEST_DIR + SOURCE_PATH_1).getCanonicalFile()));
  402. assertTrue(resultList.toString() + SOURCE_PATH_2,
  403. resultList.contains(new File(TEST_DIR + SOURCE_PATH_2).getCanonicalFile()));
  404. }
  405. //??? do we need to remove this limitation
  406. // public void testArgInConfigFileAndRelativizingPathParam() throws InvalidInputException {
  407. // String FILE_PATH = "@" + TEST_DIR + "configWithArgs.lst";
  408. // String OUT_PATH = TEST_DIR + "bin";
  409. // AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH });
  410. //
  411. // assertTrue(
  412. // config.getOutputDir().getPath() + " ?= " + OUT_PATH,
  413. // config.getOutputDir().getAbsolutePath().equals((new File(OUT_PATH)).getAbsolutePath()));
  414. // }
  415. public void testAjFileInclusion() throws InvalidInputException {
  416. genBuildConfig(new String[] { TEST_DIR + "X.aj", TEST_DIR + "Y.aj"}, messageWriter);
  417. }
  418. public void testOutxml () {
  419. IMessageHolder messageHolder = new MessageHandler();
  420. AjBuildConfig config = genBuildConfig(new String[] { "-outxml", "-showWeaveInfo" }, messageHolder);
  421. assertTrue("Warnings: " + messageHolder,!messageHolder.hasAnyMessage(IMessage.WARNING, true));
  422. assertEquals("Wrong outxml","META-INF/aop.xml",config.getOutxmlName());
  423. assertTrue("Following option currupted",config.getShowWeavingInformation());
  424. }
  425. public void testOutxmlfile () {
  426. IMessageHolder messageHolder = new MessageHandler();
  427. AjBuildConfig config = genBuildConfig(new String[] { "-outxmlfile", "custom/aop.xml", "-showWeaveInfo" }, messageHolder);
  428. assertTrue("Warnings: " + messageHolder,!messageHolder.hasAnyMessage(IMessage.WARNING, true));
  429. assertEquals("Wrong outxml","custom/aop.xml",config.getOutxmlName());
  430. assertTrue("Following option currupted",config.getShowWeavingInformation());
  431. }
  432. protected void setUp() throws Exception {
  433. super.setUp();
  434. }
  435. protected void tearDown() throws Exception {
  436. super.tearDown();
  437. }
  438. }