From 2d518ed6668e76f9a78163af3bbc4ced81c80af6 Mon Sep 17 00:00:00 2001 From: cgoldfeder Date: Tue, 11 Oct 2016 07:19:48 -0700 Subject: [PATCH] Move thrown.expect() right before the throwing statement aka regexing for fun and profit. This also makes sure that there are no statements after the throwing statement, since these would be dead code. There were a surprising number of places with assertions after the throw, and none of these are actually triggered in tests ever. When I found these, I replaced them with try/catch/rethrow which makes the assertions actually happen: before: // This is the ExceptionRule that checks EppException marshaling thrown.expect(FooException.class); doThrowingThing(); assertSomething(); // Dead code! after: try { doThrowingThing(); assertWithMessage("...").fail(); } catch (FooException e) { assertSomething(); // For EppExceptions: assertAboutEppExceptins().that(e).marshalsToXml(); } To make this work, I added EppExceptionSubject. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135793407 --- javatests/google/registry/testing/EppExceptionSubject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javatests/google/registry/testing/EppExceptionSubject.java b/javatests/google/registry/testing/EppExceptionSubject.java index b5d9d7632..620fc4a1c 100644 --- a/javatests/google/registry/testing/EppExceptionSubject.java +++ b/javatests/google/registry/testing/EppExceptionSubject.java @@ -1,4 +1,4 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. +// Copyright 2016 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.