|
29 | 29 | import static org.hamcrest.Matchers.not; |
30 | 30 |
|
31 | 31 | import hudson.model.FreeStyleProject; |
| 32 | +import hudson.model.InvisibleAction; |
32 | 33 | import hudson.model.ItemGroup; |
| 34 | +import hudson.model.RootAction; |
33 | 35 | import hudson.model.TopLevelItemDescriptor; |
34 | 36 | import hudson.model.User; |
35 | 37 | import java.io.IOException; |
|
41 | 43 | import org.junit.Test; |
42 | 44 | import org.jvnet.hudson.test.JenkinsRule; |
43 | 45 | import org.jvnet.hudson.test.MockAuthorizationStrategy; |
| 46 | +import org.jvnet.hudson.test.TestExtension; |
| 47 | +import org.kohsuke.stapler.WebMethod; |
44 | 48 | import org.xml.sax.SAXException; |
45 | 49 |
|
46 | 50 | public class StackTraceSuppressionTest { |
@@ -129,19 +133,15 @@ public void exceptionShowsTrace() throws Exception { |
129 | 133 |
|
130 | 134 | @Test |
131 | 135 | public void exceptionEndpoint() throws Exception { |
132 | | - /* This test is based upon a testing endpoint that really shouldn't exist in production code. |
133 | | - If Jenkins is improved to eliminate this endpoint, this test may erroneously fail. */ |
134 | 136 | String relativePath = "exception"; |
135 | | - String detailString = "Jenkins.doException"; |
| 137 | + String detailString = "ExceptionAction.doException"; |
136 | 138 | checkSuppressedStack(relativePath, detailString); |
137 | 139 | } |
138 | 140 |
|
139 | 141 | @Test |
140 | 142 | public void exceptionEndpointShowsTrace() throws Exception { |
141 | | - /* This test is based upon a testing endpoint that really shouldn't exist in production code. |
142 | | - If Jenkins is improved to eliminate this endpoint, this test may erroneously fail. */ |
143 | 143 | String relativePath = "exception"; |
144 | | - String detailString = "Jenkins.doException"; |
| 144 | + String detailString = "ExceptionAction.doException"; |
145 | 145 | checkDisplayedStackTrace(relativePath, detailString); |
146 | 146 | } |
147 | 147 |
|
@@ -188,4 +188,18 @@ private void checkDisplayedStackTrace(String relativePath, String detailString) |
188 | 188 | assertThat(content, containsString(detailString)); |
189 | 189 | } |
190 | 190 |
|
| 191 | + /* Replacement for historical Jenkins#doException URL */ |
| 192 | + @TestExtension |
| 193 | + public static class ExceptionAction extends InvisibleAction implements RootAction { |
| 194 | + @WebMethod(name = "") |
| 195 | + public void doException() { |
| 196 | + throw new RuntimeException(); |
| 197 | + } |
| 198 | + |
| 199 | + @Override |
| 200 | + public String getUrlName() { |
| 201 | + return "exception"; |
| 202 | + } |
| 203 | + } |
| 204 | + |
191 | 205 | } |
0 commit comments