cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Renaming SwaggerUtils to SwaggerParseUtils, moving it to swagger.parse subpackage, introducing ParseConfiguration (to be enhanced)
Date Mon, 24 Jul 2017 12:41:54 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes e43a31162 -> ad8d74672


Renaming SwaggerUtils to SwaggerParseUtils, moving it to swagger.parse subpackage, introducing ParseConfiguration (to be enhanced)


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

Branch: refs/heads/3.1.x-fixes
Commit: ad8d7467279ca94f27af72a873c05a4ee42d12c4
Parents: e43a311
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon Jul 24 15:35:51 2017 +0300
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Jul 24 15:41:30 2017 +0300

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/swagger/SwaggerUtils.java  | 199 ---------
 .../jaxrs/swagger/parse/ParseConfiguration.java |  47 +++
 .../jaxrs/swagger/parse/SwaggerParseUtils.java  | 203 +++++++++
 .../cxf/jaxrs/swagger/SwaggerUtilsTest.java     | 410 -------------------
 .../swagger/parse/SwaggerParseUtilsTest.java    | 410 +++++++++++++++++++
 .../AbstractSwagger2ServiceDescriptionTest.java |   4 +-
 6 files changed, 662 insertions(+), 611 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
deleted file mode 100644
index da2216b..0000000
--- a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs.swagger;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserApplication;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-
-public final class SwaggerUtils {
-    private static final Logger LOG = LogUtils.getL7dLogger(ResourceUtils.class);
-    private static final Map<String, Class<?>> SWAGGER_TYPE_MAP;
-    static {
-        SWAGGER_TYPE_MAP = new HashMap<String, Class<?>>();
-        SWAGGER_TYPE_MAP.put("string", String.class);
-        SWAGGER_TYPE_MAP.put("integer", long.class);
-        SWAGGER_TYPE_MAP.put("float", float.class);
-        SWAGGER_TYPE_MAP.put("double", double.class);
-        SWAGGER_TYPE_MAP.put("int", int.class);
-        SWAGGER_TYPE_MAP.put("long", long.class);
-        SWAGGER_TYPE_MAP.put("byte", byte.class);
-        SWAGGER_TYPE_MAP.put("boolean", boolean.class);
-        SWAGGER_TYPE_MAP.put("date", java.util.Date.class);
-        SWAGGER_TYPE_MAP.put("dateTime", java.util.Date.class);
-        SWAGGER_TYPE_MAP.put("File", java.io.InputStream.class);
-        SWAGGER_TYPE_MAP.put("file", java.io.InputStream.class);
-    }
-    private SwaggerUtils() {
-        
-    }
-    public static UserApplication getUserApplication(String loc) {
-        return getUserApplication(loc, BusFactory.getThreadDefaultBus());
-    }
-    public static UserApplication getUserApplication(String loc, Bus bus) {
-        try {
-            InputStream is = ResourceUtils.getResourceStream(loc, bus);
-            if (is == null) {
-                return null;
-            }
-            return getUserApplicationFromStream(is);
-        } catch (Exception ex) {
-            LOG.warning("Problem with processing a user model at " + loc);
-        }
-        return null;
-    }
-    public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
-        return getUserApplicationFromJson(IOUtils.readStringFromStream(is));
-    }
-    public static UserApplication getUserApplicationFromJson(String json) {
-        JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        Map<String, Object> map = reader.fromJson(json);
-    
-        UserApplication app = new UserApplication();
-        String relativePath = (String)map.get("basePath");
-        app.setBasePath(StringUtils.isEmpty(relativePath) ? "/" : relativePath);
-        
-        
-        Map<String, List<UserOperation>> userOpsMap = new LinkedHashMap<String, List<UserOperation>>();
-        Set<String> tags = new HashSet<String>();
-        List<Map<String, Object>> tagsProp = CastUtils.cast((List<?>)map.get("tags"));
-        if (tagsProp != null) {
-            for (Map<String, Object> tagProp : tagsProp) {
-                tags.add((String)tagProp.get("name"));
-            }
-        } else {
-            tags.add("");
-        }
-        for (String tag : tags) {
-            userOpsMap.put(tag, new LinkedList<UserOperation>());
-        }
-        
-        
-        Map<String, Map<String, Object>> paths = CastUtils.cast((Map<?, ?>)map.get("paths"));
-        for (Map.Entry<String, Map<String, Object>> pathEntry : paths.entrySet()) {
-            String operPath = pathEntry.getKey();
-            
-            Map<String, Object> operations = pathEntry.getValue();
-            for (Map.Entry<String, Object> operEntry : operations.entrySet()) {
-                
-                UserOperation userOp = new UserOperation();
-                userOp.setVerb(operEntry.getKey().toUpperCase());
-                
-                Map<String, Object> oper = CastUtils.cast((Map<?, ?>)operEntry.getValue());
-                List<String> opTags = CastUtils.cast((List<?>)oper.get("tags"));
-                String opTag = opTags == null ? "" : opTags.get(0);
-                
-                String realOpPath = operPath.equals("/" + opTag) ? "/" : operPath.substring(opTag.length() + 1);
-                userOp.setPath(realOpPath);
-                
-                userOp.setName((String)oper.get("operationId"));
-                List<String> opProduces = CastUtils.cast((List<?>)oper.get("produces"));
-                userOp.setProduces(listToString(opProduces));
-                
-                List<String> opConsumes = CastUtils.cast((List<?>)oper.get("consumes"));
-                userOp.setConsumes(listToString(opConsumes));
-                
-                List<Parameter> userOpParams = new LinkedList<Parameter>(); 
-                List<Map<String, Object>> params = CastUtils.cast((List<?>)oper.get("parameters"));
-                for (Map<String, Object> param : params) {
-                    String name = (String)param.get("name");
-                    //"query", "header", "path", "formData" or "body"
-                    String paramType = (String)param.get("in");
-                    ParameterType pType = "body".equals(paramType) ? ParameterType.REQUEST_BODY 
-                        : "formData".equals(paramType) 
-                        ? ParameterType.FORM : ParameterType.valueOf(paramType.toUpperCase()); 
-                    Parameter userParam = new Parameter(pType, name);
-                    
-                    setJavaType(userParam, (String)param.get("type"));
-                    userOpParams.add(userParam);
-                }   
-                if (!userOpParams.isEmpty()) {
-                    userOp.setParameters(userOpParams);
-                }
-                userOpsMap.get(opTag).add(userOp);    
-                
-            }
-        }
-        
-        List<UserResource> resources = new LinkedList<UserResource>();
-        
-        for (Map.Entry<String, List<UserOperation>> entry : userOpsMap.entrySet()) {
-            UserResource ur = new UserResource();
-            ur.setPath("/" + entry.getKey());
-            ur.setOperations(entry.getValue());
-            ur.setName(entry.getKey());
-            resources.add(ur);
-        }
-        
-        app.setResources(resources);
-        return app;
-    }
-    
-    private static void setJavaType(Parameter userParam, String typeName) {
-        Class<?> javaType = SWAGGER_TYPE_MAP.get(typeName);
-        if (javaType == null) {
-            try {
-                // May work if the model has already been compiled
-                // TODO: need to know the package name
-                javaType = ClassLoaderUtils.loadClass(typeName, SwaggerUtils.class); 
-            } catch (Throwable t) {
-                // ignore
-            }
-        }
-
-        userParam.setJavaType(javaType);
-    }
-    
-    private static String listToString(List<String> list) {
-        if (list != null) {
-            StringBuilder sb = new StringBuilder();
-            for (String s : list) {
-                if (sb.length() > 0) {
-                    sb.append(',');
-                }
-                sb.append(s);
-            }
-            return sb.toString();
-        } else {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java
new file mode 100644
index 0000000..18e5b67
--- /dev/null
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/ParseConfiguration.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.swagger.parse;
+
+import org.apache.cxf.Bus;
+
+public class ParseConfiguration {
+    private String docLocation;
+    private Bus bus;
+    
+    public ParseConfiguration() {
+    }
+    
+    public ParseConfiguration(String docLocation, Bus bus) {
+        this.docLocation = docLocation;
+        this.bus = bus;
+    }
+    
+    public String getDocLocation() {
+        return docLocation;
+    }
+    public void setDocLocation(String docLocation) {
+        this.docLocation = docLocation;
+    }
+    public Bus getBus() {
+        return bus;
+    }
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java
new file mode 100644
index 0000000..06aa761
--- /dev/null
+++ b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtils.java
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.swagger.parse;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserApplication;
+import org.apache.cxf.jaxrs.model.UserOperation;
+import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
+
+public final class SwaggerParseUtils {
+    private static final Logger LOG = LogUtils.getL7dLogger(ResourceUtils.class);
+    private static final Map<String, Class<?>> SWAGGER_TYPE_MAP;
+    static {
+        SWAGGER_TYPE_MAP = new HashMap<String, Class<?>>();
+        SWAGGER_TYPE_MAP.put("string", String.class);
+        SWAGGER_TYPE_MAP.put("integer", long.class);
+        SWAGGER_TYPE_MAP.put("float", float.class);
+        SWAGGER_TYPE_MAP.put("double", double.class);
+        SWAGGER_TYPE_MAP.put("int", int.class);
+        SWAGGER_TYPE_MAP.put("long", long.class);
+        SWAGGER_TYPE_MAP.put("byte", byte.class);
+        SWAGGER_TYPE_MAP.put("boolean", boolean.class);
+        SWAGGER_TYPE_MAP.put("date", java.util.Date.class);
+        SWAGGER_TYPE_MAP.put("dateTime", java.util.Date.class);
+        SWAGGER_TYPE_MAP.put("File", java.io.InputStream.class);
+        SWAGGER_TYPE_MAP.put("file", java.io.InputStream.class);
+    }
+    private SwaggerParseUtils() {
+    }
+
+    public static UserApplication getUserApplication(String loc) {
+        return getUserApplication(loc, BusFactory.getThreadDefaultBus());
+    }
+    public static UserApplication getUserApplication(String loc, Bus bus) {
+        return getUserApplication(new ParseConfiguration(loc, bus));
+    }    
+    public static UserApplication getUserApplication(ParseConfiguration cfg) {    
+        try {
+            InputStream is = ResourceUtils.getResourceStream(cfg.getDocLocation(),
+                                                             cfg.getBus());
+            if (is == null) {
+                return null;
+            }
+            return getUserApplicationFromStream(is);
+        } catch (Exception ex) {
+            LOG.warning("Problem with processing a user model at " + cfg.getDocLocation());
+        }
+        return null;
+    }
+    public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
+        return getUserApplicationFromJson(IOUtils.readStringFromStream(is));
+    }
+    public static UserApplication getUserApplicationFromJson(String json) {
+        JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
+        Map<String, Object> map = reader.fromJson(json);
+    
+        UserApplication app = new UserApplication();
+        String relativePath = (String)map.get("basePath");
+        app.setBasePath(StringUtils.isEmpty(relativePath) ? "/" : relativePath);
+        
+        
+        Map<String, List<UserOperation>> userOpsMap = new LinkedHashMap<String, List<UserOperation>>();
+        Set<String> tags = new HashSet<String>();
+        List<Map<String, Object>> tagsProp = CastUtils.cast((List<?>)map.get("tags"));
+        if (tagsProp != null) {
+            for (Map<String, Object> tagProp : tagsProp) {
+                tags.add((String)tagProp.get("name"));
+            }
+        } else {
+            tags.add("");
+        }
+        for (String tag : tags) {
+            userOpsMap.put(tag, new LinkedList<UserOperation>());
+        }
+        
+        
+        Map<String, Map<String, Object>> paths = CastUtils.cast((Map<?, ?>)map.get("paths"));
+        for (Map.Entry<String, Map<String, Object>> pathEntry : paths.entrySet()) {
+            String operPath = pathEntry.getKey();
+            
+            Map<String, Object> operations = pathEntry.getValue();
+            for (Map.Entry<String, Object> operEntry : operations.entrySet()) {
+                
+                UserOperation userOp = new UserOperation();
+                userOp.setVerb(operEntry.getKey().toUpperCase());
+                
+                Map<String, Object> oper = CastUtils.cast((Map<?, ?>)operEntry.getValue());
+                List<String> opTags = CastUtils.cast((List<?>)oper.get("tags"));
+                String opTag = opTags == null ? "" : opTags.get(0);
+                
+                String realOpPath = operPath.equals("/" + opTag) ? "/" : operPath.substring(opTag.length() + 1);
+                userOp.setPath(realOpPath);
+                
+                userOp.setName((String)oper.get("operationId"));
+                List<String> opProduces = CastUtils.cast((List<?>)oper.get("produces"));
+                userOp.setProduces(listToString(opProduces));
+                
+                List<String> opConsumes = CastUtils.cast((List<?>)oper.get("consumes"));
+                userOp.setConsumes(listToString(opConsumes));
+                
+                List<Parameter> userOpParams = new LinkedList<Parameter>(); 
+                List<Map<String, Object>> params = CastUtils.cast((List<?>)oper.get("parameters"));
+                for (Map<String, Object> param : params) {
+                    String name = (String)param.get("name");
+                    //"query", "header", "path", "formData" or "body"
+                    String paramType = (String)param.get("in");
+                    ParameterType pType = "body".equals(paramType) ? ParameterType.REQUEST_BODY 
+                        : "formData".equals(paramType) 
+                        ? ParameterType.FORM : ParameterType.valueOf(paramType.toUpperCase()); 
+                    Parameter userParam = new Parameter(pType, name);
+                    
+                    setJavaType(userParam, (String)param.get("type"));
+                    userOpParams.add(userParam);
+                }   
+                if (!userOpParams.isEmpty()) {
+                    userOp.setParameters(userOpParams);
+                }
+                userOpsMap.get(opTag).add(userOp);    
+                
+            }
+        }
+        
+        List<UserResource> resources = new LinkedList<UserResource>();
+        
+        for (Map.Entry<String, List<UserOperation>> entry : userOpsMap.entrySet()) {
+            UserResource ur = new UserResource();
+            ur.setPath("/" + entry.getKey());
+            ur.setOperations(entry.getValue());
+            ur.setName(entry.getKey());
+            resources.add(ur);
+        }
+        
+        app.setResources(resources);
+        return app;
+    }
+    
+    private static void setJavaType(Parameter userParam, String typeName) {
+        Class<?> javaType = SWAGGER_TYPE_MAP.get(typeName);
+        if (javaType == null) {
+            try {
+                // May work if the model has already been compiled
+                // TODO: need to know the package name
+                javaType = ClassLoaderUtils.loadClass(typeName, SwaggerParseUtils.class); 
+            } catch (Throwable t) {
+                // ignore
+            }
+        }
+
+        userParam.setJavaType(javaType);
+    }
+    
+    private static String listToString(List<String> list) {
+        if (list != null) {
+            StringBuilder sb = new StringBuilder();
+            for (String s : list) {
+                if (sb.length() > 0) {
+                    sb.append(',');
+                }
+                sb.append(s);
+            }
+            return sb.toString();
+        } else {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
deleted file mode 100644
index 8e8571b..0000000
--- a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs.swagger;
-
-import java.io.InputStream;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserApplication;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SwaggerUtilsTest extends Assert {
-
-    @Test
-    public void testConvertSwaggerPetShopToUserApp() {
-        UserApplication ap = SwaggerUtils.getUserApplication("/swagger2petShop.json");
-        assertNotNull(ap);
-        assertEquals("/v2", ap.getBasePath());
-        Map<String, UserResource> map = ap.getResourcesAsMap();
-        assertEquals(3, map.size());
-        
-        UserResource pet = map.get("pet");
-        verifyPetResource(pet);
-        
-        UserResource user = map.get("user");
-        verifyPetUserResource(user);
-        
-        UserResource store = map.get("store");
-        verifyPetStoreResource(store);
-        
-    }
-    //CHECKSTYLE:OFF
-    private void verifyPetResource(UserResource ur) {
-        assertNotNull(ur);
-        assertEquals("/pet", ur.getPath());
-        assertEquals(8, ur.getOperations().size());
-        //POST /pet
-        UserOperation addPet = ur.getOperations().get(0);
-        assertEquals("addPet", addPet.getName());
-        assertEquals("/", addPet.getPath());
-        assertEquals("POST", addPet.getVerb());
-        assertEquals("application/xml,application/json", addPet.getProduces());
-        assertEquals("application/json,application/xml", addPet.getConsumes());
-        assertEquals(1, addPet.getParameters().size());
-        Parameter addPetParam1 = addPet.getParameters().get(0);
-        assertEquals("body", addPetParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, addPetParam1.getType());
-        //TODO: check that addPetParam1 refers to Pet model 
-        //TODO: check default response type: JAX-RS Response ?
-        
-        //PUT /pet
-        UserOperation putPet = ur.getOperations().get(1);
-        assertEquals("updatePet", putPet.getName());
-        assertEquals("/", putPet.getPath());
-        assertEquals("PUT", putPet.getVerb());
-        assertEquals("application/xml,application/json", addPet.getProduces());
-        assertEquals("application/json,application/xml", addPet.getConsumes());
-        assertEquals(1, putPet.getParameters().size());
-        Parameter putPetParam1 = putPet.getParameters().get(0);
-        assertEquals("body", putPetParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, putPetParam1.getType());
-        //TODO: check that putPetParam1 refers to Pet model 
-        //TODO: check default response type: JAX-RS Response ?
-        
-        //GET /pet/findByStatus
-        UserOperation findPetsByStatus = ur.getOperations().get(2);
-        assertEquals("findPetsByStatus", findPetsByStatus.getName());
-        assertEquals("/findByStatus", findPetsByStatus.getPath());
-        assertEquals("GET", findPetsByStatus.getVerb());
-        assertEquals("application/xml,application/json", findPetsByStatus.getProduces());
-        assertNull(findPetsByStatus.getConsumes());
-        assertEquals(1, findPetsByStatus.getParameters().size());
-        Parameter findPetsByStatusParam1 = findPetsByStatus.getParameters().get(0);
-        assertEquals("status", findPetsByStatusParam1.getName());
-        assertEquals(ParameterType.QUERY, findPetsByStatusParam1.getType());
-        //TODO: check that findPetsByStatusParam1 refers to List of String
-        //TODO: check that response refers to List of Pets
-        
-        //GET /pet/findByTag
-        UserOperation findPetsByTags = ur.getOperations().get(3);
-        assertEquals("findPetsByTags", findPetsByTags.getName());
-        assertEquals("/findByTags", findPetsByTags.getPath());
-        assertEquals("GET", findPetsByTags.getVerb());
-        assertEquals("application/xml,application/json", findPetsByTags.getProduces());
-        assertNull(findPetsByTags.getConsumes());
-        assertEquals(1, findPetsByTags.getParameters().size());
-        Parameter findPetsByTagsParam1 = findPetsByTags.getParameters().get(0);
-        assertEquals("tags", findPetsByTagsParam1.getName());
-        assertEquals(ParameterType.QUERY, findPetsByTagsParam1.getType());
-        //TODO: check that findPetsByTagsParam1 refers to List of String
-        //TODO: check that response refers to List of Pets
-        
-        //GET /pet/{petId}
-        UserOperation getPetById = ur.getOperations().get(4);
-        assertEquals("getPetById", getPetById.getName());
-        assertEquals("/{petId}", getPetById.getPath());
-        assertEquals("GET", getPetById.getVerb());
-        assertEquals("application/xml,application/json", getPetById.getProduces());
-        assertNull(getPetById.getConsumes());
-        assertEquals(1, getPetById.getParameters().size());
-        Parameter getPetByIdParam1 = getPetById.getParameters().get(0);
-        assertEquals("petId", getPetByIdParam1.getName());
-        assertEquals(ParameterType.PATH, getPetByIdParam1.getType());
-        assertEquals(long.class, getPetByIdParam1.getJavaType());
-        
-        //POST /pet/{petId}
-        UserOperation updatePetWithForm = ur.getOperations().get(5);
-        assertEquals("updatePetWithForm", updatePetWithForm.getName());
-        assertEquals("/{petId}", updatePetWithForm.getPath());
-        assertEquals("POST", updatePetWithForm.getVerb());
-        assertEquals("application/xml,application/json", updatePetWithForm.getProduces());
-        assertEquals("application/x-www-form-urlencoded", updatePetWithForm.getConsumes());
-        assertEquals(3, updatePetWithForm.getParameters().size());
-        Parameter updatePetWithFormParam1 = updatePetWithForm.getParameters().get(0);
-        assertEquals("petId", updatePetWithFormParam1.getName());
-        assertEquals(ParameterType.PATH, updatePetWithFormParam1.getType());
-        assertEquals(long.class, updatePetWithFormParam1.getJavaType());
-        Parameter updatePetWithFormParam2 = updatePetWithForm.getParameters().get(1);
-        assertEquals("name", updatePetWithFormParam2.getName());
-        assertEquals(ParameterType.FORM, updatePetWithFormParam2.getType());
-        assertEquals(String.class, updatePetWithFormParam2.getJavaType());
-        Parameter updatePetWithFormParam3 = updatePetWithForm.getParameters().get(2);
-        assertEquals("status", updatePetWithFormParam3.getName());
-        assertEquals(ParameterType.FORM, updatePetWithFormParam3.getType());
-        assertEquals(String.class, updatePetWithFormParam3.getJavaType());
-        
-        //DELETE /pet/{petId}
-        UserOperation deletePet = ur.getOperations().get(6);
-        assertEquals("deletePet", deletePet.getName());
-        assertEquals("/{petId}", deletePet.getPath());
-        assertEquals("DELETE", deletePet.getVerb());
-        assertEquals("application/xml,application/json", deletePet.getProduces());
-        assertNull(deletePet.getConsumes());
-        assertEquals(2, deletePet.getParameters().size());
-        Parameter deletePetParam1 = deletePet.getParameters().get(0);
-        assertEquals("api_key", deletePetParam1.getName());
-        assertEquals(ParameterType.HEADER, deletePetParam1.getType());
-        assertEquals(String.class, deletePetParam1.getJavaType());
-        Parameter deletePetParam2 = deletePet.getParameters().get(1);
-        assertEquals("petId", deletePetParam2.getName());
-        assertEquals(ParameterType.PATH, deletePetParam2.getType());
-        assertEquals(long.class, deletePetParam2.getJavaType());
-        
-        //POST /pet/{petId}/uploadImage
-        UserOperation uploadFile = ur.getOperations().get(7);
-        assertEquals("uploadFile", uploadFile.getName());
-        assertEquals("/{petId}/uploadImage", uploadFile.getPath());
-        assertEquals("POST", uploadFile.getVerb());
-        assertEquals("application/json", uploadFile.getProduces());
-        assertEquals("multipart/form-data", uploadFile.getConsumes());
-        assertEquals(3, uploadFile.getParameters().size());
-        Parameter uploadFileParam1 = uploadFile.getParameters().get(0);
-        assertEquals("petId", uploadFileParam1.getName());
-        assertEquals(ParameterType.PATH, uploadFileParam1.getType());
-        assertEquals(long.class, uploadFileParam1.getJavaType());
-        Parameter uploadFileParam2 = uploadFile.getParameters().get(1);
-        assertEquals("additionalMetadata", uploadFileParam2.getName());
-        assertEquals(ParameterType.FORM, uploadFileParam2.getType());
-        assertEquals(String.class, uploadFileParam2.getJavaType());
-        Parameter uploadFileParam3 = uploadFile.getParameters().get(2);
-        assertEquals("file", uploadFileParam3.getName());
-        assertEquals(ParameterType.FORM, uploadFileParam3.getType());
-        assertEquals(InputStream.class, uploadFileParam3.getJavaType());
-        
-    }
-    //CHECKSTYLE:ON
-    //CHECKSTYLE:OFF
-    private void verifyPetUserResource(UserResource ur) {
-        assertNotNull(ur);
-        assertEquals("/user", ur.getPath());
-        assertEquals(8, ur.getOperations().size());
-        //POST /user
-        UserOperation createUser = ur.getOperations().get(0);
-        assertEquals("createUser", createUser.getName());
-        assertEquals("/", createUser.getPath());
-        assertEquals("POST", createUser.getVerb());
-        assertEquals("application/xml,application/json", createUser.getProduces());
-        assertNull(createUser.getConsumes());
-        assertEquals(1, createUser.getParameters().size());
-        Parameter createUserParam1 = createUser.getParameters().get(0);
-        assertEquals("body", createUserParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, createUserParam1.getType());
-        //TODO: check that createUserParam1 refers to User model 
-        //TODO: check default response type: JAX-RS Response ?
-        
-        //POST /user/createWithArray
-        UserOperation createWithArray = ur.getOperations().get(1);
-        assertEquals("createUsersWithArrayInput", createWithArray.getName());
-        assertEquals("/createWithArray", createWithArray.getPath());
-        assertEquals("POST", createUser.getVerb());
-        assertEquals("application/xml,application/json", createUser.getProduces());
-        assertNull(createWithArray.getConsumes());
-        assertEquals(1, createUser.getParameters().size());
-        Parameter createWithArrayParam1 = createUser.getParameters().get(0);
-        assertEquals("body", createWithArrayParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, createWithArrayParam1.getType());
-        //TODO: check that createUserParam1 refers to an array of User model 
-        //TODO: check default response type: JAX-RS Response ?
-        
-        //POST /user/createWithList
-        UserOperation createWithList = ur.getOperations().get(2);
-        assertEquals("createUsersWithListInput", createWithList.getName());
-        assertEquals("/createWithList", createWithList.getPath());
-        assertEquals("POST", createWithList.getVerb());
-        assertEquals("application/xml,application/json", createWithList.getProduces());
-        assertNull(createWithList.getConsumes());
-        assertEquals(1, createWithList.getParameters().size());
-        Parameter createWithListParam1 = createWithList.getParameters().get(0);
-        assertEquals("body", createWithListParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, createWithListParam1.getType());
-        //TODO: check that createUserParam1 refers to an array of User model 
-        //TODO: check default response type: JAX-RS Response ?
-        
-        //GET /user/login
-        UserOperation loginUser = ur.getOperations().get(3);
-        assertEquals("loginUser", loginUser.getName());
-        assertEquals("/login", loginUser.getPath());
-        assertEquals("GET", loginUser.getVerb());
-        assertEquals("application/xml,application/json", loginUser.getProduces());
-        assertNull(loginUser.getConsumes());
-        assertEquals(2, loginUser.getParameters().size());
-        Parameter loginUserParam1 = loginUser.getParameters().get(0);
-        assertEquals("username", loginUserParam1.getName());
-        assertEquals(ParameterType.QUERY, loginUserParam1.getType());
-        assertEquals(String.class, loginUserParam1.getJavaType());
-        Parameter loginUserParam2 = loginUser.getParameters().get(1);
-        assertEquals("password", loginUserParam2.getName());
-        assertEquals(ParameterType.QUERY, loginUserParam2.getType());
-        assertEquals(String.class, loginUserParam2.getJavaType());
-        //TODO: check 200 response type
-        
-        //GET /user/logout
-        UserOperation logoutUser = ur.getOperations().get(4);
-        assertEquals("logoutUser", logoutUser.getName());
-        assertEquals("/logout", logoutUser.getPath());
-        assertEquals("GET", loginUser.getVerb());
-        assertEquals("application/xml,application/json", logoutUser.getProduces());
-        assertNull(logoutUser.getConsumes());
-        assertEquals(0, logoutUser.getParameters().size());
-        //TODO: check 200 response type
-        
-        //GET /user/{username}
-        UserOperation getUserByName = ur.getOperations().get(5);
-        assertEquals("getUserByName", getUserByName.getName());
-        assertEquals("/{username}", getUserByName.getPath());
-        assertEquals("GET", getUserByName.getVerb());
-        assertEquals("application/xml,application/json", getUserByName.getProduces());
-        assertNull(getUserByName.getConsumes());
-        assertEquals(1, getUserByName.getParameters().size());
-        Parameter getUserByNameParam1 = getUserByName.getParameters().get(0);
-        assertEquals("username", getUserByNameParam1.getName());
-        assertEquals(ParameterType.PATH, getUserByNameParam1.getType());
-        assertEquals(String.class, getUserByNameParam1.getJavaType());
-        //TODO: check 200 response type
-        
-        //PUT /user/{username}
-        UserOperation updateUser = ur.getOperations().get(6);
-        assertEquals("updateUser", updateUser.getName());
-        assertEquals("/{username}", updateUser.getPath());
-        assertEquals("PUT", updateUser.getVerb());
-        assertEquals("application/xml,application/json", updateUser.getProduces());
-        assertNull(updateUser.getConsumes());
-        assertEquals(2, updateUser.getParameters().size());
-        Parameter updateUserParam1 = updateUser.getParameters().get(0);
-        assertEquals("username", updateUserParam1.getName());
-        assertEquals(ParameterType.PATH, updateUserParam1.getType());
-        assertEquals(String.class, updateUserParam1.getJavaType());
-        Parameter updateUserParam2 = updateUser.getParameters().get(1);
-        assertEquals("body", updateUserParam2.getName());
-        assertEquals(ParameterType.REQUEST_BODY, updateUserParam2.getType());
-        //TODO: check that createUserParam1 refers to an array of User model
-        //TODO: check 200 response type
-        
-        //DELETE /user/{username}
-        UserOperation deleteUser = ur.getOperations().get(7);
-        assertEquals("deleteUser", deleteUser.getName());
-        assertEquals("/{username}", deleteUser.getPath());
-        assertEquals("DELETE", deleteUser.getVerb());
-        assertEquals("application/xml,application/json", deleteUser.getProduces());
-        assertNull(deleteUser.getConsumes());
-        assertEquals(1, deleteUser.getParameters().size());
-        Parameter deleteUserParam1 = deleteUser.getParameters().get(0);
-        assertEquals("username", deleteUserParam1.getName());
-        assertEquals(ParameterType.PATH, deleteUserParam1.getType());
-        assertEquals(String.class, deleteUserParam1.getJavaType());
-        
-    }
-    //CHECKSTYLE:ON
-    private void verifyPetStoreResource(UserResource ur) {
-        assertNotNull(ur);
-        assertEquals("/store", ur.getPath());
-        assertEquals(4, ur.getOperations().size());
-        //GET /store/inventory
-        UserOperation getInv = ur.getOperations().get(0);
-        assertEquals("getInventory", getInv.getName());
-        assertEquals("/inventory", getInv.getPath());
-        assertEquals("GET", getInv.getVerb());
-        assertEquals("application/json", getInv.getProduces());
-        assertNull(getInv.getConsumes());
-        assertEquals(0, getInv.getParameters().size());
-        //TODO: check 200 response type
-        
-        //POST /store/inventory
-        UserOperation placeOrder = ur.getOperations().get(1);
-        assertEquals("placeOrder", placeOrder.getName());
-        assertEquals("/order", placeOrder.getPath());
-        assertEquals("POST", placeOrder.getVerb());
-        assertEquals("application/xml,application/json", placeOrder.getProduces());
-        assertNull(placeOrder.getConsumes());
-        assertEquals(1, placeOrder.getParameters().size());
-        Parameter placeOrderParam1 = placeOrder.getParameters().get(0);
-        assertEquals("body", placeOrderParam1.getName());
-        assertEquals(ParameterType.REQUEST_BODY, placeOrderParam1.getType());
-        //TODO: check that placeOrderParam1 refers to Order model 
-        //TODO: check 200 response type
-        
-        //GET /store/order/{orderId}
-        UserOperation getOrderById = ur.getOperations().get(2);
-        assertEquals("getOrderById", getOrderById.getName());
-        assertEquals("/order/{orderId}", getOrderById.getPath());
-        assertEquals("GET", getOrderById.getVerb());
-        assertEquals("application/xml,application/json", getOrderById.getProduces());
-        assertNull(getOrderById.getConsumes());
-        assertEquals(1, getOrderById.getParameters().size());
-        Parameter getOrderByIdParam1 = getOrderById.getParameters().get(0);
-        assertEquals("orderId", getOrderByIdParam1.getName());
-        assertEquals(ParameterType.PATH, getOrderByIdParam1.getType());
-        assertEquals(long.class, getOrderByIdParam1.getJavaType());
-        //TODO: check 200 response type
-        
-        //DELETE /store/order/{orderId}
-        UserOperation deleteOrder = ur.getOperations().get(3);
-        assertEquals("deleteOrder", deleteOrder.getName());
-        assertEquals("/order/{orderId}", deleteOrder.getPath());
-        assertEquals("DELETE", deleteOrder.getVerb());
-        assertEquals("application/xml,application/json", deleteOrder.getProduces());
-        assertNull(deleteOrder.getConsumes());
-        assertEquals(1, getOrderById.getParameters().size());
-        Parameter deleteOrderParam1 = deleteOrder.getParameters().get(0);
-        assertEquals("orderId", deleteOrderParam1.getName());
-        assertEquals(ParameterType.PATH, deleteOrderParam1.getType());
-        assertEquals(long.class, deleteOrderParam1.getJavaType());
-        //TODO: check 200 response type
-        
-    }
-    
-    
-    @Test
-    public void testConvertSwaggerToUserApp() {
-        UserApplication ap = SwaggerUtils.getUserApplication("/swagger20.json");
-        assertNotNull(ap);
-        assertEquals("/services/helloservice", ap.getBasePath());
-        Map<String, UserResource> map = ap.getResourcesAsMap();
-        assertEquals(2, map.size());
-        
-        UserResource ur = map.get("sayHello");
-        assertNotNull(ur);
-        assertEquals("/sayHello", ur.getPath());
-        assertEquals(1, ur.getOperations().size());
-        UserOperation op = ur.getOperations().get(0);
-        assertEquals("sayHello", op.getName());
-        assertEquals("/{a}", op.getPath());
-        assertEquals("GET", op.getVerb());
-        assertEquals("text/plain", op.getProduces());
-        
-        assertEquals(1, op.getParameters().size());
-        Parameter param1 = op.getParameters().get(0);
-        assertEquals("a", param1.getName());
-        assertEquals(ParameterType.PATH, param1.getType());
-        assertEquals(String.class, param1.getJavaType());
-        
-        UserResource ur2 = map.get("sayHello2");
-        assertNotNull(ur2);
-        assertEquals("/sayHello2", ur2.getPath());
-        assertEquals(1, ur2.getOperations().size());
-        UserOperation op2 = ur2.getOperations().get(0);
-        assertEquals("sayHello", op2.getName());
-        assertEquals("/{a}", op2.getPath());
-        assertEquals("GET", op2.getVerb());
-        assertEquals("text/plain", op2.getProduces());
-        
-        assertEquals(1, op2.getParameters().size());
-        Parameter param2 = op.getParameters().get(0);
-        assertEquals("a", param2.getName());
-        assertEquals(ParameterType.PATH, param2.getType());
-        assertEquals(String.class, param2.getJavaType());
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java
new file mode 100644
index 0000000..13b20dc7
--- /dev/null
+++ b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/parse/SwaggerParseUtilsTest.java
@@ -0,0 +1,410 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.swagger.parse;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserApplication;
+import org.apache.cxf.jaxrs.model.UserOperation;
+import org.apache.cxf.jaxrs.model.UserResource;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SwaggerParseUtilsTest extends Assert {
+
+    @Test
+    public void testConvertSwaggerPetShopToUserApp() {
+        UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger2petShop.json");
+        assertNotNull(ap);
+        assertEquals("/v2", ap.getBasePath());
+        Map<String, UserResource> map = ap.getResourcesAsMap();
+        assertEquals(3, map.size());
+        
+        UserResource pet = map.get("pet");
+        verifyPetResource(pet);
+        
+        UserResource user = map.get("user");
+        verifyPetUserResource(user);
+        
+        UserResource store = map.get("store");
+        verifyPetStoreResource(store);
+        
+    }
+    //CHECKSTYLE:OFF
+    private void verifyPetResource(UserResource ur) {
+        assertNotNull(ur);
+        assertEquals("/pet", ur.getPath());
+        assertEquals(8, ur.getOperations().size());
+        //POST /pet
+        UserOperation addPet = ur.getOperations().get(0);
+        assertEquals("addPet", addPet.getName());
+        assertEquals("/", addPet.getPath());
+        assertEquals("POST", addPet.getVerb());
+        assertEquals("application/xml,application/json", addPet.getProduces());
+        assertEquals("application/json,application/xml", addPet.getConsumes());
+        assertEquals(1, addPet.getParameters().size());
+        Parameter addPetParam1 = addPet.getParameters().get(0);
+        assertEquals("body", addPetParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, addPetParam1.getType());
+        //TODO: check that addPetParam1 refers to Pet model 
+        //TODO: check default response type: JAX-RS Response ?
+        
+        //PUT /pet
+        UserOperation putPet = ur.getOperations().get(1);
+        assertEquals("updatePet", putPet.getName());
+        assertEquals("/", putPet.getPath());
+        assertEquals("PUT", putPet.getVerb());
+        assertEquals("application/xml,application/json", addPet.getProduces());
+        assertEquals("application/json,application/xml", addPet.getConsumes());
+        assertEquals(1, putPet.getParameters().size());
+        Parameter putPetParam1 = putPet.getParameters().get(0);
+        assertEquals("body", putPetParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, putPetParam1.getType());
+        //TODO: check that putPetParam1 refers to Pet model 
+        //TODO: check default response type: JAX-RS Response ?
+        
+        //GET /pet/findByStatus
+        UserOperation findPetsByStatus = ur.getOperations().get(2);
+        assertEquals("findPetsByStatus", findPetsByStatus.getName());
+        assertEquals("/findByStatus", findPetsByStatus.getPath());
+        assertEquals("GET", findPetsByStatus.getVerb());
+        assertEquals("application/xml,application/json", findPetsByStatus.getProduces());
+        assertNull(findPetsByStatus.getConsumes());
+        assertEquals(1, findPetsByStatus.getParameters().size());
+        Parameter findPetsByStatusParam1 = findPetsByStatus.getParameters().get(0);
+        assertEquals("status", findPetsByStatusParam1.getName());
+        assertEquals(ParameterType.QUERY, findPetsByStatusParam1.getType());
+        //TODO: check that findPetsByStatusParam1 refers to List of String
+        //TODO: check that response refers to List of Pets
+        
+        //GET /pet/findByTag
+        UserOperation findPetsByTags = ur.getOperations().get(3);
+        assertEquals("findPetsByTags", findPetsByTags.getName());
+        assertEquals("/findByTags", findPetsByTags.getPath());
+        assertEquals("GET", findPetsByTags.getVerb());
+        assertEquals("application/xml,application/json", findPetsByTags.getProduces());
+        assertNull(findPetsByTags.getConsumes());
+        assertEquals(1, findPetsByTags.getParameters().size());
+        Parameter findPetsByTagsParam1 = findPetsByTags.getParameters().get(0);
+        assertEquals("tags", findPetsByTagsParam1.getName());
+        assertEquals(ParameterType.QUERY, findPetsByTagsParam1.getType());
+        //TODO: check that findPetsByTagsParam1 refers to List of String
+        //TODO: check that response refers to List of Pets
+        
+        //GET /pet/{petId}
+        UserOperation getPetById = ur.getOperations().get(4);
+        assertEquals("getPetById", getPetById.getName());
+        assertEquals("/{petId}", getPetById.getPath());
+        assertEquals("GET", getPetById.getVerb());
+        assertEquals("application/xml,application/json", getPetById.getProduces());
+        assertNull(getPetById.getConsumes());
+        assertEquals(1, getPetById.getParameters().size());
+        Parameter getPetByIdParam1 = getPetById.getParameters().get(0);
+        assertEquals("petId", getPetByIdParam1.getName());
+        assertEquals(ParameterType.PATH, getPetByIdParam1.getType());
+        assertEquals(long.class, getPetByIdParam1.getJavaType());
+        
+        //POST /pet/{petId}
+        UserOperation updatePetWithForm = ur.getOperations().get(5);
+        assertEquals("updatePetWithForm", updatePetWithForm.getName());
+        assertEquals("/{petId}", updatePetWithForm.getPath());
+        assertEquals("POST", updatePetWithForm.getVerb());
+        assertEquals("application/xml,application/json", updatePetWithForm.getProduces());
+        assertEquals("application/x-www-form-urlencoded", updatePetWithForm.getConsumes());
+        assertEquals(3, updatePetWithForm.getParameters().size());
+        Parameter updatePetWithFormParam1 = updatePetWithForm.getParameters().get(0);
+        assertEquals("petId", updatePetWithFormParam1.getName());
+        assertEquals(ParameterType.PATH, updatePetWithFormParam1.getType());
+        assertEquals(long.class, updatePetWithFormParam1.getJavaType());
+        Parameter updatePetWithFormParam2 = updatePetWithForm.getParameters().get(1);
+        assertEquals("name", updatePetWithFormParam2.getName());
+        assertEquals(ParameterType.FORM, updatePetWithFormParam2.getType());
+        assertEquals(String.class, updatePetWithFormParam2.getJavaType());
+        Parameter updatePetWithFormParam3 = updatePetWithForm.getParameters().get(2);
+        assertEquals("status", updatePetWithFormParam3.getName());
+        assertEquals(ParameterType.FORM, updatePetWithFormParam3.getType());
+        assertEquals(String.class, updatePetWithFormParam3.getJavaType());
+        
+        //DELETE /pet/{petId}
+        UserOperation deletePet = ur.getOperations().get(6);
+        assertEquals("deletePet", deletePet.getName());
+        assertEquals("/{petId}", deletePet.getPath());
+        assertEquals("DELETE", deletePet.getVerb());
+        assertEquals("application/xml,application/json", deletePet.getProduces());
+        assertNull(deletePet.getConsumes());
+        assertEquals(2, deletePet.getParameters().size());
+        Parameter deletePetParam1 = deletePet.getParameters().get(0);
+        assertEquals("api_key", deletePetParam1.getName());
+        assertEquals(ParameterType.HEADER, deletePetParam1.getType());
+        assertEquals(String.class, deletePetParam1.getJavaType());
+        Parameter deletePetParam2 = deletePet.getParameters().get(1);
+        assertEquals("petId", deletePetParam2.getName());
+        assertEquals(ParameterType.PATH, deletePetParam2.getType());
+        assertEquals(long.class, deletePetParam2.getJavaType());
+        
+        //POST /pet/{petId}/uploadImage
+        UserOperation uploadFile = ur.getOperations().get(7);
+        assertEquals("uploadFile", uploadFile.getName());
+        assertEquals("/{petId}/uploadImage", uploadFile.getPath());
+        assertEquals("POST", uploadFile.getVerb());
+        assertEquals("application/json", uploadFile.getProduces());
+        assertEquals("multipart/form-data", uploadFile.getConsumes());
+        assertEquals(3, uploadFile.getParameters().size());
+        Parameter uploadFileParam1 = uploadFile.getParameters().get(0);
+        assertEquals("petId", uploadFileParam1.getName());
+        assertEquals(ParameterType.PATH, uploadFileParam1.getType());
+        assertEquals(long.class, uploadFileParam1.getJavaType());
+        Parameter uploadFileParam2 = uploadFile.getParameters().get(1);
+        assertEquals("additionalMetadata", uploadFileParam2.getName());
+        assertEquals(ParameterType.FORM, uploadFileParam2.getType());
+        assertEquals(String.class, uploadFileParam2.getJavaType());
+        Parameter uploadFileParam3 = uploadFile.getParameters().get(2);
+        assertEquals("file", uploadFileParam3.getName());
+        assertEquals(ParameterType.FORM, uploadFileParam3.getType());
+        assertEquals(InputStream.class, uploadFileParam3.getJavaType());
+        
+    }
+    //CHECKSTYLE:ON
+    //CHECKSTYLE:OFF
+    private void verifyPetUserResource(UserResource ur) {
+        assertNotNull(ur);
+        assertEquals("/user", ur.getPath());
+        assertEquals(8, ur.getOperations().size());
+        //POST /user
+        UserOperation createUser = ur.getOperations().get(0);
+        assertEquals("createUser", createUser.getName());
+        assertEquals("/", createUser.getPath());
+        assertEquals("POST", createUser.getVerb());
+        assertEquals("application/xml,application/json", createUser.getProduces());
+        assertNull(createUser.getConsumes());
+        assertEquals(1, createUser.getParameters().size());
+        Parameter createUserParam1 = createUser.getParameters().get(0);
+        assertEquals("body", createUserParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, createUserParam1.getType());
+        //TODO: check that createUserParam1 refers to User model 
+        //TODO: check default response type: JAX-RS Response ?
+        
+        //POST /user/createWithArray
+        UserOperation createWithArray = ur.getOperations().get(1);
+        assertEquals("createUsersWithArrayInput", createWithArray.getName());
+        assertEquals("/createWithArray", createWithArray.getPath());
+        assertEquals("POST", createUser.getVerb());
+        assertEquals("application/xml,application/json", createUser.getProduces());
+        assertNull(createWithArray.getConsumes());
+        assertEquals(1, createUser.getParameters().size());
+        Parameter createWithArrayParam1 = createUser.getParameters().get(0);
+        assertEquals("body", createWithArrayParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, createWithArrayParam1.getType());
+        //TODO: check that createUserParam1 refers to an array of User model 
+        //TODO: check default response type: JAX-RS Response ?
+        
+        //POST /user/createWithList
+        UserOperation createWithList = ur.getOperations().get(2);
+        assertEquals("createUsersWithListInput", createWithList.getName());
+        assertEquals("/createWithList", createWithList.getPath());
+        assertEquals("POST", createWithList.getVerb());
+        assertEquals("application/xml,application/json", createWithList.getProduces());
+        assertNull(createWithList.getConsumes());
+        assertEquals(1, createWithList.getParameters().size());
+        Parameter createWithListParam1 = createWithList.getParameters().get(0);
+        assertEquals("body", createWithListParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, createWithListParam1.getType());
+        //TODO: check that createUserParam1 refers to an array of User model 
+        //TODO: check default response type: JAX-RS Response ?
+        
+        //GET /user/login
+        UserOperation loginUser = ur.getOperations().get(3);
+        assertEquals("loginUser", loginUser.getName());
+        assertEquals("/login", loginUser.getPath());
+        assertEquals("GET", loginUser.getVerb());
+        assertEquals("application/xml,application/json", loginUser.getProduces());
+        assertNull(loginUser.getConsumes());
+        assertEquals(2, loginUser.getParameters().size());
+        Parameter loginUserParam1 = loginUser.getParameters().get(0);
+        assertEquals("username", loginUserParam1.getName());
+        assertEquals(ParameterType.QUERY, loginUserParam1.getType());
+        assertEquals(String.class, loginUserParam1.getJavaType());
+        Parameter loginUserParam2 = loginUser.getParameters().get(1);
+        assertEquals("password", loginUserParam2.getName());
+        assertEquals(ParameterType.QUERY, loginUserParam2.getType());
+        assertEquals(String.class, loginUserParam2.getJavaType());
+        //TODO: check 200 response type
+        
+        //GET /user/logout
+        UserOperation logoutUser = ur.getOperations().get(4);
+        assertEquals("logoutUser", logoutUser.getName());
+        assertEquals("/logout", logoutUser.getPath());
+        assertEquals("GET", loginUser.getVerb());
+        assertEquals("application/xml,application/json", logoutUser.getProduces());
+        assertNull(logoutUser.getConsumes());
+        assertEquals(0, logoutUser.getParameters().size());
+        //TODO: check 200 response type
+        
+        //GET /user/{username}
+        UserOperation getUserByName = ur.getOperations().get(5);
+        assertEquals("getUserByName", getUserByName.getName());
+        assertEquals("/{username}", getUserByName.getPath());
+        assertEquals("GET", getUserByName.getVerb());
+        assertEquals("application/xml,application/json", getUserByName.getProduces());
+        assertNull(getUserByName.getConsumes());
+        assertEquals(1, getUserByName.getParameters().size());
+        Parameter getUserByNameParam1 = getUserByName.getParameters().get(0);
+        assertEquals("username", getUserByNameParam1.getName());
+        assertEquals(ParameterType.PATH, getUserByNameParam1.getType());
+        assertEquals(String.class, getUserByNameParam1.getJavaType());
+        //TODO: check 200 response type
+        
+        //PUT /user/{username}
+        UserOperation updateUser = ur.getOperations().get(6);
+        assertEquals("updateUser", updateUser.getName());
+        assertEquals("/{username}", updateUser.getPath());
+        assertEquals("PUT", updateUser.getVerb());
+        assertEquals("application/xml,application/json", updateUser.getProduces());
+        assertNull(updateUser.getConsumes());
+        assertEquals(2, updateUser.getParameters().size());
+        Parameter updateUserParam1 = updateUser.getParameters().get(0);
+        assertEquals("username", updateUserParam1.getName());
+        assertEquals(ParameterType.PATH, updateUserParam1.getType());
+        assertEquals(String.class, updateUserParam1.getJavaType());
+        Parameter updateUserParam2 = updateUser.getParameters().get(1);
+        assertEquals("body", updateUserParam2.getName());
+        assertEquals(ParameterType.REQUEST_BODY, updateUserParam2.getType());
+        //TODO: check that createUserParam1 refers to an array of User model
+        //TODO: check 200 response type
+        
+        //DELETE /user/{username}
+        UserOperation deleteUser = ur.getOperations().get(7);
+        assertEquals("deleteUser", deleteUser.getName());
+        assertEquals("/{username}", deleteUser.getPath());
+        assertEquals("DELETE", deleteUser.getVerb());
+        assertEquals("application/xml,application/json", deleteUser.getProduces());
+        assertNull(deleteUser.getConsumes());
+        assertEquals(1, deleteUser.getParameters().size());
+        Parameter deleteUserParam1 = deleteUser.getParameters().get(0);
+        assertEquals("username", deleteUserParam1.getName());
+        assertEquals(ParameterType.PATH, deleteUserParam1.getType());
+        assertEquals(String.class, deleteUserParam1.getJavaType());
+        
+    }
+    //CHECKSTYLE:ON
+    private void verifyPetStoreResource(UserResource ur) {
+        assertNotNull(ur);
+        assertEquals("/store", ur.getPath());
+        assertEquals(4, ur.getOperations().size());
+        //GET /store/inventory
+        UserOperation getInv = ur.getOperations().get(0);
+        assertEquals("getInventory", getInv.getName());
+        assertEquals("/inventory", getInv.getPath());
+        assertEquals("GET", getInv.getVerb());
+        assertEquals("application/json", getInv.getProduces());
+        assertNull(getInv.getConsumes());
+        assertEquals(0, getInv.getParameters().size());
+        //TODO: check 200 response type
+        
+        //POST /store/inventory
+        UserOperation placeOrder = ur.getOperations().get(1);
+        assertEquals("placeOrder", placeOrder.getName());
+        assertEquals("/order", placeOrder.getPath());
+        assertEquals("POST", placeOrder.getVerb());
+        assertEquals("application/xml,application/json", placeOrder.getProduces());
+        assertNull(placeOrder.getConsumes());
+        assertEquals(1, placeOrder.getParameters().size());
+        Parameter placeOrderParam1 = placeOrder.getParameters().get(0);
+        assertEquals("body", placeOrderParam1.getName());
+        assertEquals(ParameterType.REQUEST_BODY, placeOrderParam1.getType());
+        //TODO: check that placeOrderParam1 refers to Order model 
+        //TODO: check 200 response type
+        
+        //GET /store/order/{orderId}
+        UserOperation getOrderById = ur.getOperations().get(2);
+        assertEquals("getOrderById", getOrderById.getName());
+        assertEquals("/order/{orderId}", getOrderById.getPath());
+        assertEquals("GET", getOrderById.getVerb());
+        assertEquals("application/xml,application/json", getOrderById.getProduces());
+        assertNull(getOrderById.getConsumes());
+        assertEquals(1, getOrderById.getParameters().size());
+        Parameter getOrderByIdParam1 = getOrderById.getParameters().get(0);
+        assertEquals("orderId", getOrderByIdParam1.getName());
+        assertEquals(ParameterType.PATH, getOrderByIdParam1.getType());
+        assertEquals(long.class, getOrderByIdParam1.getJavaType());
+        //TODO: check 200 response type
+        
+        //DELETE /store/order/{orderId}
+        UserOperation deleteOrder = ur.getOperations().get(3);
+        assertEquals("deleteOrder", deleteOrder.getName());
+        assertEquals("/order/{orderId}", deleteOrder.getPath());
+        assertEquals("DELETE", deleteOrder.getVerb());
+        assertEquals("application/xml,application/json", deleteOrder.getProduces());
+        assertNull(deleteOrder.getConsumes());
+        assertEquals(1, getOrderById.getParameters().size());
+        Parameter deleteOrderParam1 = deleteOrder.getParameters().get(0);
+        assertEquals("orderId", deleteOrderParam1.getName());
+        assertEquals(ParameterType.PATH, deleteOrderParam1.getType());
+        assertEquals(long.class, deleteOrderParam1.getJavaType());
+        //TODO: check 200 response type
+        
+    }
+    
+    
+    @Test
+    public void testConvertSwaggerToUserApp() {
+        UserApplication ap = SwaggerParseUtils.getUserApplication("/swagger20.json");
+        assertNotNull(ap);
+        assertEquals("/services/helloservice", ap.getBasePath());
+        Map<String, UserResource> map = ap.getResourcesAsMap();
+        assertEquals(2, map.size());
+        
+        UserResource ur = map.get("sayHello");
+        assertNotNull(ur);
+        assertEquals("/sayHello", ur.getPath());
+        assertEquals(1, ur.getOperations().size());
+        UserOperation op = ur.getOperations().get(0);
+        assertEquals("sayHello", op.getName());
+        assertEquals("/{a}", op.getPath());
+        assertEquals("GET", op.getVerb());
+        assertEquals("text/plain", op.getProduces());
+        
+        assertEquals(1, op.getParameters().size());
+        Parameter param1 = op.getParameters().get(0);
+        assertEquals("a", param1.getName());
+        assertEquals(ParameterType.PATH, param1.getType());
+        assertEquals(String.class, param1.getJavaType());
+        
+        UserResource ur2 = map.get("sayHello2");
+        assertNotNull(ur2);
+        assertEquals("/sayHello2", ur2.getPath());
+        assertEquals(1, ur2.getOperations().size());
+        UserOperation op2 = ur2.getOperations().get(0);
+        assertEquals("sayHello", op2.getName());
+        assertEquals("/{a}", op2.getPath());
+        assertEquals("GET", op2.getVerb());
+        assertEquals("text/plain", op2.getProduces());
+        
+        assertEquals(1, op2.getParameters().size());
+        Parameter param2 = op.getParameters().get(0);
+        assertEquals("a", param2.getName());
+        assertEquals(ParameterType.PATH, param2.getType());
+        assertEquals(String.class, param2.getJavaType());
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/ad8d7467/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
index ba08f07..0d9b652 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
@@ -46,7 +46,7 @@ import org.apache.cxf.jaxrs.model.UserApplication;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.apache.cxf.jaxrs.swagger.SwaggerUtils;
+import org.apache.cxf.jaxrs.swagger.parse.SwaggerParseUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
@@ -122,7 +122,7 @@ public abstract class AbstractSwagger2ServiceDescriptionTest extends AbstractBus
         final WebClient client = createWebClient("/swagger.json");
         try {
             String swaggerJson = client.get(String.class);
-            UserApplication ap = SwaggerUtils.getUserApplicationFromJson(swaggerJson);
+            UserApplication ap = SwaggerParseUtils.getUserApplicationFromJson(swaggerJson);
             assertNotNull(ap);
             
             List<UserResource> urs = ap.getResources();


Mime
View raw message