Package org.apache.solr.client.solrj

Examples of org.apache.solr.client.solrj.SolrServerException


            result = client.POSTbytes(url, contentStream[0].getStream(), contentStream[0].getStream().available());
        }
    } else if (SolrRequest.METHOD.GET == request.getMethod()) {
        result = client.GETbytes( this._baseURL + path + ClientUtils.toQueryString( params, false ));
    } else {
        throw new SolrServerException("Unsupported method: "+request.getMethod() );
    }

      final int statusCode = client.getStatusCode();
      if (statusCode != 200) {
        throw new IOException("bad status code: " + statusCode + ", " + client.getHttpResponse().getStatusLine() + ", url = " + this._baseURL + path);
View Full Code Here


        new IOException())));
  }

  @Test
  public void testWithParseException() {
    SolrServerException solrServerException = new SolrServerException("meessage", new SolrException(
        ErrorCode.BAD_REQUEST, new org.apache.solr.parser.ParseException("parse execption message")));

    Assert.assertThat(exceptionTranslator.translateExceptionIfPossible(new RuntimeException(solrServerException)),
        IsInstanceOf.instanceOf(InvalidDataAccessApiUsageException.class));
  }
View Full Code Here

   * @see DATASOLR-158
   */
  @Test
  public void shouldConvertConnectExceptionCorrectly() {

    SolrServerException ex = new SolrServerException("message", new java.net.ConnectException(
        "Cannot connect to server"));
    Assert.assertThat(exceptionTranslator.translateExceptionIfPossible(new RuntimeException(ex)),
        IsInstanceOf.instanceOf(DataAccessResourceFailureException.class));
  }
View Full Code Here

    Assert.assertThat(exceptionTranslator.translateExceptionIfPossible(new RuntimeException(ex)),
        IsInstanceOf.instanceOf(DataAccessResourceFailureException.class));
  }

  private RuntimeException createWrappedSolrServerExceptionFor(ErrorCode errorCode, String message) {
    SolrServerException rootException = createSolrServerExceptionFor(errorCode, message);
    return new RuntimeException(rootException.getMessage(), rootException);
  }
View Full Code Here

    SolrServerException rootException = createSolrServerExceptionFor(errorCode, message);
    return new RuntimeException(rootException.getMessage(), rootException);
  }

  private SolrServerException createSolrServerExceptionFor(ErrorCode errorCode, String message) {
    return new SolrServerException("wrapper exception", new SolrException(errorCode, message));
  }
View Full Code Here

  }

  @Test(expected = DataAccessException.class)
  public void testPingThrowsException() throws SolrServerException, IOException {
    Mockito.when(solrServerMock.ping()).thenThrow(
        new SolrServerException("error", new SolrException(ErrorCode.NOT_FOUND, "not found")));
    solrTemplate.ping();
  }
View Full Code Here

  }

  @Test(expected = InvalidDataAccessApiUsageException.class)
  public void testQueryThrowsParseException() throws SolrServerException {
    Mockito.when(solrServerMock.query(Matchers.any(SolrParams.class))).thenThrow(
        new SolrServerException("error", new SolrException(ErrorCode.BAD_REQUEST, new ParseException("parse error"))));
    solrTemplate.executeSolrQuery(new SolrQuery());
  }
View Full Code Here

   */
  @Test
  public void schemaPresentCheckSouldIndicateFalseWhenServerReturnsNotFound() throws SolrServerException, IOException {

    Mockito.when(solrServerMock.request(Mockito.any(SolrRequest.class))).thenThrow(
        new SolrServerException(new SolrException(org.apache.solr.common.SolrException.ErrorCode.NOT_FOUND, "boom")));
    Assert.assertFalse(writer.isSchemaPresent("collection1"));
  }
View Full Code Here

        private NamedList<Object> request(SolrRequest request) throws SolrServerException {
            try {
                return solrCore.request(request);
            } catch (IOException e) {
                logger.log(Level.WARNING, "Could not issue Solr request. ", e); //NON-NLS
                throw new SolrServerException(
                        NbBundle.getMessage(this.getClass(), "Server.request.exception.exception.msg"), e);
            }

        }
View Full Code Here

            try {
                //commit and block
                solrCore.commit(true, true);
            } catch (IOException e) {
                logger.log(Level.WARNING, "Could not commit index. ", e); //NON-NLS
                throw new SolrServerException(NbBundle.getMessage(this.getClass(), "Server.commit.exception.msg"), e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.SolrServerException

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.