From 830dd0c371f901f85f8843d1459f83d1b4fc11da Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 24 Sep 2008 20:09:54 +0000 Subject: [PATCH] 247742:c27 --- .../tests/model/AsmDeclarationsTests.java | 149 +++++++++--------- 1 file changed, 75 insertions(+), 74 deletions(-) diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java index bc84f85eb..1ce8e88a8 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java @@ -21,18 +21,14 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { private IHierarchy model = null; - private String[] files = new String[]{ - "ModelCoverage.java", - "pkg" + File.separator + "InPackage.java" - }; - + private final String[] files = new String[] { "ModelCoverage.java", "pkg" + File.separator + "InPackage.java" }; + private TestCompilerConfiguration compilerConfig; protected void setUp() throws Exception { super.setUp(); initialiseProject("coverage"); - compilerConfig = (TestCompilerConfiguration) getCompiler() - .getCompilerConfiguration(); + compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration(); compilerConfig.setProjectSourceFiles(getSourceFileList(files)); doBuild(); model = AsmManager.getDefault().getHierarchy(); @@ -43,21 +39,21 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { compilerConfig = null; model = null; } - + public void testRoot() { IProgramElement root = model.getRoot(); assertNotNull(root); - assertEquals("Expected root to be named 'coverage' but found " - + root.toLabelString(), root.toLabelString(), "coverage"); + assertEquals("Expected root to be named 'coverage' but found " + root.toLabelString(), root.toLabelString(), "coverage"); } - + public void testAspectAccessibility() { IProgramElement packageAspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage"); assertNotNull(packageAspect); assertEquals(IProgramElement.Accessibility.PACKAGE, packageAspect.getAccessibility()); - assertEquals("aspect should not have public in it's signature","aspect AdviceNamingCoverage",packageAspect.getSourceSignature()); + assertEquals("aspect should not have public in it's signature", "aspect AdviceNamingCoverage", packageAspect + .getSourceSignature()); } - + public void testStaticModifiers() { IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "ModifiersCoverage"); assertNotNull(aspect); @@ -70,151 +66,156 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { assertTrue(finalA.getModifiers().contains(IProgramElement.Modifiers.FINAL)); } - + public void testFileInPackageAndDefaultPackage() { IProgramElement root = model.getRoot(); - assertEquals(root.toLabelString(), "coverage"); - IProgramElement pkg = (IProgramElement)root.getChildren().get(1); - assertEquals(pkg.toLabelString(), "pkg"); - assertEquals(((IProgramElement)pkg.getChildren().get(0)).toLabelString(), "InPackage.java"); - assertEquals(((IProgramElement)root.getChildren().get(0)).toLabelString(), "ModelCoverage.java"); - } + assertEquals(root.toLabelString(), "coverage"); + IProgramElement pkg = (IProgramElement) root.getChildren().get(1); + assertEquals(pkg.toLabelString(), "pkg"); + assertEquals(((IProgramElement) pkg.getChildren().get(0)).toLabelString(), "InPackage.java"); + assertEquals(((IProgramElement) ((IProgramElement) root.getChildren().get(0)).getChildren().get(0)).toLabelString(), + "ModelCoverage.java"); + } public void testDeclares() { IProgramElement node = model.getRoot(); assertNotNull(node); - + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "DeclareCoverage"); assertNotNull(aspect); - + String label = "declare error: \"Illegal construct..\""; IProgramElement decErrNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_ERROR, "declare error"); assertNotNull(decErrNode); assertEquals(decErrNode.toLabelString(), label); - + String decWarnMessage = "declare warning: \"Illegal call.\""; - IProgramElement decWarnNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_WARNING, "declare warning"); + IProgramElement decWarnNode = model + .findElementForSignature(aspect, IProgramElement.Kind.DECLARE_WARNING, "declare warning"); assertNotNull(decWarnNode); - assertEquals(decWarnNode.toLabelString(), decWarnMessage); - + assertEquals(decWarnNode.toLabelString(), decWarnMessage); + String decParentsMessage = "declare parents: implements Serializable"; - IProgramElement decParentsNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PARENTS, "declare parents"); - assertNotNull(decParentsNode); - assertEquals(decParentsNode.toLabelString(), decParentsMessage); + IProgramElement decParentsNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PARENTS, + "declare parents"); + assertNotNull(decParentsNode); + assertEquals(decParentsNode.toLabelString(), decParentsMessage); // check the next two relative to this one int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode); - String decParentsPtnMessage = "declare parents: extends Observable"; - assertEquals(decParentsPtnMessage,((IProgramElement)aspect.getChildren().get(declareIndex+1)).toLabelString()); - String decParentsTPMessage = "declare parents: extends Observable"; - assertEquals(decParentsTPMessage,((IProgramElement)aspect.getChildren().get(declareIndex+2)).toLabelString()); - + String decParentsPtnMessage = "declare parents: extends Observable"; + assertEquals(decParentsPtnMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 1)).toLabelString()); + String decParentsTPMessage = "declare parents: extends Observable"; + assertEquals(decParentsTPMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 2)).toLabelString()); + String decSoftMessage = "declare soft: SizeException"; IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft"); - assertNotNull(decSoftNode); - assertEquals(decSoftNode.toLabelString(), decSoftMessage); + assertNotNull(decSoftNode); + assertEquals(decSoftNode.toLabelString(), decSoftMessage); String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, "; - IProgramElement decPrecNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, "declare precedence"); - assertNotNull(decPrecNode); - assertEquals(decPrecNode.toLabelString(), decPrecMessage); - } + IProgramElement decPrecNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, + "declare precedence"); + assertNotNull(decPrecNode); + assertEquals(decPrecNode.toLabelString(), decPrecMessage); + } public void testInterTypeMemberDeclares() { IProgramElement node = model.getRoot(); assertNotNull(node); - + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "InterTypeDecCoverage"); assertNotNull(aspect); - + String fieldMsg = "Point.xxx"; IProgramElement fieldNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg); - assertNotNull(fieldNode); + assertNotNull(fieldNode); assertEquals(fieldNode.toLabelString(), fieldMsg); String methodMsg = "Point.check(int,Line)"; IProgramElement methodNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg); - assertNotNull(methodNode); + assertNotNull(methodNode); assertEquals(methodNode.toLabelString(), methodMsg); // TODO: enable -// String constructorMsg = "Point.new(int, int, int)"; -// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg); -// assertNotNull(constructorNode); -// assertEquals(constructorNode.toLabelString(), constructorMsg); + // String constructorMsg = "Point.new(int, int, int)"; + // ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, + // constructorMsg); + // assertNotNull(constructorNode); + // assertEquals(constructorNode.toLabelString(), constructorMsg); } - + public void testPointcuts() { IProgramElement node = model.getRoot(); assertNotNull(node); - + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage"); - assertNotNull(aspect); - + assertNotNull(aspect); + String ptct = "named()"; IProgramElement ptctNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, ptct); - assertNotNull(ptctNode); - assertEquals(ptctNode.toLabelString(), ptct); + assertNotNull(ptctNode); + assertEquals(ptctNode.toLabelString(), ptct); String params = "namedWithArgs(int,int)"; IProgramElement paramsNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, params); - assertNotNull(paramsNode); - assertEquals(paramsNode.toLabelString(), params); + assertNotNull(paramsNode); + assertEquals(paramsNode.toLabelString(), params); } public void testAbstract() { IProgramElement node = model.getRoot(); assertNotNull(node); - + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AbstractAspect"); - assertNotNull(aspect); - + assertNotNull(aspect); + String abst = "abPtct()"; IProgramElement abstNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, abst); - assertNotNull(abstNode); - assertEquals(abstNode.toLabelString(), abst); + assertNotNull(abstNode); + assertEquals(abstNode.toLabelString(), abst); } public void testAdvice() { IProgramElement node = model.getRoot(); assertNotNull(node); - + IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage"); - assertNotNull(aspect); + assertNotNull(aspect); String anon = "before(): "; IProgramElement anonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, anon); - assertNotNull(anonNode); - assertEquals(anonNode.toLabelString(), anon); + assertNotNull(anonNode); + assertEquals(anonNode.toLabelString(), anon); String named = "before(): named.."; IProgramElement namedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, named); - assertNotNull(namedNode); - assertEquals(namedNode.toLabelString(), named); + assertNotNull(namedNode); + assertEquals(namedNode.toLabelString(), named); String namedWithOneArg = "around(int): namedWithOneArg.."; IProgramElement namedWithOneArgNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg); - assertNotNull(namedWithOneArgNode); - assertEquals(namedWithOneArgNode.toLabelString(), namedWithOneArg); + assertNotNull(namedWithOneArgNode); + assertEquals(namedWithOneArgNode.toLabelString(), namedWithOneArg); String afterReturning = "afterReturning(int,int): namedWithArgs.."; IProgramElement afterReturningNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, afterReturning); - assertNotNull(afterReturningNode); + assertNotNull(afterReturningNode); assertEquals(afterReturningNode.toLabelString(), afterReturning); String around = "around(int): namedWithOneArg.."; IProgramElement aroundNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, around); - assertNotNull(aroundNode); + assertNotNull(aroundNode); assertEquals(aroundNode.toLabelString(), around); String compAnon = "before(int): .."; IProgramElement compAnonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compAnon); - assertNotNull(compAnonNode); + assertNotNull(compAnonNode); assertEquals(compAnonNode.toLabelString(), compAnon); String compNamed = "before(int): named().."; IProgramElement compNamedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compNamed); - assertNotNull(compNamedNode); + assertNotNull(compNamedNode); assertEquals(compNamedNode.toLabelString(), compNamed); } - + } -- 2.39.5