From d70742119bd688c4915880f9965cfcc788b943d5 Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 5 Jun 2015 16:45:19 +0800 Subject: [PATCH] Update unit tests --- .../java/io/swagger/client/ApiClientTest.java | 48 +++++++++++++++++++ .../io/swagger/client/ApiInvokerTest.java | 42 ---------------- 2 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java delete mode 100644 samples/client/petstore/java/src/test/java/io/swagger/client/ApiInvokerTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java new file mode 100644 index 00000000000..891b8e17d13 --- /dev/null +++ b/samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java @@ -0,0 +1,48 @@ +package io.swagger.client; + +import static org.junit.Assert.*; +import org.junit.*; + +public class ApiClientTest { + ApiClient apiClient = null; + + @Before + public void setup() { + apiClient = new ApiClient(); + } + @Test + public void testSelectHeaderAccept() { + String[] accepts = { "APPLICATION/JSON", "APPLICATION/XML" }; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[] { "application/json", "application/xml" }; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[] { "application/xml", "application/json" }; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[] { "text/plain", "application/xml" }; + assertEquals("text/plain,application/xml", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[] { }; + assertNull(apiClient.selectHeaderAccept(accepts)); + } + + @Test + public void testSelectHeaderContentType() { + String[] contentTypes = { "APPLICATION/JSON", "APPLICATION/XML" }; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[] { "application/json", "application/xml" }; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[] { "application/xml", "application/json" }; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[] { "text/plain", "application/xml" }; + assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[] { }; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + } +} diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/ApiInvokerTest.java b/samples/client/petstore/java/src/test/java/io/swagger/client/ApiInvokerTest.java deleted file mode 100644 index f117e6364df..00000000000 --- a/samples/client/petstore/java/src/test/java/io/swagger/client/ApiInvokerTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.swagger.client; - -import static org.junit.Assert.*; -import org.junit.*; - -public class ApiInvokerTest { - @Test - public void testSelectHeaderAccept() { - String[] accepts = { "APPLICATION/JSON", "APPLICATION/XML" }; - assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts)); - - accepts = new String[] { "application/json", "application/xml" }; - assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts)); - - accepts = new String[] { "application/xml", "application/json" }; - assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts)); - - accepts = new String[] { "text/plain", "application/xml" }; - assertEquals("text/plain,application/xml", ApiInvoker.selectHeaderAccept(accepts)); - - accepts = new String[] { }; - assertNull(ApiInvoker.selectHeaderAccept(accepts)); - } - - @Test - public void testSelectHeaderContentType() { - String[] contentTypes = { "APPLICATION/JSON", "APPLICATION/XML" }; - assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes)); - - contentTypes = new String[] { "application/json", "application/xml" }; - assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes)); - - contentTypes = new String[] { "application/xml", "application/json" }; - assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes)); - - contentTypes = new String[] { "text/plain", "application/xml" }; - assertEquals("text/plain", ApiInvoker.selectHeaderContentType(contentTypes)); - - contentTypes = new String[] { }; - assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes)); - } -}