/**
  * Determines if an error document contains errors.
  *
  * @param errorDoc the error document
  * @return <code>true</code> if there are any errors.
  */
 protected boolean hasErrors(Document errorDoc) {
   Element root = errorDoc.getDocumentElement();
   if (root == null) {
     return false;
   }
   PSXmlTreeWalker w = new PSXmlTreeWalker(root);
   Element e =
       w.getNextElement(
           PSItemErrorDoc.ERROR_FIELD_SET_ELEM, PSXmlTreeWalker.GET_NEXT_ALLOW_CHILDREN);
   if (e == null) {
     return false;
   }
   e = w.getNextElement(PSItemErrorDoc.ERROR_FIELD_ELEM, PSXmlTreeWalker.GET_NEXT_ALLOW_CHILDREN);
   if (e == null) {
     return false;
   }
   return true;
 }
  @Test
  public final void testHandleRequestInternalHttpServletRequestHttpServletResponse() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();

    final ImageSizeDefinition sizea =
        new ImageSizeDefinition() {
          {
            setCode("a");
            setLabel("Size A");
          }
        };
    final ImageSizeDefinition sizeb =
        new ImageSizeDefinition() {
          {
            setCode("b");
            setLabel("Size B");
          }
        };

    try {
      context.checking(
          new Expectations() {
            {
              one(defmgr).getAllImageSizes();
              will(returnValue(Arrays.asList(new ImageSizeDefinition[] {sizea, sizeb})));
            }
          });

      ModelAndView mav = cut.handleRequest(request, response);

      Document result = (Document) mav.getModel().get("result");
      assertNotNull(result);
      log.info("Document is " + PSXmlDocumentBuilder.toString(result));

      PSXmlTreeWalker walker = new PSXmlTreeWalker(result.getDocumentElement());
      walker.getNextElement("PSXEntry", PSXmlTreeWalker.GET_NEXT_ALLOW_CHILDREN);
      log.info("current element " + walker.getCurrentNodeName());
      walker.getNextElement("PSXDisplayText", PSXmlTreeWalker.GET_NEXT_ALLOW_CHILDREN);
      String display = walker.getElementData();
      assertEquals("Size A", display);
      walker.getNextElement("Value", PSXmlTreeWalker.GET_NEXT_ALLOW_SIBLINGS);
      String value = walker.getElementData();
      assertEquals("a", value);

    } catch (Exception ex) {
      log.error("Unexpected Exception " + ex, ex);
      fail("Exception Caught");
    }
  }