### Question:
ProfilesConf implements PluginConf { @Override public Map<String, String> getPlugins(String profileName) { Profile profile = getProfile(profileName); Map<String, String> result = profile.getPluginsMap(); if (result.isEmpty()) { throw new ProfileConfException(NO_PLUGINS_IN_PROFILE_DEF, profileName, externalProfilesFilename); } return result; } private  ProfilesConf();   ProfilesConf(String internalProfilesFilename, String externalProfilesFilename); static ProfilesConf getInstance(); @Override Map<String, String> getOptionMappings(String profileName); @Override Map<String, String> getPlugins(String profileName); @Override String getProtocol(String profileName); @Override String getHandler(String profileName);  }### Answer:
@Test public void definedProfile() { ProfilesConf profilesConf = getProfilesConf("definedProfile"); Map<String, String> hbaseProfile = profilesConf.getPlugins("HBase"); assertEquals(2, hbaseProfile.keySet().size()); assertEquals("X", hbaseProfile.get("OUTPUTFORMAT")); assertEquals("XX", hbaseProfile.get("METADATA")); Map<String, String> hiveProfile = profilesConf.getPlugins("hIVe"); assertEquals(1, hiveProfile.keySet().size()); assertEquals("Y", hiveProfile.get("OUTPUTFORMAT")); }
@Test public void undefinedProfile() { expectedException.expect(ProfileConfException.class); expectedException.expectMessage("UndefinedProfile is not defined in profile/undefinedProfile/pxf-profiles.xml"); ProfilesConf profilesConf = getProfilesConf("undefinedProfile"); profilesConf.getPlugins("UndefinedProfile"); }
@Test public void duplicateProfileDefinition() { ProfilesConf profilesConf = getProfilesConf("duplicateProfileDefinition"); profilesConf.getPlugins("HBase"); }
@Test public void overrideProfile() { ProfilesConf profilesConf = getProfilesConf("overrideProfile"); Map profile = profilesConf.getPlugins("HBase"); assertEquals(2, profile.keySet().size()); assertEquals("Y", profile.get("ACCESSOR")); assertEquals("YY", profile.get("RESOLVER")); }
@Test public void emptyProfileFile() { ProfilesConf profilesConf = getProfilesConf("emptyProfileFile"); profilesConf.getPlugins("HBase"); }
@Test public void malformedProfileFile() { expectedException.expect(ProfileConfException.class); expectedException.expectMessage("pxf-profiles-default.xml could not be loaded: org.xml.sax.SAXParseException"); ProfilesConf profilesConf = getProfilesConf("malformedProfileFile"); profilesConf.getPlugins("HBase"); }
@Test public void missingMandatoryProfileFile() { expectedException.expect(ProfileConfException.class); expectedException.expectMessage("profile/missingMandatoryProfileFile/pxf-profiles-default.xml was not found in the CLASSPATH"); ProfilesConf profilesConf = getProfilesConf("missingMandatoryProfileFile"); profilesConf.getPlugins("HBase"); }
@Test public void missingOptionalProfileFile() { ProfilesConf profilesConf = getProfilesConf("missingOptionalProfileFile"); Map<String, String> hbaseProfile = profilesConf.getPlugins("HBase"); assertEquals("Y", hbaseProfile.get("FRAGMENTER")); }
@Test public void testProfileWithSpacesInName() { ProfilesConf profilesConf = getProfilesConf("profileWithSpacesInName"); Map<String, String> map = profilesConf.getPlugins("HBase"); assertNotNull(map); assertEquals(1, map.size()); assertEquals("Y", map.get("accessor")); }