Running Spring/StrutsAssistant unit tests

0

Hello Taras,

Is there any description available on how to setup classpath/command
line arguments to run IDEA in test mode?


You simply create a JUnit run configuration with the classpath of a plugin module. I'm not sure what
the procedure with regular Java-modules is - if there is any at all.

I can run the plugins in sandbox mode without problems, I'm looking for
information on using IdeaTestFixtureFactory/UsefulTestCase/
BasicSpringTestCase/etc.


I'm not sure if there's something special about the Spring-tests, but generally you should set the
system properties -Didea.load.plugins=false and -Didea.system.path=SYSTEM-PATH-FOR-TESTS.

I'm afraid that except the sources for those tests there's not much other documentation available :(

Sascha

0

Hello Sascha,

>> I can run the plugins in sandbox mode without problems, I'm looking
>> for information on using IdeaTestFixtureFactory/UsefulTestCase/
>> BasicSpringTestCase/etc.
>>

I'm not sure if there's something special about the Spring-tests, but
generally you should set the system properties
-Didea.load.plugins=false and
-Didea.system.path=SYSTEM-PATH-FOR-TESTS.


So, what's a "system path"? Should I point it to "~/.IntelliJIdea70/sandbox/system"?
Also, should I be running these tests using an IDEA JDK, or a regular Java
JDK?

I'm afraid that except the sources for those tests there's not much
other documentation available :(


:)
The thing is, I assume that the actually problem that I'm running into is
completely trivial.
It would really help if the Jetbrains plugins would include an ant/maven/batch
file containing the magic incantations to run this stuff.

I've attached the output of my attempt, perhaps the exception traces point
to any obvious mistakes on my side.

Thanks,
Taras


0


Attachment not added (general error): "error.txt"

0

Hello Taras,

>> I'm not sure if there's something special about the Spring-tests, but
>> generally you should set the system properties
>> -Didea.load.plugins=false and
>> -Didea.system.path=SYSTEM-PATH-FOR-TESTS.


So, what's a "system path"? Should I point it to
"~/.IntelliJIdea70/sandbox/system"?


I'd let it point to something that is not used by anything else. If it is, something in IDEA will
either complain or appear to hang and eventually fail with a StackOverflowError - which is what I
got when I first used it in Selena. The directory may be empty and doesn't even have to exist.

Also, should I be running these tests using an IDEA JDK, or a regular
Java JDK?


When using the classpath of a plugin module, there's not much of a choice I guess ;) You'll get the
associated IDEA JDK.

>> I'm afraid that except the sources for those tests there's not much
>> other documentation available :(


:) The thing is, I assume that the actually problem that I'm running
into is completely trivial.
It would really help if the Jetbrains plugins would include an
ant/maven/batch file containing the magic incantations to run this stuff.


Yes, most likely it's a trivial problem. I've been through this as well, several times ;)

I've attached the output of my attempt, perhaps the exception traces
point to any obvious mistakes on my side.


Well, the output shows that you set the system-property "idea.plugins.load=false" which should
actually be "idea.load.plugins=false".

Also I get a lot of binary junk at the end of the post, so I don't see the complete stack trace.

Sascha

0

Hello Taras,

Maybe I'm missing something obvious, but how should IDEA know that
my plugin should be loaded (despite -Didea.load.plugins=false)?


You should use -Didea.load.plugins.id=]]> instead.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Hello Sascha,

Well, the output shows that you set the system-property
"idea.plugins.loadúlse" which should actually be
"idea.load.pluginsúlse".


Thanks for catching this.

My current VM parameters now are:
-


-Didea.load.pluginsúlse
-Didea.system.path=d:/idea_config/tests/system
-Didea.config.path=d:/idea_config/tests/config
-


(effective command line attached)

Now there is some progression, it seems:
-it takes more time before tests fail, something is happening in the background now
-d:/idea_config/tests/system and d:/idea_config/tests/config get populated during unit test runs (no log files unfortunately)

All tests still fail, but now with the following exception:
-


java.lang.NullPointerException
at com.intellij.spring.model.xml.SpringHighlightingTestCase.setUp(SpringHighlightingTestCase.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
-



The relevant code just retrieves a project component:
-


project.getComponent(SpringProjectComponent.class)
-



This kind-of makes sense to me: I don't see initComponent() getting called at all.
Maybe I'm missing something obvious, but how should IDEA know that my plugin should be loaded (despite -Didea.load.pluginsúlse)?

Thanks,

Taras

Attachment not added (general error): "command-line.txt"

0

Hello Dmitry,

>> Maybe I'm missing something obvious, but how should IDEA know that
>> my plugin should be loaded (despite -Didea.load.plugins=false)?


You should use -Didea.load.plugins.id=<your_plugin_id> instead.


Interesting, I always thought a test has to register everything (and call initComponent(), etc.)
itself. Is that system-property a new feature?

Sascha

0

Hello Sascha,

>>> Maybe I'm missing something obvious, but how should IDEA know that
>>> my plugin should be loaded (despite -Didea.load.plugins=false)?
>>>
>> You should use -Didea.load.plugins.id= instead. >>]]>

Interesting, I always thought a test has to register everything (and
call initComponent(), etc.) itself. Is that system-property a new
feature?


This was added some time in early 7.0.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Hello Dmitry,

>> Maybe I'm missing something obvious, but how should IDEA know that
>> my plugin should be loaded (despite -Didea.load.plugins=false)?
>>

You should use -Didea.load.plugins.id=<your_plugin_id> instead.


Just to double check, the syntax would be like this, correct?
-


-Didea.load.plugins.id=com.intellij.spring
-



It seems that my plugin (eg. compiled Jetbrains spring plugin) is still not
getting loaded. When I iterate the contents of "project.getComponents(Object.class)",
I see 113 projects components present. So it seems that IDEA does get into
a more-or-less initialized state.

If I make any progress, I'll post to this thread.
In the meantime, any tips/suggestions/things-to-check will be much appreciated.

Taras


0

Hello Taras,

Just to double check, the syntax would be like this, correct?
----------
-Didea.load.plugins.id=com.intellij.spring
----------
It seems that my plugin (eg. compiled Jetbrains spring plugin) is
still not getting loaded. When I iterate the contents of
"project.getComponents(Object.class)", I see 113 projects components
present. So it seems that IDEA does get into a more-or-less
initialized state.


One thing to try can be found here:
http://svn.jetbrains.org/idea/Trunk/bundled/svn4idea/svn4idea-standalone.ipr
This contains a shared run configuration for the svn4idea plugin tests which
was working for me a couple of weeks ago. :)

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Hello Dmitry,

One thing to try can be found here:
http://svn.jetbrains.org/idea/Trunk/bundled/svn4idea/svn4idea-standalo
ne.ipr This contains a shared run configuration for the svn4idea
plugin tests which was working for me a couple of weeks ago. :)


Those (appear to) run fine. 3 Tests, 20 test methods, all green.

The spring tests are more complicated though, in terms of set-up activities/fixtures.
Somehow the plugin seems not to get loaded/initialized. Is there any way
to get the "unit-test-running" IDEA instance to log more information?

Taras


0

Hello Dmitry,

>> Maybe I'm missing something obvious, but how should IDEA know that
>> my plugin should be loaded (despite -Didea.load.plugins=false)?


You should use -Didea.load.plugins.id=<your_plugin_id> instead.


Well, this does not seem to work too well with the current DevKit: The JUnit runner
doesn't add the required "idea.plugins.path" system property. It only appears to work if
the plugin is also installed in the main IDEA-instance and the plugin gets picked up from
the standard location. But that's not an option for development.

A DevKit-Patch is attached that also sets the property to the ID of the plugin by itself.
Seems to work fine for me, though I don't know what side effects it has for other users of
the testframework.

Sascha
--- src/run/JUnitDevKitPatcher.java (revision 10126)
+++ src/run/JUnitDevKitPatcher.java Thu Aug 16 00:00:18 CEST 2007
@@ -17,13 +17,19 @@

import com.intellij.execution.JUnitPatcher;
import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.ParametersList;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.ProjectJdk;
+import com.intellij.util.PathsList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.devkit.projectRoots.IdeaJdk;
+import org.jetbrains.idea.devkit.projectRoots.Sandbox;
+import org.jetbrains.idea.devkit.module.PluginModuleType;
+import org.jetbrains.idea.devkit.util.DescriptorUtil;

import java.io.File;
+import java.io.IOException;

/**

  • User: anna

@@ -37,9 +43,37 @@
if (jdk == null) return;

@NonNls String libPath = jdk.getHomePath() + File.separator + "lib";
- javaParameters.getVMParametersList().add("-Xbootclasspath/p:" + libPath + File.separator + "boot.jar");
- javaParameters.getClassPath().addFirst(libPath + File.separator + "idea.jar");
- javaParameters.getClassPath().addFirst(libPath + File.separator + "resources.jar");
- javaParameters.getClassPath().addFirst(jdk.getToolsPath());
+ final ParametersList vm = javaParameters.getVMParametersList();
+ vm.add("-Xbootclasspath/p:" + libPath + File.separator + "boot.jar");
+
+ String sandboxHome = ((Sandbox)jdk.getSdkAdditionalData()).getSandboxHome();
+ if (sandboxHome != null) {
+ try {
+ sandboxHome = new File(sandboxHome).getCanonicalPath();
- }
+ }
+ catch (IOException e) {
+ sandboxHome = new File(sandboxHome).getAbsolutePath();
-}
+ }
+ final String canonicalSandbox = sandboxHome;
+
+ if (vm.hasProperty("idea.load.plugins.id")) {
+ vm.defineProperty("idea.plugins.path", canonicalSandbox + File.separator + "plugins");
+ } else if (PluginModuleType.isOfType(module)) {
+ final String id = DescriptorUtil.getPluginId(module);
+ if (id != null) {
+ vm.defineProperty("idea.load.plugins.id", id);
+ vm.defineProperty("idea.plugins.path", canonicalSandbox + File.separator + "plugins");
+ }
+ }
+
+ if (!vm.hasProperty("idea.system.path")) {
+ vm.defineProperty("idea.system.path", canonicalSandbox + File.separator + "test" + File.separator + "system");
+ }
+ }
+
+ final PathsList classPath = javaParameters.getClassPath();
+ classPath.addFirst(libPath + File.separator + "idea.jar");
+ classPath.addFirst(libPath + File.separator + "resources.jar");
+ classPath.addFirst(jdk.getToolsPath());
+ }
+}

0

Small correction: It indeed works correctly when some kind of "plugin stub" with an up-to-date
plugin descriptor is present in the main plugins folder. The actual classes are then loaded from the
compiler output directory. However I think this is far from being an optimal solution.

Sascha

Sascha Weinreuter wrote:

Hello Dmitry,

>>> Maybe I'm missing something obvious, but how should IDEA know that
>>> my plugin should be loaded (despite -Didea.load.plugins=false)?
>>
>>
>> You should use -Didea.load.plugins.id=]]> instead.


Well, this does not seem to work too well with the current DevKit: The
JUnit runner doesn't add the required "idea.plugins.path" system
property. It only appears to work if the plugin is also installed in
the main IDEA-instance and the plugin gets picked up from the standard
location. But that's not an option for development.

A DevKit-Patch is attached that also sets the property to the ID of the
plugin by itself. Seems to work fine for me, though I don't know what
side effects it has for other users of the testframework.

Sascha

0

Dmitry, can you say a word or two about whether this analysis is correct or if the
testframework is generally supposed to be used in a way that would break with my change?

I'll even file a JIRA request if that will make a difference ;)

Thanks,
Sascha

0


It seems that spring plugin depends on "aop-commons" plugin.
Should/Can I somehow specify that it needs to be loaded as well?

Taras


0

http://www.jetbrains.net/jira/browse/IDEA-9545

I hope it will :)


Sorry, I don't understand what that means.

0

I meant JIRA request always makes a good difference... I hope :)


0

请先登录再写评论。