@Override public void doInit(Properties messageAttributes) throws PerfCakeException { client = new CoapClient(safeGetTarget(messageAttributes)); switch (requestType) { case CONFIRMABLE: client.useCONs(); break; case NON_CONFIRMABLE: client.useNONs(); break; } }
try { Thread.sleep(6*1000); } catch (InterruptedException e) { } client.setURI(uri + "/obs-non").useNONs();
@Test public void testAdvancedUsesTypeFromRequest() throws Exception { final CountDownLatch latch = new CountDownLatch(1); // But expecting CONs as specified in request client.useNONs(); Request request = new Request(Code.GET, Type.CON); // Try a put and receive a METHOD_NOT_ALLOWED client.advanced(new TestHandler("Test 9") { @Override public void onLoad(CoapResponse response) { // It is CON latch.countDown(); } }, request); assertTrue(latch.await(1, TimeUnit.SECONDS)); }
/** * Verifies that the client & server clean up the message exchange store after retrieving * a resource body using a blockwise transfer with NON messages. * * @throws Exception if the test fails. */ @Test public void testBlockwiseUsingNONMessages() throws Exception { CoapClient client = new CoapClient(uriOf(URI)).useNONs(); client.setEndpoint(clientEndpoint); testBlockwise(client, Mode.PIGGY_BACKED_RESPONSE); }
@Test public void testAdvancedUsesTypeFromRequest() throws Exception { String uri = TestTools.getUri(serverEndpoint, TARGET); CoapClient client = new CoapClient(uri).useExecutor(); // Set NONs but expecting CONs as specified in request client.useNONs(); Request request = new Request(Code.GET, Type.CON); CoapResponse resp = client.advanced(request); Assert.assertEquals(Type.ACK, resp.advanced().getType()); Assert.assertEquals(CONTENT_1, resp.getResponseText()); }