Skip to content

Commit 2a0ff13

Browse files
authored
Merge pull request #3 from ngortheone/testing
[RFC] Basic testing infrastructure
2 parents 27b81cf + d4e7d7a commit 2a0ff13

22 files changed

Lines changed: 1099 additions & 16 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ bin/
1111
.project
1212

1313
taskwarrior.properties
14+
15+
# Intellij Idea
16+
.idea/
17+
*.iml

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ taskwarrior-java-client
1818
What is it
1919
----------
2020

21-
A Java client to communicate with a [taskwarrior][] server (= [taskd](https://taskwarrior.org/docs/taskserver/why.html)).
21+
A Java client to communicate with a [taskwarrior][] server (=
22+
[taskd](https://taskwarrior.org/docs/taskserver/why.html)).
2223

2324
[taskwarrior]: https://taskwarrior.org/
2425

2526

2627
Motivation and distinction
2728
--------------------------
2829

29-
The current taskwarrior Android app does not satisfy my requirements. Therefore I created this client library to integrate it into my prefered task app.
30-
And I also want to share it with everybody who will love to use it.
30+
The current taskwarrior Android app does not satisfy my requirements. Therefore
31+
I created this client library to integrate it into my prefered task app. And I
32+
also want to share it with everybody who will love to use it.
3133

3234

3335
Requirements
@@ -39,8 +41,9 @@ Requirements
3941
Download
4042
--------
4143

42-
Currently there is no released version available but feel free to clone / fork and build it yourself. If you would love to see this on
43-
[Maven Central](http://search.maven.org/) feel free to create an issue.
44+
Currently there is no released version available but feel free to clone / fork
45+
and build it yourself. If you would love to see this on [Maven
46+
Central](http://search.maven.org/) feel free to create an issue.
4447

4548

4649
Usage example
@@ -88,6 +91,14 @@ Used `taskwarrior.properties` can be created by copying and adjusting
8891
[`src/main/resources/taskwarrior.properties.template`](https://github.com/aaschmid/taskwarrior-java-client/tree/master/src/main/resources/taskwarrior.properties.template).
8992

9093

94+
95+
Testing
96+
-------
97+
98+
To run tests manually you will need to build and run taskwarrior server container.
99+
[See here how](docker/README.md)
100+
101+
91102
Release notes
92103
-------------
93104

build.gradle

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
plugins {
22
id 'de.aaschmid.cpd' version '1.0'
3-
id 'eclipse'
43
id 'java'
54
id 'findbugs'
65
}
76

87
archivesBaseName = 'taskwarrior-java-client'
98
description = 'A Java client to communicate with a taskwarrior server (= taskd).'
109
group = 'de.aaschmid'
11-
version = '1.0-SNAPSHOT'
10+
version = '1.1-SNAPSHOT'
1211

1312
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
1413

1514
repositories {
1615
mavenCentral()
1716
}
1817

19-
task wrapper(type: Wrapper) {
20-
gradleVersion = '4.6'
21-
}
22-
2318
jar {
2419
manifest {
2520
def title = 'Taskwarrior Java client'
@@ -43,13 +38,15 @@ jar {
4338
}
4439
}
4540

41+
test {
42+
useJUnitPlatform()
43+
}
44+
4645
task javadocJar(type: Jar, dependsOn: javadoc) {
47-
classifier = 'javadoc'
4846
from javadoc.destinationDir
4947
}
5048

5149
task sourcesJar(type: Jar) {
52-
classifier = 'sources'
5350
from sourceSets.main.allSource
5451
}
5552

@@ -72,3 +69,10 @@ artifacts {
7269
archives javadocJar
7370
archives sourcesJar
7471
}
72+
73+
dependencies {
74+
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.1'
75+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.1'
76+
77+
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.1'
78+
}

docker/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM alpine:latest
2+
MAINTAINER Ihor Antonov <ihor@antonovs.family>
3+
4+
# Configuration steps closely follow official taskd manual:
5+
# https://taskwarrior.org/docs/taskserver/configure.html
6+
7+
# Taskwarrior server vars (TASKD..)
8+
# Taskwarrior user vars (TASK..)
9+
ENV TASKDDATA=/var/lib/taskd \
10+
TASKDLISTEN=localhost:53589 \
11+
TASKDLOG=/var/log/taskd.log \
12+
TASKDUSER=taskd \
13+
TASKDGROUP=taskd \
14+
TASKORG=Public \
15+
TASKUSERID=921c0dd2-728e-4a44-8605-68262754dd99
16+
17+
EXPOSE 53589
18+
19+
RUN apk add --no-cache taskd task \
20+
&& mkdir -p $TASKDDATA/orgs/$TASKORG/users/$TASKUSERID \
21+
&& touch $TASKDLOG \
22+
&& chown $TASKDUSER:$TASKDGROUP $TASKDLOG \
23+
&& chown -R $TASKDUSER:$TASKDGROUP $TASKDDATA
24+
25+
# Copy pre-created certificates
26+
COPY --chown=$TASKDUSER:$TASKDGROUP \
27+
certs/client.cert.pem \
28+
certs/client.key.pem \
29+
certs/server.cert.pem \
30+
certs/server.key.pem \
31+
certs/ca.cert.pem \
32+
certs/ca.key.pem \
33+
server/config \
34+
$TASKDDATA/
35+
36+
# Put some initial data for the user
37+
COPY --chown=$TASKDUSER:$TASKDGROUP \
38+
user/config \
39+
user/tx.data \
40+
$TASKDDATA/orgs/$TASKORG/users/$TASKUSERID/
41+
42+
# Put basic taskwarrior config for debugging
43+
COPY user/taskrc /root/.taskrc
44+
45+
CMD taskd server \
46+
--user $TASKDUSER:$TASKDGROUP \
47+
--data $TASKDDATA \
48+
--debug \
49+
--debug.tls=2 \
50+
--daemon \
51+
&& tail -f $TASKDLOG
52+
53+

docker/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Task Server container
2+
3+
Containerized taskserver for testing and debugging purposes. All commands shown
4+
below are executed from this directory. You will need
5+
[docker](https://docs.docker.com/install/) installed and docker daemon running.
6+
7+
8+
# Build
9+
10+
11+
Simple build can be done by running:
12+
13+
```sh
14+
docker build -t taskd-alpine .
15+
```
16+
17+
Dockerfile has been optimized for speed of building. Most of the configuration
18+
is statically stored in `certs/`, `server/`,and `user/` directories.
19+
20+
User and server certificates are generated by pki infrastructure provided by
21+
taskd. See [vars](certs/vars) that were used for cert generation. Additionally
22+
client key has been coverted to PKCS8 DER format to be compatible with Java
23+
client.
24+
25+
If you want to add more pre-created data (tasks) modify [tx.data](user/tx.data)
26+
file and rebuild the container.
27+
28+
29+
# Run
30+
31+
After you built the container you can run it with the following command:
32+
33+
```sh
34+
docker run --tty --interactive -p 53589:53589 taskd-alpine
35+
```
36+
37+
Task Server listens on 53589 port. The command above will map the port to the
38+
same port on your `localhost`. If you have a conflicting service listening on
39+
the same port then modify `-p` flag argument ([see
40+
how](https://docs.docker.com/engine/reference/run/#expose-incoming-ports))
41+
42+
You will need the container running before you can run JUnit tests, as tests
43+
are expecting a running server on 53589 port. Modify
44+
[test properties](../src/test/resources/taskwarrior.properties) if you need
45+
to change expected port or address of the server
46+
47+
48+
49+
50+
# Reference materials
51+
52+
- [Dockerfile reference ](https://docs.docker.com/engine/reference/builder/)
53+
54+
- [Alpine taskd package](https://pkgs.alpinelinux.org/package/edge/main/x86_64/taskd)
55+
56+
- [Alpine task package](https://pkgs.alpinelinux.org/package/edge/main/x86_64/task)

docker/certs/ca.cert.pem

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIFszCCA5ugAwIBAgIULkm6zyPClZ5fuExlZmaXRtrFJNAwDQYJKoZIhvcNAQEM
3+
BQAwcTESMBAGA1UEAxMJbG9jYWxob3N0MR4wHAYDVQQKDBVHw7Z0ZWJvcmcgQml0
4+
IEZhY3RvcnkxEjAQBgNVBAcMCUfDtnRlYm9yZzEaMBgGA1UECAwRVsOkc3RyYSBH
5+
w7Z0YWxhbmQxCzAJBgNVBAYTAlNFMB4XDTE5MDgzMTEzMTIwNVoXDTIwMDgzMDEz
6+
MTIwNVowcTESMBAGA1UEAxMJbG9jYWxob3N0MR4wHAYDVQQKDBVHw7Z0ZWJvcmcg
7+
Qml0IEZhY3RvcnkxEjAQBgNVBAcMCUfDtnRlYm9yZzEaMBgGA1UECAwRVsOkc3Ry
8+
YSBHw7Z0Y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