Skip to content

Commit 3db33cc

Browse files
Merge pull request #26 from BorderTech/latest-qa
Latest QA
2 parents 296aebc + b2d71dd commit 3db33cc

File tree

12 files changed

+109
-70
lines changed

12 files changed

+109
-70
lines changed

.circleci/config.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
before_install:
2+
- echo "MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=128m'" > ~/.mavenrc
3+
- mvn clean
4+
- wget https://github.com/codacy/codacy-coverage-reporter/releases/download/4.0.5/codacy-coverage-reporter-4.0.5-assembly.jar
5+
6+
language: Java
7+
jdk:
8+
- oraclejdk8
9+
10+
## Travis installs the project with the following maven command:- "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
11+
script:
12+
- mvn package
13+
14+
## Send Coverage to Codacy
15+
after_success:
16+
- java -jar codacy-coverage-reporter-4.0.5-assembly.jar report -l Java -r taskmaster-core/target/site/jacoco/jacoco.xml

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
Task Master helps run ASYNC tasks.
33

44
## Status
5-
[![CircleCI](https://circleci.com/gh/BorderTech/java-taskmaster.svg?style=svg)](https://circleci.com/gh/BorderTech/java-taskmaster)
5+
[![Build Status](https://travis-ci.com/BorderTech/java-taskmaster.svg?branch=master)](https://travis-ci.com/BorderTech/java-taskmaster)
66
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/83bcfdba5e34433894e8b958bdb958a5)](https://www.codacy.com/app/BorderTech/java-taskmaster?utm_source=github.com&utm_medium=referral&utm_content=BorderTech/java-taskmaster&utm_campaign=Badge_Grade)
7+
[![Javadocs](https://www.javadoc.io/badge/com.github.bordertech.taskmaster/taskmaster.svg)](https://www.javadoc.io/doc/com.github.bordertech.taskmaster/taskmaster)
8+
[![Maven Central](https://img.shields.io/maven-central/v/com.github.bordertech.taskmaster/taskmaster.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.bordertech.taskmaster%22%20AND%20a:%22taskmaster%22)
79

810
## What is TaskMaster
911

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>com.github.bordertech.common</groupId>
1212
<artifactId>qa-parent</artifactId>
13-
<version>1.0.4</version>
13+
<version>1.0.10</version>
1414
</parent>
1515

1616
<packaging>pom</packaging>
@@ -38,8 +38,8 @@
3838
</issueManagement>
3939

4040
<ciManagement>
41-
<system>CircleCI</system>
42-
<url>https://circleci.com/gh/bordertech/java-taskmaster/</url>
41+
<system>Travis CI</system>
42+
<url>https://travis-ci.com/BorderTech/java-taskmaster</url>
4343
</ciManagement>
4444

4545
<dependencyManagement>
@@ -105,7 +105,7 @@
105105
<dependency>
106106
<groupId>org.apache.commons</groupId>
107107
<artifactId>commons-lang3</artifactId>
108-
<version>3.8</version>
108+
<version>3.8.1</version>
109109
</dependency>
110110

111111
</dependencies>

taskmaster-cache-ehcache/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
<packaging>jar</packaging>
1818

19-
<properties>
20-
<bt.qa.skip>false</bt.qa.skip>
21-
</properties>
22-
2319
<description>
2420
Task Master provides a ehcache helper.
2521
</description>

taskmaster-cache-helper/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
<packaging>jar</packaging>
1818

19-
<properties>
20-
<bt.qa.skip>false</bt.qa.skip>
21-
</properties>
22-
2319
<description>
2420
Task Master provides a Cache Helper API.
2521
</description>

taskmaster-core/pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
<packaging>jar</packaging>
1818

19-
<properties>
20-
<bt.qa.skip>false</bt.qa.skip>
21-
</properties>
22-
2319
<description>
2420
Task Master allows a Runnable task to be submitted for execution and returns a Future representing that task.
2521
</description>
@@ -53,6 +49,12 @@
5349
<scope>provided</scope>
5450
</dependency>
5551

52+
<!-- Junit -->
53+
<dependency>
54+
<groupId>org.junit.vintage</groupId>
55+
<artifactId>junit-vintage-engine</artifactId>
56+
</dependency>
57+
5658
</dependencies>
5759

5860
</project>

taskmaster-core/src/main/java/com/github/bordertech/taskmaster/impl/TaskFutureResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public boolean isDone() {
4343
@Override
4444
public T get() throws InterruptedException, ExecutionException {
4545
if (result instanceof TaskMasterException) {
46-
Exception excp = (TaskMasterException) result;
46+
TaskMasterException excp = (TaskMasterException) result;
4747
throw new ExecutionException("Error processing future. " + excp.getMessage(), excp);
4848
}
4949
return result;

taskmaster-core/src/main/java/com/github/bordertech/taskmaster/logical/LogicalThreadPool.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.Serializable;
55
import java.util.concurrent.Semaphore;
66
import java.util.concurrent.TimeUnit;
7+
import org.apache.commons.lang.StringUtils;
78
import org.apache.commons.logging.Log;
89
import org.apache.commons.logging.LogFactory;
910

@@ -24,12 +25,19 @@ public class LogicalThreadPool implements Serializable {
2425
private final Semaphore semaphore;
2526
private boolean shutdown;
2627

28+
/**
29+
* Default constructor with default name and no limit to threads.
30+
*/
31+
public LogicalThreadPool() {
32+
this(null, 0);
33+
}
34+
2735
/**
2836
* @param name thread pool name
2937
* @param max the maximum threads. Zero means no limit.
3038
*/
3139
public LogicalThreadPool(final String name, final int max) {
32-
this.name = name == null ? "default" : name;
40+
this.name = StringUtils.isEmpty(name) ? "default" : name;
3341
this.max = max > 0 ? max : 0;
3442
this.semaphore = new Semaphore(this.max, true);
3543
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.github.bordertech.taskmaster.logical;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
/**
7+
* Unit tests for {@link LogicalThreadPool}.
8+
*/
9+
public class LogicalThreadPoolTest {
10+
11+
@Test
12+
public void testConstructor1() {
13+
LogicalThreadPool pool = new LogicalThreadPool();
14+
Assert.assertEquals("Incorrect pool name for default constructor", "default", pool.getName());
15+
Assert.assertEquals("Incorrect max threads for default constructor", 0, pool.getMax());
16+
}
17+
18+
@Test
19+
public void testConstructor2() {
20+
LogicalThreadPool pool = new LogicalThreadPool("foo", 5);
21+
Assert.assertEquals("Incorrect name for constructor", "foo", pool.getName());
22+
Assert.assertEquals("Incorrect default max threads for constructor", 5, pool.getMax());
23+
}
24+
25+
@Test
26+
public void testDefaultShutdown() {
27+
Assert.assertFalse("Pool should not be shutdown.", new LogicalThreadPool().isShutdown());
28+
}
29+
30+
@Test
31+
public void testNameDefault() {
32+
Assert.assertEquals("Pool name should be default for default constructor", "default", new LogicalThreadPool().getName());
33+
}
34+
35+
@Test
36+
public void testNameNull() {
37+
Assert.assertEquals("Pool name should be default for null in constructor", "default", new LogicalThreadPool(null, 0).getName());
38+
}
39+
40+
@Test
41+
public void testNameEmpty() {
42+
Assert.assertEquals("Pool name should be default for empty in constructor", "default", new LogicalThreadPool("", 0).getName());
43+
}
44+
45+
@Test
46+
public void testNameValue() {
47+
Assert.assertEquals("Pool name should be default for value in constructor", "foo", new LogicalThreadPool("foo", 0).getName());
48+
}
49+
50+
@Test
51+
public void testMaxDefault() {
52+
Assert.assertEquals("Pool max should default to zero (no limit).", 0, new LogicalThreadPool().getMax());
53+
}
54+
55+
@Test
56+
public void testMaxNegative() {
57+
Assert.assertEquals("Pool max should be zero for negative constructor value.", 0, new LogicalThreadPool(null, -1).getMax());
58+
}
59+
60+
@Test
61+
public void testMaxZero() {
62+
Assert.assertEquals("Pool max should be zero for zero constructor value.", 0, new LogicalThreadPool(null, 0).getMax());
63+
}
64+
65+
@Test
66+
public void testMaxPositive() {
67+
Assert.assertEquals("Pool max should be positive value.", 10, new LogicalThreadPool(null, 10).getMax());
68+
}
69+
70+
}

0 commit comments

Comments
 (0)