Example usage for junit.framework Assert assertNull

List of usage examples for junit.framework Assert assertNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNull.

Prototype

static public void assertNull(Object object) 

Source Link

Document

Asserts that an object is null.

Usage

From source file:org.apache.solr.client.solrj.io.stream.eval.SubtractEvaluatorTest.java

@Test
public void subTwoFieldWithNulls() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
    Object result;//from w w  w . ja  v a  2  s  .  co  m

    values.clear();
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);
}

From source file:org.apache.solr.client.solrj.io.stream.eval.SubtractEvaluatorTest.java

@Test
public void subTwoFieldsWithNull() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
    Object result;/* w  w w.j a  v  a  2s  .  c  om*/

    values.clear();
    values.put("a", 1);
    values.put("b", null);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);

    values.clear();
    values.put("a", 1.1);
    values.put("b", null);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);

    values.clear();
    values.put("a", 1.1);
    values.put("b", null);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);
}

From source file:org.apache.solr.client.solrj.io.stream.eval.SubtractEvaluatorTest.java

@Test
public void subTwoFieldsWithMissingField() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
    Object result;/*from w  w w.  j  av a 2 s . c o m*/

    values.clear();
    values.put("a", 1);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);

    values.clear();
    values.put("a", 1.1);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);

    values.clear();
    values.put("a", 1.1);
    result = evaluator.evaluate(new Tuple(values));
    Assert.assertNull(result);
}

From source file:org.apache.solr.client.solrj.io.stream.ops.ConcatOperationTest.java

@Test
public void concatWithNullValues() throws Exception {
    Tuple tuple;/* w w  w . j a  v  a  2 s. c o m*/
    StreamOperation operation;

    operation = new ConcatOperation(new String[] { "fieldA", "fieldB" }, "fieldABConcat", "-");
    values.clear();
    values.put("fieldA", "bar");
    tuple = new Tuple(values);
    operation.operate(tuple);

    Assert.assertNotNull(tuple.get("fieldA"));
    Assert.assertEquals("bar", tuple.get("fieldA"));

    Assert.assertNull(tuple.get("fieldB"));

    Assert.assertNotNull(tuple.get("fieldABConcat"));
    Assert.assertEquals("bar-null", tuple.get("fieldABConcat"));

}

From source file:org.apache.solr.client.solrj.io.stream.ops.ConcatOperationTest.java

@Test
public void concatWithNullValuesExpression() throws Exception {
    Tuple tuple;/*  w ww  . ja v  a  2s.com*/
    StreamOperation operation;

    operation = new ConcatOperation(
            StreamExpressionParser.parse("concat(fields=\"fieldA,fieldB\", as=\"fieldABConcat\", delim=\"-\")"),
            factory);
    values.clear();
    values.put("fieldA", "bar");
    tuple = new Tuple(values);
    operation.operate(tuple);

    Assert.assertNotNull(tuple.get("fieldA"));
    Assert.assertEquals("bar", tuple.get("fieldA"));

    Assert.assertNull(tuple.get("fieldB"));

    Assert.assertNotNull(tuple.get("fieldABConcat"));
    Assert.assertEquals("bar-null", tuple.get("fieldABConcat"));

}

From source file:org.apache.solr.client.solrj.io.stream.ops.OperationsTest.java

@Test
public void replaceFieldNullWithNonExistantField() throws Exception {
    Tuple tuple;//from w w w  . ja v a2s  . c om
    StreamOperation operation;

    operation = new ReplaceOperation("fieldA", StreamExpressionParser.parse("replace(null, withField=fieldD)"),
            factory);

    // replace
    values.clear();
    values.put("fieldB", "bar");
    values.put("fieldC", 123);
    tuple = new Tuple(values);
    operation.operate(tuple);

    Assert.assertNull(tuple.get("fieldA"));

    // don't replace
    values.clear();
    values.put("fieldA", "exists");
    values.put("fieldB", "bar");
    values.put("fieldC", 123);
    tuple = new Tuple(values);
    operation.operate(tuple);

    Assert.assertNotNull(tuple.get("fieldA"));
    Assert.assertEquals("exists", tuple.get("fieldA"));
}

From source file:org.b3log.latke.servlet.RequestDispachTestCase.java

@Test
public void testRetVoid() {
    final HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getRequestURI()).thenReturn("/void");
    when(request.getMethod()).thenReturn("GET");

    final HttpControl control = doFlow(request);

    Assert.assertNotNull(control.data(RequestDispatchHandler.MATCH_RESULT));
    Assert.assertNull(control.data(MethodInvokeHandler.INVOKE_RESULT));
}

From source file:org.b3log.latke.servlet.RequestDispachTestCase.java

@Test
public void testAntPathMatch() {
    final HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getRequestURI()).thenReturn("/a.html");
    when(request.getMethod()).thenReturn("GET");

    final HttpControl control = doFlow(request);

    Assert.assertNotNull(control.data(RequestDispatchHandler.MATCH_RESULT));
    Assert.assertNull(control.data(MethodInvokeHandler.INVOKE_RESULT));
}

From source file:org.b3log.solo.repository.impl.ArchiveDateArticleRepositoryImplTestCase.java

/**
 * Adds successfully.//  www.  j  a  v  a 2 s  . c o m
 * 
 * @throws Exception exception
 */
@Test
public void add() throws Exception {
    final ArchiveDateArticleRepository archiveDateArticleRepository = getArchiveDateArticleRepository();

    final JSONObject archiveDateArticle = new JSONObject();

    archiveDateArticle.put(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID, "archiveDateId");
    archiveDateArticle.put(Article.ARTICLE + "_" + Keys.OBJECT_ID, "articleId");

    final Transaction transaction = archiveDateArticleRepository.beginTransaction();
    archiveDateArticleRepository.add(archiveDateArticle);
    transaction.commit();

    final JSONObject found = archiveDateArticleRepository.getByArticleId("articleId");
    Assert.assertNotNull(found);

    final JSONObject notFound = archiveDateArticleRepository.getByArticleId("not found");
    Assert.assertNull(notFound);
}

From source file:org.b3log.solo.repository.impl.ArchiveDateArticleRepositoryImplTestCase.java

/**
 * Get By Archive Id./* ww  w . j a  va 2  s .  c o m*/
 * 
 * @throws Exception exception
 */
@Test(dependsOnMethods = "add")
public void getByArticleId() throws Exception {
    final ArchiveDateArticleRepository archiveDateArticleRepository = getArchiveDateArticleRepository();

    Assert.assertNotNull(archiveDateArticleRepository.getByArticleId("articleId"));
    Assert.assertNull(archiveDateArticleRepository.getByArticleId("not found"));
}