### Question:
TreeXmlAction extends AbstractXmlAction { @Override public void readParameters() { super.readParameters(); name = getContext().getParameterAsString("name", null); } TreeXmlAction(ActionContext context); @Override void readParameters(); static final String PATH; }### Answer:
@Test public void testExecute() throws Exception { TestActionContext context = new TestActionContext("/data/tree.xml"); TreeXmlAction action = new TreeXmlAction(context); action.readParameters(); action.execute(); assertEquals(context.getContentType(), "text/xml"); byte[] bytes = context.toByteArray(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document document = builder.parse(new ByteArrayInputStream(bytes)); Set<String> names = new HashSet<>(); names.add("A"); names.add("B"); names.add("C"); visitElement(document.getDocumentElement(), names); assertTrue(names.isEmpty()); }