This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 99737 - Assertion error thrown from tests
Summary: Assertion error thrown from tests
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: TEST
Depends on:
Blocks:
 
Reported: 2007-04-03 00:06 UTC by Jesse Glick
Modified: 2007-05-11 07:57 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stacktrace (4.05 KB, text/plain)
2007-04-04 13:22 UTC, Erno Mononen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2007-04-03 00:06:08 UTC
I have various unit tests in various modules which load the module system. If
java/source happens to be in the run CP for whatever reason, the test runs OK
but prints a useless error:

java.lang.AssertionError
        at
org.netbeans.modules.java.source.usages.Index.getNbUserDir(Index.java:195)
        at
org.netbeans.modules.java.source.usages.NBLockFactory.getLockDir(NBLockFactory.java:61)
        at
org.netbeans.modules.java.source.usages.NBLockFactory.clearLocks(NBLockFactory.java:50)
        at
org.netbeans.modules.java.source.JBrowseModule.restored(JBrowseModule.java:57)
        at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:364)
        at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:273)
        at org.netbeans.ModuleManager.enable(ModuleManager.java:903)
        at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:380)
        at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:316)
        at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:260)
        at org.netbeans.core.startup.Main.getModuleSystem(Main.java:149)
        at org.netbeans.core.startup.MainLookup.beforeLookup(MainLookup.java:190)
        at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:187)
        at org.netbeans.modules.apisupport.project.TestBase.setUp(TestBase.java:95)

Please suppress this. My tests do not deal with the Java source index and I have
no reason to set a user directory.
Comment 1 Erno Mononen 2007-04-04 13:21:02 UTC
Since 03/31 several j2ee tests fail due to the same assertion error, although 
the stack trace is different.

java.lang.AssertionError
	at 
org.netbeans.modules.java.source.usages.Index.getNbUserDir(Index.java:195)
	at 
org.netbeans.modules.java.source.usages.Index.getCacheFolder(Index.java:201)
	at 
org.netbeans.modules.java.source.usages.Index.loadSegments(Index.java:80)
...

I'm raising this to P2.
Comment 2 Erno Mononen 2007-04-04 13:22:59 UTC
Created attachment 40432 [details]
stacktrace
Comment 3 Tomas Zezula 2007-04-10 10:11:14 UTC
The issue has two parts.
The first (reported by Jesse): The test doesn't use java infrastructure, so the
assertion error shouldn't be thrown.
The second (reported by Erno): The code uses a java infrastructure, the test
should use the IndexUtil.setCacheFolder (File) to set up the java infrastructure.
Comment 4 Erno Mononen 2007-04-10 10:31:11 UTC
I see, so for tests the cache folder can be any empty folder?
Comment 5 Tomas Zezula 2007-04-10 12:34:11 UTC
Yes, an empty folder is fine. Typically an empty folder under the test work dir,
so cleanWorkingDir () deletes it.
Comment 6 Tomas Zezula 2007-04-10 14:32:14 UTC
Checking in src/org/netbeans/modules/java/source/usages/Index.java;
/cvs/java/source/src/org/netbeans/modules/java/source/usages/Index.java,v  <-- 
Index.java
new revision: 1.11; previous revision: 1.10
done
Checking in src/org/netbeans/modules/java/source/usages/NBLockFactory.java;
/cvs/java/source/src/org/netbeans/modules/java/source/usages/NBLockFactory.java,v
 <--  NBLockFactory.java
new revision: 1.2; previous revision: 1.1
done
Comment 7 Jesse Glick 2007-04-11 01:45:06 UTC
Testsuite: org.netbeans.modules.java.j2seproject.J2SESourcesTest
Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 5.664 sec

Apr 10, 2007 8:44:05 PM org.openide.util.Exceptions printStackTrace
SEVERE: null
java.lang.AssertionError
	at org.netbeans.modules.java.source.usages.Index.getCacheFolder(Index.java:199)
	at org.netbeans.modules.java.source.usages.Index.loadSegments(Index.java:78)
	at org.netbeans.modules.java.source.usages.Index.getDataFolder(Index.java:146)
	at
org.netbeans.modules.java.source.usages.ClassIndexManager.createUsagesQuery(ClassIndexManager.java:79)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.scanRoots(RepositoryUpdater.java:887)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.access$1500(RepositoryUpdater.java:617)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker$1.run(RepositoryUpdater.java:708)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker$1.run(RepositoryUpdater.java:645)
	at
org.netbeans.modules.java.source.usages.ClassIndexManager.writeLock(ClassIndexManager.java:49)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.run(RepositoryUpdater.java:642)
	at
org.netbeans.modules.java.source.usages.RepositoryUpdater$CompileWorker.run(RepositoryUpdater.java:617)
	at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1112)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
	at java.util.concurrent.FutureTask.run(FutureTask.java:123)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	at java.lang.Thread.run(Thread.java:595)
Caused by: While scanning:
jar:file:/space/src/nb_all/java/j2seproject/build/test/unit/work/org.netbeans.modules.java.j2seproject.J2SESourcesTest/testIncludesExcludes/proj/$%7Blibs.junit.classpath%7D!/
Comment 8 Tomas Zezula 2007-04-11 13:10:46 UTC
I see, the problem is that the MainClassUpdater start the java infrastructure
and the infrastructure is not properly initialized (there is no nb user dir).
Comment 9 Jesse Glick 2007-04-24 19:16:46 UTC
Here's another problem:

java.lang.AssertionError
        at
org.netbeans.modules.java.source.usages.NBLockFactory.getLockDir(NBLockFactory.java:62)
        at
org.netbeans.modules.java.source.usages.NBLockFactory.clearLocks(NBLockFactory.java:50)
        at
org.netbeans.modules.java.source.JBrowseModule.restored(JBrowseModule.java:57)
        at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:364)
        at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:273)
        at org.netbeans.ModuleManager.enable(ModuleManager.java:903)
        at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:380)
        at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:316)
        at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:260)
        at org.netbeans.core.startup.Main.getModuleSystem(Main.java:149)
        at org.netbeans.core.startup.MainLookup.beforeLookup(MainLookup.java:190)
        at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:187)
        at org.netbeans.modules.apisupport.project.TestBase.setUp(TestBase.java:98)
        at
org.netbeans.modules.apisupport.project.queries.ClassPathProviderImplTest.setUp(ClassPathProviderImplTest.java:77)
        at org.netbeans.junit.NbTestCase.runBare(NbTestCase.java:278)
        [....]
Comment 10 Tomas Zezula 2007-04-24 19:33:29 UTC
OK, this one should be easy to fix.
Comment 11 Tomas Zezula 2007-05-10 09:46:42 UTC
Checking in NBLockFactory.java;
/cvs/java/source/src/org/netbeans/modules/java/source/usages/NBLockFactory.java,v
 <--  NBLockFactory.java
new revision: 1.3; previous revision: 1.2
done
Comment 12 Tomas Zezula 2007-05-11 07:57:18 UTC
Checking in src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/MainClassUpdater.java,v
 <--  MainClassUpdater.java
new revision: 1.10; previous revision: 1.9
done