List of usage examples for junit.framework Assert assertNotNull
static public void assertNotNull(Object object)
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"); }