Package org.jtalks.jcommune.plugin.api.exceptions

Examples of org.jtalks.jcommune.plugin.api.exceptions.UnexpectedErrorException


    }

    @Test
    public void testRegisterFailIfUnexpectedErrorOccurred() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        doThrow(new UnexpectedErrorException()).when(authenticator).register(dto);

        ModelAndView mav = userController.registerUser(dto, request, Locale.ENGLISH);

        assertViewName(mav, UserController.REG_SERVICE_UNEXPECTED_ERROR_URL);
    }
View Full Code Here


    }

    @Test
    public void testRegisterAjaxFailIfUnexpectedErrorOccurred() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        doThrow(new UnexpectedErrorException()).when(authenticator).register(dto);

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL, "Unexpected error should fail registration.");
    }
View Full Code Here

    }

    @Test
    public void testLoginAjaxUserShouldFailIfUnexpectedErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new UnexpectedErrorException());
       
        JsonResponse response = userController.loginAjax(null, null, "on", request, null);
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

    }

    @Test
    public void testLoginUserShouldFailIfUnexpectedErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new UnexpectedErrorException());
       
        LoginUserDto loginUserDto = new LoginUserDto();
        ModelAndView view = userController.login(loginUserDto, null,  "on", request, null);

        assertEquals(view.getViewName(), UserController.AUTH_SERVICE_FAIL_URL);
View Full Code Here

                LOGGER.debug("Plugin {} is configured", this.getName());
            }
        } catch (PluginConfigurationException | RuntimeException e) {
            state = State.IN_ERROR;
            LOGGER.warn("Plugin {} configuration failed", this.getName(), e);
            throw new UnexpectedErrorException(e);
        }
    }
View Full Code Here

        when(componentService.getComponentOfForum()).thenReturn(component);
        String pluginName = "plugin";
        PluginConfiguration newConfiguration = new PluginConfiguration();
        newConfiguration.setName(pluginName);

        doThrow(new UnexpectedErrorException(new IllegalArgumentException("Testing exception!")))
                .when(pluginService).updateConfiguration(newConfiguration, componentId);
        return newConfiguration;
    }
View Full Code Here

            throws UnexpectedErrorException, NoConnectionException {
        try {
            return service.registerUser(userDto, validateOnly);
        } catch (IOException | JAXBException e) {
            LOGGER.error("Parse response error", e);
            throw new UnexpectedErrorException(e);
        } catch (NoConnectionException e) {
            LOGGER.error("Can't connect to Poulpe: {}", e.getMessage());
            throw e;
        }
    }
View Full Code Here

            throws UnexpectedErrorException, NoConnectionException {
        try {
            return service.authenticate(login, password);
        } catch (IOException | JAXBException e) {
            LOGGER.error("Parse response error", e);
            throw new UnexpectedErrorException(e);
        } catch (NoConnectionException e) {
            LOGGER.error("Can't connect to Poulpe: {}", e.getMessage());
            throw e;
        }
    }
View Full Code Here

        try {
            encodedUsername = loginUserDto.getUserName() == null ? null :
                    URLEncoder.encode(loginUserDto.getUserName(), "UTF-8").replace("+", "%20");
        } catch (UnsupportedEncodingException e) {
            LOGGER.error("Could not encode username '{}'", loginUserDto.getUserName());
            throw new UnexpectedErrorException(e);
        }
        Map<String, String> authInfo = authenticateByAvailablePlugin(encodedUsername, passwordHash);
        if (authInfo.isEmpty() || !authInfo.containsKey("email") || !authInfo.containsKey("username")) {
            LOGGER.info("Could not authenticate user '{}' by plugin.", loginUserDto.getUserName());
            return false;
View Full Code Here

        when(encryptionService.encryptPassword(loginUserDto.getPassword())).thenReturn(passwordHash);
        when(authPlugin.getState()).thenReturn(Plugin.State.ENABLED);
        Class cl = AuthenticationPlugin.class;
        when(pluginLoader.getPluginByClassName(cl)).thenReturn(authPlugin);
        when(authPlugin.authenticate(loginUserDto.getUserName(), passwordHash)).thenThrow(new UnexpectedErrorException());

        authenticator.authenticate(loginUserDto, httpRequest, httpResponse);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.plugin.api.exceptions.UnexpectedErrorException

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.