" <script type=\"text/javascript\">\n" +
" CLOSURE_BASE_PATH=\"<%=request.getContextPath()%>/js/closure/goog/\";\n" +
" </script>\n" +
" <g:compress method=\"closure-compiler\">\n" +
" <script src=\"../js/closure/goog/base.js\"></script></g:compress>";
TagReader s = new TagReader(text);
List<Element> all = s.getAllElements();
int jspTags = 0;
int gCompressPos = 0;
for (Element e : all)
if (e.getName() != null && e.getName().equalsIgnoreCase("%"))
jspTags++;
else if (e.getName() != null && e.getName().equals("g:compress")) gCompressPos = all.indexOf(e);
assertEquals(jspTags, 3);
Element pageTag = all.get(1);
Attributes pageAttributes = s.parseAttributes(pageTag);
assertEquals(pageAttributes.isValueExists("include"), false);
assertEquals(pageAttributes.isValueExists("file"), false);
Element includeTag = all.get(2);
Attributes includeAttributes = s.parseAttributes(includeTag);
assertEquals(includeAttributes.isValueExists("include"), true);
assertEquals(includeAttributes.isValueExists("file"), true);
assertEquals(includeTag.getBegin(), text.indexOf("<%@ include"));
assertEquals(includeTag.getEnd(), text.indexOf("<%@ include") + "<%@ include file=\"includes/test1.inc\"%>".length());
Element gCompress = all.get(gCompressPos);
Attributes gCompressAttrs = s.parseAttributes(gCompress);
assertEquals(gCompressAttrs.isValueExists("dsdsd"), false);
assertEquals(gCompressAttrs.isValueExists("method"), true);
assertEquals(gCompressAttrs.get("method").getBegin(), text.indexOf("method="));
assertEquals(gCompressAttrs.get("method").getEnd(), text.indexOf("method=") + "method=\"closure-compiler\"".length());
assertEquals(gCompress.getBegin(), text.indexOf("<g:compress"));