@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 -> {}); }
@Override public PageAndModel<String, Object> deal( ValueStack vs, HttpServletRequest request, HttpServletResponse response) throws Exception { PageAndModel<String, Object> pm = new PageAndModel<String, Object>(); pm.setPage("index.ftl"); PageResult pr = new PageResult(); long start = System.currentTimeMillis(); pr.setSecond(1); Thread.sleep(1000); pr.setSecs(System.currentTimeMillis() - start); pm.setModel(pr); return pm; }
public void acceptResult(PageResult result) throws Exception { TestSummary testSummary = result.testSummary(); pageCounts.tallyPageCounts(testSummary); for (int i = 0; i < testSummary.right; i++) output.print("."); if (testSummary.wrong > 0 || testSummary.exceptions > 0) { output.println(); if (testSummary.wrong > 0) output.println(pageDescription(result) + " has failures"); if (testSummary.exceptions > 0) output.println(pageDescription(result) + " has errors"); } }
@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); }); }
private String pageDescription(PageResult result) { String description = result.title(); if ("".equals(description)) description = "The test"; return description; }