You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2019/12/07 20:42:20 UTC

[cxf] branch 3.2.x-fixes updated: CXF-8170: Parse HTTP link headers. Adding more tests

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
     new a810083  CXF-8170: Parse HTTP link headers. Adding more tests
a810083 is described below

commit a8100836a4bd5207251822dab60b808d4d574b7e
Author: reta <dr...@gmail.com>
AuthorDate: Sat Dec 7 15:34:59 2019 -0500

    CXF-8170: Parse HTTP link headers. Adding more tests
    
    (cherry picked from commit 5e31fc7242c4d428cc6db760a3963fdd69e9ef6b)
    (cherry picked from commit 3ba38c0422c57df23653c6b3443a96d1e9d75afb)
---
 .../apache/cxf/jaxrs/impl/ResponseImplTest.java    | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
index 63b02b1..709c3a6 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseImplTest.java
@@ -465,6 +465,47 @@ public class ResponseImplTest extends Assert {
         }
     }
     
+
+    @Test
+    public void testGetMultipleWithSingleLink() {
+        try (ResponseImpl ri = new ResponseImpl(200)) {
+            MetadataMap<String, Object> meta = new MetadataMap<>();
+            ri.addMetadata(meta);
+
+            Set<Link> links = ri.getLinks();
+            assertTrue(links.isEmpty());
+
+            meta.add(HttpHeaders.LINK, "<http://next>;rel=\"next\",");
+
+            assertTrue(ri.hasLink("next"));
+            Link next = ri.getLink("next");
+            assertNotNull(next);
+
+            links = ri.getLinks();
+            assertTrue(links.contains(Link.fromUri("http://next").rel("next").build()));
+        }
+    }
+
+    @Test
+    public void testGetLink() {
+        try (ResponseImpl ri = new ResponseImpl(200)) {
+            MetadataMap<String, Object> meta = new MetadataMap<>();
+            ri.addMetadata(meta);
+
+            Set<Link> links = ri.getLinks();
+            assertTrue(links.isEmpty());
+
+            meta.add(HttpHeaders.LINK, "<http://next>;rel=\"next\"");
+
+            assertTrue(ri.hasLink("next"));
+            Link next = ri.getLink("next");
+            assertNotNull(next);
+
+            links = ri.getLinks();
+            assertTrue(links.contains(Link.fromUri("http://next").rel("next").build()));
+        }
+    }
+
     @Test
     public void testGetLinksMultipleMultiline() {
         try (ResponseImpl ri = new ResponseImpl(200)) {