3636 * @version 0.4-SNAPSHOT
3737 */
3838public final class Application {
39+ private static final int EX_FAILURE = 21 ;
3940 private static final int EX_USAGE = 64 ;
4041 private static final int EX_NOINPUT = 66 ;
4142 private static final int EX_SOFTWARE = 70 ;
@@ -87,7 +88,7 @@ private static String getJarName() {
8788 return jarName ;
8889 }
8990
90- private static void addSearchTests (final List < Test > tests ,
91+ private static void addSearchTests (final TestAggregate tests ,
9192 final ObjectClass oc ,
9293 final SearchTest st ,
9394 final String prefix ,
@@ -145,7 +146,7 @@ private static Result getDocRefProto(final String document,
145146 }
146147
147148 private static void addNonRdapTests (final Context c ,
148- final List < Test > tests ) {
149+ final TestAggregate tests ) {
149150 /* Relative URI in the HTTP request. */
150151 Result relative = new Result ();
151152 relative .setTestName ("common.bad-uri-relative" );
@@ -184,7 +185,7 @@ private static void addNonRdapTests(final Context c,
184185 }
185186
186187 private static void addUnsupportedQueryTypeTests (final Specification s ,
187- final List < Test > tests ) {
188+ final TestAggregate tests ) {
188189 /* Previously, this required that the server return a 400 (Bad
189190 * Request) for unsupported queries, as per using-http [5.4].
190191 * However, rdap-query now states that for documented query
@@ -211,7 +212,7 @@ private static void addUnsupportedQueryTypeTests(final Specification s,
211212 }
212213
213214 private static void addIpTests (final Specification s ,
214- final List < Test > tests ) {
215+ final TestAggregate tests ) {
215216 ObjectClass ocIp = s .getObjectClass ("ip" );
216217 if ((ocIp == null ) || !ocIp .isSupported ()) {
217218 return ;
@@ -259,7 +260,7 @@ private static void addIpTests(final Specification s,
259260 }
260261
261262 private static void addAutnumTests (final Specification s ,
262- final List < Test > tests ) {
263+ final TestAggregate tests ) {
263264 ObjectClass ocAn = s .getObjectClass ("autnum" );
264265 if ((ocAn == null ) || !ocAn .isSupported ()) {
265266 return ;
@@ -296,7 +297,7 @@ private static void addAutnumTests(final Specification s,
296297 }
297298
298299 private static void addNameserverTests (final Specification s ,
299- final List < Test > tests )
300+ final TestAggregate tests )
300301 throws Exception {
301302 ObjectClass ocNs = s .getObjectClass ("nameserver" );
302303 if ((ocNs == null ) || !ocNs .isSupported ()) {
@@ -347,7 +348,7 @@ private static void addNameserverTests(final Specification s,
347348 }
348349
349350 private static void addEntityTests (final Specification s ,
350- final List < Test > tests )
351+ final TestAggregate tests )
351352 throws Exception {
352353 ObjectClass ocEn = s .getObjectClass ("entity" );
353354 if ((ocEn == null ) || !ocEn .isSupported ()) {
@@ -398,7 +399,7 @@ private static void addEntityTests(final Specification s,
398399 }
399400
400401 private static void addDomainTests (final Specification s ,
401- final List < Test > tests )
402+ final TestAggregate tests )
402403 throws Exception {
403404 ObjectClass ocDom = s .getObjectClass ("domain" );
404405 if ((ocDom == null ) || !ocDom .isSupported ()) {
@@ -520,26 +521,26 @@ public static void main(final String[] args) throws Exception {
520521 }
521522
522523 String path = args [0 ];
523- Specification s = null ;
524+ Specification spec = null ;
524525 try {
525- s = Specification .fromPath (path );
526+ spec = Specification .fromPath (path );
526527 } catch (Exception e ) {
527528 System .err .println ("Unable to load specification "
528529 + "path (" + path + "): "
529530 + e .toString ());
530531 System .exit (EX_NOINPUT );
531532 }
532- if (s == null ) {
533+ if (spec == null ) {
533534 System .err .println ("Specification (" + path + ") is empty." );
534535 System .exit (EX_NOINPUT );
535536 }
536537
537538 RateLimiter rateLimiter =
538- (s .getRequestsPerSecond () > 0 )
539- ? RateLimiter .create (s .getRequestsPerSecond ())
539+ (spec .getRequestsPerSecond () > 0 )
540+ ? RateLimiter .create (spec .getRequestsPerSecond ())
540541 : null ;
541542
542- List < Test > tests = new ArrayList ();
543+ TestAggregate tests = new TestAggregate ();
543544
544545 /* For now, the non-RDAP-specific tests are disabled. These
545546 * are fairly niche, and in many cases can't easily be fixed
@@ -553,7 +554,7 @@ public static void main(final String[] args) throws Exception {
553554 * than not testing the responses at all, allow for the
554555 * supported content type to be set in the configuration, and
555556 * add a result at the beginning indicating this failure. */
556- if (s .getAcceptContentType () != null ) {
557+ if (spec .getAcceptContentType () != null ) {
557558 Result ctres = new Result ();
558559 ctres .setTestName ("common.rdap-specific-content-type" );
559560 ctres .setDocument ("rfc7480" );
@@ -563,12 +564,12 @@ public static void main(final String[] args) throws Exception {
563564 System .out .println (ctres .toString ());
564565 }
565566
566- addUnsupportedQueryTypeTests (s , tests );
567- addIpTests (s , tests );
568- addAutnumTests (s , tests );
569- addNameserverTests (s , tests );
570- addEntityTests (s , tests );
571- addDomainTests (s , tests );
567+ addUnsupportedQueryTypeTests (spec , tests );
568+ addIpTests (spec , tests );
569+ addAutnumTests (spec , tests );
570+ addNameserverTests (spec , tests );
571+ addEntityTests (spec , tests );
572+ addDomainTests (spec , tests );
572573
573574 tests .add (new net .apnic .rdap .conformance .test .help .Standard ());
574575 AtomicInteger testsRunning = new AtomicInteger (0 );
@@ -578,7 +579,7 @@ public static void main(final String[] args) throws Exception {
578579 .availableProcessors ());
579580 for (final Test t : tests ) {
580581 final Context context =
581- createContext (s , rateLimiter , executorService , testsRunning );
582+ createContext (spec , rateLimiter , executorService , testsRunning );
582583 context .submitTest (t );
583584 }
584585
@@ -598,7 +599,7 @@ public static void main(final String[] args) throws Exception {
598599 ctres
599600 );
600601 final Context context =
601- createContext (s , rateLimiter , executorService , testsRunning );
602+ createContext (spec , rateLimiter , executorService , testsRunning );
602603 context .setContentType ("application/json" );
603604 context .submitTest (test );
604605
@@ -614,5 +615,9 @@ public static void main(final String[] args) throws Exception {
614615 }
615616
616617 executorService .shutdown ();
618+
619+ if (tests .hasFailure ()) {
620+ System .exit (EX_FAILURE );
621+ }
617622 }
618623}
0 commit comments