public static String replaceFirst(String input, String from, String to) {
        if (from == null || to == null) {
            return input;
        }
        int pos = input.indexOf(from);
        if (pos != -1) {
            int len = from.length();
            return input.substring(0, pos) + to + input.substring(pos + len);
        } else {
            return input;
        }
    }
@Test
    public void testReplaceFirst() {
        assertEquals("jms:queue:bar", replaceFirst("jms:queue:bar", "foo", "bar"));
        assertEquals("jms:queue:bar", replaceFirst("jms:queue:foo", "foo", "bar"));
        assertEquals("jms:queue:bar?blah=123", replaceFirst("jms:queue:foo?blah=123", "foo", "bar"));
        assertEquals("jms:queue:bar?blah=foo", replaceFirst("jms:queue:foo?blah=foo", "foo", "bar"));
    }