@Test
    public void testModifyAndInsertProfile_WithComments() throws IOException, URISyntaxException {
        File credWithComments = ProfileResourceLoader.profilesWithComments().asFile();
        File tmpFile = copyToTempFile(credWithComments);

        String originalContent = FileUtils.readFileToString(tmpFile);

        Profile[] expected = {
                new Profile("a", basicCredA),
                new Profile("b", basicCredB),
                new Profile("c", sessionCredC),
                new Profile("d", sessionCredD)
                };

        // a <==> b, c <==> d, also renaming them to uppercase letters
        Profile[] modified = {
                new Profile("A", basicCredB),
                new Profile("B", basicCredA),
                new Profile("C", sessionCredD),
                new Profile("D", sessionCredC)
                };
        ProfilesConfigFileWriter.modifyProfiles(tmpFile, ImmutableMapParameter
                .of("a", modified[0],
                    "b", modified[1],
                    "c", modified[2],
                    "d", modified[3]));
        checkCredentialsFile(tmpFile, modified);

        // Sanity check that the content is altered
        String modifiedContent = FileUtils.readFileToString(tmpFile);
        assertFalse(originalContent.equals(modifiedContent));

        // Restore the properties
        ProfilesConfigFileWriter.modifyProfiles(tmpFile, ImmutableMapParameter
                .of("A", expected[0],
                    "B", expected[1],
                    "C", expected[2],
                    "D", expected[3]));
        checkCredentialsFile(tmpFile, expected);

        // Check that the content is now the same as the original
        String restoredContent = FileUtils.readFileToString(tmpFile);
        assertEquals(originalContent, restoredContent);
    }
Tests that comments and unsupported properties are preserved after
profile modification.
@throws URISyntaxException
aws-java-sdk-core/src/test/java/com/amazonaws/auth/profile/ProfilesConfigFileWriterTest.java