cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1351679 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Date Tue, 19 Jun 2012 12:39:55 GMT
Author: sergeyb
Date: Tue Jun 19 12:39:55 2012
New Revision: 1351679

URL: http://svn.apache.org/viewvc?rev=1351679&view=rev
Log:
Merged revisions 1351677 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1351677 | sergeyb | 2012-06-19 13:36:15 +0100 (Tue, 19 Jun 2012) | 9 lines
  
  Merged revisions 1351674 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1351674 | sergeyb | 2012-06-19 13:32:29 +0100 (Tue, 19 Jun 2012) | 1 line
    
    Avoiding checking for single specific prefixes in the schema generated by JAXB as the
output is different depending on JAXB versions
  ........
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1351674
  Merged /cxf/branches/2.6.x-fixes:r1351677

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1351679&r1=1351678&r2=1351679&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Tue Jun 19 12:39:55 2012
@@ -127,7 +127,7 @@ public class WadlGeneratorTest extends A
         Response r = wg.handleRequest(m, cri);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
-        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter", false);
+        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz",
1);
         checkBookStoreInfo(els.get(0), "prefix1:thebook", "prefix1:thebook2", "prefix1:thechapter");
     }
@@ -154,7 +154,7 @@ public class WadlGeneratorTest extends A
         List<Element> elementEls = DOMUtils.getChildrenWithName(schemasEls.get(0),

             XmlSchemaConstants.XSD_NAMESPACE_URI, "element");
         assertEquals(1, elementEls.size());
-        assertTrue(checkElement(elementEls, "books", "tns:books"));
+        assertTrue(checkElement(elementEls, "books", "books"));
 
         List<Element> complexTypesEls = DOMUtils.getChildrenWithName(schemasEls.get(0),

             XmlSchemaConstants.XSD_NAMESPACE_URI, "complexType");
@@ -235,7 +235,7 @@ public class WadlGeneratorTest extends A
         Response r = wg.handleRequest(m, cri);
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
-        checkGrammars(doc.getDocumentElement(), "book", "book2", "chapter", false);
+        checkGrammars(doc.getDocumentElement(), "book", "book2", "chapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz",
1);
         checkBookStoreInfo(els.get(0), "prefix1:book", "prefix1:book2", "prefix1:chapter");
     }
@@ -253,7 +253,7 @@ public class WadlGeneratorTest extends A
         checkResponse(r);
         Document doc = DOMUtils.readXml(new StringReader(r.getEntity().toString()));
         checkDocs(doc.getDocumentElement(), "My Application", "", "");
-        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter", true);
+        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz",
1);
         checkBookStoreInfo(els.get(0), "ns1:thebook", "ns1:thebook2", "ns1:thechapter");
     }
@@ -309,7 +309,7 @@ public class WadlGeneratorTest extends A
         
         verifyParameters(resourceEls.get(0), 1, new Param("id", "template", "xs:int"));
         
-        checkGrammars(doc.getDocumentElement(), "thebook", null, "thechapter", false);
+        checkGrammars(doc.getDocumentElement(), "thebook", null, "thechapter");
     }
     
     private void checkResponse(Response r) throws Exception {
@@ -343,15 +343,14 @@ public class WadlGeneratorTest extends A
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
         String wadl = r.getEntity().toString();
         Document doc = DOMUtils.readXml(new StringReader(wadl));
-        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter", true);
+        checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz",
2);
         checkBookStoreInfo(els.get(0), "prefix1:thebook", "prefix1:thebook2", "prefix1:thechapter");
         Element orderResource = els.get(1);
         assertEquals("/orders", orderResource.getAttribute("path"));
     }
 
-    private void checkGrammars(Element appElement, String bookEl, String book2El, String
chapterEl, 
-                               boolean customPrefix) {
+    private void checkGrammars(Element appElement, String bookEl, String book2El, String
chapterEl) {
         List<Element> grammarEls = DOMUtils.getChildrenWithName(appElement, WadlGenerator.WADL_NS,

                                                                 "grammars");
         assertEquals(1, grammarEls.size());
@@ -365,12 +364,12 @@ public class WadlGeneratorTest extends A
         int size = book2El == null ? 2 : 3;
         
         assertEquals(size, elementEls.size());
-        String prefix = "tns";
-        assertTrue(checkElement(elementEls, bookEl, prefix + ":book"));
+        
+        assertTrue(checkElement(elementEls, bookEl, "book"));
         if (book2El != null) {
-            assertTrue(checkElement(elementEls, book2El, prefix + ":book2"));
+            assertTrue(checkElement(elementEls, book2El, "book2"));
         }
-        assertTrue(checkElement(elementEls, chapterEl, prefix + ":chapter"));
+        assertTrue(checkElement(elementEls, chapterEl, "chapter"));
         
         List<Element> complexTypesEls = DOMUtils.getChildrenWithName(schemasEls.get(0),

                                         XmlSchemaConstants.XSD_NAMESPACE_URI, "complexType");
@@ -409,11 +408,16 @@ public class WadlGeneratorTest extends A
         return false;
     }
     
-    private boolean checkElement(List<Element> els, String name, String type) {
+    private boolean checkElement(List<Element> els, String name, String localTypeName)
{
         for (Element e : els) {
-            if (name.equals(e.getAttribute("name"))
-                && type.equals(e.getAttribute("type"))) {
-                return true;
+            if (name.equals(e.getAttribute("name"))) {
+                String type = e.getAttribute("type");
+                
+                String expectedType1 = "tns:" + localTypeName;
+                String expectedType2 = "os:" + localTypeName;
+                if (type.equals(expectedType1) || type.equals(expectedType2)) {
+                    return true;
+                }
             }
         }
         return false;



Mime
View raw message