gephi / gephi-plugins

Repository for Gephi Plugins maintained by the team. Each plugin has it's branch.
270 stars 623 forks source link

ImportController unable to import test resources #133

Closed carlschroedl closed 7 years ago

carlschroedl commented 7 years ago

As a plugin developer I would like to import graph data from test resource files so that I can easily test my plugin on various graphs.

Inside tests, when I try to run importFile on instances implementing ImportController, the method always returns null instead of a valid Container instance.

To ensure that my plugin wasn't the problem, I created a new plugin from scratch, and wrote new tests focusing only on the ability to import.

The isolated demonstration is available in this branch.

The errors can be reproduced by checking out the branch, and running: mvn clean install

carlschroedl commented 7 years ago

I should mention:

Product Version: NetBeans IDE 8.2 (Build 201609300101) Java: 1.8.0_72; Java HotSpot(TM) 64-Bit Server VM 25.72-b15 Runtime: Java(TM) SE Runtime Environment 1.8.0_72-b15 System: Linux version 3.16.7-48-desktop running on amd64; UTF-8; en_US (nb) Maven version: 3.0.5

carlschroedl commented 7 years ago

Should I be using a different way to import graph data into my plugin tests?

carlschroedl commented 7 years ago

This is the output I'm getting

$> mvn clean install  
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] Demo File Import Plugin
[INFO] gephi-plugins
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Demo File Import Plugin 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo-file-import-plugin ---
[INFO] Deleting /home/someUser/src/gephi-plugins/modules/DemoFileImportPlugin/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ demo-file-import-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ demo-file-import-plugin ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/someUser/src/gephi-plugins/modules/DemoFileImportPlugin/target/classes
[INFO] 
[INFO] --- nbm-maven-plugin:3.14:manifest (default-manifest) @ demo-file-import-plugin ---
[INFO] NBM Plugin generates manifest
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ demo-file-import-plugin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ demo-file-import-plugin ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/someUser/src/gephi-plugins/modules/DemoFileImportPlugin/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ demo-file-import-plugin ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.company.my.MyStatisticTest
Confirmed: file '/com/company/my/karate.gml' exists and can be read.
Confirmed: file '/com/company/my/karate.gml' exists and can be read.
Confirmed: file '/com/company/my/karate.gml' exists and can be read.
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.364 sec <<< FAILURE! - in com.company.my.MyStatisticTest
testFileGettingImportControllerFromUI(com.company.my.MyStatisticTest)  Time elapsed: 0.267 sec  <<< FAILURE!
java.lang.AssertionError
        at com.company.my.MyStatisticTest.testFileGettingImportControllerFromUI(MyStatisticTest.java:89)

testFileGettingImportControllerImplDirectly(com.company.my.MyStatisticTest)  Time elapsed: 0.002 sec  <<< FAILURE!
java.lang.AssertionError
        at com.company.my.MyStatisticTest.testFileGettingImportControllerImplDirectly(MyStatisticTest.java:77)

testFileGettingImportControllerFromLookup(com.company.my.MyStatisticTest)  Time elapsed: 0.002 sec  <<< FAILURE!
java.lang.AssertionError
        at com.company.my.MyStatisticTest.testFileGettingImportControllerFromLookup(MyStatisticTest.java:67)

Results :

Failed tests: 
  MyStatisticTest.testFileGettingImportControllerFromLookup:67
  MyStatisticTest.testFileGettingImportControllerFromUI:89
  MyStatisticTest.testFileGettingImportControllerImplDirectly:77

Tests run: 3, Failures: 3, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Demo File Import Plugin ............................ FAILURE [  5.175 s]
[INFO] gephi-plugins ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.027 s
[INFO] Finished at: 2016-11-05T22:21:59-05:00
[INFO] Final Memory: 26M/266M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project demo-file-import-plugin: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/someUser/src/gephi-plugins/modules/DemoFileImportPlugin/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
eduramiba commented 7 years ago

Hi, Since we use Netbeans Platform for Gephi, which includes filesystem management, you will need to add this dependency to your plugin pom.xml (according to http://wiki.netbeans.org/UsingFileSystemsMasterfs):

<dependency>
    <groupId>org.netbeans.modules</groupId>
    <artifactId>org-netbeans-modules-masterfs</artifactId>
    <scope>test</scope>
</dependency>

I had to add this to the parent dependency management so you don't need to specify the version (8c2f1aecbed65dd79b9d81fa63dd0f40465a7bd9).

Also, in order to have GML importer available, you need a dependency to:

<dependency>
    <groupId>org.gephi</groupId>
    <artifactId>io-importer-plugin</artifactId>
</dependency>

With these changes, it works for me. I created a pull request in your branch which includes all changes: https://github.com/carlschroedl/gephi-plugins/pull/3

carlschroedl commented 7 years ago

Now that I have merged your pull request, I can load graphs from file and start interacting with them. Thanks for the quick and comprehensive fix @eduramiba ! Thanks for merging that new dependency into gephi-plugins/master to help other plugin authors. Un saludo desde los EEUU. Echo de menos a Madrid.

eduramiba commented 7 years ago

Haha great! Glad I could help :smiley: