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.

PerTypeWithinTests.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*******************************************************************************
  2. * Copyright (c) 2005 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.ajc150;
  12. import java.io.File;
  13. import org.aspectj.testing.XMLBasedAjcTestCase;
  14. import org.aspectj.tools.ajc.CompilationResult;
  15. import junit.framework.Test;
  16. public class PerTypeWithinTests extends XMLBasedAjcTestCase {
  17. public static Test suite() {
  18. return XMLBasedAjcTestCase.loadSuite(PerTypeWithinTests.class);
  19. }
  20. protected java.net.URL getSpecFile() {
  21. return getClassResource("ajc150.xml");
  22. }
  23. /**
  24. * First few tests:
  25. *
  26. * Five types p.A, p.B, p.C, q.D, q.E and an aspect a.X.
  27. *
  28. * The aspect is pertypewithin(p..*) - this should match A,B,C but not D,E.
  29. *
  30. * Aspect instances should be accessible for A,B,C but not D,E.
  31. * The aspect instances for A,B,C should be different.
  32. *
  33. * hasAspect(), aspectOf() should work.
  34. *
  35. * We test these assumptions in A,B,C,D,E.
  36. */
  37. public void testDoesItWorkAtAll() {
  38. runTest("basic ptw test");
  39. }
  40. public void testCheckHasAspectWorks() {
  41. runTest("ptw hasAspect");
  42. }
  43. public void testCheckAspectOfWorks() {
  44. runTest("ptw aspectOf");
  45. }
  46. /**
  47. * Aspects Q and R match P with a pertypewithin() - they shouldn't clash in any way
  48. *
  49. */
  50. public void testTwoAspectsHittingOneType() {
  51. runTest("ptw multi-aspects");
  52. }
  53. /**
  54. * Checks the use of pertypewithin() doesn't result in extra join points (i.e. the
  55. * infrastructure is properly hidden in ajc$ or synthetic members)
  56. */
  57. public void testPervasivenessOfWeaving() {
  58. CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"U.java","-showWeaveInfo"});
  59. int weavingMessagesFromNormalDeploymentModel = cR.getWeaveMessages().size();
  60. cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"V.java","-showWeaveInfo"});
  61. int weavingMessagesFromPerTypeWithin = cR.getWeaveMessages().size();
  62. assertEquals("Expected same number of messages regardless of perclause",
  63. weavingMessagesFromNormalDeploymentModel,weavingMessagesFromPerTypeWithin);
  64. }
  65. public void testBinaryWeaving_ClassesAreBinary() {
  66. runTest("ptw binary");
  67. }
  68. public void testBinaryWeaving_AspectsAreBinary() {
  69. runTest("ptw binary aspect");
  70. }
  71. public void testAJDKExamples() {
  72. runTest("ajdk: ptw");
  73. }
  74. // // Compile the aspect H.java into classes3
  75. // CompilationResult cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"H.java","-outjar","aspects.jar"});
  76. // setShouldEmptySandbox(false);
  77. // // Compile the class with H.class as aspectpath, should be binary woven correctly
  78. // cR = ajc(new File("../tests/java5/pertypewithin"),new String[]{"G.java","-aspectpath","aspects.jar"});
  79. // RunResult rR = run("G");
  80. // assertTrue("Expected aspect related message 'advice running' in output from G",
  81. // rR.getStdErr().indexOf("advice running")!=-1);
  82. // setShouldEmptySandbox(true);
  83. // }
  84. //
  85. // // binary weaving case ...
  86. }