Package net.sourceforge.pebble.web.model

Examples of net.sourceforge.pebble.web.model.Model


  public void testViewMonth() throws Exception {
    request.setParameter("year", "2006");
    request.setParameter("month", "05");
    View view = action.process(request, response);

    Model model = action.getModel();
    assertEquals(blog.getBlogForMonth(2006, 5), model.get(Constants.MONTHLY_BLOG));
    assertNotNull(model.get(Constants.BLOG_ENTRIES));
    assertTrue(view instanceof BlogEntriesByMonthView);
  }
View Full Code Here


    super.setUp();

    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();

    model = new Model();
    model.put(Constants.BLOG_KEY, blog);
    action.setModel(model);
  }
View Full Code Here

      if (!validated) {
        // Forward to no security url
        request.getRequestDispatcher("/noSecurityToken.action").forward(request, response);
      } else {
        try {
          Model model = new Model();
          model.put(Constants.BLOG_KEY, blog);
          model.put(Constants.BLOG_URL, blog.getUrl());
          action.setModel(model);
          View view;
          try {
            view = action.process(request, response);
          } catch (ClassCastException cce) {
            // PEBBLE-45 Actions intended for single blog mode should fail nicely.  This is a simple method that will
            // allow has to handle all actions with minimal effort
            if (cce.getMessage().contains(MultiBlog.class.getName()) && cce.getMessage().contains(Blog.class.getName())) {
              view = new MultiBlogNotSupportedView();
            } else {
              throw cce;
            }
          }
          if (view != null) {

            view.setModel(model);
            view.setServletContext(servletContext);

            view.prepare();

            for (Object key : model.keySet()) {
              request.setAttribute(key.toString(), model.get(key.toString()));
            }

            response.setContentType(view.getContentType());
            view.dispatch(request, response, servletContext);
View Full Code Here

*/
public class FeedViewTest extends SingleBlogTestCase {

  public void testGetFeed() throws Exception {
    FeedView feedView = new FeedView(AbstractRomeFeedView.FeedType.ATOM);
    Model model = new Model();
    feedView.setModel(model);

    BlogEntry entry = new BlogEntry(blog);
    entry.setTitle("My Title");
    entry.setAuthor("author");
    entry.setBody("body");
    entry.setDate(new Date(1000));

    Category category = new Category("categoryId", "category");
    category.setBlog(blog);
    entry.setCategories(Collections.singleton(category));

    model.put(Constants.BLOG_KEY, blog);
    model.put(Constants.BLOG_ENTRIES, Collections.singleton(entry));

    SyndFeed feed = feedView.getFeed();
    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setWriter(new PrintWriter(System.out));
    feedView.dispatch(new MockHttpServletRequest(), response, null);
View Full Code Here

    super.setUp();

    action = new FeedAction();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    Model model = new Model();
    model.put(Constants.BLOG_KEY, blog1);
    action.setModel(model);
    lastModifiedService = mock(LastModifiedService.class);
    action.setLastModifiedService(lastModifiedService);
  }
View Full Code Here

    super.setUp();

    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();

    model = new Model();
    model.put(Constants.BLOG_KEY, blog);
    action.setModel(model);
  }
View Full Code Here

   * @throws Exception
   */
  public void testViewHomePage() throws Exception {
    View view = action.process(request, response);

    Model model = action.getModel();
    assertEquals(blog.getBlogForThisMonth(), model.get(Constants.MONTHLY_BLOG));
    assertEquals(blog.getRecentBlogEntries(), model.get(Constants.BLOG_ENTRIES));
    assertTrue(view instanceof BlogEntriesView);
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.web.model.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.