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.

DuplicateManifestTest.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Common Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/cpl-v10.html
  7. *
  8. * Contributors:
  9. * Matthew Webster - initial implementation
  10. *******************************************************************************/
  11. package org.aspectj.ajde;
  12. import java.io.File;
  13. import java.io.IOException;
  14. import java.util.HashSet;
  15. import java.util.Set;
  16. import java.util.jar.JarFile;
  17. import java.util.jar.Manifest;
  18. public class DuplicateManifestTest extends AjdeTestCase {
  19. public static final String PROJECT_DIR = "DuplicateManifestTest";
  20. public static final String injarName = "injar.jar";
  21. public static final String aspectjarName = "aspectjar.jar";
  22. public static final String outjarName = "outjar.jar";
  23. /*
  24. * Ensure the output directpry in clean
  25. */
  26. protected void setUp() throws Exception {
  27. super.setUp(PROJECT_DIR);
  28. }
  29. public void testWeave () {
  30. Set injars = new HashSet();
  31. injars.add(openFile(injarName));
  32. ideManager.getProjectProperties().setInJars(injars);
  33. Set aspectpath = new HashSet();
  34. aspectpath.add(openFile(aspectjarName));
  35. ideManager.getProjectProperties().setAspectPath(aspectpath);
  36. File outjar = openFile(outjarName);
  37. ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
  38. assertTrue("Build failed", doSynchronousBuild("build.lst"));
  39. assertTrue(
  40. "Build warnings",
  41. ideManager.getCompilationSourceLineTasks().isEmpty());
  42. compareManifests(openFile(injarName),openFile(outjarName));
  43. }
  44. private void compareManifests (File inFile, File outFile) {
  45. try {
  46. JarFile inJar = new JarFile(inFile);
  47. Manifest inManifest = inJar.getManifest();
  48. inJar.close();
  49. JarFile outJar = new JarFile(outFile);
  50. Manifest outManifest = outJar.getManifest();
  51. outJar.close();
  52. assertTrue("The manifests in '" + inFile.getCanonicalPath() + "' and '" + outFile.getCanonicalPath() + "' sould be the same",inManifest.equals(outManifest));
  53. }
  54. catch (IOException ex) {
  55. fail(ex.toString());
  56. }
  57. }
  58. }