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:no.abmu.common.excel.ExcelParserTest.java

public void testCheckInputValues() {
    String[] notNullNames = { "ACCOUNTNAME", "POSTCODE" };

    String errorMessage1 = excelParser1.checkInputValues(notNullNames);
    Assert.assertNull("This error message should have been null.", errorMessage1);

    // Column with name "SUBSCHEMANAME" have empty values.
    excelParser1.setInputStopTagColumnName("SUBSCHEMANAME");
    String[] notNullNamesWithError = { "ACCOUNTNAME", "POSTCODE", "SUBSCHEMANAME" };

    String errorMessage2 = excelParser1.checkInputValues(notNullNamesWithError);
    Assert.assertNotNull("Her we should have an error message.", errorMessage2);
}

From source file:org.apache.ambari.server.state.cluster.ClusterTest.java

@Test
public void testGetAndSetConfigs() throws Exception {
    createDefaultCluster();// ww  w  .j a va2  s  .c o  m

    Map<String, Map<String, String>> c1PropAttributes = new HashMap<String, Map<String, String>>();
    c1PropAttributes.put("final", new HashMap<String, String>());
    c1PropAttributes.get("final").put("a", "true");
    Map<String, Map<String, String>> c2PropAttributes = new HashMap<String, Map<String, String>>();
    c2PropAttributes.put("final", new HashMap<String, String>());
    c2PropAttributes.get("final").put("x", "true");
    Config config1 = configFactory.createNew(c1, "global", new HashMap<String, String>() {
        {
            put("a", "b");
        }
    }, c1PropAttributes);
    config1.setTag("version1");

    Config config2 = configFactory.createNew(c1, "global", new HashMap<String, String>() {
        {
            put("x", "y");
        }
    }, c2PropAttributes);
    config2.setTag("version2");

    Config config3 = configFactory.createNew(c1, "core-site", new HashMap<String, String>() {
        {
            put("x", "y");
        }
    }, new HashMap<String, Map<String, String>>());
    config3.setTag("version2");

    c1.addConfig(config1);
    c1.addConfig(config2);
    c1.addConfig(config3);

    c1.addDesiredConfig("_test", Collections.singleton(config1));
    Config res = c1.getDesiredConfigByType("global");
    Assert.assertNotNull("Expected non-null config", res);
    Assert.assertEquals("true", res.getPropertiesAttributes().get("final").get("a"));

    res = c1.getDesiredConfigByType("core-site");
    Assert.assertNull("Expected null config", res);

    c1.addDesiredConfig("_test", Collections.singleton(config2));
    res = c1.getDesiredConfigByType("global");
    Assert.assertEquals("Expected version tag to be 'version2'", "version2", res.getTag());
    Assert.assertEquals("true", res.getPropertiesAttributes().get("final").get("x"));
}

From source file:org.apache.cassandra.db.index.sasi.disk.TokenTreeTest.java

@Test
public void buildSerializeAndGet() throws Exception {
    final long tokMin = 0;
    final long tokMax = 1000;

    final TokenTree tokenTree = generateTree(tokMin, tokMax);

    for (long i = 0; i <= tokMax; i++) {
        TokenTree.OnDiskToken result = tokenTree.get(i, KEY_CONVERTER);
        Assert.assertNotNull("failed to find object for token " + i, result);

        Set<Long> found = result.getOffsets();
        Assert.assertEquals(1, found.size());
        Assert.assertEquals(i, found.toArray()[0]);
    }//from w w w  . j a  va 2s.  c  om

    Assert.assertNull("found missing object", tokenTree.get(tokMax + 10, KEY_CONVERTER));
}

From source file:org.apache.cassandra.index.sasi.disk.TokenTreeTest.java

public void buildSerializeAndGet(boolean isStatic) throws Exception {
    final long tokMin = 0;
    final long tokMax = 1000;

    final TokenTree tokenTree = generateTree(tokMin, tokMax, isStatic);

    for (long i = 0; i <= tokMax; i++) {
        TokenTree.OnDiskToken result = tokenTree.get(i, KEY_CONVERTER);
        Assert.assertNotNull("failed to find object for token " + i, result);

        LongSet found = result.getOffsets();
        Assert.assertEquals(1, found.size());
        Assert.assertEquals(i, found.toArray()[0]);
    }/*from   w w w.  ja  v a2s  .  c om*/

    Assert.assertNull("found missing object", tokenTree.get(tokMax + 10, KEY_CONVERTER));
}

From source file:org.apache.cocoon.forms.formmodel.WidgetTestHelper.java

public static void assertXPathNotExists(String message, String xpath, Document doc) {
    JXPathContext ctx = JXPathContext.newContext(doc);
    ctx.setLenient(true);/*from   w w  w.  ja  v a 2 s.  c  o m*/
    Pointer pointer = ctx.getPointer(xpath);
    Assert.assertNull(message, pointer.getNode());
}

From source file:org.apache.synapse.transport.nhttp.NHttpTransportListenerTest.java

/**
 * Test the session Context.// w  ww .  ja  va2s .  c  om
 *
 * @throws Exception
 */
@Test
public void testGetSessionContext() throws Exception {
    MessageContext messageContext = Mockito.mock(MessageContext.class);
    SessionContext sessionContext = nHttpListener.getSessionContext(messageContext);
    Assert.assertNull("SessionContext mut be null", sessionContext);
}

From source file:org.castor.xml.XMLConfigurationTest.java

public void testGetBooleanString() {
    Boolean notExistingProperty = _configuration.getBoolean("Something which doesn't exist");
    Assert.assertNull("A not existing property needs to return null", notExistingProperty);
}

From source file:org.eclipse.hudson.security.team.TeamAwareSecurityRealmTest.java

@Test
public void testGlobalSysAdminPermission() throws IOException, TeamManager.TeamAlreadyExistsException {
    Team newTeam = teamManager.createTeam("team1");
    hudsonSecurityManager.setSecurityRealm(new TeamAwareSecurityRealmImpl(newTeam, false, false));

    //Dummy Sid/*w w w  .ja  v  a2 s  . c  om*/
    Sid sid = new PrincipalSid("Paul");
    TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.GLOBAL);
    Assert.assertNull("Current user should not have global CONFIGURE permission",
            teamBasedACL.hasPermission(sid, configurePermission));
    Assert.assertTrue("Current user should have global READ permission",
            teamBasedACL.hasPermission(sid, readPermission).booleanValue());

    hudsonSecurityManager.setSecurityRealm(new TeamAwareSecurityRealmImpl(newTeam, true, false));
    Assert.assertTrue("Current user should have global CONFIGURE permission",
            teamBasedACL.hasPermission(sid, configurePermission).booleanValue());

}

From source file:org.eclipse.hudson.security.team.TeamAwareSecurityRealmTest.java

@Test
public void testJobPermission() throws IOException, TeamManager.TeamAlreadyExistsException {
    Team team1 = teamManager.createTeam("team1");
    hudsonSecurityManager.setSecurityRealm(new TeamAwareSecurityRealmImpl(team1, false, false));
    FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob");
    team1.addJob(new TeamJob(freeStyleJob.getName()));

    //Dummy Sid/*from  ww w.ja  v  a2  s .c  om*/
    Sid sid = new PrincipalSid("Paul");
    TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob);
    Assert.assertTrue("Current user should have Job CONFIGURE permission",
            teamBasedACL.hasPermission(sid, configurePermission).booleanValue());

    Team team2 = teamManager.createTeam("team2");
    freeStyleJob = new FreeStyleProjectMock("testJob2");
    team2.addJob(new TeamJob(freeStyleJob.getName()));

    teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob);
    Assert.assertNull("Current user should not have Job CONFIGURE permission",
            teamBasedACL.hasPermission(sid, configurePermission));
    Assert.assertNull("Current user should not have Job READ permission",
            teamBasedACL.hasPermission(sid, readPermission));
}

From source file:org.eclipse.hudson.security.team.TeamAwareSecurityRealmTest.java

@Test
public void testPublicJobPermission()
        throws IOException, TeamManager.TeamNotFoundException, TeamManager.TeamAlreadyExistsException {
    String teamName = "team1";
    Team newTeam = teamManager.createTeam(teamName);
    hudsonSecurityManager.setSecurityRealm(new TeamAwareSecurityRealmImpl(newTeam, false, false));

    FreeStyleProject freeStyleJob = new FreeStyleProjectMock("testJob");
    teamManager.getPublicTeam().addJob(new TeamJob(freeStyleJob.getName()));

    //Dummy Sid/*from  w ww.  j av a  2s.c  o m*/
    Sid sid = new PrincipalSid("Paul");
    TeamBasedACL teamBasedACL = new TeamBasedACL(teamManager, TeamBasedACL.SCOPE.JOB, freeStyleJob);
    Assert.assertNull("Current user should not have Job CONFIGURE permission",
            teamBasedACL.hasPermission(sid, configurePermission));
    Assert.assertTrue("Current user should have Job READ permission",
            teamBasedACL.hasPermission(sid, readPermission).booleanValue());
}