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.hupa.server.guice.ServerModulTest.java

@Test
public void testLoadProperties() throws Exception {
    String fileName = tmpDir + File.separator + "foo.properties";
    File file = new File(fileName);
    file.createNewFile();/*from w  ww. j  av  a 2  s. c  om*/
    Properties p = ConfigurationProperties.loadProperties(fileName);
    Assert.assertNotNull(p);
    Assert.assertNull(p.get("IMAPServerAddress"));
    file.delete();
}

From source file:org.apache.hyracks.algebricks.tests.pushruntime.PushRuntimeTest.java

public void compareFiles(String fileNameA, String fileNameB) throws IOException {
    BufferedReader fileA = new BufferedReader(new FileReader(fileNameA));
    BufferedReader fileB = new BufferedReader(new FileReader(fileNameB));

    String lineA, lineB;/* w  w  w. jav a2s .  co m*/
    while ((lineA = fileA.readLine()) != null) {
        lineB = fileB.readLine();
        Assert.assertEquals(lineA, lineB);
    }
    Assert.assertNull(fileB.readLine());
}

From source file:org.apache.juddi.api.impl.API_010_PublisherTest.java

private void deletePublisher(String publisherId) {
    try {//from ww w  .j  a  v  a  2s  . c  o  m
        String rootPublisherStr = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_PUBLISHER);
        String authInfo = TckSecurity.getAuthToken(security, rootPublisherStr, "");
        logger.debug("Delete publisher: " + publisherId);
        //Now deleting this publisher
        DeletePublisher dp = new DeletePublisher();
        dp.setAuthInfo(authInfo);
        dp.getPublisherId().add(publisherId);
        publisher.deletePublisher(dp);

        logger.info("Querying for publisher: " + publisherId + " after deletion.");
        //Querying for this publisher to make sure it's really gone
        //We're expecting a invalid Key exception at this point.
        GetPublisherDetail gp = new GetPublisherDetail();
        gp.getPublisherId().add(publisherId);
        gp.setAuthInfo(authInfo);
        PublisherDetail pdAfterDelete = null;
        try {
            pdAfterDelete = publisher.getPublisherDetail(gp);
            Assert.fail("We did not expect to find this publisher anymore.");
        } catch (InvalidKeyPassedException e) {
            Assert.assertNull(pdAfterDelete);
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown");
    }
}

From source file:org.apache.juddi.v2.tck.TckBusiness.java

public void checkNumberOfServices(String businessKey, int expectedServices) {

    try {/*from ww w .j  av  a2 s . c  o  m*/
        GetBusinessDetail gb = new GetBusinessDetail();
        gb.setGeneric("2.0");
        gb.getBusinessKey().add(businessKey);
        BusinessDetail bd;
        bd = inquiry.getBusinessDetail(gb);
        List<BusinessEntity> beOutList = bd.getBusinessEntity();
        BusinessEntity beOut = beOutList.get(0);
        if (expectedServices > 0) {
            assertEquals(expectedServices, beOut.getBusinessServices().getBusinessService().size());
        } else {
            Assert.assertNull(beOut.getBusinessServices());
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown");
    }
}

From source file:org.apache.juddi.v2.tck.TckFindEntity.java

public void findRelatedBusinessFromKey(boolean isOneSided) {
    try {/*from  www.j a v a 2 s  .c  om*/
        FindRelatedBusinesses body = (FindRelatedBusinesses) EntityCreator
                .buildFromDoc(FIND_RELATED_BUSINESS_FROM_KEY, "org.uddi.api_v2");
        body.setGeneric("2.0");
        RelatedBusinessesList result = inquiry.findRelatedBusinesses(body);
        if (result == null)
            Assert.fail("Null result from find related business operation");
        RelatedBusinessInfos bInfos = result.getRelatedBusinessInfos();

        //both parties need to register the assertion for it to be live.
        if (isOneSided) {
            Assert.assertNull(bInfos);
        } else {
            if (bInfos == null)
                Assert.fail("No result from find related business operation");
            List<RelatedBusinessInfo> biList = bInfos.getRelatedBusinessInfo();
            if (biList == null || biList.size() == 0)
                Assert.fail("No result from find related business operation");
            Set<String> keys = new HashSet<String>();
            for (RelatedBusinessInfo relatedBusinessInfo : biList) {
                keys.add(relatedBusinessInfo.getBusinessKey());
            }
            Assert.assertTrue(keys.contains(TckBusiness.SAM_BUSINESS_KEY));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown.");
    }
}

From source file:org.apache.juddi.v3.tck.TckBusiness.java

public void checkNumberOfServices(String businessKey, int expectedServices) {

    try {//from ww w  . ja  v  a2s  . com
        GetBusinessDetail gb = new GetBusinessDetail();
        gb.getBusinessKey().add(businessKey);
        BusinessDetail bd;
        bd = inquiry.getBusinessDetail(gb);
        List<BusinessEntity> beOutList = bd.getBusinessEntity();
        BusinessEntity beOut = beOutList.get(0);
        if (expectedServices > 0) {
            assertEquals(expectedServices, beOut.getBusinessServices().getBusinessService().size());
        } else {
            Assert.assertNull(beOut.getBusinessServices());
        }
    } catch (RemoteException e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown");
    }
}

From source file:org.apache.juddi.v3.tck.TckFindEntity.java

public void findRelatedBusiness_sortByName(boolean isOneSided) {
    try {/*from   w  w w . j av  a  2  s  .co m*/
        FindRelatedBusinesses body = (FindRelatedBusinesses) EntityCreator
                .buildFromDoc(FIND_RELATED_BUSINESS_SORT_BY_NAME_XML, "org.uddi.api_v3");
        RelatedBusinessesList result = inquiry.findRelatedBusinesses(body);
        if (result == null)
            Assert.fail("Null result from find related business operation");
        RelatedBusinessInfos bInfos = result.getRelatedBusinessInfos();

        //both parties need to register the assertion for it to be live.
        if (isOneSided) {
            Assert.assertNull(bInfos);
        } else {
            if (bInfos == null)
                Assert.fail("No result from find related business operation");
            List<RelatedBusinessInfo> biList = bInfos.getRelatedBusinessInfo();
            if (biList == null || biList.size() == 0)
                Assert.fail("No result from find related business operation");
            Set<String> keys = new HashSet<String>();
            for (RelatedBusinessInfo relatedBusinessInfo : biList) {
                keys.add(relatedBusinessInfo.getBusinessKey());
            }
            Assert.assertTrue(keys.contains("uddi:www.samco.com:samco"));
            Assert.assertTrue(keys.contains("uddi:uddi.marypublisher.com:marybusinessone"));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown.");
    }
}

From source file:org.apache.juddi.v3.tck.TckFindEntity.java

public void findRelatedBusinessToKey(boolean isOneSided) {
    try {//from  w  ww. j  a va 2s .c o m
        FindRelatedBusinesses body = (FindRelatedBusinesses) EntityCreator
                .buildFromDoc(FIND_RELATED_BUSINESS_TO_KEY, "org.uddi.api_v3");
        RelatedBusinessesList result = inquiry.findRelatedBusinesses(body);
        if (result == null)
            Assert.fail("Null result from find related business operation");
        RelatedBusinessInfos bInfos = result.getRelatedBusinessInfos();

        //both parties need to register the assertion for it to be live.
        if (isOneSided) {
            Assert.assertNull(bInfos);
        } else {
            if (bInfos == null)
                Assert.fail("No result from find related business operation");
            List<RelatedBusinessInfo> biList = bInfos.getRelatedBusinessInfo();
            if (biList == null || biList.size() == 0)
                Assert.fail("No result from find related business operation");
            Set<String> keys = new HashSet<String>();
            for (RelatedBusinessInfo relatedBusinessInfo : biList) {
                keys.add(relatedBusinessInfo.getBusinessKey());
            }
            Assert.assertTrue(keys.contains("uddi:uddi.joepublisher.com:businessone"));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown.");
    }
}

From source file:org.apache.juddi.v3.tck.TckFindEntity.java

public void findRelatedBusinessFromKey(boolean isOneSided) {
    try {/*from  w  w w .j av  a  2s  .  c  o m*/
        FindRelatedBusinesses body = (FindRelatedBusinesses) EntityCreator
                .buildFromDoc(FIND_RELATED_BUSINESS_FROM_KEY, "org.uddi.api_v3");
        RelatedBusinessesList result = inquiry.findRelatedBusinesses(body);
        if (result == null)
            Assert.fail("Null result from find related business operation");
        RelatedBusinessInfos bInfos = result.getRelatedBusinessInfos();

        //both parties need to register the assertion for it to be live.
        if (isOneSided) {
            Assert.assertNull(bInfos);
        } else {
            if (bInfos == null)
                Assert.fail("No result from find related business operation");
            List<RelatedBusinessInfo> biList = bInfos.getRelatedBusinessInfo();
            if (biList == null || biList.size() == 0)
                Assert.fail("No result from find related business operation");
            Set<String> keys = new HashSet<String>();
            for (RelatedBusinessInfo relatedBusinessInfo : biList) {
                keys.add(relatedBusinessInfo.getBusinessKey());
            }
            Assert.assertTrue(keys.contains("uddi:www.samco.com:samco"));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("No exception should be thrown.");
    }
}

From source file:org.apache.sling.etcd.client.impl.KeyResponseImplTest.java

@Test
public void testErrorResponse() throws Exception {
    KeyResponse response = new KeyResponseImpl(400, "Bad Request", HEADERS,
            new JSONObject(IOUtils.toString(getClass().getResourceAsStream("/error-1.json"))));
    Assert.assertFalse(response.isAction());
    Assert.assertNull(response.action());
    Assert.assertNotNull(response.error());
    Assert.assertNotNull(response.headers());
    Assert.assertEquals(3, response.headers().size());
    Assert.assertEquals("5398", response.headerFirst("X-Raft-Index"));
    Assert.assertEquals(105, response.error().errorCode());
    Assert.assertEquals(400, response.status());
    Assert.assertEquals("Bad Request", response.reasonPhrase());
}