@Test public void testUpdateUrlMaxConnections() { assertThat( updateUrl("mongodb: props("mongodb.maxconnections", "1234")), is("mongodb: assertThat( updateUrl("mongodb: props("mongodb.maxconnections", "1234")), is("mongodb: assertThat( updateUrl("mongodb: props("mongodb.maxconnections", "1234")), is("mongodb: assertThat( updateUrl("mongodb: is("mongodb: }
public static String updateUrl(String url, Properties props) { String result = url; final String maxConnections = props.getProperty("mongodb.maxconnections", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(maxConnections)) { result = addUrlOption(result, "maxPoolSize", maxConnections); } final String threadsAllowedToBlockForConnectionMultiplier = props .getProperty( "mongodb.threadsAllowedToBlockForConnectionMultiplier", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(threadsAllowedToBlockForConnectionMultiplier)) { result = addUrlOption(result, "waitQueueMultiple", threadsAllowedToBlockForConnectionMultiplier); } String writeConcernType = props.getProperty("mongodb.writeConcern", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(writeConcernType)) { if ("errors_ignored".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("unacknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "1"); } else if ("journaled".equals(writeConcernType)) { result = addUrlOption(result, "journal", "true"); result = addUrlOption(result, "j", "true"); } else if ("replica_acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "2"); } else if ("majority".equals(writeConcernType)) { result = addUrlOption(result, "w", "majority"); } else { System.err.println("WARNING: Invalid writeConcern: '" + writeConcernType + "' will be ignored. " + "Must be one of [ unacknowledged | acknowledged | " + "journaled | replica_acknowledged | majority ]"); } } String readPreferenceType = props.getProperty("mongodb.readPreference", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(readPreferenceType)) { if ("primary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primary"); } else if ("primary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primaryPreferred"); } else if ("secondary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondary"); } else if ("secondary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondaryPreferred"); } else if ("nearest".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "nearest"); } else { System.err.println("WARNING: Invalid readPreference: '" + readPreferenceType + "' will be ignored. " + "Must be one of [ primary | primary_preferred | " + "secondary | secondary_preferred | nearest ]"); } } return result; }
OptionsSupport { public static String updateUrl(String url, Properties props) { String result = url; final String maxConnections = props.getProperty("mongodb.maxconnections", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(maxConnections)) { result = addUrlOption(result, "maxPoolSize", maxConnections); } final String threadsAllowedToBlockForConnectionMultiplier = props .getProperty( "mongodb.threadsAllowedToBlockForConnectionMultiplier", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(threadsAllowedToBlockForConnectionMultiplier)) { result = addUrlOption(result, "waitQueueMultiple", threadsAllowedToBlockForConnectionMultiplier); } String writeConcernType = props.getProperty("mongodb.writeConcern", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(writeConcernType)) { if ("errors_ignored".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("unacknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "1"); } else if ("journaled".equals(writeConcernType)) { result = addUrlOption(result, "journal", "true"); result = addUrlOption(result, "j", "true"); } else if ("replica_acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "2"); } else if ("majority".equals(writeConcernType)) { result = addUrlOption(result, "w", "majority"); } else { System.err.println("WARNING: Invalid writeConcern: '" + writeConcernType + "' will be ignored. " + "Must be one of [ unacknowledged | acknowledged | " + "journaled | replica_acknowledged | majority ]"); } } String readPreferenceType = props.getProperty("mongodb.readPreference", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(readPreferenceType)) { if ("primary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primary"); } else if ("primary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primaryPreferred"); } else if ("secondary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondary"); } else if ("secondary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondaryPreferred"); } else if ("nearest".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "nearest"); } else { System.err.println("WARNING: Invalid readPreference: '" + readPreferenceType + "' will be ignored. " + "Must be one of [ primary | primary_preferred | " + "secondary | secondary_preferred | nearest ]"); } } return result; } }
OptionsSupport { public static String updateUrl(String url, Properties props) { String result = url; final String maxConnections = props.getProperty("mongodb.maxconnections", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(maxConnections)) { result = addUrlOption(result, "maxPoolSize", maxConnections); } final String threadsAllowedToBlockForConnectionMultiplier = props .getProperty( "mongodb.threadsAllowedToBlockForConnectionMultiplier", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(threadsAllowedToBlockForConnectionMultiplier)) { result = addUrlOption(result, "waitQueueMultiple", threadsAllowedToBlockForConnectionMultiplier); } String writeConcernType = props.getProperty("mongodb.writeConcern", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(writeConcernType)) { if ("errors_ignored".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("unacknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "1"); } else if ("journaled".equals(writeConcernType)) { result = addUrlOption(result, "journal", "true"); result = addUrlOption(result, "j", "true"); } else if ("replica_acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "2"); } else if ("majority".equals(writeConcernType)) { result = addUrlOption(result, "w", "majority"); } else { System.err.println("WARNING: Invalid writeConcern: '" + writeConcernType + "' will be ignored. " + "Must be one of [ unacknowledged | acknowledged | " + "journaled | replica_acknowledged | majority ]"); } } String readPreferenceType = props.getProperty("mongodb.readPreference", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(readPreferenceType)) { if ("primary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primary"); } else if ("primary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primaryPreferred"); } else if ("secondary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondary"); } else if ("secondary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondaryPreferred"); } else if ("nearest".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "nearest"); } else { System.err.println("WARNING: Invalid readPreference: '" + readPreferenceType + "' will be ignored. " + "Must be one of [ primary | primary_preferred | " + "secondary | secondary_preferred | nearest ]"); } } return result; } private  OptionsSupport(); }
OptionsSupport { public static String updateUrl(String url, Properties props) { String result = url; final String maxConnections = props.getProperty("mongodb.maxconnections", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(maxConnections)) { result = addUrlOption(result, "maxPoolSize", maxConnections); } final String threadsAllowedToBlockForConnectionMultiplier = props .getProperty( "mongodb.threadsAllowedToBlockForConnectionMultiplier", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(threadsAllowedToBlockForConnectionMultiplier)) { result = addUrlOption(result, "waitQueueMultiple", threadsAllowedToBlockForConnectionMultiplier); } String writeConcernType = props.getProperty("mongodb.writeConcern", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(writeConcernType)) { if ("errors_ignored".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("unacknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "1"); } else if ("journaled".equals(writeConcernType)) { result = addUrlOption(result, "journal", "true"); result = addUrlOption(result, "j", "true"); } else if ("replica_acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "2"); } else if ("majority".equals(writeConcernType)) { result = addUrlOption(result, "w", "majority"); } else { System.err.println("WARNING: Invalid writeConcern: '" + writeConcernType + "' will be ignored. " + "Must be one of [ unacknowledged | acknowledged | " + "journaled | replica_acknowledged | majority ]"); } } String readPreferenceType = props.getProperty("mongodb.readPreference", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(readPreferenceType)) { if ("primary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primary"); } else if ("primary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primaryPreferred"); } else if ("secondary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondary"); } else if ("secondary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondaryPreferred"); } else if ("nearest".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "nearest"); } else { System.err.println("WARNING: Invalid readPreference: '" + readPreferenceType + "' will be ignored. " + "Must be one of [ primary | primary_preferred | " + "secondary | secondary_preferred | nearest ]"); } } return result; } private  OptionsSupport(); static String updateUrl(String url, Properties props); }
OptionsSupport { public static String updateUrl(String url, Properties props) { String result = url; final String maxConnections = props.getProperty("mongodb.maxconnections", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(maxConnections)) { result = addUrlOption(result, "maxPoolSize", maxConnections); } final String threadsAllowedToBlockForConnectionMultiplier = props .getProperty( "mongodb.threadsAllowedToBlockForConnectionMultiplier", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(threadsAllowedToBlockForConnectionMultiplier)) { result = addUrlOption(result, "waitQueueMultiple", threadsAllowedToBlockForConnectionMultiplier); } String writeConcernType = props.getProperty("mongodb.writeConcern", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(writeConcernType)) { if ("errors_ignored".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("unacknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "0"); } else if ("acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "1"); } else if ("journaled".equals(writeConcernType)) { result = addUrlOption(result, "journal", "true"); result = addUrlOption(result, "j", "true"); } else if ("replica_acknowledged".equals(writeConcernType)) { result = addUrlOption(result, "w", "2"); } else if ("majority".equals(writeConcernType)) { result = addUrlOption(result, "w", "majority"); } else { System.err.println("WARNING: Invalid writeConcern: '" + writeConcernType + "' will be ignored. " + "Must be one of [ unacknowledged | acknowledged | " + "journaled | replica_acknowledged | majority ]"); } } String readPreferenceType = props.getProperty("mongodb.readPreference", UNAVAILABLE).toLowerCase(); if (!UNAVAILABLE.equals(readPreferenceType)) { if ("primary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primary"); } else if ("primary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "primaryPreferred"); } else if ("secondary".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondary"); } else if ("secondary_preferred".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "secondaryPreferred"); } else if ("nearest".equals(readPreferenceType)) { result = addUrlOption(result, "readPreference", "nearest"); } else { System.err.println("WARNING: Invalid readPreference: '" + readPreferenceType + "' will be ignored. " + "Must be one of [ primary | primary_preferred | " + "secondary | secondary_preferred | nearest ]"); } } return result; } private  OptionsSupport(); static String updateUrl(String url, Properties props);  }