com.googlecode.jsonrpc4j.JsonRpcClientException Java Examples
The following examples show how to use
com.googlecode.jsonrpc4j.JsonRpcClientException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HostDeletionServiceTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testOneAlreadyDeleted() throws FreeIpaClientException { Set<String> hosts = Set.of("host1", "host2"); Host host1 = new Host(); host1.setFqdn("host1"); Host host2 = new Host(); host2.setFqdn("host2"); when(freeIpaClient.findAllHost()).thenReturn(Set.of(host1, host2)); String message = "already deleted"; when(freeIpaClient.deleteHost(host2.getFqdn())).thenThrow(new FreeIpaClientException(message, new JsonRpcClientException(NOT_FOUND, message, null))); Pair<Set<String>, Map<String, String>> result = underTest.removeHosts(freeIpaClient, hosts); assertEquals(2, result.getFirst().size()); assertEquals(0, result.getSecond().size()); assertTrue(result.getFirst().contains(host1.getFqdn())); assertTrue(result.getFirst().contains(host2.getFqdn())); }
Example #2
Source File: FreeIpaClientExceptionUtilV1Test.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testIsExceptionWithErrorCode() throws Exception { Assertions.assertFalse(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new IllegalStateException(MESSAGE)), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertFalse(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null)), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null)), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null)), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY, FreeIpaErrorCodes.COMMAND_ERROR))); }
Example #3
Source File: FreeIpaClientExceptionUtilV1Test.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testIsExceptionWithErrorCodeWrappedFreeIpaClientException() throws Exception { Assertions.assertFalse(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new FreeIpaClientException(MESSAGE, new IllegalStateException(MESSAGE))), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertFalse(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null))), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException(MESSAGE, new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null))), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isExceptionWithErrorCode( new FreeIpaClientException("", new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null))), Set.of(FreeIpaErrorCodes.DUPLICATE_ENTRY, FreeIpaErrorCodes.COMMAND_ERROR))); }
Example #4
Source File: KerberosMgmtRoleComponentV1Test.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testDeleteRoleIfNoLongerUsedWhenRoleDoesNotExist() throws Exception { Mockito.when(mockIpaClient.showRole(anyString())).thenThrow(new FreeIpaClientException(ERROR_MESSAGE, new JsonRpcClientException(NOT_FOUND, ERROR_MESSAGE, null))); new KerberosMgmtRoleComponent().deleteRoleIfItIsNoLongerUsed(ROLE, mockIpaClient); Mockito.verify(mockIpaClient, Mockito.never()).deleteRole(ROLE); }
Example #5
Source File: KerberosMgmtRoleComponentV1Test.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testPrivilegeExistReturnFalse() throws Exception { RoleRequest roleRequest = new RoleRequest(); roleRequest.setRoleName(ROLE); Set<String> privileges = new HashSet<>(); privileges.add(PRIVILEGE1); privileges.add(PRIVILEGE2); roleRequest.setPrivileges(privileges); Mockito.when(mockIpaClient.showPrivilege(any())).thenThrow(new FreeIpaClientException(ERROR_MESSAGE, new JsonRpcClientException(NOT_FOUND, ERROR_MESSAGE, null))); Assertions.assertFalse(new KerberosMgmtRoleComponent().privilegesExist(roleRequest, mockIpaClient)); }
Example #6
Source File: FreeIpaClientExceptionUtil.java From cloudbreak with Apache License 2.0 | 5 votes |
public static boolean isExceptionWithErrorCode(FreeIpaClientException e, Set<FreeIpaErrorCodes> errorCodes) { return Stream.of(getAncestorCauseBeforeFreeIpaClientExceptions(e)) .filter(JsonRpcClientException.class::isInstance) .map(JsonRpcClientException.class::cast) .map(JsonRpcClientException::getCode) .peek(code -> LOGGER.debug("Error code found: [{}]", code)) .map(FreeIpaClientExceptionUtil::findFreeIpaErrorCodeByCode) .peek(code -> LOGGER.debug("Error code: [{}]", code)) .anyMatch(c -> isFreeIpaErrorCodeInSet(errorCodes, c)); }
Example #7
Source File: FreeIpaClientExceptionUtilV1Test.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testIsNotFoundException() throws Exception { Assertions.assertFalse(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE))); Assertions.assertFalse(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null)))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null)))); }
Example #8
Source File: FreeIpaClientExceptionUtilV1Test.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testIsDuplicateEntryException() throws Exception { Assertions.assertFalse(FreeIpaClientExceptionUtil.isDuplicateEntryException(new FreeIpaClientException(MESSAGE))); Assertions.assertTrue(FreeIpaClientExceptionUtil.isDuplicateEntryException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null)))); Assertions.assertFalse(FreeIpaClientExceptionUtil.isDuplicateEntryException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null)))); }
Example #9
Source File: FreeIpaClientExceptionUtilV1Test.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testConvertToRetryableIfNeeded() throws Exception { Assertions.assertTrue(FreeIpaClientExceptionUtil.convertToRetryableIfNeeded( new FreeIpaClientException(MESSAGE, new JsonRpcClientException(AUTHENTICATION_ERROR, MESSAGE, null))) instanceof RetryableFreeIpaClientException); Assertions.assertFalse(FreeIpaClientExceptionUtil.convertToRetryableIfNeeded( new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null))) instanceof RetryableFreeIpaClientException); Assertions.assertTrue(FreeIpaClientExceptionUtil.convertToRetryableIfNeeded( new FreeIpaClientException(MESSAGE, HttpStatus.UNAUTHORIZED.value())) instanceof RetryableFreeIpaClientException); Assertions.assertFalse(FreeIpaClientExceptionUtil.convertToRetryableIfNeeded( new FreeIpaClientException(MESSAGE, HttpStatus.OK.value())) instanceof RetryableFreeIpaClientException); }
Example #10
Source File: HttpCodeTest.java From jsonrpc4j with MIT License | 5 votes |
@Test public void httpCustomStatus() throws MalformedURLException { expectedEx.expectMessage(equalTo("Server Error")); expectedEx.expect(JsonRpcClientException.class); RestTemplate restTemplate = new RestTemplate(); JsonRpcRestClient client = getClient(JettyServer.SERVLET, restTemplate); // Overwrite error handler for error check. restTemplate.setErrorHandler(new DefaultResponseErrorHandler()); FakeServiceInterface service = ProxyUtil.createClientProxy(FakeServiceInterface.class, client); service.throwSomeException("function error"); }
Example #11
Source File: JsonRpcProtocol.java From dubbox with Apache License 2.0 | 4 votes |
public JsonRpcProtocol() { super(HttpException.class, JsonRpcClientException.class); }
Example #12
Source File: JsonRpcProtocol.java From dubbo-rpc-jsonrpc with Apache License 2.0 | 4 votes |
public JsonRpcProtocol() { super(HttpException.class, JsonRpcClientException.class); }