cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7440] Adding the variants as part of build() too
Date Tue, 11 Jul 2017 16:49:43 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 528cce137 -> 41433c71d


[CXF-7440] Adding the variants as part of build() too


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/41433c71
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/41433c71
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/41433c71

Branch: refs/heads/3.0.x-fixes
Commit: 41433c71dcb95dcb402edbbe7b271ebcbb668724
Parents: 528cce1
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Jul 11 17:37:55 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Jul 11 17:49:30 2017 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/VariantListBuilderImpl.java    |  1 +
 .../jaxrs/impl/VariantListBuilderImplTest.java    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/41433c71/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
index 2e07d60..17db0aa 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImpl.java
@@ -49,6 +49,7 @@ public class VariantListBuilderImpl extends VariantListBuilder {
 
     @Override
     public List<Variant> build() {
+        addVariants();
         List<Variant> vs = new ArrayList<Variant>(variants);
         reset();
         return vs;

http://git-wip-us.apache.org/repos/asf/cxf/blob/41433c71/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
index 8a31dd5..2acdfbb 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/VariantListBuilderImplTest.java
@@ -49,6 +49,24 @@ public class VariantListBuilderImplTest extends Assert {
     }
     
     @Test
+    public void testBuildAllWithoutAdd() {
+        VariantListBuilderImpl vb = new VariantListBuilderImpl();
+        MediaType mt1 = new MediaType("*", "*");
+        MediaType mt2 = new MediaType("text", "xml");
+        List<Variant> variants = vb.mediaTypes(mt1, mt2)
+            .languages(new Locale("en"), new Locale("fr")).encodings("zip", "identity").build();
+        assertEquals("8 variants need to be created", 8, variants.size());
+        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("en"), "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("en"), "identity")));
+        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("fr"), "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt1, new Locale("fr"), "identity")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("en"), "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("en"), "identity")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("fr"), "zip")));
+        assertTrue(verifyVariant(variants, new Variant(mt2, new Locale("fr"), "identity")));
+    }
+
+    @Test
     public void testBuildTypeAndEnc() {
         VariantListBuilderImpl vb = new VariantListBuilderImpl();
         MediaType mt1 = new MediaType("*", "*"); 


Mime
View raw message