From 032b041942a1783e48a265c8e2a63a3e066c27f5 Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 9 Jun 2005 14:45:16 +0000 Subject: [PATCH] This PointcutParser should *not* support if - it is not to be confused with the PatternParser in weaver.patterns --- .../aspectj/weaver/tools/PointcutParser.java | 157 ++++++++++-------- .../weaver/tools/PointcutParserTest.java | 148 +++++++++-------- 2 files changed, 168 insertions(+), 137 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/tools/PointcutParser.java b/weaver/src/org/aspectj/weaver/tools/PointcutParser.java index f1f12af67..a7c5c91d6 100644 --- a/weaver/src/org/aspectj/weaver/tools/PointcutParser.java +++ b/weaver/src/org/aspectj/weaver/tools/PointcutParser.java @@ -14,9 +14,11 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.aspectj.weaver.IHasPosition; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.internal.tools.PointcutExpressionImpl; import org.aspectj.weaver.patterns.AndPointcut; +import org.aspectj.weaver.patterns.CflowPointcut; import org.aspectj.weaver.patterns.KindedPointcut; import org.aspectj.weaver.patterns.NotPointcut; import org.aspectj.weaver.patterns.OrPointcut; @@ -24,7 +26,6 @@ import org.aspectj.weaver.patterns.ParserException; import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.patterns.ThisOrTargetPointcut; -import org.aspectj.weaver.patterns.IfPointcut; /** * A PointcutParser can be used to build PointcutExpressions for a @@ -41,20 +42,20 @@ public class PointcutParser { */ public static Set getAllSupportedPointcutPrimitives() { Set primitives = new HashSet(); - primitives.add(PointcutPrimitives.ADVICE_EXECUTION); - primitives.add(PointcutPrimitives.ARGS); - primitives.add(PointcutPrimitives.CALL); - primitives.add(PointcutPrimitives.EXECUTION); - primitives.add(PointcutPrimitives.GET); - primitives.add(PointcutPrimitives.HANDLER); - primitives.add(PointcutPrimitives.INITIALIZATION); - primitives.add(PointcutPrimitives.PRE_INITIALIZATION); - primitives.add(PointcutPrimitives.SET); - primitives.add(PointcutPrimitives.STATIC_INITIALIZATION); - primitives.add(PointcutPrimitives.TARGET); - primitives.add(PointcutPrimitives.THIS); - primitives.add(PointcutPrimitives.WITHIN); - primitives.add(PointcutPrimitives.WITHIN_CODE); + primitives.add(PointcutPrimitive.ADVICE_EXECUTION); + primitives.add(PointcutPrimitive.ARGS); + primitives.add(PointcutPrimitive.CALL); + primitives.add(PointcutPrimitive.EXECUTION); + primitives.add(PointcutPrimitive.GET); + primitives.add(PointcutPrimitive.HANDLER); + primitives.add(PointcutPrimitive.INITIALIZATION); + primitives.add(PointcutPrimitive.PRE_INITIALIZATION); + primitives.add(PointcutPrimitive.SET); + primitives.add(PointcutPrimitive.STATIC_INITIALIZATION); + primitives.add(PointcutPrimitive.TARGET); + primitives.add(PointcutPrimitive.THIS); + primitives.add(PointcutPrimitive.WITHIN); + primitives.add(PointcutPrimitive.WITHIN_CODE); return primitives; } @@ -90,10 +91,10 @@ public class PointcutParser { public PointcutParser(Set/**/ supportedPointcutKinds) { supportedPrimitives = supportedPointcutKinds; for (Iterator iter = supportedPointcutKinds.iterator(); iter.hasNext();) { - PointcutPrimitives element = (PointcutPrimitives) iter.next(); - if ((element == PointcutPrimitives.IF) || - (element == PointcutPrimitives.CFLOW) || - (element == PointcutPrimitives.CFLOW_BELOW)) { + PointcutPrimitive element = (PointcutPrimitive) iter.next(); + if ((element == PointcutPrimitive.IF) || + (element == PointcutPrimitive.CFLOW) || + (element == PointcutPrimitive.CFLOW_BELOW)) { throw new UnsupportedOperationException("Cannot handle if, cflow, and cflowbelow primitives"); } } @@ -102,21 +103,21 @@ public class PointcutParser { /** * Parse the given pointcut expression. - * @throws UnsupportedOperationException if the parser encounters a + * @throws UnsupportedPointcutPrimitiveException if the parser encounters a * primitive pointcut expression of a kind not supported by this PointcutParser. * @throws IllegalArgumentException if the expression is not a well-formed * pointcut expression */ public PointcutExpression parsePointcutExpression(String expression) - throws UnsupportedOperationException, IllegalArgumentException { + throws UnsupportedPointcutPrimitiveException, IllegalArgumentException { PointcutExpressionImpl pcExpr = null; try { Pointcut pc = new PatternParser(expression).parsePointcut(); - validateAgainstSupportedPrimitives(pc); + validateAgainstSupportedPrimitives(pc,expression); pc.resolve(); pcExpr = new PointcutExpressionImpl(pc,expression); } catch (ParserException pEx) { - throw new IllegalArgumentException(pEx.getMessage()); + throw new IllegalArgumentException(buildUserMessageFromParserException(expression,pEx)); } return pcExpr; } @@ -126,90 +127,112 @@ public class PointcutParser { return supportedPrimitives; } - private void validateAgainstSupportedPrimitives(Pointcut pc) { + private void validateAgainstSupportedPrimitives(Pointcut pc, String expression) { switch(pc.getPointcutKind()) { case Pointcut.AND: - validateAgainstSupportedPrimitives(((AndPointcut)pc).getLeft()); - validateAgainstSupportedPrimitives(((AndPointcut)pc).getRight()); + validateAgainstSupportedPrimitives(((AndPointcut)pc).getLeft(),expression); + validateAgainstSupportedPrimitives(((AndPointcut)pc).getRight(),expression); break; case Pointcut.ARGS: - if (!supportedPrimitives.contains(PointcutPrimitives.ARGS)) - throw new UnsupportedOperationException("args is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.ARGS)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.ARGS); break; case Pointcut.CFLOW: - throw new UnsupportedOperationException("cflow and cflowbelow are not supported by this parser"); + CflowPointcut cfp = (CflowPointcut) pc; + if (cfp.isCflowBelow()) { + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.CFLOW_BELOW); + } else { + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.CFLOW); + } case Pointcut.HANDLER: - if (!supportedPrimitives.contains(PointcutPrimitives.HANDLER)) - throw new UnsupportedOperationException("handler is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.HANDLER)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.HANDLER); break; case Pointcut.IF: - if (((IfPointcut)pc).extraParameterFlags >= 0) { - throw new UnsupportedOperationException("if not supported for non @AspectJ style"); - } - break; case Pointcut.IF_FALSE: case Pointcut.IF_TRUE: - break; + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.IF); case Pointcut.KINDED: - validateKindedPointcut(((KindedPointcut)pc)); + validateKindedPointcut(((KindedPointcut)pc),expression); break; case Pointcut.NOT: - validateAgainstSupportedPrimitives(((NotPointcut)pc).getNegatedPointcut()); + validateAgainstSupportedPrimitives(((NotPointcut)pc).getNegatedPointcut(),expression); break; case Pointcut.OR: - validateAgainstSupportedPrimitives(((OrPointcut)pc).getLeft()); - validateAgainstSupportedPrimitives(((OrPointcut)pc).getRight()); + validateAgainstSupportedPrimitives(((OrPointcut)pc).getLeft(),expression); + validateAgainstSupportedPrimitives(((OrPointcut)pc).getRight(),expression); break; case Pointcut.REFERENCE: - throw new UnsupportedOperationException("if pointcuts and reference pointcuts are not supported by this parser"); + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.REFERENCE); case Pointcut.THIS_OR_TARGET: boolean isThis = ((ThisOrTargetPointcut)pc).isThis(); - if (isThis && !supportedPrimitives.contains(PointcutPrimitives.THIS)) { - throw new UnsupportedOperationException("this is not supported by this parser"); - } else if (!supportedPrimitives.contains(PointcutPrimitives.TARGET)) { - throw new UnsupportedOperationException("target is not supported by this parser"); + if (isThis && !supportedPrimitives.contains(PointcutPrimitive.THIS)) { + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.THIS); + } else if (!supportedPrimitives.contains(PointcutPrimitive.TARGET)) { + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.TARGET); } break; case Pointcut.WITHIN: - if (!supportedPrimitives.contains(PointcutPrimitives.WITHIN)) - throw new UnsupportedOperationException("within is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.WITHIN)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.WITHIN); break; case Pointcut.WITHINCODE: - if (!supportedPrimitives.contains(PointcutPrimitives.WITHIN_CODE)) - throw new UnsupportedOperationException("withincode is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.WITHIN_CODE)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.WITHIN_CODE); break; case Pointcut.NONE: // deliberate fall-through default: - throw new UnsupportedOperationException("Unknown pointcut kind: " + pc.getPointcutKind()); + throw new IllegalArgumentException("Unknown pointcut kind: " + pc.getPointcutKind()); } } - private void validateKindedPointcut(KindedPointcut pc) { + private void validateKindedPointcut(KindedPointcut pc, String expression) { Shadow.Kind kind = pc.getKind(); if ((kind == Shadow.MethodCall) || (kind == Shadow.ConstructorCall)) { - if (!supportedPrimitives.contains(PointcutPrimitives.CALL)) - throw new UnsupportedOperationException("call is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.CALL)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.CALL); } else if ((kind == Shadow.MethodExecution) || (kind == Shadow.ConstructorExecution)) { - if (!supportedPrimitives.contains(PointcutPrimitives.EXECUTION)) - throw new UnsupportedOperationException("execution is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.EXECUTION)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.EXECUTION); } else if (kind == Shadow.AdviceExecution) { - if (!supportedPrimitives.contains(PointcutPrimitives.ADVICE_EXECUTION)) - throw new UnsupportedOperationException("adviceexecution is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.ADVICE_EXECUTION)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.ADVICE_EXECUTION); } else if (kind == Shadow.FieldGet) { - if (!supportedPrimitives.contains(PointcutPrimitives.GET)) - throw new UnsupportedOperationException("get is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.GET)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.GET); } else if (kind == Shadow.FieldSet) { - if (!supportedPrimitives.contains(PointcutPrimitives.SET)) - throw new UnsupportedOperationException("set is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.SET)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.SET); } else if (kind == Shadow.Initialization) { - if (!supportedPrimitives.contains(PointcutPrimitives.INITIALIZATION)) - throw new UnsupportedOperationException("initialization is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.INITIALIZATION)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.INITIALIZATION); } else if (kind == Shadow.PreInitialization) { - if (!supportedPrimitives.contains(PointcutPrimitives.PRE_INITIALIZATION)) - throw new UnsupportedOperationException("preinitialization is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.PRE_INITIALIZATION)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.PRE_INITIALIZATION); } else if (kind == Shadow.StaticInitialization) { - if (!supportedPrimitives.contains(PointcutPrimitives.STATIC_INITIALIZATION)) - throw new UnsupportedOperationException("staticinitialization is not supported by this parser"); + if (!supportedPrimitives.contains(PointcutPrimitive.STATIC_INITIALIZATION)) + throw new UnsupportedPointcutPrimitiveException(expression, PointcutPrimitive.STATIC_INITIALIZATION); } } + + private String buildUserMessageFromParserException(String pc, ParserException ex) { + StringBuffer msg = new StringBuffer(); + msg.append("Pointcut is not well-formed: expecting '"); + msg.append(ex.getMessage()); + msg.append("'"); + IHasPosition location = ex.getLocation(); + msg.append(" at character position "); + msg.append(location.getStart()); + msg.append("\n"); + msg.append(pc); + msg.append("\n"); + for (int i = 0; i < location.getStart(); i++) { + msg.append(" "); + } + for (int j=location.getStart(); j <= location.getEnd(); j++) { + msg.append("^"); + } + msg.append("\n"); + return msg.toString(); + } } diff --git a/weaver/testsrc/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/testsrc/org/aspectj/weaver/tools/PointcutParserTest.java index b5f442a03..92bb6ea55 100644 --- a/weaver/testsrc/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/testsrc/org/aspectj/weaver/tools/PointcutParserTest.java @@ -22,18 +22,18 @@ public class PointcutParserTest extends TestCase { public void testGetAllSupportedPointcutPrimitives() { Set s = PointcutParser.getAllSupportedPointcutPrimitives(); assertEquals("Should be 14 elements in the set",14,s.size()); - assertFalse("Should not contain if pcd",s.contains(PointcutPrimitives.IF)); - assertFalse("Should not contain cflow pcd",s.contains(PointcutPrimitives.CFLOW)); - assertFalse("Should not contain cflowbelow pcd",s.contains(PointcutPrimitives.CFLOW_BELOW)); + assertFalse("Should not contain if pcd",s.contains(PointcutPrimitive.IF)); + assertFalse("Should not contain cflow pcd",s.contains(PointcutPrimitive.CFLOW)); + assertFalse("Should not contain cflowbelow pcd",s.contains(PointcutPrimitive.CFLOW_BELOW)); } public void testEmptyConstructor() { PointcutParser parser = new PointcutParser(); Set s = parser.getSupportedPrimitives(); assertEquals("Should be 14 elements in the set",14,s.size()); - assertFalse("Should not contain if pcd",s.contains(PointcutPrimitives.IF)); - assertFalse("Should not contain cflow pcd",s.contains(PointcutPrimitives.CFLOW)); - assertFalse("Should not contain cflowbelow pcd",s.contains(PointcutPrimitives.CFLOW_BELOW)); + assertFalse("Should not contain if pcd",s.contains(PointcutPrimitive.IF)); + assertFalse("Should not contain cflow pcd",s.contains(PointcutPrimitive.CFLOW)); + assertFalse("Should not contain cflowbelow pcd",s.contains(PointcutPrimitive.CFLOW_BELOW)); } public void testSetConstructor() { @@ -41,10 +41,10 @@ public class PointcutParserTest extends TestCase { PointcutParser parser = new PointcutParser(p); assertEquals("Should use the set we pass in",p,parser.getSupportedPrimitives()); Set q = new HashSet(); - q.add(PointcutPrimitives.ARGS); + q.add(PointcutPrimitive.ARGS); parser = new PointcutParser(q); assertEquals("Should have only one element in set",1,parser.getSupportedPrimitives().size()); - assertEquals("Should only have ARGS pcd",PointcutPrimitives.ARGS, + assertEquals("Should only have ARGS pcd",PointcutPrimitive.ARGS, parser.getSupportedPrimitives().iterator().next()); } @@ -62,15 +62,23 @@ public class PointcutParserTest extends TestCase { } catch (IllegalArgumentException ex) {} } + public void testParseExceptionErrorMessages() { + PointcutParser p = new PointcutParser(); + try { + PointcutExpression pEx = p.parsePointcutExpression("execution(int Foo.*(..) && args(Double)"); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException ex) { + assertTrue("Pointcut is not well-formed message",ex.getMessage().startsWith("Pointcut is not well-formed: expecting ')' at character position 24")); + } + } + public void testParseIfPCD() { PointcutParser p = new PointcutParser(); try { - // AV - those 3 are supported for @style p.parsePointcutExpression("if(true)"); - p.parsePointcutExpression("if(true)"); - p.parsePointcutExpression("if()"); - } catch(Throwable t) { - fail(t.toString()); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Should not support IF",PointcutPrimitive.IF,ex.getUnsupportedPrimitive()); } } @@ -78,15 +86,15 @@ public class PointcutParserTest extends TestCase { PointcutParser p = new PointcutParser(); try { p.parsePointcutExpression("cflow(this(t))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("cflow and cflowbelow are not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Should not support CFLOW",PointcutPrimitive.CFLOW,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("cflowbelow(this(t))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("cflow and cflowbelow are not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Should not support CFLOW_BELOW",PointcutPrimitive.CFLOW_BELOW,ex.getUnsupportedPrimitive()); } } @@ -94,9 +102,9 @@ public class PointcutParserTest extends TestCase { PointcutParser p = new PointcutParser(); try { p.parsePointcutExpression("bananas(x)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("if pointcuts and reference pointcuts are not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertTrue(ex.getUnsupportedPrimitive() == PointcutPrimitive.REFERENCE); } } @@ -105,99 +113,99 @@ public class PointcutParserTest extends TestCase { PointcutParser p = new PointcutParser(s); try { p.parsePointcutExpression("args(x)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("args is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Args",PointcutPrimitive.ARGS,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("within(x)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("within is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Within",PointcutPrimitive.WITHIN,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("withincode(new(..))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("withincode is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Withincode",PointcutPrimitive.WITHIN_CODE,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("handler(Exception)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("handler is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("handler",PointcutPrimitive.HANDLER,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("this(X)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("this is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("this",PointcutPrimitive.THIS,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("target(X)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("target is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("target",PointcutPrimitive.TARGET,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("this(X) && target(Y)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("this is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("This",PointcutPrimitive.THIS,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("this(X) || target(Y)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("this is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("This",PointcutPrimitive.THIS,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("!this(X)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("this is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("This",PointcutPrimitive.THIS,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("call(* *.*(..))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("call is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Call",PointcutPrimitive.CALL,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("execution(* *.*(..))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("execution is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Execution",PointcutPrimitive.EXECUTION,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("get(* *)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("get is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Get",PointcutPrimitive.GET,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("set(* *)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("set is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Set",PointcutPrimitive.SET,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("initialization(new(..))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("initialization is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Initialization",PointcutPrimitive.INITIALIZATION,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("preinitialization(new(..))"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("preinitialization is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Prc-init",PointcutPrimitive.PRE_INITIALIZATION,ex.getUnsupportedPrimitive()); } try { p.parsePointcutExpression("staticinitialization(T)"); - fail("Expected UnsupportedOperationException"); - } catch(UnsupportedOperationException ex) { - assertTrue(ex.getMessage().startsWith("staticinitialization is not supported")); + fail("Expected UnsupportedPointcutPrimitiveException"); + } catch(UnsupportedPointcutPrimitiveException ex) { + assertEquals("Staticinit",PointcutPrimitive.STATIC_INITIALIZATION,ex.getUnsupportedPrimitive()); } } } -- 2.39.5