use of org.xml.sax.Attributes in project geode by apache.
the class LuceneIndexXmlGeneratorJUnitTest method generateWithFields.
/**
* Test of generating and reading cache configuration back in.
*/
@Test
public void generateWithFields() throws Exception {
LuceneIndex index = mock(LuceneIndex.class);
when(index.getName()).thenReturn("index");
String[] fields = new String[] { "field1", "field2" };
when(index.getFieldNames()).thenReturn(fields);
LuceneIndexXmlGenerator generator = new LuceneIndexXmlGenerator(index);
CacheXmlGenerator cacheXmlGenerator = mock(CacheXmlGenerator.class);
ContentHandler handler = mock(ContentHandler.class);
when(cacheXmlGenerator.getContentHandler()).thenReturn(handler);
generator.generate(cacheXmlGenerator);
ArgumentCaptor<Attributes> captor = ArgumentCaptor.forClass(Attributes.class);
verify(handler).startElement(eq(""), eq("index"), eq("lucene:index"), captor.capture());
Attributes value = captor.getValue();
assertEquals("index", value.getValue(LuceneXmlConstants.NAME));
captor = ArgumentCaptor.forClass(Attributes.class);
verify(handler, times(2)).startElement(eq(""), eq("field"), eq("lucene:field"), captor.capture());
Set<String> foundFields = new HashSet<String>();
for (Attributes fieldAttr : captor.getAllValues()) {
foundFields.add(fieldAttr.getValue(LuceneXmlConstants.NAME));
}
HashSet<String> expected = new HashSet<String>(Arrays.asList(fields));
assertEquals(expected, foundFields);
verify(handler, times(2)).endElement(eq(""), eq("field"), eq("lucene:field"));
verify(handler).endElement(eq(""), eq("index"), eq("lucene:index"));
}
use of org.xml.sax.Attributes in project sling by apache.
the class Parser method parseParam.
/**
* Param ::= '<jsp:param' S Attributes S? EmptyBody S?
*/
private void parseParam(Node parent) throws JasperException {
if (!reader.matches("<jsp:param")) {
err.jspError(reader.mark(), "jsp.error.paramexpected");
}
Attributes attrs = parseAttributes();
reader.skipSpaces();
Node paramActionNode = new Node.ParamAction(attrs, start, parent);
parseEmptyBody(paramActionNode, "jsp:param");
reader.skipSpaces();
}
use of org.xml.sax.Attributes in project sling by apache.
the class Parser method parsePageDirective.
/*
* Parses a page directive with the following syntax: PageDirective ::= ( S
* Attribute)*
*/
private void parsePageDirective(Node parent) throws JasperException {
Attributes attrs = parseAttributes();
Node.PageDirective n = new Node.PageDirective(attrs, start, parent);
/*
* A page directive may contain multiple 'import' attributes, each of
* which consists of a comma-separated list of package names. Store each
* list with the node, where it is parsed.
*/
for (int i = 0; i < attrs.getLength(); i++) {
if ("import".equals(attrs.getQName(i))) {
n.addImport(attrs.getValue(i));
}
}
}
use of org.xml.sax.Attributes in project sling by apache.
the class Parser method parseElement.
private void parseElement(Node parent) throws JasperException {
Attributes attrs = parseAttributes();
reader.skipSpaces();
Node elementNode = new Node.JspElement(attrs, start, parent);
parseOptionalBody(elementNode, "jsp:element", TagInfo.BODY_CONTENT_JSP);
}
use of org.xml.sax.Attributes in project sling by apache.
the class Parser method parseVariableDirective.
/*
* Parses a variable directive with the following syntax: PageDirective ::= (
* S Attribute)*
*/
private void parseVariableDirective(Node parent) throws JasperException {
Attributes attrs = parseAttributes();
Node.VariableDirective n = new Node.VariableDirective(attrs, start, parent);
}
Aggregations