protected Date parseDate(String toParse) { try { return dateService.iso8601DateParse(toParse); } catch (RuntimeException e) { return dateService.iso8601SecondsDateParse(toParse); } }
public CopyOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { this.headers.put(HttpHeaders.IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(ifUnmodifiedSince)); return this; } }
/** * End date of the request. If this is a one-time request, the request remains active until all * instances launch, the request is canceled, or this date is reached. If the request is * persistent, it remains active until it is canceled or this date and time is reached. */ public RequestSpotInstancesOptions validUntil(Date end) { formParameters.put("ValidUntil", service.iso8601SecondsDateFormat(checkNotNull(end, "end"))); return this; }
creationDate = new Date(0); .iso8601DateFormat(creationDate).trim());
public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); Invokable<?, ?> method = method(TestRequest.class, "get", String.class, HttpRequestOptions.class); GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of("1", options))); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 2); assertEquals(request.getHeaders().get(HttpHeaders.HOST), ImmutableList.of("localhost:9999")); assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE), ImmutableList.of(dateService.rfc822DateFormat(date))); }
@Test void testUTCIsGMT() { assertEquals(dateService.iso8601SecondsDateParse("2012-11-26T17:32:31UTC+0000").getTime(), dateService.iso8601SecondsDateParse("2012-11-26T17:32:31UTC+0000").getTime()); }
@Test void testTzNoT() { assertEquals(dateService.iso8601DateParse("2011-05-25 16:12:21.656+0000").getTime(), 1306339941656l); }
public void testApplyInputStream() { DateService dateService = injector.getInstance(DateService.class); InputStream is = getClass().getResourceAsStream("/describe_bundle_tasks.xml"); BundleTask expected = new BundleTask(defaultRegion, "bun-c1a540a8", null, "i-12345678", 20, dateService .iso8601DateParse("2008-10-07T11:41:50.000Z"), "canceling", "my-bucket", "winami", dateService .iso8601DateParse("2008-10-07T11:51:50.000Z")); DescribeBundleTasksResponseHandler handler = injector.getInstance(DescribeBundleTasksResponseHandler.class); addDefaultRegionToHandler(handler); BundleTask result = Iterables.getOnlyElement(factory.create(handler).parse(is)); assertEquals(result, expected); }
public void testApplyInputStream2() { InputStream is = getClass().getResourceAsStream("/task-hosting.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), null, TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService .iso8601SecondsDateParse("2010-01-15T20:05:02Z"), new ReferenceTypeImpl("188849-96", VCloudMediaType.VAPP_XML, URI .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null); assertEquals(result, expects); }
@Test public void testIso8601SecondsDateParse() { Date dsDate = dateService.iso8601SecondsDateParse(testData[0].iso8601SecondsDateString); assertEquals(dsDate, testData[0].date); }
@Test public void testRfc822DateFormat() { String dsString = dateService.rfc822DateFormat(testData[0].date); assertEquals(dsString, testData[0].rfc822DateString); }
@Test public void testRfc822DateParse() { Date dsDate = dateService.rfc822DateParse(testData[0].rfc822DateString); assertEquals(dsDate, testData[0].date); }
/** * The ending date to retrieve alarm history. * * @param endDate the ending date to retrieve alarm history * * @return this {@code ListAlarmHistoryOptions} object */ public ListAlarmHistoryOptions endDate(Date endDate) { formParameters.put("EndDate", dateService.iso8601DateFormat(checkNotNull(endDate, "endDate"))); return this; }
@Test public void testIso8601SecondsDateFormat() { String dsString = dateService.iso8601SecondsDateFormat(testData[0].date); assertEquals(dsString, testData[0].iso8601SecondsDateString); }
@Test public void testIso8601DateParse() { Date dsDate = dateService.iso8601DateParse(testData[0].iso8601DateString); assertEquals(dsDate, testData[0].date); }
@Test public void testIso8601DateFormat() { String dsString = dateService.iso8601DateFormat(testData[0].date); assertEquals(dsString, testData[0].iso8601DateString); }
@Test public void testIso8601DateOrSecondsDateParse() { Date dsDate = dateService .iso8601DateOrSecondsDateParse(testData[0].iso8601DateString); assertEquals(dsDate, testData[0].date); Date dsSecondsDate = dateService .iso8601DateOrSecondsDateParse(testData[0].iso8601SecondsDateString); assertEquals(dsSecondsDate, testData[0].date); }
@Test public void testApply() throws Exception { WindowsLoginCredentialsFromEncryptedData f = new WindowsLoginCredentialsFromEncryptedData(new JCECrypto()); PasswordData passwordData = PasswordData.builder() .instanceId("i-2574e22a") .timestamp(dateService.iso8601DateParse("2012-07-30T07:27:23.000+0000")) .passwordData(ENCRYPTED_PASSWORD).build(); LoginCredentials credentials = f.apply(new PasswordDataAndPrivateKey(passwordData, PRIVATE_KEY)); assertEquals(credentials.getUser(), "Administrator"); assertEquals(credentials.getPassword(), "u4.y9mb;nR."); assertFalse(credentials.getOptionalPrivateKey().isPresent()); } }
public void testOptions() { InputStream is = getClass().getResourceAsStream("/test_list_blobs_options.xml"); Set<BlobProperties> contents = ImmutableSet.<BlobProperties> of(new BlobPropertiesImpl(BlobType.BLOCK_BLOB, "a", "adriancole-blobstore3", URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore3/a"), dateService.rfc822DateParse("Sat, 30 Jan 2010 17:46:15 GMT"), "0x8CC6FEB41736428", 8, "application/octet-stream", null, null, null, null, LeaseStatus.UNLOCKED, ImmutableMap.<String, String> of())); ListBlobsResponse list = new HashSetListBlobsResponse(contents, URI.create("https://jclouds.blob.core.windows.net/adriancole-blobstore3"), null, null, 1, "2!68!MDAwMDA2IWFwcGxlcyEwMDAwMjghOTk5OS0xMi0zMVQyMzo1OTo1OS45OTk5OTk5WiE-", "/", Sets.<String> newTreeSet()); ListBlobsResponse result = factory.create( injector.getInstance(ContainerNameEnumerationResultsHandler.class)).parse(is); assertEquals(result, list); } }
@Test void testParseIso8601DateSerialResponseTime() { for (int i = 0; i < LOOP_COUNT; i++) dateService.iso8601DateParse(testData[0].iso8601DateString); }