[jbosstools-issues] [JBoss JIRA] Commented: (JBIDE-1628) NulPointerException in model when executing JUnit tests for VPE without delay time.

Snjezana Peco (JIRA) jira-events at lists.jboss.org
Sat Jan 26 21:18:21 EST 2008


    [ http://jira.jboss.com/jira/browse/JBIDE-1628?page=comments#action_12397010 ] 
            
Snjezana Peco commented on JBIDE-1628:
--------------------------------------

I have tested HtmlAllTests and noticed a few issues :

1) Threading problem in the PreferenceModelUtilities class
The problem happens no matter if line 35 is commented or not.
The following code doesn't help:

static {
ClassLoaderUtil.init();
}
 
The cause of this problem is that Xerces isn't thread-safe.
The solution is to make synchronized all the methods in the PreferenceModelUtilities class.

2) The WTPTextJspKbConnector.invokeDelayedUpdateKnownTagLists() method schedules the MyTimerTask timer for execution after 0.5 sec.
If the editor is closed before starting the timer, the tests will throw NPE.
One solution would be to uncomment line 35. A better solution would be to check if the editor is closed in the MyTimerTask class.

3) The problem with wtp validators.
I'm not sure if this is a bug in the wtp validators or some validator is implemented incorrectly.
The result is throwing the following exception :

java.lang.NullPointerException
    at org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy.endProcessing(ValidatorStrategy.java:140)
    at org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor.endProcessing(DocumentRegionProcessor.java:71)
    at org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor.run(DirtyRegionProcessor.java:647)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

or NPE in the DirtyRegionProcessor.computePartitioning(int drOffset, int drLength) method.

I propose suspending all validators unless if the validators are tested.
This can be achieved by the following code (VpeTest.java) :

protected void performTestForVpeComponent(IFile componentPage)
            throws PartInitException, Throwable {
        performTestForVpeComponent(componentPage, true);
    }
   
    protected void performTestForVpeComponent(IFile componentPage, boolean disableValidation)
            throws PartInitException, Throwable {
        TestUtil.waitForJobs();

        if (disableValidation) {
            IProject project = componentPage.getProject();
            if (project != null) {
                ProjectConfiguration projectConfiguration = ConfigurationManager
                        .getManager().getProjectConfiguration(project);
                projectConfiguration.setDoesProjectOverride(true);
                projectConfiguration.setDisableAllValidation(true);
            }
        }

It is necessary to add org.eclipse.wst.validation to the required plugins of the org.jboss.tools.jsf.vpe.ui.test plugin.

4) The problem with the IModelLifecycleListener listener in the VpeController class

VpeController is added to the sourceModel object as IModelLifecycleListener (the init() method), but it isn't removed. This causes NPE sometimes.
The solution is to add the following code to the dispose method:

IDOMModel sourceModel = (IDOMModel)getModel();
        if (sourceModel != null) {
            sourceModel.removeModelLifecycleListener(this);
        }

This issue has been fixed within my patch for JBIDE-1105.

5) The JBIDE1479Test test doesn't test jira 1479.
The problem in jira 1479  happens because VpeController.notifyChanged is called in non-UI thread. The test calls this method in the UI thread.
The correct test would be as follows:

...
assertNotNull("Editor input is null", input);

       
        TestUtil.waitForJobs();
        JSPMultiPageEditor  part = openEditor(input);
        TestUtil.waitForJobs();
        assertNotNull(part);
        Job job = new WorkspaceJob("Test"){
            public IStatus runInWorkspace(IProgressMonitor monitor) {
                try {
                    new FormatProcessorXML().formatFile(file);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                finished = true;
                return Status.OK_STATUS;
            }

        };
        job.setPriority(Job.SHORT);
        job.schedule(0L);
        TestUtil.waitForJobs();
        while (!finished) {
            TestUtil.delay(1000L);
        }
        TestUtil.delay(15000L);
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                                .closeAllEditors(false);
...


> NulPointerException in model when executing JUnit tests for VPE without delay time.
> -----------------------------------------------------------------------------------
>
>                 Key: JBIDE-1628
>                 URL: http://jira.jboss.com/jira/browse/JBIDE-1628
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: Visual Page Editor
>    Affects Versions: 2.0.0.GA
>            Reporter: Maxim Areshkau
>         Assigned To: Max Andersen
>             Fix For: 2.1
>
>         Attachments: JUnitNullPointer-exception.log.txt
>
>
> java.lang.NullPointerException exception throws in org.jboss.tools.common.model.options.PreferenceModelUtilities when we executing junit without delay time.
> Steps to Reroduce:
> 1. Run Junit for JSF components and look in TestResult file.
> 2.Go into class VpeTest and comment in function performTestForVpeComponent line TestUtil.delay(1000);
> 3. Set breakpoint in org.jboss.tools.common.model.options.PreferenceModelUtilities on line 35(catch block in first static initialization block)
> 4.Run again JUnit tests for jsf and look in testResultFile again.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbosstools-issues mailing list