-
Notifications
You must be signed in to change notification settings - Fork 137
Entity Provider for java.nio.file.Path #1275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| //// | ||
| ******************************************************************* | ||
| * Copyright (c) 2024 Eclipse Foundation | ||
| * | ||
| * This specification document is made available under the terms | ||
| * of the Eclipse Foundation Specification License v1.0, which is | ||
| * available at https://www.eclipse.org/legal/efsl.php. | ||
| ******************************************************************* | ||
| //// | ||
|
|
||
| [[changes-since-4.0-release]] | ||
| === Changes Since 4.0 Release | ||
|
|
||
| * <<standard_entity_providers>>: Added entity provider for `java.nio.file.Path` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0, which is available at | ||
|
|
@@ -22,6 +22,7 @@ | |
| import java.io.IOException; | ||
| import java.io.InputStreamReader; | ||
| import java.io.InputStream; | ||
| import java.nio.file.Files; | ||
|
|
||
| import javax.xml.namespace.QName; | ||
|
|
||
|
|
@@ -548,7 +549,7 @@ public void fileReaderContainerInterceptorTest() throws Fault { | |
| @Test | ||
| @Tag("xml_binding") | ||
| public void fileReaderNoInterceptorTest() throws Fault { | ||
| setProperty(Property.REQUEST, buildRequest(Request.POST, "postfile")); | ||
| setProperty(Property.REQUEST, buildRequest(Request.POST, "postpath")); | ||
| setRequestContentEntity(content); | ||
| setProperty(Property.SEARCH_STRING, content); | ||
| invoke(); | ||
|
|
@@ -620,6 +621,110 @@ public void fileWriterClientInterceptorTest() throws Fault { | |
| logMsg("JAXRS called registered writer interceptor for file provider"); | ||
| } | ||
|
|
||
| // ------------------------- Path ----------------------------------- | ||
|
|
||
| /* | ||
| * @testName: pathReaderContainerInterceptorTest | ||
| * | ||
| * @assertion_ids: JAXRS:SPEC:84; | ||
| * | ||
| * @test_Strategy: JAX-RS implementations are REQUIRED to call registered | ||
| * interceptors when mapping representations to Java types and vice versa. | ||
| */ | ||
| @Test | ||
| @Tag("xml_binding") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: All of these tests (including what was added here) have this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, given Jakarta XML Binding is no longer required, implementations won't need to run these effectively allowing implementations to pass without even implementing the feature.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually did a 1:1 copy from the "file" originals, just replacing "file" by "path". So I assume that why you mention was already wrong before. I hence kindly ask to separate that discussion from this PR, and address that issue in a separate PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've written Issue 1277 to document this. However, I don't see the point of adding additional tests that will not run. I understand that you may not have time to evaluate/address all of the tests in this class, but any new that you add should not have that dependency.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what is the correct solution?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see your point Markus. As long as Issue 1277 is addressed prior to the next release. Can you confirm that the new TCK tests you've added have run successfully (since they currently would be skipped as part of a Jakarta Rest 4.0 TCK execution correct?)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we should be adding new TCK tests that don't run. It kind of defeats the purpose of a test. While I can understand that's how the old tests work, there's not reason to make new tests work the same way. There could very easily be a new There would be new interceptors needed too, but again IMO that's not really a big deal.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jim-krueger I cannot confirm that they run, as there is not yet any implementation that fulfils the new API (or maybe I misunderstood your question).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jamezp For me it is a big deal, as it imposes unnecessary work for me now and it imposes a temporary deviation from the original code, which I want to prevent as good as possible. OTOH as you feel this is not a big deal, maybe you like to chime in and fix #1277 upfront, so I can rebase on the already fixed code base in a second step? We can leave open this PR for the time being. WDYT?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| public void pathReaderContainerInterceptorTest() throws Fault { | ||
| addInterceptors(EntityReaderInterceptor.class); | ||
| setProperty(Property.REQUEST, buildRequest(Request.POST, "postpath")); | ||
| setRequestContentEntity(content); | ||
| setProperty(Property.SEARCH_STRING, | ||
| EntityReaderInterceptor.class.getName()); | ||
| setProperty(Property.UNEXPECTED_RESPONSE_MATCH, Resource.DIRECTION); | ||
| invoke(); | ||
| logMsg("JAXRS called registered reader interceptor for path provider"); | ||
| } | ||
|
|
||
| /* | ||
| * @testName: pathReaderNoInterceptorTest | ||
| * | ||
| * @assertion_ids: JAXRS:SPEC:84; | ||
| * | ||
| * @test_Strategy: JAX-RS implementations are REQUIRED to call registered | ||
| * interceptors when mapping representations to Java types and vice versa. | ||
| */ | ||
| @Test | ||
| @Tag("xml_binding") | ||
| public void pathReaderNoInterceptorTest() throws Fault { | ||
| setProperty(Property.REQUEST, buildRequest(Request.POST, "postpath")); | ||
| setRequestContentEntity(content); | ||
| setProperty(Property.SEARCH_STRING, content); | ||
| invoke(); | ||
| } | ||
|
|
||
| /* | ||
| * @testName: pathWriterContainerInterceptorTest | ||
| * | ||
| * @assertion_ids: JAXRS:SPEC:84; | ||
| * | ||
| * @test_Strategy: JAX-RS implementations are REQUIRED to call registered | ||
| * interceptors when mapping representations to Java types and vice versa. | ||
| */ | ||
| @Test | ||
| @Tag("xml_binding") | ||
| public void pathWriterContainerInterceptorTest() throws Fault { | ||
| addInterceptors(EntityWriterInterceptor.class); | ||
| setProperty(Property.REQUEST, buildRequest(Request.GET, "getpath")); | ||
| setProperty(Property.SEARCH_STRING, | ||
| EntityWriterInterceptor.class.getName()); | ||
| setProperty(Property.SEARCH_STRING, Resource.DIRECTION); | ||
| invoke(); | ||
| logMsg("JAXRS called registered writer interceptor for path provider"); | ||
| } | ||
|
|
||
| /* | ||
| * @testName: pathWriterNoInterceptorTest | ||
| * | ||
| * @assertion_ids: JAXRS:SPEC:84; | ||
| * | ||
| * @test_Strategy: JAX-RS implementations are REQUIRED to call registered | ||
| * interceptors when mapping representations to Java types and vice versa. | ||
| */ | ||
| @Test | ||
| @Tag("xml_binding") | ||
| public void pathWriterNoInterceptorTest() throws Fault { | ||
| setProperty(Property.REQUEST, buildRequest(Request.GET, "getpath")); | ||
| setProperty(Property.SEARCH_STRING, Resource.getName()); | ||
| invoke(); | ||
| } | ||
|
|
||
| /* | ||
| * @testName: pathWriterClientInterceptorTest | ||
| * | ||
| * @assertion_ids: JAXRS:SPEC:84; | ||
| * | ||
| * @test_Strategy: JAX-RS implementations are REQUIRED to call registered | ||
| * interceptors when mapping representations to Java types and vice versa. | ||
| */ | ||
| @Test | ||
| @Tag("xml_binding") | ||
| public void pathWriterClientInterceptorTest() throws Fault { | ||
| try { | ||
| java.nio.file.Path path = Files.createTempFile("temp", "tmp"); | ||
| Files.writeString(path, content); | ||
| setRequestContentEntity(path); | ||
| } catch (IOException e) { | ||
| throw new Fault(e); | ||
| } | ||
| addProvider(EntityWriterInterceptor.class); | ||
| addInterceptors(EntityWriterInterceptor.class); | ||
| setProperty(Property.REQUEST, buildRequest(Request.POST, "poststring")); | ||
| setProperty(Property.SEARCH_STRING, | ||
| EntityWriterInterceptor.class.getName()); | ||
| setProperty(Property.UNEXPECTED_RESPONSE_MATCH, Resource.DIRECTION); | ||
| invoke(); | ||
| logMsg("JAXRS called registered writer interceptor for path provider"); | ||
| } | ||
|
|
||
| // ------------------------- DataSource ----------------------------------- | ||
|
|
||
| /* | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.