Subversion Repositories Study

Compare Revisions

Ignore whitespace Rev 359 → Rev 360

/trunk/maven/jacoco-maven-plugin/pom.xml
0,0 → 1,133
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
 
<groupId>fr.ejn.tutorial.maven</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Study Failsafe plugin</name>
<description>Example for the Maven Failsafe plugin</description>
 
<contributors>
<contributor>
<name>Etienne Jouvin</name>
<email>etienne.jouvin@free.fr</email>
<organization>Jouvinio</organization>
<organizationUrl>http://www.jouvinio.net/wiki</organizationUrl>
<timezone>+1</timezone>
<roles>
<role>Java Developer</role>
</roles>
</contributor>
</contributors>
 
<scm>
<connection>scm:svn:http://www.svn.jouvinio.net/study/trunk/maven/jacoco-maven-plugin/</connection>
<developerConnection>scm:svn:https://www.svn.jouvinio.net/study/trunk/maven/jacoco-maven-plugin/</developerConnection>
<url>http://www.svn.jouvinio.net/study/trunk/maven/jacoco-maven-plugin/</url>
</scm>
 
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
 
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<!-- Unit test -->
<dependency>
<groupId>org.meanbean</groupId>
<artifactId>meanbean</artifactId>
<version>2.0.3</version>
<scope>test</scope>
</dependency>
 
<dependency>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
 
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>
</build>
 
</project>
/trunk/maven/jacoco-maven-plugin/src/it/java/fr/ejn/tutorial/maven/jacocoMavenPlugin/service/UserServiceImplIT.java
0,0 → 1,55
package fr.ejn.tutorial.maven.jacocoMavenPlugin.service;
 
import static org.junit.Assert.assertEquals;
 
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
 
import fr.ejn.tutorial.maven.jacocoMavenPlugin.model.User;
import fr.ejn.tutorial.maven.jacocoMavenPlugin.repository.UserRepository;
 
public class UserServiceImplIT {
 
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
 
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
 
private UserServiceImpl instance = new UserServiceImpl();
 
@Before
public void setUp() throws Exception {
instance.setUserRepository(new UserRepository() {
 
@Override
public User getUser(String userId) {
User user = new User();
 
user.setId(userId);
user.setName("userName");
user.setSurname("userSurname");
 
return user;
}
});
}
 
@After
public void tearDown() throws Exception {
}
 
@Test
public void testSayHello() {
String actual = instance.sayHello("userId");
String expected = "Hello userName userSurname";
 
assertEquals(expected, actual);
}
 
}
/trunk/maven/jacoco-maven-plugin/src/main/java/fr/ejn/tutorial/maven/jacocoMavenPlugin/model/User.java
0,0 → 1,55
package fr.ejn.tutorial.maven.jacocoMavenPlugin.model;
 
/**
* @author Etienne Jouvin
*
*/
public class User {
 
private String id;
private String name;
private String surname;
 
/**
* @return the id.
*/
public String getId() {
return id;
}
 
/**
* @return the name.
*/
public String getName() {
return name;
}
 
/**
* @return the surname.
*/
public String getSurname() {
return surname;
}
 
/**
* @param id the id to set.
*/
public void setId(String id) {
this.id = id;
}
 
/**
* @param name the name to set.
*/
public void setName(String name) {
this.name = name;
}
 
/**
* @param surname the surname to set.
*/
public void setSurname(String surname) {
this.surname = surname;
}
 
}
/trunk/maven/jacoco-maven-plugin/src/main/java/fr/ejn/tutorial/maven/jacocoMavenPlugin/repository/UserRepository.java
0,0 → 1,19
package fr.ejn.tutorial.maven.jacocoMavenPlugin.repository;
 
import fr.ejn.tutorial.maven.jacocoMavenPlugin.model.User;
 
/**
* @author Etienne Jouvin
*
*/
public interface UserRepository {
 
/**
* Get user from his id.
*
* @param userId User id to search.
* @return User instance for this id.
*/
User getUser(String userId);
 
}
/trunk/maven/jacoco-maven-plugin/src/main/java/fr/ejn/tutorial/maven/jacocoMavenPlugin/service/UserServiceImpl.java
0,0 → 1,48
package fr.ejn.tutorial.maven.jacocoMavenPlugin.service;
 
import java.text.MessageFormat;
 
import org.apache.commons.lang3.StringUtils;
 
import fr.ejn.tutorial.maven.jacocoMavenPlugin.model.User;
import fr.ejn.tutorial.maven.jacocoMavenPlugin.repository.UserRepository;
 
/**
* @author Etienne Jouvin
*
*/
public class UserServiceImpl {
 
private static final String MSG_HELLO = "Hello {0} {1}";
private UserRepository userRepository;
 
/**
* Search the user and say hello.
*
* @param userId Id to search.
*/
public String sayHello(String userId) {
String message = null;
 
/* Get the user from the DAO. */
User user = null;
 
if (StringUtils.isNotBlank(userId)) {
user = this.userRepository.getUser(userId);
}
 
if (null != user) {
message = MessageFormat.format(MSG_HELLO, user.getName(), user.getSurname());
}
 
return StringUtils.defaultIfBlank(message, StringUtils.EMPTY);
}
 
/**
* @param userDao the userDao to set.
*/
public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}
 
}
/trunk/maven/jacoco-maven-plugin/src/test/java/fr/ejn/tutorial/maven/jacocoMavenPlugin/model/UserTest.java
0,0 → 1,33
package fr.ejn.tutorial.maven.jacocoMavenPlugin.model;
 
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.meanbean.test.BeanTester;
 
public class UserTest {
 
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
 
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
 
@Before
public void setUp() throws Exception {
}
 
@After
public void tearDown() throws Exception {
}
 
@Test
public void testInstance() {
new BeanTester().testBean(User.class);
}
 
}