Skip to content

Commit 45144bf

Browse files
committed
Remove invalid-v4 inline BasicAsyncRequestProducer tests
migratesShape2BasicAsyncRequestProducerWithNStringEntity and migratesShape2WithHoistedNStringEntity fed inline-chained input (new HttpPost(path).setEntity(...)) that is not valid HttpClient 4.x, since setEntity returns void — which is why they needed constructorInvocations(false). That inline shape is only ever an in-memory intermediate produced by InlineBasicAsyncRequestProducerLocals, never real source. Made valid (hoisted), both are byte-for-byte duplicates of migratesShape2WithHoistedRequest and migratesShape2WithHoistedRequestAndEntity, which already exercise the full Inline -> Migrate path. Remove them; no valid-input coverage is lost and all constructorInvocations(false)/typeValidationOptions suppressions are gone.
1 parent 12d885f commit 45144bf

1 file changed

Lines changed: 0 additions & 83 deletions

File tree

src/test/java/org/openrewrite/apache/httpclient5/MigrateApacheHttpCoreNioTest.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -424,47 +424,6 @@ void method(HttpPost post, File file) {
424424
);
425425
}
426426

427-
@Test
428-
void migratesShape2BasicAsyncRequestProducerWithNStringEntity() {
429-
rewriteRun(
430-
// Before-image: `setEntity(...)` returns void in 4.x so the inlined `new BasicAsyncRequestProducer(...)` constructor cannot be typed.
431-
// After-image: the migrated `build()` returns a core5 producer the un-migrated 4.x `BasicAsyncRequestProducer` return type cannot accept.
432-
spec -> spec.typeValidationOptions(TypeValidation.all().constructorInvocations(false))
433-
.afterTypeValidationOptions(TypeValidation.all().methodInvocations(false)),
434-
//language=java
435-
java(
436-
"""
437-
import org.apache.http.HttpHost;
438-
import org.apache.http.client.methods.HttpPost;
439-
import org.apache.http.entity.ContentType;
440-
import org.apache.http.nio.entity.NStringEntity;
441-
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
442-
443-
class A {
444-
BasicAsyncRequestProducer producer(String body) {
445-
return new BasicAsyncRequestProducer(
446-
HttpHost.create("http://example.com"),
447-
new HttpPost("/api").setEntity(new NStringEntity(body, ContentType.APPLICATION_JSON)));
448-
}
449-
}
450-
""",
451-
"""
452-
import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers;
453-
import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
454-
import org.apache.http.client.methods.HttpPost;
455-
import org.apache.http.entity.ContentType;
456-
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
457-
458-
class A {
459-
BasicAsyncRequestProducer producer(String body) {
460-
return AsyncRequestBuilder.post("http://example.com" + "/api").setEntity(AsyncEntityProducers.create(body, ContentType.APPLICATION_JSON)).build();
461-
}
462-
}
463-
"""
464-
)
465-
);
466-
}
467-
468427
@Test
469428
void migratesShape2WithHoistedRequest() {
470429
rewriteRun(
@@ -504,48 +463,6 @@ BasicAsyncRequestProducer producer(String body) {
504463
);
505464
}
506465

507-
@Test
508-
void migratesShape2WithHoistedNStringEntity() {
509-
rewriteRun(
510-
// Before-image: `setEntity(...)` returns void in 4.x so the inlined `new BasicAsyncRequestProducer(...)` constructor cannot be typed.
511-
// After-image: the migrated `build()` returns a core5 producer the un-migrated 4.x `BasicAsyncRequestProducer` return type cannot accept.
512-
spec -> spec.typeValidationOptions(TypeValidation.all().constructorInvocations(false))
513-
.afterTypeValidationOptions(TypeValidation.all().methodInvocations(false)),
514-
//language=java
515-
java(
516-
"""
517-
import org.apache.http.HttpHost;
518-
import org.apache.http.client.methods.HttpPost;
519-
import org.apache.http.entity.ContentType;
520-
import org.apache.http.nio.entity.NStringEntity;
521-
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
522-
523-
class A {
524-
BasicAsyncRequestProducer producer(String body) {
525-
NStringEntity entity = new NStringEntity(body, ContentType.APPLICATION_JSON);
526-
return new BasicAsyncRequestProducer(
527-
HttpHost.create("http://example.com"),
528-
new HttpPost("/api").setEntity(entity));
529-
}
530-
}
531-
""",
532-
"""
533-
import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers;
534-
import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder;
535-
import org.apache.http.client.methods.HttpPost;
536-
import org.apache.http.entity.ContentType;
537-
import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
538-
539-
class A {
540-
BasicAsyncRequestProducer producer(String body) {
541-
return AsyncRequestBuilder.post("http://example.com" + "/api").setEntity(AsyncEntityProducers.create(body, ContentType.APPLICATION_JSON)).build();
542-
}
543-
}
544-
"""
545-
)
546-
);
547-
}
548-
549466
@Test
550467
void migratesShape2WithHoistedRequestAndEntity() {
551468
rewriteRun(

0 commit comments

Comments
 (0)