]> source.dussan.org Git - aspectj.git/commitdiff
251277: making asmmanager non-singleton
authoraclement <aclement>
Mon, 20 Oct 2008 04:41:58 +0000 (04:41 +0000)
committeraclement <aclement>
Mon, 20 Oct 2008 04:41:58 +0000 (04:41 +0000)
ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
ajde/testsrc/org/aspectj/ajde/SymbolFileGenerationTest.java
ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java

index 3d8f52f22e1b1d3d9d81a9380aa01fe8d890a824..5f2b2f2f780272c9f174fd65e20bacc28c887247 100644 (file)
@@ -20,8 +20,6 @@ import java.util.List;
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.IconRegistry;
 import org.aspectj.ajde.core.AjCompiler;
 import org.aspectj.ajde.ui.utils.TestBuildProgressMonitor;
 import org.aspectj.ajde.ui.utils.TestCompilerConfiguration;
@@ -29,118 +27,109 @@ import org.aspectj.ajde.ui.utils.TestEditorAdapter;
 import org.aspectj.ajde.ui.utils.TestIdeUIAdapter;
 import org.aspectj.ajde.ui.utils.TestMessageHandler;
 import org.aspectj.ajde.ui.utils.TestRuntimeProperties;
-import org.aspectj.asm.AsmManager;
 import org.aspectj.tools.ajc.Ajc;
 
 public class AjdeTestCase extends TestCase {
 
-    public final static String testdataSrcDir = "../ajde/testdata";
+       public final static String testdataSrcDir = "../ajde/testdata";
        protected static File sandboxDir;
-       
+
        private String projectDir;
-    
+
        protected void setUp() throws Exception {
                super.setUp();
                // Create a sandbox in which to work
                sandboxDir = Ajc.createEmptySandbox();
-               // AMC - added this next line as a temporary workaround for 
+               // AMC - added this next line as a temporary workaround for
                // listener leakage in AsmManager induced by the Ajde test suite.
-               AsmManager.getDefault().removeAllListeners();
+               // Ajde.getDefault().getModel().removeAllListeners();
        }
-       
+
        protected void tearDown() throws Exception {
                super.tearDown();
                projectDir = null;
                sandboxDir = null;
        }
-       
+
        /**
-        * Fill in the working directory with the project files and
-        * creates a compiler instance for this project
+        * Fill in the working directory with the project files and creates a compiler instance for this project
         */
        public void initialiseProject(String projectName) {
-               
-               
-               File projectSrc=new File(testdataSrcDir + File.separatorChar + projectName);
-               File destination=new File(getWorkingDir(),projectName);
-               if (!destination.exists()) {destination.mkdir();}
-               copy(projectSrc,destination);
+
+               File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName);
+               File destination = new File(getWorkingDir(), projectName);
+               if (!destination.exists()) {
+                       destination.mkdir();
+               }
+               copy(projectSrc, destination);
                projectDir = destination.getAbsolutePath();
 
                // need to initialize via AjdeUIManager
-               Ajde.getDefault().init(
-                               new TestCompilerConfiguration(projectDir), 
-                               new TestMessageHandler(), 
-                               new TestBuildProgressMonitor(), 
-                               new TestEditorAdapter(), 
-                               new TestIdeUIAdapter(), 
-                               new IconRegistry(), 
-                               null, //new JFrame(), 
-                               new TestRuntimeProperties(), 
-                               true);
+               Ajde.getDefault().init(new TestCompilerConfiguration(projectDir), new TestMessageHandler(), new TestBuildProgressMonitor(),
+                               new TestEditorAdapter(), new TestIdeUIAdapter(), new IconRegistry(), null, // new JFrame(),
+                               new TestRuntimeProperties(), true);
        }
-       
+
        /**
         * @return the working directory
         */
-       protected File getWorkingDir() { 
-               return sandboxDir; 
+       protected File getWorkingDir() {
+               return sandboxDir;
        }
-       
+
        /**
-        * @return the absolute path of the project directory
-        * for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject
+        * @return the absolute path of the project directory for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject
         */
        protected String getAbsoluteProjectDir() {
                return projectDir;
        }
-       
+
        /**
-        * Copy the contents of some directory to another location - the
-        * copy is recursive.
+        * Copy the contents of some directory to another location - the copy is recursive.
         */
        private void copy(File from, File to) {
                String contents[] = from.list();
-               if (contents==null) return;
+               if (contents == null)
+                       return;
                for (int i = 0; i < contents.length; i++) {
                        String string = contents[i];
-                       File f = new File(from,string);
-                       File t = new File(to,string);
-                       
+                       File f = new File(from, string);
+                       File t = new File(to, string);
+
                        if (f.isDirectory()) {
                                t.mkdir();
-                               copy(f,t);
+                               copy(f, t);
                        } else if (f.isFile()) {
                                try {
-                                       org.aspectj.util.FileUtil.copyFile(f,t);
+                                       org.aspectj.util.FileUtil.copyFile(f, t);
                                } catch (IOException e) {
                                        throw new AssertionFailedError("Unable to copy " + f + " to " + t);
                                }
-                       } 
+                       }
                }
        }
-       
+
        protected File openFile(String path) {
                return new File(projectDir + File.separatorChar + path);
        }
-       
+
        public void doBuild(String configFile) {
                getCompilerForConfigFileWithName(configFile).build();
        }
-       
+
        public AjCompiler getCompilerForConfigFileWithName(String configFileName) {
                return Ajde.getDefault().getCompilerForConfigFile(projectDir + File.separator + configFileName);
        }
 
        public List getErrorMessages(String configFileName) {
-               return ((TestMessageHandler)getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getErrors();
+               return ((TestMessageHandler) getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getErrors();
        }
-       
+
        public List getMessages(String configFileName) {
-               return ((TestMessageHandler)getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getMessages();
+               return ((TestMessageHandler) getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getMessages();
+       }
+
+       protected String genStructureModelExternFilePath(String configFilePath) {
+               return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym";
        }
-       
-    protected String genStructureModelExternFilePath(String configFilePath) {
-        return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym";
-    }
 }
index b1c4e40eff6efa4021da4a84aefc0e4c24eb8d85..f2fd49bcf637bb31088235992a3ea4307dd1ed54 100644 (file)
  *******************************************************************************/
 package org.aspectj.ajde;
 
+import java.io.File;
 import java.util.Iterator;
 import java.util.List;
-//import java.util.Properties;
-import java.io.File;
 
 import org.aspectj.asm.AsmManager;
 import org.aspectj.asm.IProgramElement;
 import org.aspectj.bridge.IMessage;
+import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
 import org.aspectj.tools.ajc.AjcTestCase;
 import org.aspectj.tools.ajc.CompilationResult;
-import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
 
 /**
- * Tests the 'extensions' to AJDE:
- * 1) ID is now available on messages to allow you to see what 'kind' of 
- *    message it is - this activates quick fixes/etc in Eclipse.
+ * Tests the 'extensions' to AJDE: 1) ID is now available on messages to allow you to see what 'kind' of message it is - this
+ * activates quick fixes/etc in Eclipse.
  */
 public class ExtensionTests extends AjcTestCase {
 
        public static final String PROJECT_DIR = "extensions";
        private static final boolean debugTests = false;
        private File baseDir;
-       
+
        protected void setUp() throws Exception {
                super.setUp();
-        // TODO-path
-               baseDir = new File("../ajde/testdata",PROJECT_DIR);
+               // TODO-path
+               baseDir = new File("../ajde/testdata", PROJECT_DIR);
        }
-       
+
        /**
         * Aim: Check that the ID of certain message kinds are correct
         * 
-        *   ajc -warn:unusedImport UnusedImport.java
+        * ajc -warn:unusedImport UnusedImport.java
         * 
         * Expected result is that id matches IProblem.UnusedImport
         */
-       public void testMessageID () {
-               String[] args = new String[] {"UnusedImport.java","-warn:unusedImport"};
-               CompilationResult result = ajc(baseDir,args);
+       public void testMessageID() {
+               String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" };
+               CompilationResult result = ajc(baseDir, args);
                List l = result.getWarningMessages();
-               IMessage m = ((IMessage)l.get(0));
-               assertTrue("Expected ID of message to be "+IProblem.UnusedImport+" (UnusedImport) but found an ID of "+m.getID(),
-                       m.getID()==IProblem.UnusedImport);
+               IMessage m = ((IMessage) l.get(0));
+               assertTrue("Expected ID of message to be " + IProblem.UnusedImport + " (UnusedImport) but found an ID of " + m.getID(), m
+                               .getID() == IProblem.UnusedImport);
        }
-       
+
        public void testInnerClassesInASM() {
-               String[] args = new String[] {"InnerClasses.java","-emacssym"};
-               CompilationResult result = ajc(baseDir,args);
-               /*List l = */result.getWarningMessages();
-               /*Properties p = */AsmManager.ModelInfo.summarizeModel().getProperties();
-               if (debugTests) System.out.println("Structure Model for InnerClasses.java:");
-               walkit(AsmManager.getDefault().getHierarchy().getRoot(),0);
+               String[] args = new String[] { "InnerClasses.java", "-emacssym" };
+               CompilationResult result = ajc(baseDir, args);
+               /* List l = */result.getWarningMessages();
+               /* Properties p = */AsmManager.lastActiveStructureModel.summarizeModel().getProperties();
+               if (debugTests)
+                       System.out.println("Structure Model for InnerClasses.java:");
+               walkit(AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0);
                foundNode = null;
-               findChild("main",AsmManager.getDefault().getHierarchy().getRoot());
-               assertTrue("Should have found node 'main' in the model",foundNode!=null);
-               IProgramElement runnableChild = getChild(foundNode,"new Runnable() {..}");
-               assertTrue("'main' should have a child 'new Runnable() {..}'",
-                               runnableChild!=null);
-               assertTrue("'new Runnable() {..}' should have a 'run' child",
-                               getChild(runnableChild,"run")!=null);
-               
-               /* Left hand side is before the fix, right hand side is after:
-<root>
-  InnerClasses.java
-    import declarations
-    InnerClasses
-      A                                                        A
-        method                                         method
-        1                                                              new Runnable() {..}
-          run                                                          run
-      main                                             main
-      2                                                                new Runnable() {..}
-         run                                                   run
-      3                                                        new Object() {..}
-        toString                                               toString
-      4                                                                new Runnable
-        run                                                            run
+               findChild("main", AsmManager.lastActiveStructureModel.getHierarchy().getRoot());
+               assertTrue("Should have found node 'main' in the model", foundNode != null);
+               IProgramElement runnableChild = getChild(foundNode, "new Runnable() {..}");
+               assertTrue("'main' should have a child 'new Runnable() {..}'", runnableChild != null);
+               assertTrue("'new Runnable() {..}' should have a 'run' child", getChild(runnableChild, "run") != null);
+
+               /*
+                * Left hand side is before the fix, right hand side is after: <root> InnerClasses.java import declarations InnerClasses A A
+                * method method 1 new Runnable() {..} run run main main 2 new Runnable() {..} run run 3 new Object() {..} toString toString
+                * 4 new Runnable run run
                 */
 
        }
-       
-       private IProgramElement getChild(IProgramElement parent,String s) {
+
+       private IProgramElement getChild(IProgramElement parent, String s) {
                List kids = parent.getChildren();
                for (Iterator iter = kids.iterator(); iter.hasNext();) {
                        IProgramElement element = (IProgramElement) iter.next();
-                       if (element.getName().indexOf(s)!=-1) return element;
+                       if (element.getName().indexOf(s) != -1)
+                               return element;
                }
                return null;
        }
-       
+
        private IProgramElement foundNode = null;
-       
-       private void findChild(String s,IProgramElement ipe) {
-               if (ipe == null) return;
-               if (ipe.getName().indexOf(s)!=-1) {foundNode = ipe; return;}
-               if (ipe.getChildren()!=null) {
+
+       private void findChild(String s, IProgramElement ipe) {
+               if (ipe == null)
+                       return;
+               if (ipe.getName().indexOf(s) != -1) {
+                       foundNode = ipe;
+                       return;
+               }
+               if (ipe.getChildren() != null) {
                        List kids = ipe.getChildren();
                        for (Iterator iter = kids.iterator(); iter.hasNext();) {
                                IProgramElement element = (IProgramElement) iter.next();
-                               findChild(s,element);
+                               findChild(s, element);
                        }
                }
        }
-       
-       public void walkit(IProgramElement ipe,int indent) {
-         if (ipe!=null) {
-                 if (debugTests) for (int i = 0 ;i<indent;i++) System.out.print(" ");
-                 if (debugTests) System.out.println(ipe.toLabelString());//getName());
-           if (ipe.getChildren()!=null) {
-               List kids = ipe.getChildren();
-               for (Iterator iter = kids.iterator(); iter.hasNext();) {
-                               IProgramElement element = (IProgramElement) iter.next();
-                               walkit(element,indent+2);
+
+       public void walkit(IProgramElement ipe, int indent) {
+               if (ipe != null) {
+                       if (debugTests)
+                               for (int i = 0; i < indent; i++)
+                                       System.out.print(" ");
+                       if (debugTests)
+                               System.out.println(ipe.toLabelString());// getName());
+                       if (ipe.getChildren() != null) {
+                               List kids = ipe.getChildren();
+                               for (Iterator iter = kids.iterator(); iter.hasNext();) {
+                                       IProgramElement element = (IProgramElement) iter.next();
+                                       walkit(element, indent + 2);
+                               }
                        }
-           }
-         }
+               }
        }
-       
 
        /**
         * Aim: Check that the start/end of certain warnings are correct
         * 
-        *   ajc -warn:unusedImport UnusedImport.java
+        * ajc -warn:unusedImport UnusedImport.java
         * 
         * Expected result is first warning message has start=7 end=20
         */
        public void testMessageSourceStartEnd() {
-               String[] args = new String[] {"UnusedImport.java","-warn:unusedImport"};
-               CompilationResult result = ajc(baseDir,args);
+               String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" };
+               CompilationResult result = ajc(baseDir, args);
                List l = result.getWarningMessages();
-               IMessage m = ((IMessage)l.get(0));
-               assertTrue("Expected source start to be 7 but was "+m.getSourceStart(),
-                       m.getSourceStart()==7);
-               assertTrue("Expected source end to be 20 but was "+m.getSourceEnd(),
-                               m.getSourceEnd()==20);
-       }       
+               IMessage m = ((IMessage) l.get(0));
+               assertTrue("Expected source start to be 7 but was " + m.getSourceStart(), m.getSourceStart() == 7);
+               assertTrue("Expected source end to be 20 but was " + m.getSourceEnd(), m.getSourceEnd() == 20);
+       }
 
 }
index 96122bd5f12f99ccc401053fe748715dd31d4ae8..2d166969507f4e592970be01063d6dac97318835 100644 (file)
@@ -26,61 +26,55 @@ public class SymbolFileGenerationTest extends AjcTestCase {
        private static final String DIR = "../ajde/testdata/examples/coverage";
 
        protected File dir = new File(DIR);
-       protected File configFile = new File(DIR + "/coverage.lst");    
+       protected File configFile = new File(DIR + "/coverage.lst");
        protected File esymFile, outDir, crossRefsFile;
-       
+
        protected void setUp() throws Exception {
                super.setUp();
                esymFile = new File(DIR + "/ModelCoverage.ajesym");
-               outDir = new File(DIR + "/bin");        
+               outDir = new File(DIR + "/bin");
                crossRefsFile = new File(outDir.getAbsolutePath() + "/build.ajsym");
        }
-       
+
        protected void tearDown() throws Exception {
                super.tearDown();
-                               
-               FileUtil.deleteContents(new File(DIR),ajesymResourceFileFilter);
-               FileUtil.deleteContents(new File(DIR + "/pkg"),ajesymResourceFileFilter);
-               
+
+               FileUtil.deleteContents(new File(DIR), ajesymResourceFileFilter);
+               FileUtil.deleteContents(new File(DIR + "/pkg"), ajesymResourceFileFilter);
+
                FileUtil.deleteContents(new File(DIR + "/bin"));
                (new File(DIR + "/bin")).delete();
 
        }
-       
-       public FileFilter ajesymResourceFileFilter =
-               new FileFilter() {
+
+       public FileFilter ajesymResourceFileFilter = new FileFilter() {
                public boolean accept(File pathname) {
                        String name = pathname.getName().toLowerCase();
                        return name.endsWith(".ajesym");
                }
        };
-               
+
        public void testCrossRefsFileGeneration() {
-               if (crossRefsFile.exists()) assertTrue(crossRefsFile.delete());
-               if (esymFile.exists()) assertTrue(esymFile.delete());
-               String[] args = new String[] {
-                               "-d",
-                               outDir.getAbsolutePath(),
-                               "-crossrefs",
-                               "@" + configFile.getAbsolutePath()
-               };
+               if (crossRefsFile.exists())
+                       assertTrue(crossRefsFile.delete());
+               if (esymFile.exists())
+                       assertTrue(esymFile.delete());
+               String[] args = new String[] { "-d", outDir.getAbsolutePath(), "-crossrefs", "@" + configFile.getAbsolutePath() };
                ajc(dir, args);
-               
+
                assertFalse(esymFile.exists());
                assertTrue(crossRefsFile.exists());
        }
 
        public void testEmacssymGeneration() {
-               if (crossRefsFile.exists()) assertTrue(crossRefsFile.delete());
-               if (esymFile.exists()) assertTrue(esymFile.delete());
-               String[] args = new String[] {
-                               "-d",
-                               outDir.getAbsolutePath(),
-                               "-emacssym",
-                               "@" + configFile.getAbsolutePath()
-               };
+               if (crossRefsFile.exists()) {
+                       assertTrue(crossRefsFile.delete());
+               }
+               if (esymFile.exists())
+                       assertTrue(esymFile.delete());
+               String[] args = new String[] { "-d", outDir.getAbsolutePath(), "-emacssym", "@" + configFile.getAbsolutePath() };
                ajc(dir, args);
-               
+
                assertTrue(esymFile.exists());
                assertFalse(crossRefsFile.exists());
        }
index d88bbc33241b60ef972edcc435ec5ee5b64032df..8e407f48db39ee189cd9a3e409c6a99ed7d4569b 100644 (file)
@@ -11,8 +11,7 @@
  *     Helen Hawkins  Converted to new interface (bug 148190) 
  * ******************************************************************/
 
-
-package org.aspectj.ajde.ui; 
+package org.aspectj.ajde.ui;
 
 import java.io.File;
 import java.util.Iterator;
@@ -29,13 +28,13 @@ import org.aspectj.asm.IProgramElement;
  * @author Mik Kersten
  */
 public class StructureViewManagerTest extends AjdeTestCase {
-       
-    // TODO-path
+
+       // TODO-path
        private final String CONFIG_FILE_PATH = "all.lst";
        private final String CONFIG_FILE_PATH_2 = "inheritance.lst";
-       
+
        private FileStructureView currentView;
-       private NullIdeStructureViewRenderer renderer = new NullIdeStructureViewRenderer();
+       private final NullIdeStructureViewRenderer renderer = new NullIdeStructureViewRenderer();
        private File testFile;
        private StructureViewProperties properties;
 
@@ -45,12 +44,12 @@ public class StructureViewManagerTest extends AjdeTestCase {
 
        public static TestSuite suite() {
                TestSuite result = new TestSuite();
-               result.addTestSuite(StructureViewManagerTest.class);    
+               result.addTestSuite(StructureViewManagerTest.class);
                return result;
        }
 
        public void testModelExists() {
-               assertTrue(AsmManager.getDefault().getHierarchy() != null);
+               assertTrue(Ajde.getDefault().getModel().getHierarchy() != null);
        }
 
        public void testNotificationAfterConfigFileChange() {
@@ -58,61 +57,55 @@ public class StructureViewManagerTest extends AjdeTestCase {
                doBuild(CONFIG_FILE_PATH_2);
                renderer.setHasBeenNotified(false);
                assertTrue("not yet notified", !renderer.getHasBeenNotified());
-               Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(CONFIG_FILE_PATH_2);                      
+               Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(CONFIG_FILE_PATH_2);
                assertTrue("notified", renderer.getHasBeenNotified());
                renderer.setHasBeenNotified(false);
-               Ajde.getDefault().getBuildConfigManager().setActiveConfigFile("MumbleDoesNotExist.lst");                        
-               assertTrue("notified", renderer.getHasBeenNotified());          
-               
-               assertTrue(
-                       "no structure", 
-                       currentView.getRootNode().getStructureNode().getChildren().get(0) 
-                       == IHierarchy.NO_STRUCTURE
-               );                      
+               Ajde.getDefault().getBuildConfigManager().setActiveConfigFile("MumbleDoesNotExist.lst");
+               assertTrue("notified", renderer.getHasBeenNotified());
+
+               assertTrue("no structure", currentView.getRootNode().getStructureNode().getChildren().get(0) == IHierarchy.NO_STRUCTURE);
        }
 
        /**
-        * @todo        this should be moved to a StructureModelManager test
+        * @todo this should be moved to a StructureModelManager test
         */
        public void testFreshStructureModelCreation() {
                renderer.setHasBeenNotified(false);
                String modelPath = genStructureModelExternFilePath(CONFIG_FILE_PATH);
                openFile(modelPath).delete();
-               
-               AsmManager.getDefault().readStructureModel(CONFIG_FILE_PATH);
-               
-               assertTrue("notified", renderer.getHasBeenNotified());  
-               // AMC should this be currentView, or should we recreate the root... do the latter      
-               //IProgramElement n = currentView.getRootNode().getIProgramElement();
-               IProgramElement n = AsmManager.getDefault().getHierarchy().getRoot();
-               assertTrue(
-                       "no structure", 
-                       //currentView.getRootNode().getIProgramElement().getChildren().get(0) 
-                       n == IHierarchy.NO_STRUCTURE
-               );      
+
+               Ajde.getDefault().getModel().readStructureModel(CONFIG_FILE_PATH);
+
+               assertTrue("notified", renderer.getHasBeenNotified());
+               // AMC should this be currentView, or should we recreate the root... do the latter
+               // IProgramElement n = currentView.getRootNode().getIProgramElement();
+               IProgramElement n = Ajde.getDefault().getModel().getHierarchy().getRoot();
+               assertTrue("no structure",
+               // currentView.getRootNode().getIProgramElement().getChildren().get(0)
+                               n == IHierarchy.NO_STRUCTURE);
        }
 
        public void testModelIntegrity() {
                doBuild(CONFIG_FILE_PATH);
-               IProgramElement modelRoot = AsmManager.getDefault().getHierarchy().getRoot();
-               assertTrue("root exists", modelRoot != null);   
-               
+               IProgramElement modelRoot = Ajde.getDefault().getModel().getHierarchy().getRoot();
+               assertTrue("root exists", modelRoot != null);
+
                try {
                        testModelIntegrityHelper(modelRoot);
                } catch (Exception e) {
-                       assertTrue(e.toString(), false);        
+                       assertTrue(e.toString(), false);
                }
        }
 
        private void testModelIntegrityHelper(IProgramElement node) throws Exception {
-               for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
-                       IProgramElement child = (IProgramElement)it.next();
+               for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
+                       IProgramElement child = (IProgramElement) it.next();
                        if (node == child.getParent()) {
                                testModelIntegrityHelper(child);
                        } else {
                                throw new Exception("parent-child check failed for child: " + child.toString());
                        }
-               }               
+               }
        }
 
        public void testNotificationAfterBuild() {
@@ -122,21 +115,19 @@ public class StructureViewManagerTest extends AjdeTestCase {
        }
 
        public void testViewCreationWithNullSourceFileAndProperties() {
-               currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(null, null);  
-               assertTrue(
-                       "no structure", 
-                       currentView.getRootNode().getStructureNode() 
-                       == IHierarchy.NO_STRUCTURE
-               );
+               currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(null, null);
+               assertTrue("no structure", currentView.getRootNode().getStructureNode() == IHierarchy.NO_STRUCTURE);
        }
-  
+
        protected void setUp() throws Exception {
                super.setUp();
+
+               AsmManager.forceSingletonBehaviour = true;
                initialiseProject("figures-coverage");
-               doBuild(CONFIG_FILE_PATH);              
-               
+               doBuild(CONFIG_FILE_PATH);
+
                properties = Ajde.getDefault().getStructureViewManager().getDefaultViewProperties();
-        // TODO-path
+               // TODO-path
                testFile = openFile("../examples/figures-coverage/figures/Figure.java");
                currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(testFile.getAbsolutePath(), properties);
                currentView.setRenderer(renderer);
@@ -144,6 +135,6 @@ public class StructureViewManagerTest extends AjdeTestCase {
 
        protected void tearDown() throws Exception {
                super.tearDown();
+               AsmManager.forceSingletonBehaviour = false;
        }
 }
-