request.made=Request made:
route=Route
s=s
+server.timeout=Frank requested information from the OC Transpo server, but it did not respond in a timely manner. This probably indicates that the OC Transpo server is temporarily unavailable. It may come back online soon; please try again in a few minutes.
unexpected.error=Unexpected Error
unexpected.exception=An unexpected exception has been raised. This probably indicates a bug in Frank.
url.contacted=URL contacted:
request.made=Request made:
route=Route
s=s
+server.timeout=Frank requested information from the OC Transpo server, but it did not respond in a timely manner. This probably indicates that the OC Transpo server is temporarily unavailable. It may come back online soon; please try again in a few minutes.
unexpected.error=Unexpected Error
unexpected.exception=An unexpected exception has been raised. This probably indicates a bug in Frank.
url.contacted=URL contacted:
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.net.SocketTimeoutException;
import java.util.Locale;
import net.jaekl.qd.http.InvalidResponseException;
pw.println("</P>");
pw.println("<P>" + bundle.get(FrankBundle.MAYBE_SERVER_PROBLEM) + "</P>");
}
+ else if (cause instanceof SocketTimeoutException) {
+ pw.println(bundle.get(FrankBundle.SERVER_TIMEOUT));
+ }
else {
pw.println(bundle.get(FrankBundle.UNEXPECTED_EXCEPTION));
}
public static final String REQUEST_MADE = "request.made";
public static final String ROUTE = "route";
public static final String SECONDS = "s";
+ public static final String SERVER_TIMEOUT = "server.timeout";
public static final String UNEXPECTED_ERROR = "unexpected.error";
public static final String UNEXPECTED_EXCEPTION = "unexpected.exception";
public static final String URL_CONTACTED = "url.contacted";
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.net.SocketTimeoutException;
import java.sql.SQLException;
import java.util.Locale;
}
@Test
- public void testExplain_unexpectedException() {
+ public void testExplain_simpleExceptions() {
Locale[] locales = { Locale.CANADA, Locale.FRANCE, Locale.JAPAN, Locale.CHINA};
+ Object[][] data = {
+ {new NullPointerException(), FrankBundle.UNEXPECTED_EXCEPTION},
+ {new SocketTimeoutException(), FrankBundle.SERVER_TIMEOUT}
+ };
ErrorHandler eh = new ErrorHandler();
for (Locale locale : locales) {
FrankBundle bundle = FrankBundle.getInst(locale);
- m_baos.reset();
- eh.writeErrorPage(m_pw, new NullPointerException(), Locale.CANADA);
- m_pw.flush();
-
- String actual = m_baos.toString();
- Assert.assertTrue(actual.contains(bundle.get(FrankBundle.UNEXPECTED_EXCEPTION)));
+ for (Object[] tuple : data) {
+ Exception e = (Exception)tuple[0];
+ String key = (String)tuple[1];
+
+ m_baos.reset();
+ eh.writeErrorPage(m_pw, e, locale);
+ m_pw.flush();
+
+ String actual = m_baos.toString();
+ Assert.assertTrue(actual.contains(bundle.get(key)));
+ }
}
}