@Test public void testLoadPage_Character_Remote() throws IOException { System.out.println("loadPage(Character remote)"); // NOI18N. final String appKey = loadApplicationKey(); final String path = String.format("https://api.guildwars2.com/v2/characters?access_token=%s", appKey); final URL url = new URL(path); final PageResult<String> result = JsonpContext.SAX.loadPage(String.class, url); assertNotNull(result); result.stream().forEach(characterName -> {}); }
@Test public void testLoadPage_Integer_Local() throws IOException { System.out.println("loadPage(integer local)"); // NOI18N. final int expPageTotal = 1; final int expPageSize = 10; final int expResultCount = expPageSize; final int expResultTotal = expPageSize; final URL url = getClass().getResource("test_page1.json"); // NOI18N. final JsonpContext instance = JsonpContext.SAX; final PageResult<Integer> value = instance.loadPage(Integer.class, url); assertNotNull(value); assertEquals(expPageTotal, value.getPageTotal()); assertEquals(expPageSize, value.getPageSize()); assertEquals(expResultCount, value.getResultCount()); assertEquals(expResultTotal, value.getResultTotal()); final Iterator<Integer> iterator = value.iterator(); IntStream.range(0, expPageSize) .forEach( index -> { final int expResult = index; final int result = iterator.next(); assertEquals(expResult, result); }); }