Fix tests on date format by using custom date format

This commit is contained in:
xhh 2015-11-12 17:10:03 +08:00
parent e3c44b5af3
commit 55bcceac07
3 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.junit.*;
import static org.junit.Assert.*;
@ -21,6 +22,8 @@ public class StoreApiTest {
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
// set custom date format that is used by the petstore server
api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
}
@Test

View File

@ -8,6 +8,7 @@ import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.junit.*;
import static org.junit.Assert.*;
@ -21,6 +22,8 @@ public class StoreApiTest {
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
// set custom date format that is used by the petstore server
api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
}
@Test

View File

@ -8,6 +8,7 @@ import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.junit.*;
import static org.junit.Assert.*;
@ -21,6 +22,10 @@ public class StoreApiTest {
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
// set custom date format that is used by the petstore server
// Note: it would still work without this setting as okhttp-gson Java client supports
// various date formats by default, including the one used by petstore server
api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
}
@Test