*
* @throws Exception
*/
public void testNonExistentID() throws Exception {
ServletRunner runner = new ServletRunner(createDefaultWebXML());
ServletUnitClient client = runner.newClient();
WebRequest request = createPostRequest(VALID_TEST_XML, READER_TEST_URL);
WebResponse response = client.getResponse(request);
String id = response.getHeaderField(
MessageStoreServlet.MESSAGE_RESPONSE_HEADER_NAME);
// Check the ID has been returned OK
assertNotNull("ID should exist in the headers", id);
// Use a fake servlet class to avoid the need to initialise and run
// an entire MCS session.
request = new GetMethodWebRequest(PARTIAL_TEST_URL);
request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
id);
client = runner.newClient();
response = client.getResponse(request);
assertEquals("The response code should indicate success",
MessageStoreMessageEnumeration.SUCCESS.getValue(),
response.getResponseCode());
// create invalid ID
String invalidID = "123h23h29t";
// get the invalid ID
request = new GetMethodWebRequest(FULL_TEST_URL);
request.setHeaderField("User-Agent", "Mozilla/5.0 Firefox...");
request.setParameter(MessageStoreServlet.MESSAGE_RETRIEVE_PARAM_NAME,
invalidID);
client = runner.newClient();
try {
client.getResponse(request);
fail("Getting an invalid ID is not allowed and should throw a 404");
} catch (HttpException he) {