Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support status 500 #926

Merged
merged 2 commits into from
Jan 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;

import com.google.common.base.Joiner;

import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.config.Configuration;
import br.com.caelum.vraptor.controller.HttpMethod;
Expand All @@ -38,6 +36,8 @@
import br.com.caelum.vraptor.proxy.Proxifier;
import br.com.caelum.vraptor.proxy.SuperMethod;

import com.google.common.base.Joiner;

/**
* Allows header related results.
*
Expand Down Expand Up @@ -199,4 +199,10 @@ public void notModified() {
public void notImplemented() {
response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
}

@Override
public void internalServerError() {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,10 @@ public interface Status extends View {
*/
void notImplemented();

/**
* Return Internal Server Error (500) Status
*/
void internalServerError();

void header(String key, String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ public void shouldSetNotImplementedStatus() throws Exception {

verify(response).setStatus(501);
}

@Test
public void shouldSetInternalServerErrorStatus() throws Exception {
status.internalServerError();

verify(response).setStatus(500);
}

@Test
public void shouldSetMethodNotAllowedStatus() throws Exception {
Expand Down Expand Up @@ -179,6 +186,7 @@ public void shouldSetMovedPermanentlyStatusOfLogic() throws Exception {
verify(response).addHeader("Location", "http://myapp.com/resource/method");
}

@SuppressWarnings("deprecation")
@Test
public void shouldSerializeErrorMessages() throws Exception {
Message normal = new SimpleMessage("category", "The message");
Expand All @@ -199,6 +207,7 @@ public void shouldSerializeErrorMessages() throws Exception {
assertThat(serialized, not(containsString("<i18nMessage>")));
}

@SuppressWarnings("deprecation")
@Test
public void shouldSerializeErrorMessagesInJSON() throws Exception {
Message normal = new SimpleMessage("category", "The message");
Expand Down