/** * Handles unknown fields (required and not required) * * @throws FeathercoinURIParseException If something goes wrong */ @Test public void testUnknown() throws FeathercoinURIParseException { // Unknown not required field testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?aardvark=true"); assertEquals( "FeathercoinURI['address'='LQz2pJYaeqntA9BFB8rDX5AL2TTKGd5AuN','aardvark'='true']", testObject.toString()); assertEquals("true", (String) testObject.getParameterByName("aardvark")); // Unknown not required field (isolated) try { testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?aardvark"); fail("Expecting FeathercoinURIParseException"); } catch (FeathercoinURIParseException e) { assertTrue(e.getMessage().contains("cannot parse name value pair")); } // Unknown and required field try { testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?req-aardvark=true"); fail("Expecting FeathercoinURIParseException"); } catch (FeathercoinURIParseException e) { assertTrue(e.getMessage().contains("req-aardvark")); } }
/** * Handles various well-formed combinations * * @throws FeathercoinURIParseException If something goes wrong */ @Test public void testGood_Combinations() throws FeathercoinURIParseException { testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=9876543210&label=Hello%20World&message=Be%20well"); assertEquals( "FeathercoinURI['address'='LQz2pJYaeqntA9BFB8rDX5AL2TTKGd5AuN','amount'='987654321000000000','label'='Hello World','message'='Be well']", testObject.toString()); }