this is the maven surefire plugin i am using
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>runner.TestSuite.java</include>
</includes>
<skipTests>true</skipTests>
</configuration>
</plugin>
This is testSuite class
package runner;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import action.TestLogin;
import action.TestRegister;
#RunWith(Suite.class)
#Suite.SuiteClasses({ TestRegister.class, TestLogin.class })
public class TestSuite {
}
Test Suite runs fine on alone.
But when I run maven-Install with eclipse I want to run the test suite without running all the test cases individually. But it says
[INFO] --- maven-surefire-plugin:2.16:test (default-test) # FinalProject ---
[INFO] Tests are skipped.
Also I am using sonar to check line coverage which is also not able to detect testSuite I made.
I am new to Junit TestSuite & do not know how to configure them with maven & sonar.
Any link, reference or clue will be helpful.
Thank you.
Make sure you have JUnit dependency specified in your pom.xml
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
This is the only step that is required to get started - you can now create tests in your test source directory.
More on this at Maven Surefire Plugin
Related
I am using WSO2EI 7.0 with WSO2 developer Studio 7.0.2. I was trying to implement the following code for setting the payload in a WSO2 custom mediator.
String jsonPayloadToString = JsonUtil.jsonPayloadToString(((Axis2MessageContext) messageContext).getAxis2MessageContext());
System.out.println("Payload in string -"+ jsonPayloadToString);
But I am unable to import the JsonUtil class in Maven generated code.
Can I know if I need to set the class path or jar manually to import this package?
Have you tried adding the following imports?
import org.apache.synapse.commons.json.JsonUtil;
import org.apache.synapse.core.axis2.Axis2MessageContext;
Also, you need to have the corresponding synapse version in the pom file under dependencies
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
<version>2.1.7-wso2v105</version>
</dependency>
I faced similar issue, But resolved above JsonUtil ERROR by adding below dependency in pom.xml
Note: after updating pom.xml, please do mvn update by clicking alt+f5.
dependency:
<!-- https://mvnrepository.com/artifact/org.apache.synapse/synapse-commons -->
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-commons</artifactId>
<version>2.1.7-wso2v228</version>
</dependency>
Reference Link: dependency ref
Is it possible in Laravel to run unit test based on the folder they're placed in?
Currently, the phpunit.xml specifies /tests as the root directory for unit testing:
...
<testsuites>
<testsuite name="Application Test Suite">
<directory>./app/tests/</directory>
</testsuite>
</testsuites>
...
Test are ran via CLI with phpunit command. I would like to organize tests into subfolders, like this:
/tests
/unit
/integration
so I can run tests only from the specified subfolder like: phpunit integration.
I tried the above, however the framework assumes that "integration" is the name of a PHP file that doesn't exist.
How do I achieve my goal?
This actually has nothing to do with Laravel. It's just PHPUnit.
You can define testsuites and execute them by name.
<testsuites>
<testsuite name="unit">
<directory>./app/tests/unit/</directory>
</testsuite>
<testsuite name="integration">
<directory>./app/tests/integration/</directory>
</testsuite>
</testsuites>
Then run phpunit --testsuite integration
I'm been trying to deployed a simple web service on tomcat, but I have not success and it always return me 404 error.
I used the codes from this example:
http://maksim.sorokin.dk/it/2011/01/20/jax-ws-web-services-maven-tomcat/
http://maksim.sorokin.dk/it/wp-content/uploads/2011/01/jaxwsExample.zip
JAX-WS not being initialized:
So my ws is set up right? But I'm really out of clue why it is still not working.
Thank you for your time,
Droid
With your current settings, try in your browser:
http://localhost:8080/jaxwsExample-1.0.0-SNAPSHOT/HelloWs
You can see the problem (in the first link):
Now we just build the project with maven by mvn clean install, rename it to jaxwsExample.war (we can do that automatically in maven, but omit it for simplicity) and deploy it to the Tomcat.
So, in the pom.xml add the finalName:
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>dk.sorokin.maksim</groupId>
<artifactId>jaxwsExample</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>JAX-WS Example</name>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
<build>
<finalName>jaxwsExample</finalName>
</build>
</project>
I have a Java web project that consumes a web service, using Apache CXF to generate the underlying code, based on the WSDL published by the service.
I have a test version of the service for development and a production version.
The endpoints of the 2 services are at different URLs and whilst their public interfaces are pretty much identical I regenerate the CXF code (using the cxf-codegen-plugin) as I promote my project to the production environment.
What is the best way to configure Maven to do this?
At the moment I set a property in the pom.xml called ws_status
<properties>
<ws_status>test</ws_status>
</properties>
which I subsequently use to tweak the path to the WSDL file used by the codegen plugin:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<configuration>
<fork>once</fork>
<encoding>UTF-8</encoding>
<additionalJvmArgs>-Djava.endorsed.dirs=${project.build.directory}/endorsed</additionalJvmArgs>
<!-- rest of the normal codegen configuration options -->
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/${ws_status}/Cmis.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/${ws_status}/Cmis.wsdl</wsdlLocation>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
<extraarg>-compile</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
This works OK, but it annoys me that I need to change the ws_status inside the pom.xml every time I release a production version, as the pom file is tracked by git.
What I want is a maven command-line switch to tell it to refer to one WSDL file or the other , so I can generate the sources for the test or production environment without having to change the code inside the project. Is this the "build profile" in Maven speak?
Any ideas? Thanks.
You should remove your property on the top of your POM.
The you can call your Maven command lines as follows:
mvn goal -Dws_status=your_status_value
And it should be Ok.
I'm trying to use a class mediator with the WSO2 ESB.
Following is my mediator class.
package samples.mediators;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class SiriBankMediator extends AbstractMediator {
#Override
public boolean mediate(MessageContext messageContext) {
System.out.println("Hurraaaayyyy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
return false;
}
}
As suggested by Writing a WSO2 ESB Mediator, I tried the "Easier Way", created a jar with synapse-core_2.1.0.wso2v8.jar included in class path.
MANIFEST.MF is as follows
Manifest-Version: 1.0
Class-Path: synapse-core_2.1.0.wso2v8.jar
Created-By: 1.7.0_07 (Oracle Corporation)
And then as article suggested, dropped the jar to repository/components/lib in the ESB.
But after ESB restart when I try to load class it gives the error Class not found in the path
Jar file used is shared at siri.jar
Wonder what is missing in the steps I followed.
Thank you in advance.
Note: I used WSO2 Enterprise Service Bus 4.5.1
I've successfully deployed your custom mediator using the maven approach. Here's what I've done.
I created the following directory structure and placed your SiriBankMediator.java in src/main/java:
.
├── pom.xml
├── src
│ └── main
│ └── java
│ └── SiriBankMediator.java
The pom.xml file is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.samples.mediator</groupId>
<artifactId>siribankmediator</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<url>http://dist.wso2.org/maven2</url>
</repository>
<repository>
<id>apache-Incubating-repo</id>
<name>Maven Incubating Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
<repository>
<id>apache-maven2-repo</id>
<name>Apache Maven2 Repository</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.test</Bundle-SymbolicName>
<Bundle-Name>org.test</Bundle-Name>
<Export-Package>
org.test.mediator.*,
</Export-Package>
<Import-Package>
*; resolution:=optional
</Import-Package>
<Fragment-Host>synapse-core</Fragment-Host>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
<version>1.3.0.wso2v1</version>
</dependency>
</dependencies>
</project>
Then inside the directory containing the POM file, we do mvn compile package. This should build the jar file you need to put inside of $ESB_HOME/repository/components/lib in the folder called target.
Finally you can load the class as org.samples.mediator.SiriBankMediator through the carbon management frontend. Don't forget to restart your ESB. Hope that helps. :)
My Manifest of my Custom Mediator jars look like this:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_27-b07 (Sun Microsystems Inc.)
So maybe do not add that classpath and if this does not work, try to build with a Java 1.6 version.
Then it should all be fine.
Remember add your jar in "components/lib". Check the "components/dropins" folder after startup if WSO2 ESB has created a OSGi bundle of your jar. Then the class should be available.
try with your mediator class package name with at least three letters ,
example : package samples.mediators;
instead of that package name , try, package samples.mediators.anything;
This answer might not useful for you because this was asked like 2 years ago but anyone else came across this issue will be find my answer useful.
Just use package name other than samples.mediators that'll solve this issue. cheers..!