Example usage for junit.framework Assert assertNotNull

List of usage examples for junit.framework Assert assertNotNull

Introduction

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

Prototype

static public void assertNotNull(Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:org.apache.sling.discovery.etcd.EtcdServiceTest.java

@Test
public void testAnnounceLocalInstance() throws Exception {
    HttpServlet servlet = new HttpServlet() {
        @Override/*from   www  . java2s . c o m*/
        protected void service(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
            if (!"POST".equals(req.getMethod())) {
                throw new IllegalArgumentException("create key requires POST");
            }
            String ttl = req.getParameter("ttl");
            if (ttl == null) {
                throw new IllegalArgumentException("ttl not specified");
            }
            String value = req.getParameter("value");
            if (value == null) {
                throw new IllegalArgumentException("value not specified");
            }
            res.setStatus(201);
            res.getWriter()
                    .write(IOUtils.toString(getClass().getResourceAsStream("/announce-local-instance.json")));
        }
    };
    AnnounceData annData = new AnnounceData("sling-id", "server-info", "default-cluster", 1926);
    server = startServer(servlet, "/v2/keys/discovery/announces");
    EtcdService etcdService = buildEtcdService(serverPort(server));
    EtcdNode annNode = etcdService.createAnnounce(annData.toString(), 10);
    Assert.assertNotNull(annNode);
    Assert.assertEquals(annNode.key(), "/discovery/announces/244");
}