Erling Holmqvist created CXF-4379:
-------------------------------------
Summary: InjectionUtils failes to convert path-value to class
annotated with XmlJavaTypeAdapter
Key: CXF-4379
URL: https://issues.apache.org/jira/browse/CXF-4379
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 2.6.1, 2.5.4
Reporter: Erling Holmqvist
{code:java}
package no.nrk.panorama.serum;
import static org.fest.assertions.Assertions.assertThat;
import java.lang.annotation.Annotation;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.cxf.jaxrs.model.ParameterType;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
import org.apache.cxf.message.MessageImpl;
import org.junit.Test;
public class CXFInjectionUtilsJUnitTest {
public static class Adapter extends XmlAdapter<String, Id> {
@Override
public String marshal(final Id id) throws Exception {
return id.getId();
}
@Override
public Id unmarshal(final String idStr) throws Exception {
Id id = new DelegatingId();
id.setId(idStr);
return id;
}
}
@XmlJavaTypeAdapter(Adapter.class)
public interface Id {
public String getId();
public void setId(String id);
}
public static class DelegatingId implements Id {
private String id;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
}
@Test
public void
handleParameter_givenValidInput_shouldReturnIdWithCorrectValue() throws
Exception {
// Arrange
String value = "1.1";
// Act
Object id = InjectionUtils.handleParameter(value, true,
Id.class, new Annotation[] {}, ParameterType.PATH,
new MessageImpl());
// Assert
assertThat(id).isInstanceOf(Id.class);
assertThat(((Id)id).getId()).isEqualTo(value);
}
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira