You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StructureModelUtilTest.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * Helen Hawkins Converted to new interface (bug 148190)
  12. * ******************************************************************/
  13. package org.aspectj.testing.util;
  14. import java.io.File;
  15. import java.util.List;
  16. import org.aspectj.ajde.core.AjdeCoreTestCase;
  17. import org.aspectj.ajde.core.TestCompilerConfiguration;
  18. import org.aspectj.asm.IProgramElement;
  19. import junit.framework.TestSuite;
  20. /**
  21. * @author Mik Kersten
  22. */
  23. public class StructureModelUtilTest extends AjdeCoreTestCase {
  24. private final String[] files = new String[] { "figures" + File.separator + "Debug.java",
  25. "figures" + File.separator + "Figure.java", "figures" + File.separator + "FigureElement.java",
  26. "figures" + File.separator + "Main.java", "figures" + File.separator + "composites" + File.separator + "Line.java",
  27. "figures" + File.separator + "composites" + File.separator + "Square.java",
  28. "figures" + File.separator + "primitives" + File.separator + "planar" + File.separator + "Point.java",
  29. "figures" + File.separator + "primitives" + File.separator + "solid" + File.separator + "SolidPoint.java" };
  30. public static void main(String[] args) {
  31. junit.swingui.TestRunner.run(StructureModelUtilTest.class);
  32. }
  33. public static TestSuite suite() {
  34. TestSuite result = new TestSuite();
  35. result.addTestSuite(StructureModelUtilTest.class);
  36. return result;
  37. }
  38. public void testPackageViewUtil() {
  39. List packages = StructureModelUtil.getPackagesInModel(getCompiler().getModel());
  40. assertTrue("packages list not null", packages != null);
  41. assertTrue("packages list not empty", !packages.isEmpty());
  42. IProgramElement packageNode = (IProgramElement) ((Object[]) packages.get(0))[0];
  43. assertTrue("package node not null", packageNode != null);
  44. List files = StructureModelUtil.getFilesInPackage(packageNode);
  45. assertTrue("fle list not null", files != null);
  46. // TODO: re-enable
  47. // Map lineAdviceMap = StructureModelUtil.getLinesToAspectMap(
  48. // ((IProgramElement)files.get(0)).getSourceLocation().getSourceFile().getAbsolutePath()
  49. // );
  50. //
  51. // assertTrue("line->advice map not null", lineAdviceMap != null);
  52. //
  53. // Set aspects = StructureModelUtil.getAspectsAffectingPackage(packageNode);
  54. // assertTrue("aspect list not null", aspects != null);
  55. }
  56. protected void setUp() throws Exception {
  57. super.setUp();
  58. initialiseProject("figures-coverage");
  59. TestCompilerConfiguration compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
  60. compilerConfig.setProjectSourceFiles(getSourceFileList(files));
  61. doBuild();
  62. }
  63. protected void tearDown() throws Exception {
  64. super.tearDown();
  65. }
  66. }