If I do create-app with grails 2.3, create a simple spock unit-test, and change the configuration en grails to use ivy resolver:
grails.project.dependency.resolver = "ivy" // or maven
The unit test crashes with the following error:
| Running without daemon...
| Running 1 unit test...
| Running 1 unit test... 1 of 1
| Error Error running unit tests: org/hamcrest/SelfDescribing (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
... 7 more
| Error Error running unit tests: org/hamcrest/SelfDescribing
| Running 1 unit test....
| Running 1 unit test.....
| Tests FAILED - view reports in C:\ivytry\foobar\target\test-reports
Any ideas how to get around this? The reason why we need to use Ivy is that Maven doesn't seem to support custom remote repositories, where I need to specify username/password. -Besides in buildconfig, but I don't want my credentials under source control :)
EDIT (Solved): See comments!
The issue was because of the "infamous" intellij fix with idea 12 and grails 2.3 - restoring the "sources" and "javadoc" jar files, fixes the issue!
Related
Im try to test unit in Nestjs
But its showing error
Test suite failed to run
Cannot find module '#nestjs/core/inspector/graph-inspector' from '../node_modules/#nestjs/testing/testing-module.builder.js'
Require stack:
/Volumes/My Files/IdeaProjects/ChecklistApp/server/node_modules/#nestjs/testing/testing-module.builder.js
/Volumes/My Files/IdeaProjects/ChecklistApp/server/node_modules/#nestjs/testing/test.js
/Volumes/My Files/IdeaProjects/ChecklistApp/server/node_modules/#nestjs/testing/index.js
task/task.spec.ts
I have same problem with you, and i solved it. This problem is occurred because "#nestjs/core/inspector/graph-inspector" is missing but still referenced in "../node_modules/#nestjs/testing/testing-module.builder.js".
To solve this problem do following command:
npm i #nestjs/core && npm i #nestjs/testing
Note: above command will update the version of #nestjs/core and #nestjs/testing package to the latest version.
When I run grails war I got the following error
Compiling 30 GSP files for package [appInfo].
| Error GSP Compilation error in file /WEB-INF/plugins/app-info-0.4.3/grails-app/views/appinfo/hibernateEntityInfo.gsp at line 69: Tag [each] missing required attribute [in]
I used
grails 2.2.4
and also I want to know the app-info plugin location in the application
It is the problem with App-info plugin. I also got similar problem . I solved by following way
Clean the application using
grails Clean
then run the application using
grails RunApp
and make sure If you are using sequences in the application do not use mysql because mysql does not support sequences.
I am using maven surefire plugin for unit testing. One of the unit tests crash because of the following exception:
java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/output/DirectFileOutputCommitter
Googling on this tells me that this class def is found in amazon-s3.jar, which resides in the hadoop/lib folder of my hadoop distribution. How do I get around this exception in unit tests?
I am trying to run unit test from netbeans but it fails with this error.
PHP Fatal error: Class 'App' not found in /home/user/cakephp/app/Test/Case/Model/AceScoreTest.php on line 3
Stack trace:
1. {main}() /usr/bin/phpunit:0
2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:150
5. ReflectionMethod->invoke() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:124
6. NetBeansSuite::suite() /usr/local/netbeans-7.2.1/php/phpunit/NetBeansSuite.php:0
Unit test works fine when run from the command line as
./cake test app Model/AceScore
What do I need to do to get cakephp unit test to work in Netbeans?
There must be some way to tell phpunit to look for App.php in lib/Cake/Core/App.php
Thanks.
Perhaps, you have to create a bootstrap file for PHPUnit and set it to NetBeans.
I have added new Action (PHPUnit Test Init Action[1]) to CakePHP pluign for NetBeans[2].
If you are using this plugin, please try it ;) Please see [1] about bootstrap file.
[1] https://github.com/junichi11/cakephp-netbeans#phpunit-test-settings-phpunit-test-init-action
[2] http://plugins.netbeans.org/plugin/44579/php-cakephp-framework
I started exploring the possibilities of using OpenEJB in embedded mode for unit-testing my EJB3 components. At first I got errors like the below output
Testsuite: HelloBeanTest
Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 1,779 sec
------------- Standard Output ---------------
Apache OpenEJB 3.1.4 build: 20101112-03:32
http://openejb.apache.org/
------------- ---------------- ---------------
------------- Standard Error -----------------
log4j:WARN No appenders could be found for logger
(org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
------------- ---------------- ---------------
Testcase: sum took 1,758 sec
Caused an ERROR
Name "HelloBeanLocal" not found.
javax.naming.NameNotFoundException: Name "HelloBeanLocal" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:193)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
at
org.apache.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java:115)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at HelloBeanTest.bootContainer(Unknown Source)
# ... output is the same for all the rest of the tests
The openejb.home property is set as a system property and points to my OpenEJB installation dir.
The HelloBeanTest#bootContainer() is a setUp method and it fails on the JNDI lookup. Shown below.
#Before
public void bootContainer() throws Exception{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
Context context = new InitialContext(props);
hello = (Hello) context.lookup("HelloBeanLocal");
}
After struggling with problems like this I started to try out OpenEJB in non-embedded mode, and started the container from it's installation directory and deployed the components as an ejb.jar. Deployment was successful and I started creating a stand-alone Java client. The stand-alone Java client is still unfinished, but meanwhile I came back to testing in embedded mode.
To my surprise, the tests suddenly started to pass. I added some more functionality to the component and tests for those. Everything worked just fine. Below is the output for that run.
Testsuite: HelloBeanTest
Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 2,281 sec
------------- Standard Output ---------------
Apache OpenEJB 3.1.4 build: 20101112-03:32
http://openejb.apache.org/
------------- ---------------- ---------------
------------- Standard Error -----------------
log4j:WARN No appenders could be found for logger
(org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
------------- ---------------- ---------------
Testcase: sum took 2,263 sec
Testcase: hello took 0,001 sec
Testcase: sum2 took 0 sec
Testcase: avg took 0,001 sec
I was happily coding and testing until it broke again. It seems that removing the ejb.jar from /apps directory caused it. So, it seems that OpenEJB does the JNDI lookup still from the installation dir, but uses the current dir to find the actual implementations when running in embedded mode. I made this conclusion as the ejb.jar deployed in apps/ dir does not have all the methods that the local version has. (I double checked with javap.) Only the class signature is the same.
After this very long introduction, it's question time.
Can anyone provide any explanation for this behaviour?
Packaging and deploying the EJBs in the apps/ dir before testing is simple task, but can I be sure that even then I am testing the correct implementation?
Does this all have something to do with the openejb.home property pointing at the OpenEJB installation dir?
For summary, OpenEJB version is Apache OpenEJB 3.1.4 build: 20101112-03:32, which is visible in the log outputs as well.
Thanks in advance.
It does have something to do with setting the openejb.home to point to the installation dir.
There's a conf/openejb.xml file that likely has a apps/ listed as where deployments live. All the log output went to the logs/ dir and not in System.out of the test case where you can read it easily.
To use OpenEJB embedded you don't need any config files, directories, or ports. You just include the libs in your project's classpath.
First thing I'd say is to check out the openejb-examples-3.1.4.zip. There are maybe two dozen example projects all setup with both Ant and Maven build scripts. All the examples will work in any environment as long as the OpenEJB libraries are in the classpath. Here's a video of using one of the examples to unit test in Eclipse. I recommend the simple-stateless example as the best starting point.