List of usage examples for org.springframework.mock.web MockPageContext getResponse
@Override
public ServletResponse getResponse()
From source file:test.pl.chilldev.web.tags.page.PrintTitleTagTest.java
@Test public void doTag() throws IOException, JspTagException { MockPageContext context = new MockPageContext(); PrintTitleTag tag = new PrintTitleTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);//from w w w .j ava 2 s.c om // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String part = "bar"; page.addTitlePart(part); // run the tag tag.doTag(); assertEquals("PrintTitleTag.doTag() should print page title.", page.generateTitleContent(), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }
From source file:test.pl.chilldev.web.tags.page.PrintLinksTagTest.java
@Test public void doTag() throws IOException, JspTagException { MockPageContext context = new MockPageContext(); PrintLinksTag tag = new PrintLinksTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);//from w w w . j a v a 2s. c o m // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String href = "href"; page.addStylesheet(href); // run the tag tag.doTag(); assertEquals("PrintLinksTag.doTag() should print page title.", page.generateLinkElements(), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }
From source file:test.pl.chilldev.web.tags.page.PrintScriptsTagTest.java
@Test public void doTag() throws IOException, JspTagException { MockPageContext context = new MockPageContext(); PrintScriptsTag tag = new PrintScriptsTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);/*from w ww. j av a 2 s .c o m*/ // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String src = "bar"; page.addScript(src); // run the tag tag.doTag(); assertEquals("PrintScriptsTag.doTag() should print page title.", page.generateScriptElements(), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }
From source file:test.pl.chilldev.web.tags.page.PrintMetaTagTest.java
@Test public void doTag() throws IOException, JspTagException { MockPageContext context = new MockPageContext(); PrintMetaTag tag = new PrintMetaTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);/* w w w .j a v a 2 s. co m*/ // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); String key = "bar"; String value = "baz"; page.setMetaName(key, value); // run the tag tag.doTag(); assertEquals("PrintMetaTag.doTag() should print page title.", page.generateMetaElements(), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }
From source file:test.pl.chilldev.web.tags.page.PrintXmlnsTagTest.java
@Test public void doTag() throws URISyntaxException, IOException, JspTagException { MockPageContext context = new MockPageContext(); PrintXmlnsTag tag = new PrintXmlnsTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);//from w w w . java 2s. com // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); URI namespace = new URI("http://chilldev.pl/"); String alias = "cdv"; page.setXmlNamespace(namespace, alias); // run the tag tag.doTag(); assertEquals("PrintXmlnsTag.doTag() should print XML namespace attributes.", page.generateXmlnsAttributes(), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }
From source file:test.pl.chilldev.web.tags.page.XmlPrefixTagTest.java
@Test public void doTag() throws URISyntaxException, IOException, JspTagException { MockPageContext context = new MockPageContext(); XmlPrefixTag tag = new XmlPrefixTag(); PageMetaModel page = new PageMetaModel(); tag.setJspContext(context);/*w w w . java 2 s. co m*/ // set up context String attribute = "foo"; context.setAttribute(attribute, page); // set up resolver PageMetaModelContextUtils.setPageMetaModelResolver(new JspPageMetaModelResolver(attribute)); URI namespace = new URI("http://chilldev.pl/"); String alias = "cdv"; page.setXmlNamespace(namespace, alias); // run the tag tag.setNamespace(namespace); tag.doTag(); assertEquals("XmlPrefixTag.doTag() should print XML prefix for given namespace.", page.getXmlPrefix(namespace), ((org.springframework.mock.web.MockHttpServletResponse) context.getResponse()) .getContentAsString()); }