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(String message, Object object) 

Source Link

Document

Asserts that an object is null.

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.Pie3DChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*w w w. j a va  2 s. c  om*/

    JFreeChart chart = getChart("summary.chart1", 0);
    Plot plot = chart.getPlot();
    Assert.assertEquals("plot", PiePlot3D.class, plot.getClass());
    Assert.assertTrue("circular", ((PiePlot) plot).isCircular());
    Assert.assertEquals("label format", "label {0}",
            ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLabelGenerator()).getLabelFormat());
    Assert.assertEquals("legend label format", "legend label {0}",
            ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLegendLabelGenerator()).getLabelFormat());
    Assert.assertEquals("depth factor", 0.5, ((PiePlot3D) plot).getDepthFactor());

    chart = getChart("summary.chart2", 0);
    plot = chart.getPlot();
    Assert.assertNull("label format", ((PiePlot) plot).getLabelGenerator());
}

From source file:cz.PA165.vozovyPark.dao.VehicleDAOTest.java

/**
 * Test of remove method, of class VehicleDAO.
 *//*from  ww  w  .  jav  a 2s  .  c o  m*/
@Test
public void testRemove() {
    try {
        Vehicle mercedes = VehicleDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "E",
                UserClassEnum.PRESIDENT, "2a-447i-882a45", 2009, "UEW6828");
        this.vehicleDao.createVehicle(mercedes);
        Long id = mercedes.getId();
        System.out.println("Log: vehicle created!");
        em.getTransaction().begin();
        this.vehicleDao.removeVehicle(mercedes);
        em.getTransaction().commit();
        System.out.println("Log: vehicle removed!");

        Vehicle loaded = this.vehicleDao.getById(id);
        System.out.println("Log: vehicle loaded!");

        Assert.assertNull("Vehicle was not deleted from database", loaded);
    } catch (Exception ex) {
        Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage());
    }
}

From source file:de.extra.client.core.builder.impl.MessageBuilderLocatorTest.java

/**
 * Test method for/*from w  w  w.j ava 2  s  . co  m*/
 * {@link de.extra.client.core.builder.impl.MessageBuilderLocator#getXmlComplexTypeBuilder(java.lang.String, de.extra.client.core.model.InputDataContainer)}
 * .
 */
public void testGetXmlComplexMultipleTypeBuilderException() {
    final Map<String, IXmlComplexTypeBuilder> complexTypeBuilderMap = new HashMap<String, IXmlComplexTypeBuilder>();
    final IXmlComplexTypeBuilder expectedXmlComplexTypeBuilder = new DataTransformConfigurablePluginsBuilder();
    complexTypeBuilderMap.put("test1", expectedXmlComplexTypeBuilder);
    complexTypeBuilderMap.put("test2", expectedXmlComplexTypeBuilder);
    final MessageBuilderLocator messageBuilderLocator = createMessageBuilderlocator(complexTypeBuilderMap);

    final IInputDataContainer senderData = createTestinputData("Dummy Content");
    final IXmlComplexTypeBuilder xmlComplexTypeBuilder = messageBuilderLocator
            .getXmlComplexTypeBuilder(expectedXmlComplexTypeBuilder.getXmlType(), senderData);
    Assert.assertNull("xmlComplexTypeBuilder is not null", xmlComplexTypeBuilder);

}

From source file:net.sf.dynamicreports.test.jasper.chart.ChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);//ww  w  .  j a  v a2 s  .c  om

    chartCountTest("summary.chart1", 1);
    JFreeChart chart = getChart("summary.chart1", 0);

    TextTitle title = chart.getTitle();
    Assert.assertEquals("title", "title", title.getText());
    Assert.assertEquals("title color", Color.BLUE, title.getPaint());
    Assert.assertEquals("title font", new Font("Arial", Font.BOLD, 10), title.getFont());
    Assert.assertEquals("title position", RectangleEdge.RIGHT, title.getPosition());

    TextTitle subtitle = (TextTitle) chart.getSubtitle(1);
    Assert.assertEquals("subtitle", "subtitle", subtitle.getText());
    Assert.assertEquals("subtitle color", Color.CYAN, subtitle.getPaint());
    Assert.assertEquals("subtitle font", new Font("Arial", Font.PLAIN, 10), subtitle.getFont());

    LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
    Assert.assertEquals("legend color", Color.BLUE, legend.getItemPaint());
    Assert.assertEquals("legend backgroundcolor", Color.LIGHT_GRAY, legend.getBackgroundPaint());
    Assert.assertEquals("legend font", new Font("Courier New", Font.PLAIN, 10), legend.getItemFont());
    Assert.assertEquals("legend position", RectangleEdge.LEFT, legend.getPosition());

    chartCountTest("summary.chart2", 1);
    chart = getChart("summary.chart2", 0);
    Assert.assertNull("legend", chart.getLegend());
    Assert.assertEquals("plot orientation", PlotOrientation.HORIZONTAL,
            chart.getCategoryPlot().getOrientation());
    Assert.assertEquals("plot series colors", Color.BLUE, chart.getPlot().getDrawingSupplier().getNextPaint());
    Assert.assertEquals("plot series colors", Color.GREEN, chart.getPlot().getDrawingSupplier().getNextPaint());
    Assert.assertEquals("plot series colors", Color.RED, chart.getPlot().getDrawingSupplier().getNextPaint());
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void transformStringForPartialWordIndexationWithLongString() {
    char delimiter = '-';
    String longString = RandomStringUtils.random(StringHelper.MAX_STRING_INDEXABLE_LENGTH + 1,
            new char[] { 'e' });
    Assert.assertEquals("the string to test is not of the expected size the test will fail",
            StringHelper.MAX_STRING_INDEXABLE_LENGTH + 1, longString.length());
    String transformedString = StringHelper.transformStringForPartialWordIndexation(longString, delimiter);
    Assert.assertNull(
            "string that are longer than " + StringHelper.MAX_STRING_INDEXABLE_LENGTH + " should return null",
            transformedString);//from   w  w  w .  ja  v  a 2s  . co m
}

From source file:fll.web.WebTestUtils.java

/**
 * Submit a query to developer/QueryHandler, parse the JSON and return it.
 *//*from w w  w . j a  v a2s .  co m*/
public static QueryHandler.ResultData executeServerQuery(final String query) throws IOException, SAXException {
    final WebClient conversation = getConversation();

    final URL url = new URL(TestUtils.URL_ROOT + "developer/QueryHandler");
    final WebRequest request = new WebRequest(url);
    request.setRequestParameters(
            Collections.singletonList(new NameValuePair(QueryHandler.QUERY_PARAMETER, query)));

    final Page response = loadPage(conversation, request);
    final String contentType = response.getWebResponse().getContentType();
    if (!"application/json".equals(contentType)) {
        final String text = getPageSource(response);
        final File output = File.createTempFile("json-error", ".html", new File("screenshots"));
        final FileWriter writer = new FileWriter(output);
        writer.write(text);
        writer.close();
        Assert.fail("Error JSON from QueryHandler: " + response.getUrl()
                + " Contents of error page written to: " + output.getAbsolutePath());
    }

    final String responseData = getPageSource(response);

    final ObjectMapper jsonMapper = new ObjectMapper();
    QueryHandler.ResultData result = jsonMapper.readValue(responseData, QueryHandler.ResultData.class);
    Assert.assertNull("SQL Error: " + result.getError(), result.getError());

    return result;
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void updateOpenStreetMapEntityForIndexationWithANullName() {
    OpenStreetMap openStreetMap = GisgraphyTestHelper.createOpenStreetMapForPeterMartinStreet();
    openStreetMap.setName(null);// www .  j  a v  a2  s.com
    openStreetMap.setPartialSearchName(null);
    openStreetMap.setTextSearchName(null);
    StringHelper.updateOpenStreetMapEntityForIndexation(openStreetMap);
    Assert.assertNull("The value of partial search name should be null if name is null",
            openStreetMap.getPartialSearchName());
    Assert.assertNull("The value of text search name should be null if name is null",
            openStreetMap.getTextSearchName());
}

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testEvaluateIntegerWithSocketPoolSizeExpressionValueNotFound()
        throws XPathExpressionException, SAXException, IOException, ParserConfigurationException {
    PTestServerConfigurationParser p = new PTestServerConfigurationParser();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder()
            .parse(new ByteArrayInputStream("<ptest-server></ptest-server>".getBytes()));
    Integer result = p.evaluateInteger(p.xpathExpressionSocketPoolSize, document);
    Assert.assertNull("The result must be null", result);
}

From source file:com.rmn.qa.aws.VmManagerTest.java

@Test
// Happy path test flow for launching nodes
public void testLaunchNodes() throws NodesCouldNotBeStartedException {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    RunInstancesResult runInstancesResult = new RunInstancesResult();
    Reservation reservation = new Reservation();
    reservation.setInstances(Arrays.asList(new Instance()));
    runInstancesResult.setReservation(reservation);
    client.setRunInstances(runInstancesResult);
    Properties properties = new Properties();
    String region = "east", uuid = "uuid", browser = "chrome", os = "windows";
    Integer threadCount = 5, maxSessions = 5;
    MockManageVm manageEC2 = new MockManageVm(client, properties, region);
    String userData = "userData";
    manageEC2.setUserData(userData);// w ww .j  a  va2s. co m
    List<Instance> instances = manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions);
    RunInstancesRequest request = client.getRunInstancesRequest();
    Assert.assertEquals("Min count should match thread count requested", threadCount, request.getMinCount());
    Assert.assertEquals("Max count should match thread count requested", threadCount, request.getMaxCount());
    Assert.assertEquals("User data should match", userData, request.getUserData());
    Assert.assertTrue("No security group should be set", request.getSecurityGroupIds().isEmpty());
    Assert.assertNull("No subnet should be set", request.getSubnetId());
    Assert.assertNull("No key name should be set", request.getKeyName());
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void updateOpenStreetMapEntityForIndexationWithALongName() {
    OpenStreetMap openStreetMap = GisgraphyTestHelper.createOpenStreetMapForPeterMartinStreet();
    String longName = RandomStringUtils.random(StringHelper.MAX_STRING_INDEXABLE_LENGTH + 1,
            new char[] { 'e' });
    openStreetMap.setName(longName);/*  w  w w . ja  va2  s . c o  m*/
    openStreetMap.setPartialSearchName(null);
    openStreetMap.setTextSearchName(null);
    StringHelper.updateOpenStreetMapEntityForIndexation(openStreetMap);
    Assert.assertNull("The value of partial search should be null if name is too long",
            openStreetMap.getPartialSearchName());
    Assert.assertEquals("The value of text search name should not be null and correct if name is too long",
            StringHelper.normalize(openStreetMap.getName()), openStreetMap.getTextSearchName());
}