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:io.cloudslang.engine.node.services.WorkerNodeServiceTest.java

@Test
public void keepAlive() throws Exception {
    when(versionService.getCurrentVersion(anyString())).thenReturn(5L);

    WorkerNode worker = workerNodeService.readByUUID("H1");
    Date origDate = worker.getAckTime();
    Assert.assertNull(origDate);
    workerNodeService.keepAlive("H1");
    workerNodeRepository.flush();/*from  w  w  w  .j a v  a 2  s .  com*/
    worker = workerNodeService.readByUUID("H1");
    Assert.assertNotNull(worker.getAckTime());
    Assert.assertEquals(5, worker.getAckVersion());

}

From source file:net.roboconf.dm.rest.commons.json.JSonBindingUtilsTest.java

@Test
public void testApplicationBinding_3() throws Exception {

    final String result = "null";
    ObjectMapper mapper = JSonBindingUtils.createObjectMapper();

    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, null);//from   w ww. j a v  a  2  s.  com
    String s = writer.toString();

    Assert.assertEquals(result, s);
    Application readApp = mapper.readValue(result, Application.class);
    Assert.assertNull(readApp);
}

From source file:org.openxdata.server.service.impl.ReportServiceTest.java

@Test
public void saveReportGroup_shouldSaveReportAndGroup() throws Exception {
    final String groupName = "New Report Group";
    final String reportName = "New Report";

    List<ReportGroup> reportGroups = reportsService.getReportGroups();
    Assert.assertEquals(1, reportGroups.size());
    Assert.assertNull(ReportGroup.getReport(reportName, reportGroups));
    Assert.assertNull(getReportGroup(groupName, reportGroups));

    ReportGroup reportGroup = new ReportGroup(groupName);
    reportGroup.setCreator(userService.getUsers().get(0));
    reportGroup.setDateCreated(new Date());

    Report report = new Report(reportName);
    report.setCreator(userService.getUsers().get(0));
    report.setDateCreated(new Date());
    report.setReportGroup(reportGroup);//from  w  w  w .j  av a 2 s  . c  om
    reportGroup.addReport(report);

    reportsService.saveReportGroup(reportGroup);

    reportGroups = reportsService.getReportGroups();
    Assert.assertEquals(2, reportGroups.size());

    reportGroup = getReportGroup(groupName, reportGroups);
    Assert.assertNotNull(reportGroup);
    Assert.assertEquals(1, reportGroup.getReports().size());
    Assert.assertEquals(groupName, reportGroup.getName());

    report = ReportGroup.getReport(reportName, reportGroups);
    Assert.assertNotNull(report);
}

From source file:com.streamreduce.datasource.BootstrapDatabaseDataPopulatorITCase.java

/**
 * Make sure connections and inventory items that are public do not leak sensitive information.
 *
 * @throws Exception if anything goes wrong
 *///  w w w .  j a v a2  s. c  o  m
@Test
@Ignore
public void testForSecurityLeaks() throws Exception {
    // NOTE: This could be put elsewhere but since it was written as part of SOBA-1855, here it sits for now

    String authnToken = login(testUsername, testUsername);
    List<ConnectionResponseDTO> allConnections = jsonToObject(
            makeRequest(connectionsBaseUrl, "GET", null, authnToken),
            TypeFactory.defaultInstance().constructCollectionType(List.class, ConnectionResponseDTO.class));
    String awsAccessKeyId = cloudProperties.getString("nodeable.integrations.aws.accessKeyId");
    String awsSecretKey = cloudProperties.getString("nodeable.integrations.aws.secretKey");

    Assert.assertEquals(26, allConnections.size());

    for (ConnectionResponseDTO connection : allConnections) {
        // Make sure public connections do not have the connection credentials in them
        Assert.assertFalse(connection.isOwner());
        Assert.assertNull(connection.getIdentity());

        // Only cloud inventory items can be leaked so let's filter our inventory items
        if (connection.getType().equals(CloudProvider.TYPE)) {
            inventoryService.refreshInventoryItemCache(connectionService.getConnection(connection.getId()));

            List<InventoryItem> rawInventoryItems = inventoryService.getInventoryItems(connection.getId());
            int retry = 0;

            while (rawInventoryItems.size() == 0 && retry < 3) {
                Thread.sleep(30000);
                rawInventoryItems = inventoryService.getInventoryItems(connection.getId());
                retry++;
            }

            if (rawInventoryItems.size() == 0) {
                throw new Exception("Unable to prepare for the test so tests are unable to run.");
            }

            // Make sure public inventory items do not have anything sensitive in them
            String rawResponse = makeRequest(connectionsBaseUrl + "/" + connection.getId() + "/inventory",
                    "GET", null, authnToken);
            ConnectionInventoryResponseDTO responseDTO = jsonToObject(rawResponse,
                    TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

            for (InventoryItemResponseDTO inventoryItem : responseDTO.getInventoryItems()) {
                BasicDBObject payload = inventoryItem.getPayload();

                Assert.assertFalse(JSONObject.fromObject(payload).toString().contains(awsAccessKeyId));
                Assert.assertFalse(JSONObject.fromObject(payload).toString().contains(awsSecretKey));
                Assert.assertFalse(payload.containsField("adminPassword"));
                Assert.assertFalse(payload.containsField("credentials"));
            }

        }
    }
}

From source file:com.couchbase.lite.DocumentTest.java

public void testDeleteDocument() throws CouchbaseLiteException {
    Document document = database.createDocument();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("foo", "foo");
    properties.put("bar", Boolean.FALSE);
    document.putProperties(properties);//from  w  w w  .  j a  v  a 2  s .c  om
    Assert.assertNotNull(document.getCurrentRevision());
    String docId = document.getId();
    document.delete();
    Assert.assertTrue(document.isDeleted());
    Document fetchedDoc = database.getExistingDocument(docId);
    Assert.assertNull(fetchedDoc);

    // query all docs and make sure we don't see that document
    //database.getAllDocs(new QueryOptions());
    Query queryAllDocs = database.createAllDocumentsQuery();
    QueryEnumerator queryEnumerator = queryAllDocs.run();
    for (Iterator<QueryRow> it = queryEnumerator; it.hasNext();) {
        QueryRow row = it.next();
        Assert.assertFalse(row.getDocument().getId().equals(docId));
    }
}

From source file:com.opensourceagility.springintegration.alerts.AlertsIntegrationTest.java

@SuppressWarnings("unchecked")
@Test//from   www. j a  v  a 2  s  .co  m
public void testChannelAdapterDemo() throws InterruptedException, ParseException {

    System.setProperty("spring.profiles.active", "testCase");

    final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(
            configFilesChannelAdapterDemo);

    final MessageChannel createAlertRequestChannel = applicationContext.getBean("createAlertRequestChannel",
            MessageChannel.class);

    createAlertTestData(createAlertRequestChannel, thisMinuteDate);

    final QueueChannel queueChannel = applicationContext.getBean("queueChannel", QueueChannel.class);

    for (int counter = 1; counter <= 50; counter++) {
        int id = counter * 2;
        Message<String> reply = (Message<String>) queueChannel.receive(10000);
        Assert.assertNotNull(reply);
        String out = reply.getPayload();
        Assert.assertEquals(getExpectedXml(id), out);
        LOGGER.debug("Received expected Alert XML from queue:" + out);
    }
    LOGGER.debug(
            "Asserted that urgent alerts are those 50 alerts with even ids, ranging from 2 up to 100... and that these are received from the queue");

    Message<String> reply = (Message<String>) queueChannel.receive(10000);
    Assert.assertNull(reply);

    LOGGER.debug("Sleeping for 2 minutes until files are expected to have been (mock) uploaded...");
    Thread.sleep(120 * 1000);

    final MockAmazonS3FileUploader mockFileProcessor = applicationContext.getBean("amazonS3FileUploader",
            MockAmazonS3FileUploader.class);
    Assert.assertEquals(2, mockFileProcessor.getLinesByFileName().size());
    LOGGER.debug("Asserted successfully that 2 csv files were expected");

    List<String> minute1Lines = mockFileProcessor.getLinesByFileName().get(thisMinuteString);
    List<String> minute2Lines = mockFileProcessor.getLinesByFileName().get(nextMinuteString);

    // Assert we have the correct 30 entries in the csv file for the 1st minute
    Assert.assertEquals(30, minute1Lines.size());
    LOGGER.debug("Asserted successfully that 30 alerts found in file:" + thisMinuteString);

    // Assert we have 20 correct entries in the csv file for the 2nd minute
    Assert.assertEquals(20, minute2Lines.size());
    LOGGER.debug("Asserted successfully that 20 alerts found in file:" + nextMinuteString);

    // Check that the 1st minute's csv lines are as expected
    for (int counter = 1; counter <= 30; counter++) {
        int id = counter * 2 - 1;
        String line = minute1Lines.get(counter - 1);
        Assert.assertEquals(getExpectedCsvLine(id), line);
        LOGGER.debug("Found expected csv line in file:" + thisMinuteString + ":" + line);

    }

    // Check that the 2nd minute's csv lines are as expected
    for (int counter = 31; counter <= 50; counter++) {
        int id = counter * 2 - 1;
        String line = minute2Lines.get(counter - 31);
        Assert.assertEquals(getExpectedCsvLine(id), line);
        LOGGER.debug("Found expected csv line in file:" + nextMinuteString + " : " + line);

    }

    LOGGER.debug(
            "Asserted that non-urgent alerts are those 50 alerts with odd ids, ranging from 1 up to 99... and that these are written to csv files and uploaded");

    LOGGER.debug("Completed test successfully, closing application context");

    applicationContext.close();
}

From source file:com.vmware.identity.sts.auth.impl.UserCertAuthenticatorTest.java

@Test
public void testNullUserCertificateToken() throws Exception {
    com.vmware.identity.sts.idm.Authenticator idmAuth = EasyMock
            .createMock(com.vmware.identity.sts.idm.Authenticator.class);
    final Authenticator authenticator = new UserCertAuthenticator(idmAuth);

    final SecurityHeaderType header = new SecurityHeaderType();
    ObjectFactory objectFactory = new ObjectFactory();
    header.getAny().add(objectFactory.createUserCertificateToken(null));

    final Result authResult = authenticator.authenticate(newReq(header));
    Assert.assertNull(authResult);
}

From source file:com.netflix.curator.TestSessionFailRetryLoop.java

@Test
public void testRetryStatic() throws Exception {
    Timing timing = new Timing();
    final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(),
            timing.session(), timing.connection(), null, new RetryOneTime(1));
    SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY);
    retryLoop.start();/*from  w w  w  .ja va  2s . c o  m*/
    try {
        client.start();
        final AtomicBoolean secondWasDone = new AtomicBoolean(false);
        final AtomicBoolean firstTime = new AtomicBoolean(true);
        SessionFailRetryLoop.callWithRetry(client, SessionFailRetryLoop.Mode.RETRY, new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        if (firstTime.compareAndSet(true, false)) {
                            Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                            KillSession.kill(client.getZooKeeper(), server.getConnectString());
                            client.getZooKeeper();
                            client.blockUntilConnectedOrTimedOut();
                        }

                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        return null;
                    }
                });

                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        Assert.assertFalse(firstTime.get());
                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        secondWasDone.set(true);
                        return null;
                    }
                });
                return null;
            }
        });

        Assert.assertTrue(secondWasDone.get());
    } finally {
        retryLoop.close();
        IOUtils.closeQuietly(client);
    }
}

From source file:de.itsvs.cwtrpc.controller.config.AutowiredRemoteServiceGroupConfigBeanDefinitionParserTest.java

@Test
public void test5() {
    AutowiredRemoteServiceGroupConfig config;
    Iterator<Pattern> filterIter;
    Pattern pattern;//from w w  w . jav a 2s .  c  o  m

    config = appContext.getBean("autowiredServiceGroup200", AutowiredRemoteServiceGroupConfig.class);
    Assert.assertEquals(1, config.getBasePackages().size());
    Assert.assertEquals("de.itsvs.test.", config.getBasePackages().iterator().next());
    Assert.assertNull(config.getResponseCompressionEnabled());
    Assert.assertNull(config.getRpcTokenProtectionEnabled());
    Assert.assertNull(config.getRpcTokenValidatorName());

    Assert.assertEquals(3, config.getIncludeFilters().size());
    filterIter = config.getIncludeFilters().iterator();
    pattern = filterIter.next();
    Assert.assertEquals("de\\..*Service10.+", pattern.getPatternString());
    Assert.assertTrue(pattern.matches("de.itsvs.test.Service10xyz"));
    pattern = filterIter.next();
    Assert.assertEquals("de.**.Service10*", pattern.getPatternString());
    Assert.assertTrue(pattern.matches("de.itsvs.test.Service10xyz"));
    pattern = filterIter.next();
    Assert.assertEquals("de\\..*Service20", pattern.getPatternString());
    Assert.assertTrue(pattern.matches("de.itsvs.test.Service20"));

    Assert.assertEquals(2, config.getExcludeFilters().size());
    filterIter = config.getExcludeFilters().iterator();
    pattern = filterIter.next();
    Assert.assertEquals("de\\..*Service40.+", pattern.getPatternString());
    Assert.assertTrue(pattern.matches("de.itsvs.test.Service40x"));
    pattern = filterIter.next();
    Assert.assertEquals("de.**.Service50*", pattern.getPatternString());
    Assert.assertTrue(pattern.matches("de.itsvs.test.Service50a"));
}

From source file:io.cloudslang.lang.compiler.modeller.transformers.ResultsTransformerTest.java

@Test
public void testNoExpressionResult() throws Exception {
    List<Result> results = resultsTransformer.transform(resultsMapOpWithData).getTransformedData();
    Result result = results.get(2);
    Assert.assertEquals(ScoreLangConstants.FAILURE_RESULT, result.getName());
    Assert.assertNull(result.getValue());
}