Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

zhouhao 7 rokov pred
rodič
commit
502833c6f1

+ 14 - 3
.travis.yml

@@ -1,5 +1,16 @@
 language: java
-jdk: oraclejdk8
 sudo: false
-install: false
-script: mvn test
+install: true
+addons:
+  sonarcloud:
+    organization: "hsweb"
+    token:
+      secure: "fba01e9fb57104fd0cfbed380e8c90301e35ff09"
+jdk:
+  - oraclejdk8
+script:
+  - mvn clean jacoco:report package sonar:sonar
+cache:
+  directories:
+    - '$HOME/.m2/repository'
+    - '$HOME/.sonar/cache'

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 ## hsweb  3.0
 [![Maven Central](https://img.shields.io/maven-central/v/org.hswebframework/hsweb-framework.svg?style=plastic)](http://search.maven.org/#search%7Cga%7C1%7Chswebframework)
+[![Coverage Status](https://sonarcloud.io/api/badges/measure?key=org.hswebframework.web:hsweb-framework&metric=coverage)](https://sonarcloud.io/dashboard?id=org.hswebframework.web%3Ahsweb-framework)
 [![Build Status](https://travis-ci.org/hs-web/hsweb-framework.svg?branch=master)](https://travis-ci.org/hs-web/hsweb-framework)
 [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)
 [![Insight.io](https://www.insight.io/repoBadge/github.com/hs-web/hsweb-framework)](https://insight.io/github.com/hs-web/hsweb-framework)

+ 7 - 5
hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
@@ -25,12 +26,12 @@ public class DynamicScheduleTests extends SimpleWebApplicationTests {
     private ScheduleJobService scheduleJobService;
 
 
-    public static final AtomicLong counter=new AtomicLong();
+    public static final CountDownLatch counter=new CountDownLatch(1);
+    public static final AtomicLong value=new AtomicLong();
     private String id;
 
     @Before
     public void initJob() throws InterruptedException {
-        Thread.sleep(5000);
         id = scheduleJobService.insert(createJob());
         scheduleJobService.enable(id);
     }
@@ -41,7 +42,8 @@ public class DynamicScheduleTests extends SimpleWebApplicationTests {
         entity.setType("test");
         entity.setLanguage("javascript");
         entity.setScript("" +
-                "org.hswebframework.web.schedule.test.DynamicScheduleTests.counter.incrementAndGet()\n" +
+                "org.hswebframework.web.schedule.test.DynamicScheduleTests.value.incrementAndGet();\n" +
+                "org.hswebframework.web.schedule.test.DynamicScheduleTests.counter.countDown();\n" +
                 "java.lang.System.out.println('job running...')");
         entity.setQuartzConfig("{\"type\":\"cron\",\"config\":\"0/1 * * * * ?\"}");
         return entity;
@@ -49,7 +51,7 @@ public class DynamicScheduleTests extends SimpleWebApplicationTests {
 
     @Test
     public void testCreateJob() throws InterruptedException {
-        Thread.sleep(20000);
-        Assert.assertTrue(counter.get()>0);
+        counter.await();
+        Assert.assertTrue(value.get()>0);
     }
 }

+ 5 - 3
hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java

@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -20,16 +21,17 @@ public class ScheduleTests extends SimpleWebApplicationTests {
 
     AtomicInteger counter = new AtomicInteger();
 
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+
     @Scheduled(cron = "0/1 * * * * ?")
     public void quartzTest() {
-        System.out.println(1234);
         counter.incrementAndGet();
+        countDownLatch.countDown();
     }
 
     @Test
     public void test() throws InterruptedException {
-        Thread.sleep(10000);
+        countDownLatch.await();
         Assert.assertTrue(counter.get() > 0);
-        System.out.println(counter.get());
     }
 }

+ 82 - 11
pom.xml

@@ -45,7 +45,9 @@
 
     <name>hsweb framework</name>
     <url>http://www.hswebframework.org</url>
-    <description>hsweb (haʊs wɛb) 是一个用于快速搭建企业后台管理系统的基础项目,集成一揽子便捷功能如:通用增删改查,在线代码生成,权限管理(可控制到列和行),动态多数据源分布式事务,动态脚本,动态定时任务,在线数据库维护等等</description>
+    <description>hsweb (haʊs wɛb)
+        是一个用于快速搭建企业后台管理系统的基础项目,集成一揽子便捷功能如:通用增删改查,在线代码生成,权限管理(可控制到列和行),动态多数据源分布式事务,动态脚本,动态定时任务,在线数据库维护等等
+    </description>
 
     <licenses>
         <license>
@@ -173,9 +175,78 @@
             </distributionManagement>
         </profile>
     </profiles>
-
     <build>
+
         <plugins>
+            <!--<plugin>-->
+                <!--<groupId>org.eluder.coveralls</groupId>-->
+                <!--<artifactId>coveralls-maven-plugin</artifactId>-->
+                <!--<version>4.3.0</version>-->
+            <!--</plugin>-->
+
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.7.9</version>
+                <configuration>
+                    <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
+                    <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
+                    <output>file</output>
+                    <append>true</append>
+                </configuration>
+                <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>
+
+
+
+            <!--<plugin>-->
+                <!--<groupId>org.codehaus.mojo</groupId>-->
+                <!--<artifactId>cobertura-maven-plugin</artifactId>-->
+                <!--<version>2.7</version>-->
+                <!--<configuration>-->
+                    <!--<formats>-->
+                        <!--<format>xml</format>-->
+                        <!--<format>html</format>-->
+                    <!--</formats>-->
+                    <!--<aggregate>true</aggregate>-->
+                    <!--<instrumentation>-->
+                        <!--<excludes>-->
+                            <!--<exclude>**/*Test.class</exclude>-->
+                            <!--<exclude>**/*Tests.class</exclude>-->
+                            <!--<exclude>**/*Entity.class</exclude>-->
+                            <!--<exclude>**/*Configuration.class</exclude>-->
+                        <!--</excludes>-->
+                    <!--</instrumentation>-->
+                <!--</configuration>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<phase>package</phase>-->
+                        <!--<goals>-->
+                            <!--<goal>cobertura</goal>-->
+                        <!--</goals>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+                <!--<dependencies>-->
+                    <!--<dependency>-->
+                        <!--<groupId>org.codehaus.javancss</groupId>-->
+                        <!--<artifactId>javancss</artifactId>-->
+                        <!--<version>33.54</version>-->
+                    <!--</dependency>-->
+                <!--</dependencies>-->
+            <!--</plugin>-->
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -401,18 +472,18 @@
     </distributionManagement>
 
     <pluginRepositories>
-        <pluginRepository>
-            <id>hsweb-nexus</id>
-            <name>Nexus Release Repository</name>
-            <url>http://nexus.hsweb.me/content/groups/public/</url>
-            <snapshots>
-                <enabled>true</enabled>
-            </snapshots>
-        </pluginRepository>
+        <!--<pluginRepository>-->
+            <!--<id>hsweb-nexus</id>-->
+            <!--<name>Nexus Release Repository</name>-->
+            <!--<url>http://nexus.hsweb.me/content/groups/public/</url>-->
+            <!--<snapshots>-->
+                <!--<enabled>true</enabled>-->
+            <!--</snapshots>-->
+        <!--</pluginRepository>-->
         <pluginRepository>
             <id>aliyun-nexus</id>
             <name>aliyun</name>
             <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
         </pluginRepository>
     </pluginRepositories>
-</project>
+</project>