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.

VarargsTests.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 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 org.aspectj.testing.XMLBasedAjcTestCase;
  13. import junit.framework.Test;
  14. /**
  15. * Varargs, the rules/tests:
  16. *
  17. * 1. cannot match on a varargs method by using 'Object[]' in your signature,
  18. * this affects call/execution/initialization/withincode
  19. */
  20. public class VarargsTests extends XMLBasedAjcTestCase {
  21. public static Test suite() {
  22. return XMLBasedAjcTestCase.loadSuite(VarargsTests.class);
  23. }
  24. protected java.net.URL getSpecFile() {
  25. return getClassResource("ajc150.xml");
  26. }
  27. // check when signature is from a call PCD
  28. // should get message:
  29. // "an array type as the last parameter in a signature does not match on the varargs declared method: <blah>"
  30. public void test001_cantMatchVarargsWithObjectArray_callPCD() {
  31. runTest("varargs not matched by Object[] (call)");
  32. }
  33. // check when signature is from an execution PCD
  34. public void test002_cantMatchVarargsWithObjectArray_execPCD() {
  35. runTest("varargs not matched by Object[] (exe)");
  36. }
  37. // check when signature is from an initialization PCD
  38. public void test003_cantMatchVarargsWithObjectArray_initPCD() {
  39. runTest("varargs not matched by Object[] (init)");
  40. }
  41. // check when signature is from an withincode PCD
  42. public void test003_cantMatchVarargsWithObjectArray_withincodePCD() {
  43. runTest("varargs not matched by Object[] (withincode)");
  44. }
  45. // before(): call(* *(Integer...)) { }
  46. public void test_usingVarargsInPointcuts1() {
  47. runTest("call with varargs signature");
  48. }
  49. // before(): call(* *(int,Integer...)) { } - slightly more complex pcut
  50. public void test_usingVarargsInPointcuts2() {
  51. runTest("call with varargs multi-signature");
  52. }
  53. public void testAJDKExamples() {
  54. runTest("ajdk: varargs");
  55. }
  56. public void testStarVarargs() {
  57. runTest("star varargs pattern");
  58. }
  59. public void testVarargsWithDotDotInPointcut() {
  60. runTest("Varargs with .. in pointcut");
  61. }
  62. }