use of com.dd.plist.NSString in project buck by facebook.
the class PlistProcessStepTest method testAdditionDoesNotReplaceExistingKey.
@Test
public void testAdditionDoesNotReplaceExistingKey() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.empty(), OUTPUT_PATH, ImmutableMap.of("Key1", new NSString("OverrideValue")), ImmutableMap.of(), PlistProcessStep.OutputFormat.XML);
NSDictionary dict = new NSDictionary();
dict.put("Key1", "Value1");
dict.put("Key2", "Value2");
projectFilesystem.writeContentsToPath(dict.toXMLPropertyList(), INPUT_PATH);
ExecutionContext executionContext = TestExecutionContext.newInstance();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(0));
assertThat(projectFilesystem.readFileIfItExists(OUTPUT_PATH), equalTo(Optional.of(dict.toXMLPropertyList())));
}
use of com.dd.plist.NSString in project buck by facebook.
the class PlistProcessStepTest method testHandlesNonDictionaryPlists.
@Test
public void testHandlesNonDictionaryPlists() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.empty(), OUTPUT_PATH, ImmutableMap.of(), ImmutableMap.of("Key1", new NSString("OverrideValue")), PlistProcessStep.OutputFormat.XML);
NSArray array = new NSArray(new NSString("Value1"), new NSString("Value2"));
projectFilesystem.writeContentsToPath(array.toXMLPropertyList(), INPUT_PATH);
ExecutionContext executionContext = TestExecutionContext.newInstance();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(0));
assertThat(projectFilesystem.readFileIfItExists(OUTPUT_PATH), equalTo(Optional.of(array.toXMLPropertyList())));
}
use of com.dd.plist.NSString in project buck by facebook.
the class ProvisioningProfileCopyStepTest method testDoesNotFailInDryRunMode.
@Test
public void testDoesNotFailInDryRunMode() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
Path emptyDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles_empty");
ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, emptyDir), outputFile, xcentFile, codeSignIdentityStore, Optional.of(dryRunResultFile));
Future<Optional<ProvisioningProfileMetadata>> profileFuture = step.getSelectedProvisioningProfileFuture();
step.execute(executionContext);
assertTrue(profileFuture.isDone());
assertNotNull(profileFuture.get());
assertFalse(profileFuture.get().isPresent());
Optional<String> resultContents = projectFilesystem.readFileIfItExists(dryRunResultFile);
assertTrue(resultContents.isPresent());
NSDictionary resultPlist = (NSDictionary) PropertyListParser.parse(resultContents.get().getBytes(Charsets.UTF_8));
assertEquals(new NSString("com.example.TestApp"), resultPlist.get("bundle-id"));
}
use of com.dd.plist.NSString 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());
}
use of com.dd.plist.NSString in project buck by facebook.
the class ProjectGeneratorTest method assertHasSingletonSourcesPhaseWithSourcesAndFlags.
private void assertHasSingletonSourcesPhaseWithSourcesAndFlags(PBXTarget target, ImmutableMap<String, Optional<String>> sourcesAndFlags) {
PBXSourcesBuildPhase sourcesBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXSourcesBuildPhase.class);
assertEquals("Sources build phase should have correct number of sources", sourcesAndFlags.size(), sourcesBuildPhase.getFiles().size());
// map keys to absolute paths
ImmutableMap.Builder<String, Optional<String>> absolutePathFlagMapBuilder = ImmutableMap.builder();
for (Map.Entry<String, Optional<String>> name : sourcesAndFlags.entrySet()) {
absolutePathFlagMapBuilder.put(projectFilesystem.getRootPath().resolve(name.getKey()).toAbsolutePath().normalize().toString(), name.getValue());
}
ImmutableMap<String, Optional<String>> absolutePathFlagMap = absolutePathFlagMapBuilder.build();
for (PBXBuildFile file : sourcesBuildPhase.getFiles()) {
String filePath = assertFileRefIsRelativeAndResolvePath(file.getFileRef());
Optional<String> flags = absolutePathFlagMap.get(filePath);
assertNotNull(String.format("Unexpected file ref '%s' found", filePath), flags);
if (flags.isPresent()) {
assertTrue("Build file should have settings dictionary", file.getSettings().isPresent());
NSDictionary buildFileSettings = file.getSettings().get();
NSString compilerFlags = (NSString) buildFileSettings.get("COMPILER_FLAGS");
assertNotNull("Build file settings should have COMPILER_FLAGS entry", compilerFlags);
assertEquals("Build file settings should be expected value", flags.get(), compilerFlags.getContent());
} else {
assertFalse("Build file should not have settings dictionary", file.getSettings().isPresent());
}
}
}
Aggregations