TCTokenParser { public List<TCToken> parse(@Nonnull String data) throws InvalidTCTokenException { return parse(new ByteArrayInputStream(data.getBytes())); } TCTokenParser(); List<TCToken> parse(@Nonnull String data); List<TCToken> parse(@Nonnull InputStream inputStream);  }
@Test(enabled = true) public void testParse() throws Exception { InputStream testFile = FileUtils.resolveResourceAsStream(getClass(), "TCToken.xml"); TCTokenParser parser = new TCTokenParser(); List<TCToken> tokens = parser.parse(testFile); TCTokenType t = tokens.get(0); assertEquals(t.getSessionIdentifier(), "3eab1b41ecc1ce5246acf6f4e2751234"); assertEquals(t.getServerAddress().toString(), "https: assertEquals(t.getRefreshAddress().toString(), "https: assertEquals(t.getBinding(), "urn:liberty:paos:2006-08"); }
@Test public void testParseMalformed() throws Exception { String data = FileUtils.toString(FileUtils.resolveResourceAsStream(getClass(), "TCToken-malformed.xml")); data = TCTokenHacks.fixPathSecurityParameters(data); TCTokenParser parser = new TCTokenParser(); List<TCToken> tokens = parser.parse(data); TCTokenType t = tokens.get(0); assertEquals(t.getSessionIdentifier(), "3eab1b41ecc1ce5246acf6f4e275"); assertEquals(t.getServerAddress().toString(), "https: assertEquals(t.getRefreshAddress().toString(), "https: assertEquals(t.getBinding(), "urn:liberty:paos:2006-08"); assertEquals(t.getPathSecurityParameters().getPSK(), StringUtils.toByteArray("b7e9dd2ba2568c3c8d572aaadb3eebf7d4515e66d5fc2fd8e46626725a9abba2")); }