Skip to content

Commit 2bc7a91

Browse files
authored
Merge pull request #36 from tlmiller/SCRUM-3593
Scrum 3593
2 parents 77ee9f3 + a72645d commit 2bc7a91

26 files changed

+80
-137
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ RUN cd /build && \
2525

2626
WORKDIR /app
2727
RUN useradd -MrU conformance && \
28-
chown -R conformance /app
28+
mkdir -p /rdap-config && \
29+
chown -R conformance /app && \
30+
chown -R conformance /rdap-config
2931

3032
EXPOSE 8080
3133
USER conformance
32-
ENTRYPOINT ["/app/entrypoint.sh", "rdap-configuration.json"]
34+
ENTRYPOINT ["/app/entrypoint.sh", "/rdap-config/rdap-configuration.json"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ docker build -t apnic/rdap-conformance .
154154
To run the Docker container:
155155

156156
```
157-
docker run -d -v "{configuration-path}:/app/rdap-configuration.json" \
157+
docker run -d -v "{configuration-path}:/rdap-config/rdap-configuration.json" \
158158
--name rdap-conformance apnic/rdap-conformance
159159
```
160160

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>net.apnic.rdap</groupId>
77
<artifactId>rdap-conformance</artifactId>
88
<packaging>jar</packaging>
9-
<version>0.4</version>
9+
<version>0.5</version>
1010
<name>rdap-conformance</name>
1111
<description>RDAP conformance</description>
1212
<inceptionYear>2014</inceptionYear>

src/main/java/net/apnic/rdap/conformance/Application.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static String getJarName() {
8888
return jarName;
8989
}
9090

91-
private static void addSearchTests(final TestAggregate tests,
91+
private static void addSearchTests(final List<Test> tests,
9292
final ObjectClass oc,
9393
final SearchTest st,
9494
final String prefix,
@@ -146,7 +146,7 @@ private static Result getDocRefProto(final String document,
146146
}
147147

148148
private static void addNonRdapTests(final Context c,
149-
final TestAggregate tests) {
149+
final List<Test> tests) {
150150
/* Relative URI in the HTTP request. */
151151
Result relative = new Result();
152152
relative.setTestName("common.bad-uri-relative");
@@ -185,7 +185,7 @@ private static void addNonRdapTests(final Context c,
185185
}
186186

187187
private static void addUnsupportedQueryTypeTests(final Specification s,
188-
final TestAggregate tests) {
188+
final List<Test> tests) {
189189
/* Previously, this required that the server return a 400 (Bad
190190
* Request) for unsupported queries, as per using-http [5.4].
191191
* However, rdap-query now states that for documented query
@@ -212,7 +212,7 @@ private static void addUnsupportedQueryTypeTests(final Specification s,
212212
}
213213

214214
private static void addIpTests(final Specification s,
215-
final TestAggregate tests) {
215+
final List<Test> tests) {
216216
ObjectClass ocIp = s.getObjectClass("ip");
217217
if ((ocIp == null) || !ocIp.isSupported()) {
218218
return;
@@ -260,7 +260,7 @@ private static void addIpTests(final Specification s,
260260
}
261261

262262
private static void addAutnumTests(final Specification s,
263-
final TestAggregate tests) {
263+
final List<Test> tests) {
264264
ObjectClass ocAn = s.getObjectClass("autnum");
265265
if ((ocAn == null) || !ocAn.isSupported()) {
266266
return;
@@ -297,7 +297,7 @@ private static void addAutnumTests(final Specification s,
297297
}
298298

299299
private static void addNameserverTests(final Specification s,
300-
final TestAggregate tests)
300+
final List<Test> tests)
301301
throws Exception {
302302
ObjectClass ocNs = s.getObjectClass("nameserver");
303303
if ((ocNs == null) || !ocNs.isSupported()) {
@@ -348,7 +348,7 @@ private static void addNameserverTests(final Specification s,
348348
}
349349

350350
private static void addEntityTests(final Specification s,
351-
final TestAggregate tests)
351+
final List<Test> tests)
352352
throws Exception {
353353
ObjectClass ocEn = s.getObjectClass("entity");
354354
if ((ocEn == null) || !ocEn.isSupported()) {
@@ -399,7 +399,7 @@ private static void addEntityTests(final Specification s,
399399
}
400400

401401
private static void addDomainTests(final Specification s,
402-
final TestAggregate tests)
402+
final List<Test> tests)
403403
throws Exception {
404404
ObjectClass ocDom = s.getObjectClass("domain");
405405
if ((ocDom == null) || !ocDom.isSupported()) {
@@ -540,7 +540,7 @@ public static void main(final String[] args) throws Exception {
540540
? RateLimiter.create(spec.getRequestsPerSecond())
541541
: null;
542542

543-
TestAggregate tests = new TestAggregate();
543+
List<Test> tests = new ArrayList<Test>();
544544

545545
/* For now, the non-RDAP-specific tests are disabled. These
546546
* are fairly niche, and in many cases can't easily be fixed
@@ -577,10 +577,12 @@ public static void main(final String[] args) throws Exception {
577577
final ExecutorService executorService =
578578
Executors.newFixedThreadPool(Runtime.getRuntime()
579579
.availableProcessors());
580+
ContextList contexts = new ContextList();
580581
for (final Test t : tests) {
581582
final Context context =
582583
createContext(spec, rateLimiter, executorService, testsRunning);
583584
context.submitTest(t);
585+
contexts.add(context);
584586
}
585587

586588
/* application/json content-type. This is deliberately using
@@ -602,6 +604,7 @@ public static void main(final String[] args) throws Exception {
602604
createContext(spec, rateLimiter, executorService, testsRunning);
603605
context.setContentType("application/json");
604606
context.submitTest(test);
607+
contexts.add(context);
605608

606609
while (true) {
607610
if (testsRunning.get() != 0) {
@@ -616,7 +619,7 @@ public static void main(final String[] args) throws Exception {
616619

617620
executorService.shutdown();
618621

619-
if(tests.hasFailure()) {
622+
if(contexts.hasFailedResult()) {
620623
System.exit(EX_FAILURE);
621624
}
622625
}

src/main/java/net/apnic/rdap/conformance/Context.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ public Specification getSpecification() {
135135
return specification;
136136
}
137137

138+
/**
139+
* <p>Indicates if a failed result is present in this context</p>
140+
*
141+
* @return True of false if this context has a failed result
142+
*/
143+
public boolean hasFailedResult()
144+
{
145+
for(Result res: results)
146+
{
147+
if(res.isStatus(Result.Status.Failure)) {
148+
return true;
149+
}
150+
}
151+
return false;
152+
}
153+
138154
/**
139155
* <p>Setter for the field <code>specification</code>.</p>
140156
*
@@ -249,7 +265,6 @@ public void onSuccess(final HttpResponse httpResponse) {
249265
testsRunning.getAndDecrement();
250266
}
251267
public void onFailure(final Throwable t) {
252-
System.out.println("**********");
253268
test.setError(t);
254269
test.run();
255270
synchronized (System.out) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package net.apnic.rdap.conformance;
2+
3+
import java.util.ArrayList;
4+
5+
/**
6+
* Represents a list of Context objects.
7+
*
8+
* Class is a wrapper around {@link java.util.ArrayList} that provides
9+
* convenience functions for getting information about a list of Context objects.
10+
*
11+
* Note: This class does not implement any ArrayList constructors as they are
12+
* not needed at present.
13+
*/
14+
public class ContextList
15+
extends ArrayList<Context>
16+
{
17+
/**
18+
* Indiciates if at least one Context object in this list has a failed
19+
* result.
20+
*
21+
* @return boolean if at least one Context has a failed result.
22+
*/
23+
public boolean hasFailedResult()
24+
{
25+
for(Context context : this)
26+
{
27+
if(context.hasFailedResult()) {
28+
return true;
29+
}
30+
}
31+
return false;
32+
}
33+
}

src/main/java/net/apnic/rdap/conformance/Result.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ public Status getStatus() {
9090
return status;
9191
}
9292

93+
/**
94+
* True if the supplied status is equal to the internal status of this
95+
* result.
96+
*
97+
* @param checkStatus Status to check against
98+
* @return true if the provided status matches the internal status of this
99+
* result
100+
*/
101+
public boolean isStatus(final Status checkStatus) {
102+
return status == checkStatus;
103+
}
104+
93105
/**
94106
* <p>Setter for the field <code>status</code>.</p>
95107
*

src/main/java/net/apnic/rdap/conformance/Test.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ public interface Test {
3434
*/
3535
HttpRequest getRequest();
3636

37-
/**
38-
* <p>isFailure.</p>
39-
*
40-
* @return boolean indiciator if the test succeeded or passed
41-
*/
42-
boolean hasFailed();
43-
4437
/**
4538
* <p>setResponse.</p>
4639
*

src/main/java/net/apnic/rdap/conformance/TestAggregate.java

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

src/main/java/net/apnic/rdap/conformance/test/autnum/BadRequest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ public BadRequest() {
3434
);
3535
}
3636

37-
/** {@inheritDoc} */
38-
public boolean hasFailed() {
39-
return cbr.hasFailed();
40-
}
41-
4237
/** {@inheritDoc} */
4338
public void setContext(final Context c) {
4439
cbr.setContext(c);

0 commit comments

Comments
 (0)