// Path: org.juzidian.dataload/src/main/java/org/juzidian/dataload/DictionaryResource.java
// public interface DictionaryResource {
// 
// 	/**
// 	 * @return the URL for downloading the remote dictionary resource.
// 	 */
// 	String getUrl();
// 
// 	/**
// 	 * @return the size of the dictionary resource in bytes.
// 	 */
// 	int getSize();
// 
// 	/**
// 	 * @return the SHA-1 hash of the dictionary resource.
// 	 */
// 	String getSha1();
// 
// }


import org.juzidian.dataload.DictionaryResource;
import org.juzidian.dataload.DictionaryResourceRegistry;
import org.juzidian.dataload.DictionaryResourceRegistryDeserializer;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import java.io.ByteArrayInputStream;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.junit.Before;
import org.junit.Test;
/*
 * Copyright Nathan Jones 2013
 *
 * This file is part of Juzidian.
 *
 * Juzidian is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Juzidian is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Juzidian.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.juzidian.dataload;





public class DictionaryResourceRegistryDeserializerTest {

	private DictionaryResourceRegistryDeserializer deserializer;

	@Before
	public void setUp() throws Exception {
		final SAXParserFactory factory = SAXParserFactory.newInstance();
		final SAXParser saxParser = factory.newSAXParser();
		this.deserializer = new DictionaryResourceRegistryDeserializer(saxParser);
	}

	@Test
	public void test() throws Exception {
		final String xml = "<juzidianDictionaries>\n" +
				"	  <dictionary formatVersion='0'>\n" +
				"	    <size>12345678</size>\n" +
				"	    <sha1>1234abcd</sha1>\n" +
				"	    <url>http://test/dict1</url>\n" +
				"	  </dictionary>\n" +
				"	</juzidianDictionaries>\n";
		final DictionaryResourceRegistry registry = this.deserializer.deserialize(new ByteArrayInputStream(xml.getBytes()));
// Path: org.juzidian.dataload/src/main/java/org/juzidian/dataload/DictionaryResource.java
// public interface DictionaryResource {
// 
// 	/**
// 	 * @return the URL for downloading the remote dictionary resource.
// 	 */
// 	String getUrl();
// 
// 	/**
// 	 * @return the size of the dictionary resource in bytes.
// 	 */
// 	int getSize();
// 
// 	/**
// 	 * @return the SHA-1 hash of the dictionary resource.
// 	 */
// 	String getSha1();
// 
// }


// Path: org.juzidian.dataload/src/test/java/org/juzidian/dataload/DictionaryResourceRegistryDeserializerTest.java
import org.juzidian.dataload.DictionaryResource;
import org.juzidian.dataload.DictionaryResourceRegistry;
import org.juzidian.dataload.DictionaryResourceRegistryDeserializer;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import java.io.ByteArrayInputStream;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.junit.Before;
import org.junit.Test;

/*
 * Copyright Nathan Jones 2013
 *
 * This file is part of Juzidian.
 *
 * Juzidian is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Juzidian is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Juzidian.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.juzidian.dataload;





public class DictionaryResourceRegistryDeserializerTest {

	private DictionaryResourceRegistryDeserializer deserializer;

	@Before
	public void setUp() throws Exception {
		final SAXParserFactory factory = SAXParserFactory.newInstance();
		final SAXParser saxParser = factory.newSAXParser();
		this.deserializer = new DictionaryResourceRegistryDeserializer(saxParser);
	}

	@Test
	public void test() throws Exception {
		final String xml = "<juzidianDictionaries>\n" +
				"	  <dictionary formatVersion='0'>\n" +
				"	    <size>12345678</size>\n" +
				"	    <sha1>1234abcd</sha1>\n" +
				"	    <url>http://test/dict1</url>\n" +
				"	  </dictionary>\n" +
				"	</juzidianDictionaries>\n";
		final DictionaryResourceRegistry registry = this.deserializer.deserialize(new ByteArrayInputStream(xml.getBytes()));
		final List<DictionaryResource> dictionaryResources = registry.getDictionaryResources();