### Question:
ReadOnlyCoapResource extends CoapResource { @Override public void get(CoapExchange ex) { ex.setResponseBody(payloadSupplier.get()); ex.setResponseCode(Code.C205_CONTENT); if (contentType != null) { ex.setResponseContentType(contentType); } if (maxAgeSeconds != null) { ex.getResponseHeaders().setMaxAge((long) maxAgeSeconds); } ex.sendResponse(); } ReadOnlyCoapResource(String body);  ReadOnlyCoapResource(Supplier<String> body);  ReadOnlyCoapResource(String body, String resourceType, int maxAgeSeconds);  ReadOnlyCoapResource(String body, String resourceType, Short contentType, int maxAgeSeconds);  ReadOnlyCoapResource(Supplier<String> body, String resourceType, Short contentType, int maxAgeSeconds); void setResourceBody(String resourceBody); @Override void get(CoapExchange ex);  }### Answer:
@Test public void test() throws Exception { srv.addRequestHandler("/test", new ReadOnlyCoapResource("11")); assertEquals("11", cli.resource("/test").get().get().getPayloadString()); srv.addRequestHandler("/test2", new ReadOnlyCoapResource("22", "", 61)); assertEquals("22", cli.resource("/test2").get().get().getPayloadString()); assertEquals(61, cli.resource("/test2").get().get().headers().getMaxAgeValue()); srv.addRequestHandler("/test3", new ReadOnlyCoapResource("33", "", MediaTypes.CT_TEXT_PLAIN, -1)); assertEquals("33", cli.resource("/test3").get().get().getPayloadString()); assertEquals(MediaTypes.CT_TEXT_PLAIN, cli.resource("/test3").get().get().headers().getContentFormat().shortValue()); }