mirror of https://github.com/apache/jclouds.git
Issue 77: iso8601 timezones aren't supported in DateService. changed to use regular DateTime constructor
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1639 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
cf8fa7aa33
commit
73ec708b03
|
@ -71,7 +71,10 @@ public class ParserModule extends AbstractModule {
|
|||
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
String toParse = json.getAsJsonPrimitive().getAsString();
|
||||
return dateService.iso8601DateParse(toParse);
|
||||
DateTime toReturn = dateService.iso8601DateParse(toParse);
|
||||
if (toReturn == null) toReturn = new DateTime(toParse);
|
||||
if (toReturn == null) throw new RuntimeException("could not parse: "+toParse);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,9 +121,9 @@ public class CloudServersConnectionLiveTest {
|
|||
for (Image image : response) {
|
||||
assertTrue(image.getId() >= 1);
|
||||
assert null != image.getName() : image;
|
||||
// TODO: Web Hosting #118779
|
||||
// sometimes this is not present per: Web Hosting #118820
|
||||
// assert null != image.getCreated() : image;
|
||||
// assert null != image.getUpdated() : image;
|
||||
assert null != image.getUpdated() : image;
|
||||
assert null != image.getStatus() : image;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.http.functions.config.ParserModule;
|
|||
import org.jclouds.rackspace.cloudservers.domain.Image;
|
||||
import org.jclouds.rackspace.cloudservers.domain.ImageStatus;
|
||||
import org.jclouds.util.DateService;
|
||||
import org.joda.time.DateTime;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -69,23 +70,20 @@ public class ParseImageListFromGsonResponseTest {
|
|||
List<Image> response = parser.apply(is);
|
||||
assertEquals(response.get(0).getId(), 2);
|
||||
assertEquals(response.get(0).getName(), "CentOS 5.2");
|
||||
// Web Hosting #118779
|
||||
assertEquals(null, response.get(0).getCreated());
|
||||
assertEquals(response.get(0).getCreated(), new DateTime("2010-08-10T12:00:00Z"));
|
||||
assertEquals(response.get(0).getProgress(), null);
|
||||
assertEquals(response.get(0).getServerId(), null);
|
||||
assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE);
|
||||
assertEquals(response.get(0).getUpdated(), dateService
|
||||
.iso8601DateParse("2010-10-10T12:00:00Z"));
|
||||
assertEquals(response.get(0).getUpdated(), new DateTime("2010-10-10T12:00:00Z"));
|
||||
|
||||
assertEquals(response.get(1).getId(), 743);
|
||||
assertEquals(response.get(1).getName(), "My Server Backup");
|
||||
assertEquals(response.get(1).getCreated(), dateService
|
||||
.iso8601DateParse("2010-08-10T12:00:00Z"));
|
||||
assertEquals(response.get(1).getCreated(), new DateTime("2009-07-07T09:56:16-05:00"));
|
||||
;
|
||||
assertEquals(response.get(1).getProgress(), new Integer(80));
|
||||
assertEquals(response.get(1).getServerId(), new Integer(12));
|
||||
assertEquals(response.get(1).getStatus(), ImageStatus.SAVING);
|
||||
assertEquals(response.get(1).getUpdated(), dateService
|
||||
.iso8601DateParse("2010-10-10T12:00:00Z"));
|
||||
assertEquals(response.get(1).getUpdated(), new DateTime("2010-10-10T12:00:00Z"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue