@Test
public void testQueryStringParsing() {

  String policyValue = "{policy:'value'}";
  String signatureValue = "randomString";
  String queryString = "?" + ResourceRequest.POLICY_KEY + "=" + policyValue + "&" + ResourceRequest.SIGNATURE_KEY
          + "=" + signatureValue + "&" + ResourceRequest.ENCRYPTION_ID_KEY + "=" + keyId;
  List<NameValuePair> parameters = ResourceRequestUtil.parseQueryString(queryString);
  boolean foundOrg = false;
  boolean foundPolicy = false;
  boolean foundSignature = false;
  for (NameValuePair nameValuePair : parameters) {
    if (ResourceRequest.ENCRYPTION_ID_KEY.equals(nameValuePair.getName())) {
      assertEquals(keyId, nameValuePair.getValue());
      foundOrg = true;
    }
    if (ResourceRequest.POLICY_KEY.equals(nameValuePair.getName())) {
      assertEquals(policyValue, nameValuePair.getValue());
      foundPolicy = true;
    }
    if (ResourceRequest.SIGNATURE_KEY.equals(nameValuePair.getName())) {
      assertEquals(signatureValue, nameValuePair.getValue());
      foundSignature = true;
    }
  }
  assertTrue("Didn't find the organization value.", foundOrg);
  assertTrue("Didn't find the policy value.", foundPolicy);
  assertTrue("Didn't find the signature value.", foundSignature);
}