Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MigrationTests.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM
  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. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc150;
  12. import java.io.File;
  13. import org.aspectj.tools.ajc.CompilationResult;
  14. /**
  15. * Checks if we are obeying migration rules.
  16. */
  17. public class MigrationTests extends TestUtils {
  18. protected void setUp() throws Exception {
  19. super.setUp();
  20. baseDir = new File("../tests/migration");
  21. }
  22. /**
  23. * Compile a simple java class with an aspect library built with aspectj 1.2.1 - this
  24. * checks that we can load in attributes (especially pointcuts) that were written out
  25. * in the 'old way'
  26. *
  27. */
  28. public void testMigrationFrom121_pointcutsAndAdvice() {
  29. CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects121.jar","Program.java"});
  30. System.err.println(cR.getStandardError());
  31. assertTrue("Should not coredump: "+cR.getStandardError(),cR.getStandardError().indexOf("Dumping to ajcore")==-1);
  32. assertTrue("Should be no error messages: \n"+cR.getErrorMessages(),cR.getErrorMessages().size()==0);
  33. File f = new File(ajc.getSandboxDirectory()+File.separator+"Program.class");
  34. assertTrue("Missing class file",f.exists());
  35. run("Program");
  36. }
  37. // /**
  38. // * We cannot support all aspects built prior to AspectJ 1.2.1 - so we don't support any.
  39. // * There are probably many reasons but the first one I've hit is:
  40. // * - Changes for cflow optimizations (counters instead of stacks where we can) mean that an aspect
  41. // * compiled at AspectJ1.2.0 will contain stack cases but AspectJ1.5.0 will look for counter
  42. // * fields in some cases.
  43. // *
  44. // * This means we should get a reasonable failure message in this case.
  45. // */
  46. // public void testMigrationFrom120_pointcutsAndAdvice() {
  47. // CompilationResult cR = ajc(baseDir,new String[]{"-aspectpath","aspects120.jar","Program.java"});
  48. // assertTrue("Should have failed",cR.getFailMessages().size()>0);
  49. // assertTrue("Should have produced nice message",cR.getFailMessages().get(0).toString().indexOf("Unable to continue")!=-1);
  50. // }
  51. }