public static String encode(String plain) {
        Preconditions.checkNotNull(plain, "Cannot encode null object");
        String encoded;
        try {
            encoded = URLEncoder.encode(plain, CHARSET);
        } catch (UnsupportedEncodingException uee) {
            throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee);
        }
        for (Map.Entry<String, String> rule : ENCODING_RULES.entrySet()) {
            encoded = applyRule(encoded, rule.getKey(), rule.getValue());
        }
        return encoded;
    }
@Test
    public void shouldPercentEncodeString() {
        final String plain = "this is a test &^";
        final String encoded = "this%20is%20a%20test%20%26%5E";
        assertEquals(encoded, OAuthEncoder.encode(plain));
    }