/**
 * Copyright (C) 2012 Gist Labs, LLC. (http://gistlabs.com)
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.gistlabs.mechanize.json.impl;

import static org.junit.Assert.*;

import org.apache.http.entity.ContentType;
import org.junit.Test;

import com.gistlabs.mechanize.MechanizeTestCase;
import com.gistlabs.mechanize.Resource;
import com.gistlabs.mechanize.json.JsonPage;

/**
 */
public class JsonPageTest extends MechanizeTestCase {

	@Test
	public void testLoadJson() {
		agent.addPageRequest("GET", "http://test.com", getClass().getResourceAsStream("dropbox.account.info.json")).setContentType(ContentType.APPLICATION_JSON.getMimeType());
		Resource page = agent.get("http://test.com");
		assertNotNull(page);
		assertEquals(JsonPage.class, page.getClass());
	}

	@Test
	public void testParseJson() {
		agent.addPageRequest("GET", "http://test.com", getClass().getResourceAsStream("dropbox.account.info.json")).setContentType(ContentType.APPLICATION_JSON.getMimeType());
		JsonPage page = (JsonPage) agent.get("http://test.com");
		assertNotNull(page.getRoot());
	}
}
@@ -544,16 +544,66 @@
 sonPage;
+%0Aimport com.gistlabs.mechanize.json.node.JsonNode;
 %0A%0A/**%0A *
@@ -1285,17 +1285,197 @@
 .getRoot());
+%0A%0A%09%09assertEquals(%22US%22, page.getRoot().getAttribute(%22country%22));%0A%0A%09%09JsonNode node = page.getRoot().find(%22quota_info%22);%0A%09%09assertEquals(%22107374182400000%22, node.getAttribute(%22quota%22));
 %0A%09%7D%0A%7D

Extend Json test to inspect root element and perform css selector search