From 78d3b3abde28d3064ffb6dacffe47a952b912fce Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 6 Aug 2004 12:30:35 +0000 Subject: [PATCH] incremental model tests. --- .../model/IncrementalModelTests.java | 167 ++++++++++++++++++ .../model/incremental-model-tests.xml | 98 ++++++++++ .../incremental/model/incremental-model.xml | 10 ++ 3 files changed, 275 insertions(+) create mode 100644 tests/src/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java create mode 100644 tests/src/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml create mode 100644 tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml diff --git a/tests/src/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java b/tests/src/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java new file mode 100644 index 000000000..f8d322a4f --- /dev/null +++ b/tests/src/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java @@ -0,0 +1,167 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM Corporation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * ******************************************************************/ +package org.aspectj.systemtest.incremental.model; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.ajde.ui.StructureModelUtil; +import org.aspectj.asm.AsmManager; +import org.aspectj.testing.XMLBasedAjcTestCase; + +public class IncrementalModelTests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(IncrementalModelTests.class); + } + + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml"); + } + + // This first test doesnt do a lot currently, but is ready too... + public void test001() throws Exception { + runTest("Testing incremental structure model: Intertype declarations (and a declare parents)"); + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/CloneablePoint.20.java","src/introduction/CloneablePoint.java"); + nextIncrement(false); + copyFile("changes/Point.30.java","src/introduction/Point.java"); + copyFileAndDoIncrementalBuild("changes/HashablePoint.30.java","src/introduction/HashablePoint.java"); + StructureModelUtil.checkModel("declare parents=2"); + } + + public void test002() throws Exception { + runTest("Testing incremental structure model: Intertype field declarations"); + + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/secondary/BetaA.20.java","src/secondary/BetaA.java"); + StructureModelUtil.checkModel("inter-type field=2,RelationshipMapSize=3"); + + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/secondary/BetaA.30.java","src/secondary/BetaA.java"); + StructureModelUtil.checkModel("inter-type field=1,RelationshipMapSize=2"); + } + + public void test003() throws Exception{ + runTest("Testing incremental structure model: Weaving handlers"); + + // + nextIncrement(false); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java","src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/GammaA.30.java","src/secondary/GammaA.java"); + StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=3"); + + // + nextIncrement(true); + deleteFileAndDoIncrementalBuild("src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + + } + + + public void test004() throws Exception { + runTest("Testing incremental structure model: Weaving"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java","src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=4"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.30.java","src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/BetaA.40.java","src/primary/BetaA.java"); + StructureModelUtil.checkModel("code=0,RelationshipMapSize=0,advice=0"); + } + + public void test005() throws Exception { + runTest("Testing incremental structure model: Updating files"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/Beta.20.java","src/primary/Beta.java"); + StructureModelUtil.checkModel("java source file=5,method=4,class=3,FileMapSize=4"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Delta.30.java","src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=5,method=4,class=4,advice=1"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.40.java","src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.50.java","src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=2,pointcut=1"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.60.java","src/secondary/Gamma.java"); + StructureModelUtil.checkModel("advice=0,pointcut=1"); + + } + + public void test006() throws Exception { + runTest("Testing incremental structure model: Adding and removing files"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/primary/Beta.20.java","src/primary/Beta.java"); + StructureModelUtil.checkModel("java source file=3,FileMapSize=2"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Gamma.30.java","src/secondary/Gamma.java"); + StructureModelUtil.checkModel("java source file=4"); + + // + nextIncrement(true); + copyFileAndDoIncrementalBuild("changes/secondary/Delta.40.java","src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=5,package=2,FileMapSize=4"); + + // + nextIncrement(true); + deleteFileAndDoIncrementalBuild("src/secondary/Gamma.java"); + StructureModelUtil.checkModel("java source file=4,package=2"); + + // + nextIncrement(true); + deleteFile("src/primary/Beta.java"); + deleteFileAndDoIncrementalBuild("src/secondary/Delta.java"); + StructureModelUtil.checkModel("java source file=2,FileMapSize=1"); + } + + protected void setUp() throws Exception { + super.setUp(); + AsmManager.attemptIncrementalModelRepairs = true; + } + + protected void tearDown() throws Exception { + // To see the model after a test, uncomment these lines... +// AsmManager.ModelInfo mi = AsmManager.ModelInfo.summarizeModel(); +// System.err.println(mi.toString()); + super.tearDown(); + + AsmManager.attemptIncrementalModelRepairs = false; + } +} + diff --git a/tests/src/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml b/tests/src/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml new file mode 100644 index 000000000..5add6cb72 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/incremental/model/incremental-model-tests.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml b/tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml new file mode 100644 index 000000000..1768ea102 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/incremental/model/incremental-model.xml @@ -0,0 +1,10 @@ + +]> + + + + +&tests; + + \ No newline at end of file -- 2.39.5