HttpRequestMethodNotSupportedException when testing controller
0 comments Posted by Rey Jexter Bumalay at 10:43 AMAfter a spending about 2 days researching on the HttpRequestMethodNotSupportedException thrown when running AbstractController.handleRequest in my test, I decided to view spring source code to see the real cause of this problem.
The problem was when creating MockHttpServletRequest, it doesn't set a default method name. To solve this problem, I simply added a request method type on the mock request object. See the following code:
request = new MockHttpServletRequest();
request.setMethod("POST");
Labels: spring, spring mvc, testing
Execute hbm2ddl create-drop when running integration test
0 comments Posted by Rey Jexter Bumalay at 8:32 AMWhen using JBoss Tools 2.0.0 GA, the generated test project doesn't allow me to provide a custom persistence.xml. I'm not sure if this is a bug or the feature is not yet included on the given version. The persistence.xml being used when the application is deployed and when running test is the same. So what I did is update the hbm2ddl.auto property of the projectname-ejb/META-INF/persistence.xml to create/create-drop when running test and then when deploying the application, i switch it back to update.
Right now I don't want to waste my time just figuring out how to run test that uses a different persistence context. I have already spent 2 days just doing that but nothing happened. Its either I wait for a major JBoss Tools update or I'll try solving the problem again once I get some free time.
Labels: hibernate, jboss tools, seam, testing
Integration testing in Seam 2.0.0 GA, JDK 1.6 and JBoss 4.2.2 GA using JBoss Tools 2.0.0 GA is broken
0 comments Posted by Rey Jexter Bumalay at 9:00 PMI was trying my first integration test but just using the default generated test class and xml meta data by jboss tools, i get the following error:
ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Instantiated: name=DeploymentFilter state=Described
java.lang.IllegalStateException: Class not found: [Ljava.lang.String;
at org.jboss.metadata.spi.signature.Signature.stringsToClasses(Signature.java:174)
i tried the following things:
1. followed this http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassNotFoundJava.lang.StringInJDK6
2. downloaded jboss embedded beta
3. upgraded to seam 2.1.0 AI
none of them worked for me.
lastly, i tried downloading seam 2.0.1 GA and installed jdk 1.5. i configured the test project's compiler compliance level to 5.0 instead of 6.0 (6.0 default for some reason. maybe because my default jdk is 1.6) and the result were so much better.
to remove the error message saying something like this:
Could not instantiate Seam component: authenticatordrools related libraries needs to be included since we are using the rule based engine and Identity class is part of it. just include the seam/lib/drools-core.jar, seam/lib/drools-compiler.jar and seam/lib/core.jar.
after copying the drools related libraries and executing the test, a different kind of error is thrown. this time an error saying that the "security.drl is missing" you will need to copy that file from seam/seam-gen/resource/security.drl and place it to
run it again and the test will be successful!
embedded jboss is needed when testing seam components or ejb's but based on the jboss seam integration testing documenation, the stable version have problems when using jdk 1.6. since there are compatability issues when testing using seam 2.0 GA on jdk 1.6, i think staying with 2.0.1GA and jdk 1.5 is better at the moment.