Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyonghao committed Aug 31, 2018
1 parent 2049d40 commit 8aa085f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
35 changes: 30 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>org.zyh</groupId>
Expand Down Expand Up @@ -40,10 +41,10 @@

<!-- this driver should be putted at tomcat lib.-->
<!--<dependency>-->
<!--<groupId>com.microsoft.sqlserver</groupId>-->
<!--<artifactId>sqljdbc4</artifactId>-->
<!--<version>4.0</version>-->
<!--<scope>provided</scope>-->
<!--<groupId>com.microsoft.sqlserver</groupId>-->
<!--<artifactId>sqljdbc4</artifactId>-->
<!--<version>4.0</version>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand All @@ -67,16 +68,40 @@
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken>7GmVopyNiLm8DJGG8Qa6SRIUGbSGPNXPD</repoToken>
<sourceEncoding>UTF-8</sourceEncoding>
</configuration>
</plugin>
</plugins>
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/org/zyh/service/URLTestServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.zyh.service;

import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.zyh.model.URLTest;

import static org.junit.Assert.assertNotNull;

public class URLTestServiceTest {

@Test
public void create() {
}

@Test
public void list() {
}

@Test
public void execute() {
URLTest test = new URLTest();
HibernateTemplate template = Mockito.mock(HibernateTemplate.class);
URLTestService service = new URLTestService(template);
Mockito.doReturn(test).when(template).get(Mockito.eq(URLTest.class), Mockito.anyInt());
test.setUrl("http://www.bing.com");
assertNotNull(service.execute(123));
}
}

0 comments on commit 8aa085f

Please sign in to comment.