Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [wtp-releng] Failing JAX-WS tools unit tests in WTP 3.2 S-Build ... how to delete a test project


Thanks for the quick assessment, I've restarted a build and test and we'll see if it magically works ... but, does sound like you think it is a "test only" problem and no issue with quality of the build.

> Has anyone got any ideas on what might be causing this?

I know many others have had trouble deleting projects during tests. I think essentially something else "gets hold" of the project so it can not be deleted (yet).
Something like validation? Indexing? Compiling?

But, before discussing that more, I notice you create and delete the project for each test method. Is that intended and required? Can be kind of "expensive".
I know it is often required, but I always ask people this since I wrote Unit tests for several years thinking setup and teardown methods were called just once per suite, or once per class. But they are called before and after each test method. If you need a fresh project for each test method, that's fine ... just thought I'd mention it.

As for "how to delete a project", I'm sure others can better relate their direct experience, but I searched for and examined several "teardown" methods, and found these nuggets you might make use of, in your tear down method in AbstractAnnotationTest. Also, I see even in other jaxws or cfx tests there are other examples of other methods of deleting projects ... so, you'd want to look most closely at those.
These following methods are just from a quick sampling. I suspect the first and last would be most promising. Maybe "we" should write up a FAQ on this. (Or, find one ... I did some quick searches, but no hits).

How to delete a project in Unit tests.

 1. run as a workspace runnable, to ensure proper "access".
   
        IWorkspaceRunnable r = new IWorkspaceRunnable() {
                public void run(IProgressMonitor monitor) throws CoreException {
                        prj.delete(true, monitor);
                }
        };
        ResourcesPlugin.getWorkspace().run(r, prj, 0, null);
   
   
   
   2. Explicitly wait for (other) jobs to finish.
   Also note the refreshLocal.
   That should not be required, if "true, true, null" specified in delete method.
   In fact should probably be avoided, since could trigger other jobs.
   
   
        JobUtils.waitForJobs();
        try {
                project.refreshLocal(IResource.DEPTH_INFINITE, null);
                project.delete(true, true, null);
        } catch (ResourceException re) {
                /*
                 * silently swallow the resource exception. For some reason this exception gets thrown
                 * from time to time and reports the test failing. The project deletion itself happens
                 * after the test has completed and a failure will not report a problem in the test.
         * Only ResourceException is caught in order not to hide unexpected errors.        
                 */
                return;
        }
               
               
   
   
    3. Avoid problems with locked jars. Note too its good to 'fail fast' if you need to delete a project, and can not.
   
    protected void tearDown() throws Exception
    {
        super.tearDown();

        // ensure the project can be deleted (no jar lock:
        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195867)
        final IVirtualContainer container = _testEnv.getWebRoot(false, false);
        assertNotNull(container);
        final IFile file =
            container.getFile("WEB-INF/lib/fail2.jar").getUnderlyingFile();
        assertNotNull(file);
        assertTrue(file.exists());
        _testEnv.getTestProject().delete(true, null);
        assertFalse(_testEnv.getTestProject().exists());
        assertFalse(file.exists());
    }
   
   
    4. Close a project before deleting it.
   
   
    protected void tearDown() throws Exception
        {
            super.tearDown();
            final IProject project = _jdtTestEnvironment.getJavaProject().getProject();
   
            try
            {
                project.close(null);
                project.delete(true, null);
            }
            catch (final CoreException ce)
            {
                ce.printStackTrace(System.err);
            }
    }


Good luck.

Oh, and doh ... GMT ... I keep thinking that means UTC. :)





From: shane clarke <shane_clarke@xxxxxxxxxxx>
To: <wtp-releng@xxxxxxxxxxx>
Date: 12/10/2009 06:50 AM
Subject: [wtp-releng] Failing JAX-WS tools unit tests in WTP 3.2 S-Build
Sent by: wtp-releng-bounces@xxxxxxxxxxx





Hi,

The failing JAX-WS unit tests in the last S-Build all have to do with project deletion and have only just started appearing.

It happened once on the 8th in the JAX-WS build where 31 tests failed for the same reason but the same tests ran green a few hours later in the WTP stable build.

Now it's the reverse where last nights JAX-WS build ran green.

I won't be able to look at updating the project deletion code to try and fix this until later on this evening GMT time.

Has anyone got any ideas on what might be causing this?

Thanks,
Shane


New Windows 7: Simplify what you do everyday. Find the right PC for you._______________________________________________
wtp-releng mailing list
wtp-releng@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/wtp-releng



Back to the top