<artifactId>org.aspectj.ajdt.core</artifactId> | <artifactId>org.aspectj.ajdt.core</artifactId> | ||||
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<!-- enables easy dependency on tools.jar --> | |||||
<groupId>com.github.olivergondza</groupId> | |||||
<artifactId>maven-jdk-tools-wrapper</artifactId> | |||||
<version>0.1</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>asm</groupId> | |||||
<artifactId>asm</artifactId> | |||||
<version>1.0</version> | |||||
<scope>system</scope> | |||||
<systemPath>${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar</systemPath> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
</project> | </project> |
package org.aspectj.tools.ajdoc; | |||||
/* ******************************************************************* | |||||
* Copyright (c) 2003 Contributors. | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* Mik Kersten initial implementation | |||||
* ******************************************************************/ | |||||
import junit.framework.Test; | |||||
import junit.framework.TestSuite; | |||||
/** | |||||
* @author Mik Kersten | |||||
*/ | |||||
public class AjdocModuleTests { | |||||
public static Test suite() { | |||||
TestSuite suite = new TestSuite(AjdocModuleTests.class.getName()); | |||||
suite.addTest(AjdocTests.suite()); | |||||
return suite; | |||||
} | |||||
} |
* @return List of those requiredStrings not found | * @return List of those requiredStrings not found | ||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
public static List /*String*/ getMissingStringsInSection(File htmlFile, | |||||
public static List<String> getMissingStringsInSection(File htmlFile, | |||||
String[] requiredStrings, String sectionHeader) throws Exception { | String[] requiredStrings, String sectionHeader) throws Exception { | ||||
List missingStrings = new ArrayList(); | |||||
List<String> missingStrings = new ArrayList<String>(); | |||||
for (int i = 0; i < requiredStrings.length; i++) { | for (int i = 0; i < requiredStrings.length; i++) { | ||||
String string = requiredStrings[i]; | String string = requiredStrings[i]; | ||||
if (!containsStringWithinSection(htmlFile,string,sectionHeader)) { | if (!containsStringWithinSection(htmlFile,string,sectionHeader)) { |
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import org.aspectj.tools.ajc.Ajc; | |||||
import org.aspectj.testing.util.TestUtil; | |||||
import org.aspectj.util.LangUtil; | import org.aspectj.util.LangUtil; | ||||
import junit.framework.AssertionFailedError; | import junit.framework.AssertionFailedError; | ||||
* This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over | * This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over | ||||
* the test projects and running the ajdoc command | * the test projects and running the ajdoc command | ||||
*/ | */ | ||||
public class AjdocTestCase extends TestCase { | |||||
public abstract class AjdocTestCase extends TestCase { | |||||
public final static String testdataSrcDir = "../ajdoc/testdata"; | public final static String testdataSrcDir = "../ajdoc/testdata"; | ||||
protected static File sandboxDir; | protected static File sandboxDir; | ||||
docOutdir = null; | docOutdir = null; | ||||
projectDir = null; | projectDir = null; | ||||
// Create a sandbox in which to work | // Create a sandbox in which to work | ||||
sandboxDir = Ajc.createEmptySandbox(); | |||||
sandboxDir = TestUtil.createEmptySandbox(); | |||||
// create the ajdocworkdingdir in the sandbox | // create the ajdocworkdingdir in the sandbox | ||||
Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath()); | Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath()); | ||||
} | } |
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import junit.framework.TestSuite; | import junit.framework.TestSuite; | ||||
public class AjdocTests extends TestCase { | |||||
public class AjdocTests {//extends TestCase { | |||||
public static File ASPECTJRT_PATH; | public static File ASPECTJRT_PATH; | ||||
"../runtime/bin"}; | "../runtime/bin"}; | ||||
ASPECTJRT_PATH = FileUtil.getBestFile(paths); | ASPECTJRT_PATH = FileUtil.getBestFile(paths); | ||||
} | } | ||||
public static Test suite() { | |||||
TestSuite suite = new TestSuite(AjdocTests.class.getName()); | |||||
//$JUnit-BEGIN$ | |||||
suite.addTestSuite(DeclareFormsTest.class); | |||||
suite.addTestSuite(SpacewarTestCase.class); | |||||
suite.addTestSuite(PatternsTestCase.class); | |||||
suite.addTestSuite(CoverageTestCase.class); | |||||
suite.addTestSuite(ITDTest.class); | |||||
suite.addTestSuite(FullyQualifiedArgumentTest.class); | |||||
suite.addTestSuite(EnumTest.class); | |||||
suite.addTestSuite(PointcutVisibilityTest.class); | |||||
suite.addTestSuite(ExecutionTestCase.class); | |||||
suite.addTestSuite(BugTests.class); | |||||
//$JUnit-END$ | |||||
return suite; | |||||
} | |||||
// | |||||
// public static Test suite() { | |||||
// TestSuite suite = new TestSuite(AjdocTests.class.getName()); | |||||
// //$JUnit-BEGIN$ | |||||
// suite.addTestSuite(DeclareFormsTest.class); | |||||
// suite.addTestSuite(SpacewarTestCase.class); | |||||
// suite.addTestSuite(PatternsTestCase.class); | |||||
// suite.addTestSuite(CoverageTestCase.class); | |||||
// suite.addTestSuite(ITDTest.class); | |||||
// suite.addTestSuite(FullyQualifiedArgumentTest.class); | |||||
// suite.addTestSuite(EnumTest.class); | |||||
// suite.addTestSuite(PointcutVisibilityTest.class); | |||||
// suite.addTestSuite(ExecutionTestCase.class); | |||||
// suite.addTestSuite(BugTest.class); | |||||
// //$JUnit-END$ | |||||
// return suite; | |||||
// } | |||||
} | } |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
public class BugTests extends AjdocTestCase { | |||||
public class BugTest extends AjdocTestCase { | |||||
public void testPr160302() throws Exception { | public void testPr160302() throws Exception { | ||||
initialiseProject("pr160302"); | initialiseProject("pr160302"); |
// the file contains the getI() method but doesn't contain | // the file contains the getI() method but doesn't contain | ||||
// the private ClassBar, Bazz and Jazz classes. | // the private ClassBar, Bazz and Jazz classes. | ||||
String[] strings = { "private", "getI()","ClassBar", "Bazz", "Jazz"}; | String[] strings = { "private", "getI()","ClassBar", "Bazz", "Jazz"}; | ||||
List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings); | |||||
List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings); | |||||
assertEquals("There should be 4 missing strings",4,missing.size()); | assertEquals("There should be 4 missing strings",4,missing.size()); | ||||
assertTrue(htmlFile.getName() + " should not contain the private modifier",missing.contains("private")); | assertTrue(htmlFile.getName() + " should not contain the private modifier",missing.contains("private")); | ||||
assertTrue(htmlFile.getName() + " should not contain the private ClassBar class",missing.contains("ClassBar")); | assertTrue(htmlFile.getName() + " should not contain the private ClassBar class",missing.contains("ClassBar")); | ||||
"Aspect ClassA</H2>", | "Aspect ClassA</H2>", | ||||
"public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"}; | "public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"}; | ||||
} | } | ||||
List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings); | |||||
List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings); | |||||
assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size()); | assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size()); | ||||
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>")); | assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>")); | ||||
if (LangUtil.is18VMOrGreater()) { | if (LangUtil.is18VMOrGreater()) { | ||||
"before(int):", | "before(int):", | ||||
"before(int): named()..", | "before(int): named()..", | ||||
"before():"}; | "before():"}; | ||||
List missing = AjdocOutputChecker.getMissingStringsInSection( | |||||
List<String> missing = AjdocOutputChecker.getMissingStringsInSection( | |||||
htmlFile, strings,"ADVICE DETAIL SUMMARY"); | htmlFile, strings,"ADVICE DETAIL SUMMARY"); | ||||
assertTrue(htmlFile.getName() + " should contain all advice in the Advice Detail section",missing.isEmpty()); | assertTrue(htmlFile.getName() + " should contain all advice in the Advice Detail section",missing.isEmpty()); | ||||
missing = AjdocOutputChecker.getMissingStringsInSection( | missing = AjdocOutputChecker.getMissingStringsInSection( |
<version>${project.version}</version> | <version>${project.version}</version> | ||||
</dependency> | </dependency> | ||||
</dependencies> | </dependencies> | ||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-jar-plugin</artifactId> | |||||
<version>2.2</version> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>test-jar</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> | </project> |