In my java spring mvc app, I am trying to reset a bunch of records for test with Junit.
but in line:
#DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
It complains with:
ClassMode cannot be resolved to a variable
Update:
I have added
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5</version>
</dependency>
but then it complains with other lines
#ActiveProfiles("test")
#Sql(scripts="requests-dataset.sql")
#DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
the error is:
ActiveProfiles cannot be resolved to a type
Sql cannot be resolved to a type
Sql cannot be resolved to a type
First of all, the class name is DirtiesContext.ClassMode (it's a nested class of DirtiesContext).
Second, as any other class, it must be imported.
Third, as the javadoc shows, it exists since Spring 3.0. So you won't find it in Spring 2.5. Use the same version of spring-test as the version used for the rest of the spring framework libraries that you're using.
Related
I am trying to mock the objects returning from the server to the client. So I need to deploy my Wiremock Code in Server. So is this possible or is there any other way to achieve this scenario?
And I am completely new to Wiremock. So How can I run this on JBoss?
I followed the method of running wiremock-standalone jar and I am able to capture my request and response.
But my main question is, can I able to get mock responses from #Test methods?
You could use Arquillian to test JBoss. You can test microservices using this approach and use Jboss Forge ~ another tool, to speed up the testing/dev. The start guide with Forge is here.
You will just need to add on the pom.xml the dependency for Arquillian:
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR9</version>
<scope>test</scope>
</dependency>
To avoid any library clash you can use the standalone version of WireMock. I used it with wildly (JBoss AS) adding the following dependency:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.27.2</version>
<scope>test</scope>
</dependency>
For further information see http://wiremock.org/docs/download-and-installation/
What you've done with wiremock-standalone is very similar to what arquillian does in an integration test. You write your server code then you test it inside a container using a client extension.
Try reading the documentation at http://arquillian.org/arquillian-core/
I am creating a Spring boot project for testing my rest API (Very Very tiny Project). The Project contains three files.
1) App.java (Main Program)
2) AppConfig (Configuration file)
3) Main Controller (Simple Rest controller)
I added Spring-boot-starter-parent (1.4.0.RELEASE) and spring-boot-starter-web as dependency.
But While executing,getting an exception like follows.
"javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath."
I added the following dependency and the error gone.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.4.Final</version>
</dependency>
My question is, what is the root cause of the specific error message?
Why we are adding the validator?
It means the classloader could only find the API of bean validator. You have to add some implementation package into the classpath.
Like:
org.glassfish.jersey.ext:jersey-bean-validation
I have encountered a strange situation, the decision which I cant find.
I`m runnig simple demo application using Spring Boot 1.3.0 and Intelij Idea 14.1.3
The problem is that Spring MVC cant resolve the view:
javax.servlet.ServletException: Could not resolve view with name 'home' in servlet with name 'dispatcherServlet'
Oddity is that when I run application by Maven Spring Boot-plugin
mvn clean spring-boot:run
everythig works fine.
Both views ("home.jsp" - returning from Controller and "start.jsp" - described in Configuration class) resolve correctly.
Full source code you can see here
I`ve downloaded another demo project - the same situation.
So, I think that something wrong with my IDE configuration.
But what is going wrong - I don`t know.
In File->Project Structure
I have added Spring and web module in "Modules" tab, the same I`ve made in "Facets" tab.
What is possible to do to make application run correctly using IDE?
Problem was in dependecies configuration in pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
I have change <scope>provided</scope> to <scope>compile</scope> and it works well.
A quick question: is there a stand-alone package for org.hibernate.validator.constraints.*?
I want to put these annotations on a DTO package, but don't want to force the user to have hibernate-validator on their class path.
I don't really know what you mean by standalone in this context but here is a link to the 4.3.1 version of hibernate-validator.
Adding this to your pom will give you access to all the annotations in org.hibernate.validator.constraints package:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
mvnrepository.com is a very good place to search for maven artifacts.
Edit
Ok now I understand your question, you only want the annotations in the org.hibernate.validator.constraints as a dependency w/o all the other validation stuff.
Then my answer is no, there is no such thin jar. You will have to use the hibernate-validator to get the annotations.
If you use custom Hibernate Validator constraints you would have to add the actual core classes as well anyways. As long as you rely on Bean Validation constraints (javax.validation.*) it is enough to add the Bean Validation API jar.
What is your concen with adding the hibernate Validator jar?
I have 4 flex project,3 are modules,1 is application.
compile these project with Flash Builder,integrate and run,is ok.
But when I compile these use maven script(Flex SDK merged into code).integrate and run,pop up error:
VerifyError: Error #1014: Class mx.controls::List could not be found.
Somebody said because a library was loaded as external.
is that playerglobal.swc????
but after I change my pom.xml like this,seem like nothing changed.
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>playerglobal</artifactId>
<version>${flex.sdk.version}</version>
<type>rb.swc</type>
<classifier>en_US</classifier>
<scope>external</scope>
</dependency>
Did you add all Flex dependencies? Do your modules use Flex SDK with scope external? If so, does your application (which I assume, loads those modules) includes those classes?
When you use List in Module A and SDK is in scope external, then Module A expects that List will be available during runtime from Application. If you don't compile List into Application (as in, use List in Application) then Module A will complain about missing List class.
This is how Adobe decided to handle SWF optimizations :( Classes that are not used in Application or Module are not compiled into resulting SWF.