Search in sources :

Example 11 with Date

use of java.util.Date in project buck by facebook.

the class AaptPackageResourcesIntegrationTest method testAaptPackageIsScrubbed.

@Test
public void testAaptPackageIsScrubbed() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    workspace.runBuckBuild(MAIN_BUILD_TARGET).assertSuccess();
    Path aaptOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(MAIN_BUILD_TARGET).withFlavors(AndroidBinaryGraphEnhancer.AAPT_PACKAGE_FLAVOR), AaptPackageResources.RESOURCE_APK_PATH_FORMAT));
    Date dosEpoch = new Date(ZipUtil.dosToJavaTime(ZipConstants.DOS_FAKE_TIME));
    try (ZipInputStream is = new ZipInputStream(new FileInputStream(aaptOutput.toFile()))) {
        for (ZipEntry entry = is.getNextEntry(); entry != null; entry = is.getNextEntry()) {
            assertThat(entry.getName(), new Date(entry.getTime()), Matchers.equalTo(dosEpoch));
        }
    }
}
Also used : Path(java.nio.file.Path) ZipInputStream(java.util.zip.ZipInputStream) ZipEntry(java.util.zip.ZipEntry) Date(java.util.Date) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 12 with Date

use of java.util.Date in project buck by facebook.

the class ProvisioningProfileStoreTest method testEntitlementKeysAreMatched.

@Test
public void testEntitlementKeysAreMatched() throws Exception {
    final NSString[] fakeKeychainAccessGroups = { new NSString("AAAAAAAAAA.*") };
    final NSArray fakeKeychainAccessGroupsArray = new NSArray(fakeKeychainAccessGroups);
    ImmutableMap<String, NSObject> fakeDevelopmentEntitlements = ImmutableMap.of("keychain-access-groups", fakeKeychainAccessGroupsArray, "aps-environment", new NSString("development"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar")));
    ImmutableMap<String, NSObject> fakeProductionEntitlements = ImmutableMap.of("keychain-access-groups", fakeKeychainAccessGroupsArray, "aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar"), new NSString("baz")));
    ProvisioningProfileMetadata expected = makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "11111111-1111-1111-1111-111111111111", fakeProductionEntitlements);
    ProvisioningProfileStore profiles = ProvisioningProfileStore.fromProvisioningProfiles(ImmutableList.of(makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000", fakeDevelopmentEntitlements), expected));
    Optional<ProvisioningProfileMetadata> actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("keychain-access-groups", fakeKeychainAccessGroupsArray, "aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertThat(actual.get(), is(equalTo(expected)));
    actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("keychain-access-groups", fakeKeychainAccessGroupsArray, "aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("xxx")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertFalse(actual.isPresent());
    // Test without keychain access groups.
    actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertThat(actual.get(), is(equalTo(expected)));
    actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("xxx")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertFalse(actual.isPresent());
}
Also used : NSObject(com.dd.plist.NSObject) NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) Date(java.util.Date) Test(org.junit.Test)

Example 13 with Date

use of java.util.Date in project buck by facebook.

the class ProvisioningProfileStoreTest method testOnlyProfilesContainingValidFingerprintsAreMatched.

@Test
public void testOnlyProfilesContainingValidFingerprintsAreMatched() throws Exception {
    CodeSignIdentity validIdentity = CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")).setSubjectCommonName("iPhone Developer: Foo Bar (54321EDCBA)").build();
    CodeSignIdentity otherIdentity = CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")).setSubjectCommonName("iPhone Developer: Foo Bar (ABCDE12345)").build();
    ProvisioningProfileMetadata expected = makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "11111111-1111-1111-1111-111111111111", ImmutableMap.of(), ImmutableSet.of(validIdentity.getFingerprint().get(), otherIdentity.getFingerprint().get()));
    ProvisioningProfileStore profiles = ProvisioningProfileStore.fromProvisioningProfiles(ImmutableList.of(makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000", ImmutableMap.of(), ImmutableSet.of(otherIdentity.getFingerprint().get())), expected));
    Optional<ProvisioningProfileMetadata> actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, ProvisioningProfileStore.MATCH_ANY_ENTITLEMENT, Optional.of(ImmutableList.of(validIdentity)));
    assertThat(actual.get(), is(equalTo(expected)));
}
Also used : Date(java.util.Date) Test(org.junit.Test)

Example 14 with Date

use of java.util.Date in project buck by facebook.

the class ProvisioningProfileStoreTest method testMatchesSpecificApp.

@Test
public void testMatchesSpecificApp() throws Exception {
    ProvisioningProfileMetadata expected = makeTestMetadata("BBBBBBBBBB.com.facebook.test", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000");
    ProvisioningProfileStore profiles = ProvisioningProfileStore.fromProvisioningProfiles(ImmutableList.of(expected, makeTestMetadata("BBBBBBBBBB.com.facebook.*", new Date(Long.MAX_VALUE), "11111111-1111-1111-1111-111111111111")));
    Optional<ProvisioningProfileMetadata> actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, ProvisioningProfileStore.MATCH_ANY_ENTITLEMENT, ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertThat(actual.get(), is(equalTo(expected)));
}
Also used : Date(java.util.Date) Test(org.junit.Test)

Example 15 with Date

use of java.util.Date in project jetty.project by eclipse.

the class DateTag method doAfterBody.

public int doAfterBody() throws JspException {
    try {
        SimpleDateFormat format = new SimpleDateFormat(body.getString());
        format.setTimeZone(TimeZone.getTimeZone(tz));
        body.getEnclosingWriter().write(format.format(new Date()));
        return SKIP_BODY;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new JspTagException(ex.toString());
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) JspTagException(javax.servlet.jsp.JspTagException) Date(java.util.Date) JspException(javax.servlet.jsp.JspException) JspTagException(javax.servlet.jsp.JspTagException)

Aggregations

Date (java.util.Date)33499 Test (org.junit.Test)8112 SimpleDateFormat (java.text.SimpleDateFormat)4502 ArrayList (java.util.ArrayList)3177 Calendar (java.util.Calendar)2351 HashMap (java.util.HashMap)1985 IOException (java.io.IOException)1914 File (java.io.File)1649 ParseException (java.text.ParseException)1578 List (java.util.List)1106 DateFormat (java.text.DateFormat)1022 Map (java.util.Map)983 GregorianCalendar (java.util.GregorianCalendar)884 Test (org.junit.jupiter.api.Test)853 HashSet (java.util.HashSet)576 Test (org.testng.annotations.Test)527 Timestamp (java.sql.Timestamp)458 BigDecimal (java.math.BigDecimal)436 LocalDate (java.time.LocalDate)423 DateTime (org.joda.time.DateTime)391