private CoercionTarget target(Class<?> type) { return CoercionTargets.find(type); } }
protected CoercionTarget coercionType(final Class<?> type) { return CoercionTargets.find(type); }
private CoercionTarget coercionTarget() { return CoercionTargets.find(DateTimeFormatter.class); }
private CoercionTarget coercionTarget(final Class<?> type) { return CoercionTargets.find(type); }
private CoercionTarget coercionTarget(Class<?> type) { return CoercionTargets.find(type); }
private CoercionTarget coercionTarget(final Class<?> type) { return CoercionTargets.find(type); }
private CoercionTarget coercionTarget() { return CoercionTargets.find(InetSocketAddress.class); }
private CoercionTarget componentCoercionType() { String name = testName.getMethodName(); Field field = getField(name); return CoercionTargets.find(field.getGenericType(), getClass(), field.getName()); }
private CoercionTarget componentCoercionType() { String name = testName.getMethodName(); Field field = getField(name); return CoercionTargets.find(field); }
private CoercionTarget componentCoercionType() { String name = testName.getMethodName(); Field field = getField(name); return CoercionTargets.find(field); }
@Test(expected = RuntimeException.class) public void coerce() { TestWs coerced = (TestWs) new WebServiceCoercion().coerce(CoercionTargets.find(TestWs.class), null); assertThat(coerced).isNotNull(); }
@Test public void applicability() { assertThat(new InetSocketAddressCoercion().isApplicableTo(coercionTarget())).isTrue(); assertThat(new InetSocketAddressCoercion().isApplicableTo(CoercionTargets.find(String.class))).isFalse(); assertThat(new InetSocketAddressCoercion().isApplicableTo(CoercionTargets.find(Pattern.class))).isFalse(); }
@Test public void notApplicable() { assertThat(new WebServiceCoercion().isApplicableTo(CoercionTargets.find(Integer.class))).isFalse(); }
@Test public void isApplicable() { assertThat(new WebServiceCoercion().isApplicableTo(CoercionTargets.find(TestWs.class))).isTrue(); }
@Test public void coerceit() { WhatTestWs implementor = new WhatTestWs(); Endpoint endpoint = Endpoint.publish(WS_URL, implementor); try { TestWs coerced = (TestWs) new WebServiceCoercion() .coerce(CoercionTargets.find(TestWs.class), WS_URL); assertThat(coerced).isNotNull(); assertThat(coerced.giveMe()).isEqualTo("1"); assertThat(coerced.giveMe()).isEqualTo("2"); assertThat(implementor.counter).isEqualTo(2); } finally { endpoint.stop(); } }
@Test(expected = CouldNotConnectToWebServiceException.class) public void coerceNothing() { new WebServiceCoercion().coerce(CoercionTargets.find(OtherWs.class), WS_URL); }
@Test(expected = CouldNotConnectToWebServiceException.class) public void coerceWhere() { new WebServiceCoercion().coerce(CoercionTargets.find(OtherWs.class), "http://where"); }
@Test(expected = CouldNotCreateServiceProxyException.class) public void coerceOther() { WhatTestWs implementor = new WhatTestWs(); Endpoint endpoint = Endpoint.publish(WS_URL, implementor); try { new WebServiceCoercion().coerce(CoercionTargets.find(OtherWs.class), WS_URL); } finally { endpoint.stop(); } }
@Test(expected = CouldNotConnectToWebServiceException.class) public void coerceWrongUrl() { WhatTestWs implementor = new WhatTestWs(); Endpoint endpoint = Endpoint.publish(WS_URL + "/moved", implementor); try { new WebServiceCoercion().coerce(CoercionTargets.find(TestWs.class), WS_URL); } finally { endpoint.stop(); } }