Gephi: Unit Tests (JUnit)

Problem

When I created a JUnit unit test for a Gephi’s module (NetBeans) there seemed to be no way to execute it; since the “Test”, “Test File”, “Run File” were all greyed out (disabled).

Solution

Right click on the module and select “Create NBM”; then restart gephi so that the module is re-initialized; this seems to fix it (may need to also execute Clean and Build and then Run).

 

- OLD

This is an old and somewhat more detailed description of the problem

Problem

I tried to get unit tests set up for my gephi’s module (module’s zip).  It does not seem to work well; there are quite a few NullpointerExcpetions caused by Lookup and ImportController etc. It does look like that it is a problem caused by NetBeans rather than Gephi itself.

Even the most basic task does not seem to work:

        //Init a project - and therefore a workspace
        ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
        pc.newProject();
        Workspace workspace = pc.getCurrentWorkspace();

        //Get controllers and models
        ImportController importController = Lookup.getDefault().lookup(ImportController.class);
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

        File file = new File(getClass().getResource("/org/activeintel/gephi/les-miserables.gexf").toURI());

        //Import file
        Container container = importController.importFile(file);

        //Append imported data to GraphAPI
        importController.process(container, new DefaultProcessor(), workspace);

The following error is thrown:

GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

 

Testcase: testDoTheDew(org.activeintel.gephi.DriverTest):	Caused an ERROR
null
java.lang.NullPointerException
	at org.activeintel.gephi.DriverTest.testDoTheDew

 

 

Solution

The work around was to create a regular netbeans project and then to included the toolkit.jar (which could be built by using ant).

Suggested approach is: http://wiki.gephi.org/index.php/NetBeans_Tips#How_to_use_other_modules_in_Unit_Test (thanks Mathieu for pointing it out)

I have not tried it yet; will update the post as soon as I do.

Comments

For more information see comments at the very end of the post.

 

 

Keywords & References

 

Searched for test-roots netbeans 3:38pm

Bug 69390 – No tests root folder was found - netbeans.org 3:39pm

Netbeans and creating JUnit tests – Stack… - stackoverflow.com 3:39pm

Netbeans IDE Users – Junit and NB - nabble.com 3:39pm

Searched for netbeans run module junit run file greyed out 2:49pm

Gephi: Unit Tests (JUnit) | Active Intelligence - activeintelligence.org 2:50pm

Netbeans IDE Users – Junit tests from… - nabble.com 2:55pm

Creating, Importing, and Configuring… - netbeans.org 2:56pm

Bug 159256 – Groovy Unit tests cannot be run - netbeans.org 

 

Yesterday (cont.)

 

Searched for netbeans run module junit 2:42pm

Build Gephi – Gephi:Wiki - gephi.org 2:45pm

java – How do I run JUnit from NetBeans?… - stackoverflow.com 2:46pm

 

 

null

Searched for netbeans add lookup library 10:35am

AboutLookup – NetBeans Wiki - netbeans.org 10:35am

Searched for netbeans add lookup 10:34am

NetBeans Lookups Explained! | NetBeans Zone - dzone.com 10:35am

DevFaqLookup – NetBeans Wiki - netbeans.org 10:35am

Searched for gephi NullPointerException graphmodel lookup toolkit 10:12am

Gephi Toolkit Tutorial - slideshare.net - Viewed 6 times 10:12am

Searched for gephi NullPointerException graphmodel lookup 10:12am

Searched for gephi plugin developer 9:53am

Plugin Quick Start (5 minutes) – Gephi:Wiki - gephi.org - Viewed 2 times 9:53am

Searched for netbeans run file greyed out 9:52am

How to compile & run a project-less file… - stackoverflow.com 9:52am

java – NetBeans Tips and Tricks – Stack Overflow - stackoverflow.com 9:52am

Searched for jung file 9:43am

JUNG – Java Universal Network/Graph Framework - sourceforge.net 9:43am

Searched for gephi junit nullpointerexception 9:29am

Searched for gephi junit null 9:29am

Searched for gephi junit 9:29am

Build Gephi – Gephi:Wiki - gephi.org 9:29am

https://answers.launchpad.net/gephi/+question… 9:29am

Question #106928 : Questions : Gephi - launchpad.net - Viewed 2 times

 

Searched for gephi unit test 9:28am

Searched for gephi Lookup.getDefault().lookup(GraphController.class).getModel() 9:25am

Gephi forums • View topic – Resize… - gephi.org 9:26am

Getting Graph Model for the Panel in… - activeintelligence.org - Viewed 2 times 9:26am

Searched for file input stream 9:09am

FileInputStream (Java 2 Platform SE v1.4.2) - oracle.com 9:09am

Searched for athome 9431921301 8:06am

http://www.athome.co.jp/ks_13/dtl_9431921301 8:07am

Searched for Alan Turing to be pardoned 7:28am

No posthumous pardon for Alan Turing - wired.co.uk
Wired.co.uk - Feb 6, 2012
7:29am

Searched for russia 7:24am

Yesterday


Searched for jgrapht open file 11:43pm

Welcome to JGraphT – a free Java Graph Library - jgrapht.org 11:43pm

Searched for jgrapht import 11:43pm

Searched for gephi importController 11:40pm

Gephi API Index - gephi.org 11:40pm

Searched for gephi getMatchingImporter 11:35pm

https://bugs.launchpad.net/bugs/770518 11:35pm

https://github.com/gephi/gephi/issues/319 11:35pm

Searched for masterfs netbeans The module is not a friend of 11:25pm

http://osdir.com/ml/java.netbeans.modules.ope… 11:25pm

http://netbeans-org.1045718.n5.nabble.com/fri… 11:25pm

http://netbeans.org/projects/platform/lists/d… 11:26pm

NetBeans Forums – toFileObject returns null. - netbeans.org

Yesterday (cont.)

 


Searched for FileUtil.toFileObject 11:21pm

Searched for gephi toFileObject 11:13pm

org.gephi.io.importer.impl.ImportControllerIm… - massapi.com 11:13pm

Gephi forums • View topic – [SOLVED]… - gephi.org 11:14pm

ProjectAPI/src/org/gephi/project/io/LoadTask…. - github.com 11:16pm

File (Java Platform SE 6) - oracle.com 11:09pm

Searched for java file 11:09pm

File (Java Platform SE 6) - sun.com 11:09pm

Searched for gephi import nullpointerexception 11:06pm

Searched for gephi graphmodel panel 10:38pm

Getting Graph Model for the Panel in… - activeintelligence.org - Viewed 2 times 10:38pm

Searched for gephi graphmodel 10:37pm

org.gephi.graph.api (Gephi API Index) - gephi.org 10:37pm

Searched for gephi ImportHelper java.lang.NullPointerException 10:31pm

Question #157823 : Questions : Gephi - launchpad.net 10:31pm

Searched for gephi toolkit 10:18pm

Gephi Toolkit | Gephi, open source graph… - gephi.org - Viewed 7 times 10:18pm

Searched for gephi File file = new File(getClass().getResource 10:18pm

Toolkit – Import Dynamic Network from… - gephi.org 10:18pm

Searched for netbeans junit 9:53pm

Writing JUnit Tests in NetBeans IDE - netbeans.org 9:54pm

java – How do I run JUnit from NetBeans?… - stackoverflow.com 9:54pm

Searched for netbeans 9:51pm

Welcome to NetBeans - netbeans.org 9:51pm

Searched for gephi netbeans “7.1″

Yesterday (cont.)

 


Searched for gephi netbeans 7.1 9:46pm

Searched for gephi unit test 9:42pm

NetBeans Tips – Gephi:Wiki - gephi.org 9:42pm

Question #106928 : Questions : Gephi - launchpad.net - Viewed 2 times 9:44pm

Searched for git multiple projects 9:26pm

Multiple projects in a single git repository…. - metafilter.com 9:26pm

GIT repository layout for server with… - stackoverflow.com 9:26pm

organizing – How do you organise multiple… - stackoverflow.com 9:26pm

version control – What is the best way… - stackoverflow.com 9:26pm

Searched for data science 9:23pm

What is data science? – Quora - quora.com 9:23pm

Searched for netbeans lacks a unit test dependency on org.netbeans.libs.junit4; using default dependencies for compatibility 5:55pm

NetBeans Forums – Warning: firstmodule… - netbeans.org 5:56pm

Searched for netbeans java.lang.IllegalStateException: Cannot find myself as 5:45pm

NetBeans Forums – Strange sudden error… - netbeans.org 5:45pm

Searched for netbeans add library 5:20pm

jGuru: How can I add third party libraries… - jguru.com 5:20pm

Searched for gephi plugin developer 4:58pm

Plugin Quick Start (5 minutes) – Gephi:Wiki - gephi.org - Viewed 2 times 4:58pm

Searched for org.gephi.project.api.ProjectController 4:52pm

ProjectController (Gephi API Index) - gephi.org 4:52pm

Searched for responsiveness 3:57pm

Searched for responsivness 3:57pm

java – How to Find Which classes implements… - stackoverflow.com 3:47pm

Program to find classes implementing… - stackoverflow.com

About Neil Rubens

see http://ActiveIntelligence.org
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Gephi: Unit Tests (JUnit)

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>