Lines 45-50
Link Here
|
45 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareWarningDeclaration; |
45 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareWarningDeclaration; |
46 |
import org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut; |
46 |
import org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut; |
47 |
import org.aspectj.org.eclipse.jdt.core.dom.DefaultTypePattern; |
47 |
import org.aspectj.org.eclipse.jdt.core.dom.DefaultTypePattern; |
|
|
48 |
import org.aspectj.org.eclipse.jdt.core.dom.IExtendedModifier; |
48 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration; |
49 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration; |
49 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration; |
50 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration; |
50 |
import org.aspectj.org.eclipse.jdt.core.dom.NotPointcut; |
51 |
import org.aspectj.org.eclipse.jdt.core.dom.NotPointcut; |
Lines 393-398
Link Here
|
393 |
"the ReferencePointcut",rp,pd.getDesignator()); |
394 |
"the ReferencePointcut",rp,pd.getDesignator()); |
394 |
} |
395 |
} |
395 |
|
396 |
|
|
|
397 |
public void testGetAndSetPointcutArguments(){ |
398 |
AjAST ajast = createAjAST(); |
399 |
PointcutDeclaration pd = ajast.newPointcutDeclaration(); |
400 |
assertEquals("by default the number of arguments is zero",pd.parameters().size(), 0); |
401 |
List l = pd.parameters(); |
402 |
assertEquals("there shouldn't be any arguments associated with" + |
403 |
"the pointcut yet",0,l.size()); |
404 |
SingleVariableDeclaration p1 = ajast.newSingleVariableDeclaration(); |
405 |
l.add(p1); |
406 |
assertEquals("there should be one parameter associated with" + |
407 |
"the pointcut",1,pd.parameters().size()); |
408 |
assertEquals("there should be a SingleVariableDeclaration associated with" + |
409 |
"the pointcut",p1,pd.parameters().get(0)); |
410 |
} |
411 |
|
412 |
public void testPropertyDescriptorsForPointcutDeclaration() { |
413 |
AjAST ajast = createAjAST(); |
414 |
PointcutDeclaration d = ajast.newPointcutDeclaration(); |
415 |
List props = PointcutDeclaration.propertyDescriptors(AST.JLS3); |
416 |
boolean foundJavadoc = false; |
417 |
boolean foundModifiers = false; |
418 |
boolean foundName = false; |
419 |
boolean foundParamList = false; |
420 |
boolean foundDesignator = false; |
421 |
for (Iterator iter = props.iterator(); iter.hasNext();) { |
422 |
Object o = iter.next(); |
423 |
if ((o instanceof ChildPropertyDescriptor)) { |
424 |
ChildPropertyDescriptor element = (ChildPropertyDescriptor)o; |
425 |
String id = element.getId(); |
426 |
if (id.equals("javadoc")) { |
427 |
foundJavadoc = true; |
428 |
} else if (id.equals("designator")) { |
429 |
foundDesignator = true; |
430 |
} else if (id.equals("name")) { |
431 |
foundName = true; |
432 |
} else { |
433 |
fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + element.getId()); |
434 |
} |
435 |
} else if (o instanceof ChildListPropertyDescriptor) { |
436 |
ChildListPropertyDescriptor element = (ChildListPropertyDescriptor)o; |
437 |
if (element.getId().equals("parameters")) { |
438 |
foundParamList= true; |
439 |
} else if (element.getId().equals("modifiers")) { |
440 |
foundModifiers = true; |
441 |
} |
442 |
} else { |
443 |
fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + o); |
444 |
} |
445 |
} |
446 |
assertTrue("PointcutDeclaration should have a javadoc PropertyDescriptor",foundJavadoc); |
447 |
assertTrue("PointcutDeclaration should have a designator PropertyDescriptor",foundDesignator); |
448 |
assertTrue("PointcutDeclaration should have an name PropertyDescriptor",foundName); |
449 |
assertTrue("PointcutDeclaration should have a parameters PropertyDescriptor",foundParamList); |
450 |
assertTrue("PointcutDeclaration should have a modifiers PropertyDescriptor",foundModifiers); |
451 |
} |
452 |
|
453 |
public void testClonePointcutDeclaration() { |
454 |
AjAST ajast = createAjAST(); |
455 |
PointcutDeclaration d = ajast.newPointcutDeclaration(); |
456 |
d.setName(ajast.newSimpleName("pointcut_name")); |
457 |
d.parameters().add(ajast.newSingleVariableDeclaration()); |
458 |
PointcutDeclaration copy = (PointcutDeclaration)ASTNode.copySubtree(ajast,d); |
459 |
assertEquals("there should be one parameter associated with" + |
460 |
"the pointcut copy",1,copy.parameters().size()); |
461 |
assertEquals("the PointcutDeclaration clone should have the name ", "pointcut_name", |
462 |
copy.getName().toString()); |
463 |
} |
464 |
|
465 |
public void testInternalPointcutDeclaration() { |
466 |
AjAST ajast = createAjAST(); |
467 |
PointcutDeclaration d = ajast.newPointcutDeclaration(); |
468 |
List props = PointcutDeclaration.propertyDescriptors(AST.JLS3); |
469 |
for (Iterator iter = props.iterator(); iter.hasNext();) { |
470 |
Object o = iter.next(); |
471 |
if (o instanceof ChildPropertyDescriptor) { |
472 |
ChildPropertyDescriptor element = (ChildPropertyDescriptor)o; |
473 |
if (element.getId().equals("name")) { |
474 |
assertNotNull("PointcutDeclaration's " + element.getId() + " property" + |
475 |
" should not be null since it is lazily created", |
476 |
d.getStructuralProperty(element)); |
477 |
} else { |
478 |
assertNull("PointcutDeclaration's " + element.getId() + " property" + |
479 |
" should be null since we haven't set it yet", |
480 |
d.getStructuralProperty(element)); |
481 |
} |
482 |
} else if (o instanceof ChildListPropertyDescriptor) { |
483 |
ChildListPropertyDescriptor element = (ChildListPropertyDescriptor)o; |
484 |
assertNotNull("PointcutDeclaration's " + element.getId() + " property" + |
485 |
"should not be null since it is a list", |
486 |
d.getStructuralProperty(element)); |
487 |
boolean isIExtendedModifier = element.getElementType().equals(IExtendedModifier.class); |
488 |
boolean isSingleVariable = element.getElementType().equals(SingleVariableDeclaration.class); |
489 |
assertTrue("should only be able to put SingleVariableDeclaration's" + |
490 |
" (which itself has node type IExtendedModifier) into the list", |
491 |
isIExtendedModifier || isSingleVariable); |
492 |
} else if (o instanceof SimplePropertyDescriptor) { |
493 |
SimplePropertyDescriptor element = (SimplePropertyDescriptor)o; |
494 |
assertNotNull("PointcutDeclaration's " + element.getId() + " property" + |
495 |
"should not be null since it is a boolean", |
496 |
d.getStructuralProperty(element)); |
497 |
} else { |
498 |
fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + o); |
499 |
} |
500 |
} |
501 |
for (Iterator iter = props.iterator(); iter.hasNext();) { |
502 |
Object o = iter.next(); |
503 |
if (o instanceof ChildPropertyDescriptor) { |
504 |
ChildPropertyDescriptor element = (ChildPropertyDescriptor) o; |
505 |
if (element.getId().equals("designator")) { |
506 |
ReferencePointcut rp = ajast.newReferencePointcut(); |
507 |
d.setStructuralProperty(element,rp); |
508 |
assertEquals("PointcutDeclaration's designator property should" + |
509 |
" now be a ReferencePointcut",rp,d.getStructuralProperty(element)); |
510 |
} else if (element.getId().equals("javadoc")) { |
511 |
// do nothing since makes no sense to have javadoc |
512 |
} else if (element.getId().equals("name")) { |
513 |
SimpleName sn = ajast.newSimpleName("p"); |
514 |
d.setStructuralProperty(element,sn); |
515 |
assertEquals("PointcutDeclaration's name property should" + |
516 |
" now be a SimpleName",sn,d.getStructuralProperty(element)); |
517 |
} |
518 |
} |
519 |
} |
520 |
} |
521 |
|
396 |
// -------------- AspectDeclaration tests --------------- |
522 |
// -------------- AspectDeclaration tests --------------- |
397 |
|
523 |
|
398 |
public void testNewAspectDeclaration() { |
524 |
public void testNewAspectDeclaration() { |