protected void checkCassandraException(Exception e) { _mexceptions.incr(); if (e instanceof AlreadyExistsException || e instanceof AuthenticationException || e instanceof DriverException || e instanceof DriverInternalError || e instanceof InvalidConfigurationInQueryException || e instanceof InvalidQueryException || e instanceof InvalidTypeException || e instanceof QueryExecutionException || e instanceof QueryTimeoutException || e instanceof QueryValidationException || e instanceof ReadTimeoutException || e instanceof SyntaxError || e instanceof TraceRetrievalException || e instanceof TruncateException || e instanceof UnauthorizedException || e instanceof UnavailableException || e instanceof ReadTimeoutException || e instanceof WriteTimeoutException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }
private boolean checkCassandraReachable(List<ConfigIssue> issues) { boolean isReachable = true; try (Cluster validationCluster = getCluster()) { Session validationSession = validationCluster.connect(); validationSession.close(); } catch (NoHostAvailableException | AuthenticationException | IllegalStateException | StageException e) { isReachable = false; Target.Context context = getContext(); LOG.error(Errors.CASSANDRA_05.getMessage(), e.toString(), e); issues.add( context.createConfigIssue( Groups.CASSANDRA.name(), CONTACT_NODES_LABEL, Errors.CASSANDRA_05, e.toString() ) ); } return isReachable; }
@Test public void testNoUsername() { CassandraConnection cc = new CassandraConnection(); cc.setProperty("contactPoints", NODE_1_IP); cc.setProperty("sessionName", "testsession2"); Boolean exeptionCaught=false; try { cc.testStarted(); } catch (AuthenticationException e) { exeptionCaught = true; } assertTrue(exeptionCaught, "AuthenticationException did not occur."); }
@Test public void testShouldReturnAuthenticationError() throws Exception { String message = "Invalid password, man!"; server.prime(when(query).then(authenticationError(message))); thrown.expect(AuthenticationException.class); thrown.expectMessage(endsWith(message)); query(); }