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.

PipeliningTests.java 3.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*******************************************************************************
  2. * Copyright (c) 2006 IBM
  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. * Andy Clement - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.systemtest.ajc153;
  12. import java.net.URL;
  13. //import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
  14. import org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter;
  15. import org.aspectj.testing.XMLBasedAjcTestCase;
  16. import junit.framework.Test;
  17. /**
  18. * testplan: (x = complete)
  19. *
  20. * x @AspectJ aspects - are they recognized and sorted correctly ?
  21. * x compiling classes (various orderings)
  22. * x compiling classes (inheritance relationships)
  23. * x compiling aspects and classes (various orderings - aspects first/last)
  24. * x eclipse annotation transformation logic
  25. * x aspects extending classes
  26. * x nested types (and aspect inside a regular class)
  27. * x set of files that are only aspects
  28. * x pointcuts in super classes
  29. * - classes with errors
  30. * - aspects with errors
  31. * - Xterminate after compilation (now == skip weaving??)
  32. *
  33. * That this pipeline works OK for large systems is kind of confirmed by using it to build shadows!
  34. *
  35. */
  36. public class PipeliningTests extends org.aspectj.testing.XMLBasedAjcTestCase {
  37. // straightforward compilation
  38. public void testBuildTwoClasses() { runTest("build two classes");}
  39. public void testBuildOneAspectTwoClasses() { runTest("build one aspect and two classes");}
  40. public void testBuildTwoClassesOneAspect() { runTest("build two classes and one aspect");}
  41. public void testBuildTwoAspects() { runTest("build two aspects");}
  42. public void testBuildClassAndNestedAspect() { runTest("build one class and deeply nested aspect");}
  43. public void testAspectExtendsClass() { runTest("aspect extends class"); }
  44. // verifying the type sorting
  45. public void testRecognizingAnnotationStyleAspects1() {
  46. AjPipeliningCompilerAdapter.pipelineTesting=true;
  47. runTest("recognizing annotation style aspects - 1");
  48. String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
  49. assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));
  50. String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder");
  51. String expectedOrder="[AtAJAspect.java,ClassOne.java]";
  52. assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
  53. }
  54. public void testRecognizingAnnotationStyleAspects2() {
  55. AjPipeliningCompilerAdapter.pipelineTesting=true;
  56. runTest("recognizing annotation style aspects - 2");
  57. String filesContainingAspects = AjPipeliningCompilerAdapter.getPipelineDebugOutput("filesContainingAspects");
  58. assertTrue("Should be one file containing aspects but it thinks there are "+filesContainingAspects,filesContainingAspects.equals("1"));
  59. String weaveOrder = AjPipeliningCompilerAdapter.getPipelineDebugOutput("weaveOrder");
  60. String expectedOrder="[AtInnerAJAspect.java,ClassOne.java]";
  61. assertTrue("Expected weaving order to be "+expectedOrder+" but was "+weaveOrder,weaveOrder.equals(expectedOrder));
  62. }
  63. // verifying the new code for transforming Eclipse Annotations into AspectJ ones
  64. public void testAnnotationTransformation() { runTest("annotation transformation"); }
  65. // --
  66. protected void tearDown() throws Exception {
  67. super.tearDown();
  68. //AjPipeliningCompilerAdapter.pipelineTesting=false;
  69. }
  70. public static Test suite() {
  71. return XMLBasedAjcTestCase.loadSuite(PipeliningTests.class);
  72. }
  73. protected URL getSpecFile() {
  74. return getClassResource("pipelining.xml");
  75. }
  76. }