/** * Registers the platform at the CMR. * * @throws ServerUnavailableException * If the sending wasn't successful in any way, a {@link ServerUnavailableException} * exception is thrown. * @throws RegistrationException * This exception is thrown when a problem with the registration process appears. * @throws StorageException * If setting configuration to the {@link #configurationStorage} fails. */ private void register() throws ServerUnavailableException, RegistrationException, StorageException { try { AgentConfig agentConfiguration = connection.register(configurationStorage.getAgentName(), versionService.getVersionAsString()); platformId = agentConfiguration.getPlatformId(); configurationStorage.setAgentConfiguration(agentConfiguration); if (log.isDebugEnabled()) { log.debug("Received platform ID: " + platformId); } } catch (BusinessException exception) { log.error("The agent was not able to get configuration from the server. " + exception.getMessage()); throw new BeanInitializationException("The agent was not able to get configuration from the server.", exception); } }
/** * Test the Business exception. */ @Test public void businessException() throws SerializationException { BusinessException businessException = new BusinessException("Message", StorageErrorCodeEnum.CAN_NOT_START_RECORDING); businessException.printStackTrace(); BusinessException deserialized = serializeBackAndForth(businessException); assertThat(deserialized, is(instanceOf(BusinessException.class))); assertThat(deserialized.getMessage(), is(equalTo(businessException.getMessage()))); assertThat(deserialized.getStackTrace(), is(equalTo(businessException.getStackTrace()))); assertThat(deserialized.getActionPerformed(), is(equalTo(businessException.getActionPerformed()))); assertThat(deserialized.getErrorCode(), is(equalTo(businessException.getErrorCode()))); }