/** * Returns an instance of request handler adapted to the {@link RequestHandler2} interface from * the given request handler implementing the deprecated {@link RequestHandler} interface. */ public static RequestHandler2 adapt(@SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
/** * @return an instance of request handler adapted to the * {@link RequestHandler2} interface from the given request handler * implementing the deprecated {@link RequestHandler} interface. * @param old the request handler. */ public static RequestHandler2 adapt( @SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
/** * Returns an instance of request handler adapted to the {@link RequestHandler2} interface from * the given request handler implementing the deprecated {@link RequestHandler} interface. */ public static RequestHandler2 adapt(@SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
@Test public void sameOldButDiffAdapters() { RequestHandler old = createRequestHandler(); RequestHandler2 new1 = new RequestHandler2Adaptor(old); RequestHandler2 new2 = new RequestHandler2Adaptor(old); assertNotSame(new1, new2); assertEquals(new1, new2); assertTrue(new1.hashCode() == new2.hashCode()); }
@Test public void diffOldDiffAdapters() { RequestHandler old1 = createRequestHandler(); RequestHandler old2 = createRequestHandler(); RequestHandler2 new1 = new RequestHandler2Adaptor(old1); RequestHandler2 new2 = new RequestHandler2Adaptor(old2); assertNotSame(new1, new2); assertFalse(new1.equals(new2)); assertFalse(new1.hashCode() == new2.hashCode()); }
/** * Returns an instance of request handler adapted to the {@link RequestHandler2} interface from * the given request handler implementing the deprecated {@link RequestHandler} interface. */ public static RequestHandler2 adapt(@SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
/** * @return an instance of request handler adapted to the * {@link RequestHandler2} interface from the given request handler * implementing the deprecated {@link RequestHandler} interface. * @param old the request handler. */ public static RequestHandler2 adapt( @SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
/** * @return an instance of request handler adapted to the * {@link RequestHandler2} interface from the given request handler * implementing the deprecated {@link RequestHandler} interface. * @param old the request handler. */ public static RequestHandler2 adapt( @SuppressWarnings("deprecation") RequestHandler old) { return new RequestHandler2Adaptor(old); } }
@Test public void testDelegation() { for (int i = 0; i < bs.length; i++) { assertFalse(bs[i]); } RequestHandler old = createRequestHandler(); RequestHandler2 v2 = new RequestHandler2Adaptor(old); v2.beforeRequest(null); int i = 0; assertTrue("beforeRequest is expected to have been invoked", bs[i++]); bs[i - 1] = false; // reset the flag v2.afterResponse(null, null); assertTrue("beforeRequest is expected to have been invoked", bs[i++]); bs[i - 1] = false; // reset the flag v2.afterError(null, null, null); assertTrue("beforeRequest is expected to have been invoked", bs[i++]); bs[i - 1] = false; // reset the flag }