You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (Jira)" <ji...@apache.org> on 2022/10/02 15:51:00 UTC

[jira] [Commented] (CXF-8769) inherited static method 'fromString(String)' not considered on localTransport

    [ https://issues.apache.org/jira/browse/CXF-8769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17612133#comment-17612133 ] 

Andriy Redko commented on CXF-8769:
-----------------------------------

Hey [~bmarwell] , I have difficulties to reproduce the behavior you are referring to. Please take a look at this pull request [1] which adds the tests for that specific case, let me know if I am missing something.

One thing to mention, in the description you have provided, the `HelmId` **does not** inherit from `AbstractHelmId`, so it is logical that the `fromString` method is not there. I am not sure this is a typo or issue with your implementation.

 

[1] https://github.com/apache/cxf/pull/1004

> inherited static method 'fromString(String)' not considered on localTransport
> -----------------------------------------------------------------------------
>
>                 Key: CXF-8769
>                 URL: https://issues.apache.org/jira/browse/CXF-8769
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS, JAX-WS Runtime
>    Affects Versions: 3.5.3
>         Environment: Junit 5
> cxf local transport
>            Reporter: Benjamin Marwell
>            Priority: Major
>
> Hi CXF team!
>  
> h3. Description of the error and code
> I tried to use a local transport for testing my services. However, I have a path and/or query parameter set to something like this:
> {code:java}
> @Path("api")
> public class HelmResource {
>   // body left out for brevity
>   @PUT
>   @Path("helm/{id}/files")
>   public Response putFile(@PathParam("id") HelmId helmId, String entity);
> }
> // important parts of the parameter class
> abstract class AbstractHelmId {
>   // watch the return type!
>   public static HelmId fromString(String id) {
>     return HelmId.of(new UUID(id));
>   }
> }
> @Generated // by immutables.org
> public class HelmId {
>   private final UUID id;
>   // should inherit the fromString(String id) method.
>   public static HelmId of(UUID uuid) {
>     return new HelmId(uuid);
>   }
> }
> {code}
> This works perfectly fine on Open Liberty (which uses CXF), but it does not when using CXF in local test mode. I wrote a Junit5 extension based on your wiki: [https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing#JAXRSTesting-LocalTransport]
>  
> h3. Expected behaviour
> HelmId is being read from the path
>  
> h3. Actual behaviour
> {code:java}
> HelmId has no constructor with single String parameter, static valueOf(String) or fromString(String) methods{code}
>  
> h3. Workaround
> Create a ParamConverterProvider and a ParamConverter for all the classes. This eliminates the idea of the integration test though, as the test uses a provider, the production code does not.
>  
> h3. Expected solution
> The error is being thrown here: [cxf/InjectionUtils.java at b6e3ab83a37cfb777d6eebf9711e552027bde37a · apache/cxf (github.com)|https://github.com/apache/cxf/blob/b6e3ab83a37cfb777d6eebf9711e552027bde37a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java#L526-L535]
> I assume this method must be changed or is not properly called for local transports.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)