Package org.springframework.web.bind.support

Examples of org.springframework.web.bind.support.SessionStatus


    @Test(expected = SecurityException.class)
    public void updateWidget_wrongToken() {
        WidgetImpl widget = new WidgetImpl();
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        sessionStatus.setComplete();
        expectLastCall();
        replay(sessionStatus);

        String otherToken = AdminControllerUtil.generateSessionToken();
View Full Code Here


    @Test
    public void updateWidget_invalid() {
        WidgetImpl widget = new WidgetImpl("123", "http://broken/url");
        BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        ModelMap modelMap = new ExtendedModelMap();

        String view = controller.updateWidgetDetail(widget, errors, validToken, validToken, modelMap, sessionStatus);

        assertTrue("Errors", errors.hasErrors());
View Full Code Here

    @Test
    public void testUpdatePreferences_valid() {
        ModelMap model = new ExtendedModelMap();
        PortalPreferenceForm form = new PortalPreferenceForm(new HashMap<String, PortalPreference>());
        final BindingResult errors = new BeanPropertyBindingResult(form, "form");
        SessionStatus sessionStatus = createMock(SessionStatus.class);

        final Set<Map.Entry<String, PortalPreference>> entries = form.getPreferenceMap().entrySet();

        for (Map.Entry<String, PortalPreference> entry : entries) {
            service.savePreference(entry.getValue());
        }
        sessionStatus.setComplete();

        expectLastCall();
        replay(service, sessionStatus);
        String view = controller.updatePreferences(form, errors, validToken, validToken, model, sessionStatus);
View Full Code Here

    public void testUpdatePreferences_invalidToken() {
        ModelMap model = new ExtendedModelMap();
        String invalidToken = AdminControllerUtil.generateSessionToken();
        PortalPreferenceForm form = new PortalPreferenceForm(new HashMap<String, PortalPreference>());
        final BindingResult errors = new BeanPropertyBindingResult(form, "form");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        sessionStatus.setComplete();
       
        expectLastCall();
        replay(service, sessionStatus);
        controller.updatePreferences(form, errors, validToken, invalidToken, model, sessionStatus);
View Full Code Here

        HashMap<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
        PortalPreference pageSizePref = new PortalPreferenceImpl(PortalPreferenceKeys.PAGE_SIZE, "invalid");
        preferenceMap.put(PortalPreferenceKeys.PAGE_SIZE, pageSizePref);
        PortalPreferenceForm form = new PortalPreferenceForm(preferenceMap);
        final BindingResult errors = new BeanPropertyBindingResult(form, "form");
        SessionStatus sessionStatus = createMock(SessionStatus.class);

        replay(service, sessionStatus);
        String view = controller.updatePreferences(form, errors, validToken, validToken, model, sessionStatus);

        assertEquals(ViewNames.ADMIN_PREFERENCE_DETAIL, view);
View Full Code Here

        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.create(categoryText, user)).andReturn(new CategoryImpl());
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.createCategory(category, validToken, validToken, model, sessionStatus);
        assertEquals("ViewName match", "redirect:/app/admin/categories?action=create", view);
        assertTrue("empty model", model.asMap().isEmpty());
View Full Code Here

        String invalidToken =  AdminControllerUtil.generateSessionToken();
        User user = new UserImpl();
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.create(categoryText, user)).andReturn(new CategoryImpl());
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.createCategory(category, validToken, invalidToken, model, sessionStatus);
        assertTrue("Test should catch exception and never hit this test", false);
    }
View Full Code Here

        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        String categoryText = "";
        CategoryImpl category = new CategoryImpl();
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        replay(userService);
        String view = controller.createCategory(category, validToken, validToken, model, sessionStatus);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORIES, view);
        assertFalse("empty model", model.asMap().isEmpty());
View Full Code Here

        String id = "1";
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl(id);
        category.setCreatedUserId(user.getId());
        category.setText(categoryText);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.get(id)).andReturn(category);
        expect(categoryService.update(id, categoryText, user)).andReturn(category);
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.updateCategory(category, validToken, validToken, model, sessionStatus);
        assertEquals("ViewName match", "redirect:/app/admin/categories?action=update", view);
        assertTrue("empty model", model.asMap().isEmpty());
View Full Code Here

        String invalidToken = AdminControllerUtil.generateSessionToken();
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUserId(user.getId());
        category.setText(categoryText);
        category.setId(id);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        expect(categoryService.get(id)).andReturn(category);
        expect(categoryService.update(id, categoryText, user)).andReturn(category);
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, categoryService,sessionStatus);
        String view = controller.updateCategory(category, validToken, invalidToken, model, sessionStatus);assertTrue("Test should catch exception and never hit this test", false);
        assertTrue("Test should catch exception and never hit this test", false);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.bind.support.SessionStatus

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.