You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ma...@apache.org on 2011/06/07 17:47:33 UTC

svn commit: r1133050 - /tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/

Author: mattmann
Date: Tue Jun  7 15:47:32 2011
New Revision: 1133050

URL: http://svn.apache.org/viewvc?rev=1133050&view=rev
Log:
- progress towards TIKA-245 Support of CHM Format (Oleg's patch, in parts, as suggested by Jukka)

Added:
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmBlockInfo.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmDocumentInformation.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtraction.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtractor.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItsfHeader.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItspHeader.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxState.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcControlData.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcResetTable.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestDirectoryListingEntry.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestParameters.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmgiHeader.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmglHeader.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestUtils.java

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmBlockInfo.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmBlockInfo.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmBlockInfo.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmBlockInfo.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.accessor.ChmItspHeader;
+import org.apache.tika.parser.chm.accessor.ChmLzxcControlData;
+import org.apache.tika.parser.chm.accessor.ChmLzxcResetTable;
+import org.apache.tika.parser.chm.accessor.DirectoryListingEntry;
+import org.apache.tika.parser.chm.core.ChmCommons;
+import org.apache.tika.parser.chm.core.ChmConstants;
+import org.apache.tika.parser.chm.lzx.ChmBlockInfo;
+
+/**
+ * Tests major functionality of ChmBlockInfo
+ * 
+ */
+public class TestChmBlockInfo extends TestCase {
+	private byte[] data;
+	private ChmBlockInfo chmBlockInfo;
+	private ChmDirectoryListingSet chmDirListCont = null;
+	private ChmLzxcResetTable clrt = null;
+	private ChmLzxcControlData chmLzxcControlData = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+
+		data = TestUtils.toByteArray(stream);
+
+		/* Creates and parses itsf header */
+		ChmItsfHeader chmItsHeader = new ChmItsfHeader();
+		chmItsHeader.parse(
+				Arrays.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1),
+				chmItsHeader);
+		/* Creates and parses itsp block */
+		ChmItspHeader chmItspHeader = new ChmItspHeader();
+		chmItspHeader.parse(Arrays.copyOfRange(data,
+				(int) chmItsHeader.getDirOffset(),
+				(int) chmItsHeader.getDirOffset()
+						+ ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
+		/* Creating instance of ChmDirListingContainer */
+		chmDirListCont = new ChmDirectoryListingSet(data, chmItsHeader,
+				chmItspHeader);
+		int indexOfControlData = chmDirListCont.getControlDataIndex();
+
+		int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data,
+				ChmConstants.LZXC.getBytes());
+		byte[] dir_chunk = null;
+		if (indexOfResetTable > 0) {
+			dir_chunk = Arrays.copyOfRange(data, indexOfResetTable,
+					indexOfResetTable
+							+ chmDirListCont.getDirectoryListingEntryList()
+									.get(indexOfControlData).getLength());
+		}
+
+		/* Creates and parses control block */
+		chmLzxcControlData = new ChmLzxcControlData();
+		chmLzxcControlData.parse(dir_chunk, chmLzxcControlData);
+
+		int indexOfFeList = chmDirListCont.getResetTableIndex();
+		int startIndex = (int) chmDirListCont.getDataOffset()
+				+ chmDirListCont.getDirectoryListingEntryList()
+						.get(indexOfFeList).getOffset();
+		dir_chunk = Arrays.copyOfRange(
+				data,
+				startIndex,
+				startIndex
+						+ chmDirListCont.getDirectoryListingEntryList()
+								.get(indexOfFeList).getLength());
+		clrt = new ChmLzxcResetTable();
+		clrt.parse(dir_chunk, clrt);
+	}
+
+	public void testToString() {
+		if (chmBlockInfo == null)
+			testGetChmBlockInfo();
+		Assert.assertTrue(chmBlockInfo.toString().length() > 0);
+	}
+
+	public void testGetChmBlockInfo() {
+		for (Iterator<DirectoryListingEntry> it = chmDirListCont
+				.getDirectoryListingEntryList().iterator(); it.hasNext();) {
+			DirectoryListingEntry directoryListingEntry = it.next();
+			chmBlockInfo = ChmBlockInfo.getChmBlockInfoInstance(
+					directoryListingEntry, (int) clrt.getBlockLen(),
+					chmLzxcControlData);
+			Assert.assertTrue(!directoryListingEntry.getName().isEmpty()
+					&& chmBlockInfo.toString() != null);
+		}
+	}
+
+	public void tearDown() throws Exception {
+		data = null;
+		chmBlockInfo = null;
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmDocumentInformation.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmDocumentInformation.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmDocumentInformation.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmDocumentInformation.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,37 @@
+package org.apache.tika.parser.chm;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+
+public class TestChmDocumentInformation extends TestCase {
+	private CHMDocumentInformation chmDoc = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		chmDoc = CHMDocumentInformation.load(stream);
+	}
+
+	public void testGetCHMDocInformation() throws TikaException, IOException {
+		Metadata md = new Metadata();
+		chmDoc.getCHMDocInformation(md);
+		Assert.assertEquals(TestParameters.VP_CHM_MIME_TYPE, md.toString()
+				.trim());
+	}
+
+	public void testGetText() throws TikaException {
+		Assert.assertTrue(chmDoc.getText().contains(
+				"The TCard method accepts only numeric arguments"));
+	}
+
+	public void tearDown() throws Exception {
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtraction.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtraction.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtraction.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtraction.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tika.parser.chm;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
+
+public class TestChmExtraction extends TestCase {
+
+	private List<String> files = new ArrayList<String>();
+
+	public void setUp() {
+		files.add("/test-documents/testChm.chm");
+		files.add("/test-documents/testChm2.chm");
+		files.add("/test-documents/testChm3.chm");
+	}
+
+	public void testMultiThreadedChmExtraction() throws InterruptedException {
+		ExecutorService executor = Executors
+				.newFixedThreadPool(TestParameters.NTHREADS);
+		for (int i = 0; i < TestParameters.NTHREADS; i++) {
+			executor.execute(new Runnable() {
+				public void run() {
+					Lock mutex = new ReentrantLock();
+					for (String fileName : files) {
+						TikaInputStream stream;
+						try {
+							stream = TikaInputStream
+									.get(TestContainerAwareDetector.class
+											.getResource(fileName));
+							mutex.lock();
+							try {
+								CHMDocumentInformation chmDocInfo = CHMDocumentInformation
+										.load(stream);
+								Metadata md = new Metadata();
+								String text = chmDocInfo.getText();
+								chmDocInfo.getCHMDocInformation(md);
+								assertEquals(TestParameters.VP_CHM_MIME_TYPE,
+										md.toString().trim());
+								assertTrue(text.length() > 0);
+							} catch (TikaException e) {
+								e.printStackTrace();
+							} finally {
+								mutex.unlock();
+							}
+						} catch (IOException e) {
+							e.printStackTrace();
+						}
+					}
+
+				}
+			});
+		}
+		executor.shutdown();
+		// Waits until all threads will have finished
+		while (!executor.isTerminated()) {
+			Thread.sleep(500);
+		}
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtractor.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtractor.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtractor.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmExtractor.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet;
+import org.apache.tika.parser.chm.accessor.DirectoryListingEntry;
+import org.apache.tika.parser.chm.core.ChmExtractor;
+
+public class TestChmExtractor extends TestCase {
+	private ChmExtractor chmExtractor = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		chmExtractor = new ChmExtractor(stream);
+	}
+
+	public void testEnumerateChm() {
+		List<String> chmEntries = chmExtractor.enumerateChm();
+		Assert.assertEquals(TestParameters.VP_CHM_ENTITIES_NUMBER,
+				chmEntries.size());
+	}
+
+	public void testGetChmDirList() {
+		Assert.assertNotNull(chmExtractor.getChmDirList());
+	}
+
+	public void testExtractChmEntry() {
+		ChmDirectoryListingSet entries = chmExtractor.getChmDirList();
+		byte[][] localFile;
+		int count = 0;
+		for (Iterator<DirectoryListingEntry> it = entries
+				.getDirectoryListingEntryList().iterator(); it.hasNext();) {
+			localFile = chmExtractor.extractChmEntry(it.next());
+			if (localFile != null) {
+				++count;
+			}
+		}
+		Assert.assertEquals(TestParameters.VP_CHM_ENTITIES_NUMBER, count);
+	}
+
+	public void tearDown() throws Exception {
+	}
+
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItsfHeader.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItsfHeader.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItsfHeader.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItsfHeader.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.core.ChmConstants;
+
+/**
+ * Tests all public functions of ChmItsfHeader
+ * 
+ */
+public class TestChmItsfHeader extends TestCase {
+	private ChmItsfHeader chmItsfHeader = null;
+
+	public void setUp() throws Exception {
+		chmItsfHeader = new ChmItsfHeader();
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		byte[] data = TestUtils.toByteArray(stream);
+		chmItsfHeader.parse(
+				Arrays.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1),
+				chmItsfHeader);
+	}
+
+	public void testGetDataOffset() {
+		Assert.assertEquals(TestParameters.VP_DATA_OFFSET_LENGTH,
+				chmItsfHeader.getDataOffset());
+	}
+
+	public void testGetDir_uuid() {
+		Assert.assertNotNull(chmItsfHeader.getDir_uuid());
+	}
+
+	public void testGetDirLen() {
+		Assert.assertEquals(TestParameters.VP_DIRECTORY_LENGTH,
+				chmItsfHeader.getDirLen());
+	}
+
+	public void testGetDirOffset() {
+		Assert.assertEquals(TestParameters.VP_DIRECTORY_OFFSET,
+				chmItsfHeader.getDirOffset());
+	}
+
+	public void testGetHeaderLen() {
+		Assert.assertEquals(TestParameters.VP_ITSF_HEADER_LENGTH,
+				chmItsfHeader.getHeaderLen());
+	}
+
+	public void testGetLangId() {
+		Assert.assertEquals(TestParameters.VP_LANGUAGE_ID,
+				chmItsfHeader.getLangId());
+	}
+
+	public void testGetLastModified() {
+		Assert.assertEquals(TestParameters.VP_LAST_MODIFIED,
+				chmItsfHeader.getLastModified());
+	}
+
+	public void testGetUnknown_000c() {
+		Assert.assertEquals(TestParameters.VP_UNKNOWN_000C,
+				chmItsfHeader.getUnknown_000c());
+	}
+
+	public void testGetUnknownLen() {
+		Assert.assertEquals(TestParameters.VP_UNKNOWN_LEN,
+				chmItsfHeader.getUnknownLen());
+	}
+
+	public void testGetUnknownOffset() {
+		Assert.assertEquals(TestParameters.VP_UNKNOWN_OFFSET,
+				chmItsfHeader.getUnknownOffset());
+	}
+
+	public void testGetVersion() {
+		Assert.assertEquals(TestParameters.VP_VERSION,
+				chmItsfHeader.getVersion());
+	}
+
+	public void testToString() {
+		Assert.assertTrue(chmItsfHeader.toString().contains(
+				TestParameters.VP_ISTF_SIGNATURE));
+	}
+
+	public void tearDown() throws Exception {
+		chmItsfHeader = null;
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItspHeader.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItspHeader.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItspHeader.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmItspHeader.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.accessor.ChmItspHeader;
+import org.apache.tika.parser.chm.core.ChmConstants;
+
+/**
+ * Tests all public methods of the ChmItspHeader
+ * 
+ */
+public class TestChmItspHeader extends TestCase {
+	private ChmItspHeader chmItspHeader = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		byte[] data = TestUtils.toByteArray(stream);
+
+		ChmItsfHeader chmItsfHeader = new ChmItsfHeader();
+		chmItsfHeader.parse(
+				Arrays.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1),
+				chmItsfHeader);
+
+		chmItspHeader = new ChmItspHeader();
+		chmItspHeader.parse(Arrays.copyOfRange(data,
+				(int) chmItsfHeader.getDirOffset(),
+				(int) chmItsfHeader.getDirOffset()
+						+ ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
+	}
+
+	public void testGetBlock_len() {
+		Assert.assertEquals(TestParameters.VP_BLOCK_LENGTH,
+				chmItspHeader.getBlock_len());
+	}
+
+	public void testGetBlockidx_intvl() {
+		Assert.assertEquals(TestParameters.VP_BLOCK_INDEX_INTERVAL,
+				chmItspHeader.getBlockidx_intvl());
+	}
+
+	public void testGetHeader_len() {
+		Assert.assertEquals(TestParameters.VP_ITSP_HEADER_LENGTH,
+				chmItspHeader.getHeader_len());
+	}
+
+	public void testGetIndex_depth() {
+		Assert.assertEquals(TestParameters.VP_INDEX_DEPTH,
+				chmItspHeader.getIndex_depth());
+	}
+
+	public void testGetIndex_head() {
+		Assert.assertEquals(TestParameters.VP_INDEX_HEAD,
+				chmItspHeader.getIndex_head());
+	}
+
+	public void testGetIndex_root() {
+		Assert.assertEquals(TestParameters.VP_INDEX_ROOT,
+				chmItspHeader.getIndex_root());
+	}
+
+	public void testGetLang_id() {
+		Assert.assertEquals(TestParameters.VP_LANGUAGE_ID,
+				chmItspHeader.getLang_id());
+	}
+
+	public void testGetNum_blocks() {
+		Assert.assertEquals(TestParameters.VP_UNKNOWN_NUM_BLOCKS,
+				chmItspHeader.getNum_blocks());
+	}
+
+	public void testGetUnknown_000c() {
+		Assert.assertEquals(TestParameters.VP_ITSP_UNKNOWN_000C,
+				chmItspHeader.getUnknown_000c());
+	}
+
+	public void testGetUnknown_0024() {
+		Assert.assertEquals(TestParameters.VP_ITSP_UNKNOWN_0024,
+				chmItspHeader.getUnknown_0024());
+	}
+
+	public void testGetUnknown_002() {
+		Assert.assertEquals(TestParameters.VP_ITSP_UNKNOWN_002C,
+				chmItspHeader.getUnknown_002c());
+	}
+
+	public void testGetUnknown_0044() {
+		Assert.assertEquals(TestParameters.VP_ITSP_BYTEARR_LEN,
+				chmItspHeader.getUnknown_0044().length);
+	}
+
+	public void testGetVersion() {
+		Assert.assertEquals(TestParameters.VP_ITSP_VERSION,
+				chmItspHeader.getVersion());
+	}
+
+	public void testGetSignature() {
+		Assert.assertEquals(TestParameters.VP_ISTP_SIGNATURE, new String(
+				chmItspHeader.getSignature()));
+	}
+
+	public void testGetSystem_uuid() {
+		Assert.assertEquals(TestParameters.VP_ITSP_BYTEARR_LEN,
+				chmItspHeader.getSystem_uuid().length);
+	}
+
+	public void testToString() {
+		Assert.assertTrue(chmItspHeader.toString().contains(
+				TestParameters.VP_ISTP_SIGNATURE));
+	}
+
+	public void tearDown() throws Exception {
+		chmItspHeader = null;
+	}
+
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxState.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxState.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxState.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxState.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.accessor.ChmItspHeader;
+import org.apache.tika.parser.chm.accessor.ChmLzxcControlData;
+import org.apache.tika.parser.chm.core.ChmCommons;
+import org.apache.tika.parser.chm.core.ChmConstants;
+import org.apache.tika.parser.chm.lzx.ChmLzxState;
+
+public class TestChmLzxState extends TestCase {
+	private ChmLzxState chmLzxState;
+	private int windowSize;
+
+	public void setUp() throws Exception {
+		try {
+			TikaInputStream stream = TikaInputStream
+					.get(TestContainerAwareDetector.class
+							.getResource(TestParameters.chmFile));
+
+			byte[] data = TestUtils.toByteArray(stream);
+
+			/* Creates and parses itsf header */
+			ChmItsfHeader chmItsHeader = new ChmItsfHeader();
+			chmItsHeader.parse(Arrays.copyOfRange(data, 0,
+					ChmConstants.CHM_ITSF_V3_LEN - 1), chmItsHeader);
+			/* Creates and parses itsp block */
+			ChmItspHeader chmItspHeader = new ChmItspHeader();
+			chmItspHeader.parse(Arrays.copyOfRange(data,
+					(int) chmItsHeader.getDirOffset(),
+					(int) chmItsHeader.getDirOffset()
+							+ ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
+
+			/* Creating instance of ChmDirListingContainer */
+			ChmDirectoryListingSet chmDirListCont = new ChmDirectoryListingSet(
+					data, chmItsHeader, chmItspHeader);
+			int indexOfControlData = ChmCommons.indexOf(
+					chmDirListCont.getDirectoryListingEntryList(),
+					ChmConstants.CONTROL_DATA);
+
+			int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data,
+					ChmConstants.LZXC.getBytes());
+			byte[] dir_chunk = null;
+			if (indexOfResetTable > 0) {
+				dir_chunk = Arrays.copyOfRange(data, indexOfResetTable,
+						indexOfResetTable
+								+ chmDirListCont.getDirectoryListingEntryList()
+										.get(indexOfControlData).getLength());
+			}
+
+			ChmLzxcControlData clcd = new ChmLzxcControlData();
+			clcd.parse(dir_chunk, clcd);
+			windowSize = (int) clcd.getWindowSize();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void testChmLzxStateConstructor() {
+		chmLzxState = new ChmLzxState(windowSize);
+		Assert.assertNotNull(chmLzxState);
+	}
+
+	public void testToString() {
+		if (chmLzxState == null)
+			testChmLzxStateConstructor();
+		Assert.assertTrue(chmLzxState.toString().length() > 20);
+	}
+
+	public void tearDown() throws Exception {
+	}
+
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcControlData.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcControlData.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcControlData.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcControlData.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.accessor.ChmItspHeader;
+import org.apache.tika.parser.chm.accessor.ChmLzxcControlData;
+import org.apache.tika.parser.chm.core.ChmCommons;
+import org.apache.tika.parser.chm.core.ChmConstants;
+
+/**
+ * Tests all public methods of ChmLzxcControlData block
+ */
+public class TestChmLzxcControlData extends TestCase {
+	private ChmLzxcControlData chmLzxcControlData = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+
+		byte[] data = TestUtils.toByteArray(stream);
+		/* Creates and parses itsf header */
+		ChmItsfHeader chmItsHeader = new ChmItsfHeader();
+		chmItsHeader.parse(
+				Arrays.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1),
+				chmItsHeader);
+		/* Creates and parses itsp block */
+		ChmItspHeader chmItspHeader = new ChmItspHeader();
+		chmItspHeader.parse(Arrays.copyOfRange(data,
+				(int) chmItsHeader.getDirOffset(),
+				(int) chmItsHeader.getDirOffset()
+						+ ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
+		/* Creating instance of ChmDirListingContainer */
+		ChmDirectoryListingSet chmDirListCont = new ChmDirectoryListingSet(
+				data, chmItsHeader, chmItspHeader);
+		int indexOfControlData = chmDirListCont.getControlDataIndex();
+
+		int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data,
+				ChmConstants.LZXC.getBytes());
+		byte[] dir_chunk = null;
+		if (indexOfResetTable > 0) {
+			dir_chunk = Arrays.copyOfRange(data, indexOfResetTable,
+					indexOfResetTable
+							+ chmDirListCont.getDirectoryListingEntryList()
+									.get(indexOfControlData).getLength());
+		}
+
+		/* Creates and parses control block */
+		chmLzxcControlData = new ChmLzxcControlData();
+		chmLzxcControlData.parse(dir_chunk, chmLzxcControlData);
+
+	}
+
+	public void testConstructorNotNull() {
+		Assert.assertNotNull(chmLzxcControlData);
+	}
+
+	public void testGetResetInterval() {
+		Assert.assertEquals(TestParameters.VP_RESET_INTERVAL,
+				chmLzxcControlData.getResetInterval());
+	}
+
+	public void testGetSize() {
+		Assert.assertEquals(TestParameters.VP_CONTROL_DATA_SIZE,
+				chmLzxcControlData.getSize());
+	}
+
+	public void testGetUnknown_18() {
+		Assert.assertEquals(TestParameters.VP_UNKNOWN_18,
+				chmLzxcControlData.getUnknown_18());
+	}
+
+	public void testGetVersion() {
+		Assert.assertEquals(TestParameters.VP_CONTROL_DATA_VERSION,
+				chmLzxcControlData.getVersion());
+	}
+
+	public void testGetWindowSize() {
+		Assert.assertEquals(TestParameters.VP_WINDOW_SIZE,
+				chmLzxcControlData.getWindowSize());
+	}
+
+	public void testGetWindowsPerReset() {
+		Assert.assertEquals(TestParameters.VP_WINDOWS_PER_RESET,
+				chmLzxcControlData.getWindowsPerReset());
+	}
+
+	public void testGetToString() {
+		Assert.assertTrue(chmLzxcControlData.toString().contains(
+				TestParameters.VP_CONTROL_DATA_SIGNATURE));
+	}
+
+	public void testGetSignature() {
+		Assert.assertEquals(
+				TestParameters.VP_CONTROL_DATA_SIGNATURE.getBytes().length,
+				chmLzxcControlData.getSignature().length);
+	}
+
+	public void testGetSignaure() {
+		Assert.assertEquals(
+				TestParameters.VP_CONTROL_DATA_SIGNATURE.getBytes().length,
+				chmLzxcControlData.getSignature().length);
+	}
+
+	public void tearDown() throws Exception {
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcResetTable.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcResetTable.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcResetTable.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestChmLzxcResetTable.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmDirectoryListingSet;
+import org.apache.tika.parser.chm.accessor.ChmItsfHeader;
+import org.apache.tika.parser.chm.accessor.ChmItspHeader;
+import org.apache.tika.parser.chm.accessor.ChmLzxcControlData;
+import org.apache.tika.parser.chm.accessor.ChmLzxcResetTable;
+import org.apache.tika.parser.chm.assertion.ChmAssert;
+import org.apache.tika.parser.chm.core.ChmCommons;
+import org.apache.tika.parser.chm.core.ChmConstants;
+
+public class TestChmLzxcResetTable extends TestCase {
+	private ChmLzxcResetTable chmLzxcResetTable = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+
+		byte[] data = TestUtils.toByteArray(stream);
+		/* Creates and parses itsf header */
+		ChmItsfHeader chmItsfHeader = new ChmItsfHeader();
+		chmItsfHeader.parse(
+				Arrays.copyOfRange(data, 0, ChmConstants.CHM_ITSF_V3_LEN - 1),
+				chmItsfHeader);
+		/* Creates and parses itsp block */
+		ChmItspHeader chmItspHeader = new ChmItspHeader();
+		chmItspHeader.parse(Arrays.copyOfRange(data,
+				(int) chmItsfHeader.getDirOffset(),
+				(int) chmItsfHeader.getDirOffset()
+						+ ChmConstants.CHM_ITSP_V1_LEN), chmItspHeader);
+		/* Creating instance of ChmDirListingContainer */
+		ChmDirectoryListingSet chmDirListCont = new ChmDirectoryListingSet(
+				data, chmItsfHeader, chmItspHeader);
+		int indexOfControlData = chmDirListCont.getControlDataIndex();
+
+		int indexOfResetTable = ChmCommons.indexOfResetTableBlock(data,
+				ChmConstants.LZXC.getBytes());
+		byte[] dir_chunk = null;
+		if (indexOfResetTable > 0) {
+			dir_chunk = Arrays.copyOfRange(data, indexOfResetTable,
+					indexOfResetTable
+							+ chmDirListCont.getDirectoryListingEntryList()
+									.get(indexOfControlData).getLength());
+		}
+
+		/* Creates and parses control block */
+		ChmLzxcControlData chmLzxcControlData = new ChmLzxcControlData();
+		chmLzxcControlData.parse(dir_chunk, chmLzxcControlData);
+
+		indexOfResetTable = chmDirListCont.getResetTableIndex();
+		chmLzxcResetTable = new ChmLzxcResetTable();
+
+		int startIndex = (int) chmDirListCont.getDataOffset()
+				+ chmDirListCont.getDirectoryListingEntryList()
+						.get(indexOfResetTable).getOffset();
+
+		ChmAssert.assertCopyingDataIndex(startIndex, data.length);
+
+		dir_chunk = Arrays.copyOfRange(
+				data,
+				startIndex,
+				startIndex
+						+ chmDirListCont.getDirectoryListingEntryList()
+								.get(indexOfResetTable).getLength());
+
+		chmLzxcResetTable.parse(dir_chunk, chmLzxcResetTable);
+	}
+
+	public void testGetBlockAddress() {
+		Assert.assertEquals(TestParameters.VP_RESET_TABLE_BA,
+				chmLzxcResetTable.getBlockAddress().length);
+	}
+
+	public void testGetBlockCount() {
+		Assert.assertEquals(TestParameters.VP_RESET_TABLE_BA,
+				chmLzxcResetTable.getBlockCount());
+	}
+
+	public void testGetBlockLen() {
+		Assert.assertEquals(TestParameters.VP_RES_TBL_BLOCK_LENGTH,
+				chmLzxcResetTable.getBlockLen());
+	}
+
+	public void testGetCompressedLen() {
+		Assert.assertEquals(TestParameters.VP_RES_TBL_COMPR_LENGTH,
+				chmLzxcResetTable.getCompressedLen());
+	}
+
+	public void testGetTableOffset() {
+		Assert.assertEquals(TestParameters.VP_TBL_OFFSET,
+				chmLzxcResetTable.getTableOffset());
+	}
+
+	public void testGetUncompressedLen() {
+		Assert.assertEquals(TestParameters.VP_RES_TBL_UNCOMP_LENGTH,
+				chmLzxcResetTable.getUncompressedLen());
+	}
+
+	public void testGetUnknown() {
+		Assert.assertEquals(TestParameters.VP_RES_TBL_UNKNOWN,
+				chmLzxcResetTable.getUnknown());
+	}
+
+	public void testGetVersion() {
+		Assert.assertEquals(TestParameters.VP_RES_TBL_VERSION,
+				chmLzxcResetTable.getVersion());
+	}
+
+	public void testToString() {
+		Assert.assertTrue(chmLzxcResetTable.toString().length() > 0);
+	}
+
+	public void tearDown() throws Exception {
+	}
+
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestDirectoryListingEntry.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestDirectoryListingEntry.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestDirectoryListingEntry.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestDirectoryListingEntry.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tika.parser.chm.accessor.DirectoryListingEntry;
+
+/**
+ * Tests public methods of the DirectoryListingEntry class
+ * 
+ */
+public class TestDirectoryListingEntry extends TestCase {
+	private DirectoryListingEntry dle = null;
+
+	public void setUp() throws Exception {
+		dle = new DirectoryListingEntry(TestParameters.nameLength,
+				TestParameters.entryName, TestParameters.entryType,
+				TestParameters.offset, TestParameters.length);
+	}
+
+	public void testDefaultConstructor() {
+		Assert.assertNotNull(dle);
+	}
+
+	public void testParamConstructor() {
+		Assert.assertEquals(TestParameters.nameLength, dle.getNameLength());
+		Assert.assertEquals(TestParameters.entryName, dle.getName());
+		Assert.assertEquals(TestParameters.entryType, dle.getEntryType());
+		Assert.assertEquals(TestParameters.offset, dle.getOffset());
+		Assert.assertEquals(TestParameters.length, dle.getLength());
+	}
+
+	public void testToString() {
+		Assert.assertNotNull(dle.toString());
+	}
+
+	public void testGetNameLength() {
+		Assert.assertEquals(TestParameters.nameLength, dle.getNameLength());
+	}
+
+	public void testGetName() {
+		Assert.assertEquals(TestParameters.entryName, dle.getName());
+	}
+
+	public void testGetEntryType() {
+		Assert.assertEquals(TestParameters.entryType, dle.getEntryType());
+	}
+
+	public void testGetOffset() {
+		Assert.assertEquals(TestParameters.offset, dle.getOffset());
+	}
+
+	public void testGetLength() {
+		Assert.assertEquals(TestParameters.length, dle.getLength());
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestParameters.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestParameters.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestParameters.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestParameters.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import org.apache.tika.parser.chm.core.ChmCommons.EntryType;
+
+/**
+ * Holds test parameters such as verification points
+ */
+public class TestParameters {
+	/* Prevents initialization */
+	private TestParameters() {
+	}
+
+	/* Tests values */
+	static final int nameLength = 5;
+	static final String entryName = TestParameters.class.getName();
+	static EntryType entryType = EntryType.COMPRESSED;
+	static final int offset = 3;
+	static final int length = 20;
+	static final int NTHREADS = 2;
+
+	static final int BUFFER_SIZE = 16384;
+
+	static final String chmFile = "/test-documents/testChm.chm";
+
+	/* Verification points */
+	static final String VP_CHM_MIME_TYPE = "Content-Type=application/x-chm";
+	static final String VP_EXTRACTED_TEXT = "The TCard method accepts only numeric arguments";
+	static final String VP_ISTF_SIGNATURE = "ITSF";
+	static final String VP_ISTP_SIGNATURE = "ITSP";
+	static final String VP_PMGL_SIGNATURE = "PMGL";
+	static final String VP_CONTROL_DATA_SIGNATURE = "LZXC";
+
+	static final int VP_DIRECTORY_LENGTH = 4180;
+	static final int VP_DATA_OFFSET_LENGTH = 4300;
+	static final int VP_DIRECTORY_OFFSET = 120;
+	static final int VP_ITSF_HEADER_LENGTH = 96;
+	static final int VP_LANGUAGE_ID = 1033;
+	static final int VP_LAST_MODIFIED = 1042357880;
+	static final int VP_UNKNOWN_000C = 1;
+	static final int VP_UNKNOWN_LEN = 24;
+	static final int VP_UNKNOWN_OFFSET = 96;
+	static final int VP_VERSION = 3;
+	static final int VP_BLOCK_LENGTH = 4096;
+	static final int VP_BLOCK_INDEX_INTERVAL = 2;
+	static final int VP_ITSP_HEADER_LENGTH = 84;
+	static final int VP_INDEX_DEPTH = 1;
+	static final int VP_INDEX_HEAD = 0;
+	static final int VP_INDEX_ROOT = -1;
+	static final int VP_UNKNOWN_NUM_BLOCKS = -1;
+	static final int VP_ITSP_UNKNOWN_000C = 10;
+	static final int VP_ITSP_UNKNOWN_0024 = 0;
+	static final int VP_ITSP_UNKNOWN_002C = 1;
+	static final int VP_ITSP_BYTEARR_LEN = 16;
+	static final int VP_ITSP_VERSION = 1;
+	static final int VP_RESET_INTERVAL = 2;
+	static final int VP_CONTROL_DATA_SIZE = 6;
+	static final int VP_UNKNOWN_18 = 0;
+	static final int VP_CONTROL_DATA_VERSION = 2;
+	static final int VP_WINDOW_SIZE = 65536;
+	static final int VP_WINDOWS_PER_RESET = 1;
+	static final int VP_CHM_ENTITIES_NUMBER = 101;
+	static final int VP_PMGI_FREE_SPACE = 3;
+	static final int VP_PMGL_BLOCK_NEXT = -1;
+	static final int VP_PMGL_BLOCK_PREV = -1;
+	static final int VP_PMGL_FREE_SPACE = 1644;
+	static final int VP_PMGL_UNKNOWN_008 = 0;
+	static final int VP_RESET_TABLE_BA = 12;
+	static final int VP_RES_TBL_BLOCK_LENGTH = 32768;
+	static final int VP_RES_TBL_COMPR_LENGTH = 177408;
+	static final int VP_RES_TBL_UNCOMP_LENGTH = 383786;
+	static final int VP_TBL_OFFSET = 40;
+	static final int VP_RES_TBL_UNKNOWN = 8;
+	static final int VP_RES_TBL_VERSION = 2;
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmgiHeader.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmgiHeader.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmgiHeader.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmgiHeader.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,34 @@
+package org.apache.tika.parser.chm;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmPmgiHeader;
+import org.apache.tika.parser.chm.core.ChmCommons;
+
+public class TestPmgiHeader extends TestCase {
+	ChmPmgiHeader chmPmgiHeader = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		byte[] data = ChmCommons.toByteArray(stream);
+		chmPmgiHeader = new ChmPmgiHeader();
+		chmPmgiHeader.parse(data, chmPmgiHeader);
+	}
+
+	public void testToString() {
+		Assert.assertTrue((chmPmgiHeader != null)
+				&& (chmPmgiHeader.toString().length() > 0));
+	}
+
+	public void testGetFreeSpace() {
+		Assert.assertEquals(TestParameters.VP_PMGI_FREE_SPACE,
+				chmPmgiHeader.getFreeSpace());
+	}
+
+	public void tearDown() throws Exception {
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmglHeader.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmglHeader.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmglHeader.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestPmglHeader.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,58 @@
+package org.apache.tika.parser.chm;
+
+import java.util.Arrays;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tika.detect.TestContainerAwareDetector;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.parser.chm.accessor.ChmPmglHeader;
+import org.apache.tika.parser.chm.core.ChmCommons;
+import org.apache.tika.parser.chm.core.ChmConstants;
+
+public class TestPmglHeader extends TestCase {
+	ChmPmglHeader chmPmglHeader = null;
+
+	public void setUp() throws Exception {
+		TikaInputStream stream = TikaInputStream
+				.get(TestContainerAwareDetector.class
+						.getResource(TestParameters.chmFile));
+		byte[] data = ChmCommons.toByteArray(stream);
+		chmPmglHeader = new ChmPmglHeader();
+		chmPmglHeader.parse(Arrays.copyOfRange(data, ChmConstants.START_PMGL,
+				ChmConstants.START_PMGL + ChmConstants.CHM_PMGL_LEN + 10),
+				chmPmglHeader);
+	}
+
+	public void testToString() {
+		Assert.assertTrue((chmPmglHeader != null)
+				&& chmPmglHeader.toString().length() > 0);
+	}
+
+	public void testChmPmglHeaderGet() {
+		Assert.assertEquals(TestParameters.VP_PMGL_SIGNATURE, new String(
+				chmPmglHeader.getSignature()));
+	}
+
+	public void testGetBlockNext() {
+		Assert.assertEquals(TestParameters.VP_PMGL_BLOCK_NEXT,
+				chmPmglHeader.getBlockNext());
+	}
+
+	public void testGetBlockPrev() {
+		Assert.assertEquals(TestParameters.VP_PMGL_BLOCK_PREV,
+				chmPmglHeader.getBlockPrev());
+	}
+
+	public void testGetFreeSpace() {
+		Assert.assertEquals(TestParameters.VP_PMGL_FREE_SPACE,
+				chmPmglHeader.getFreeSpace());
+	}
+
+	public void testGetUnknown0008() {
+		Assert.assertEquals(TestParameters.VP_PMGL_UNKNOWN_008,
+				chmPmglHeader.getUnknown0008());
+	}
+
+	public void tearDown() throws Exception {
+	}
+}

Added: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestUtils.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestUtils.java?rev=1133050&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestUtils.java (added)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/chm/TestUtils.java Tue Jun  7 15:47:32 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.chm;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tika.parser.chm.exception.ChmParsingException;
+
+public class TestUtils {
+	/**
+	 * Converts InputStream to byte array
+	 * 
+	 * @param is
+	 *            InputStream
+	 * @return byte[]
+	 * 
+	 * @throws IOException
+	 */
+	public static byte[] toByteArray(InputStream is) throws IOException {
+		synchronized (is) {
+			if (is != null) {
+				ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+				int nRead;
+				byte[] data = new byte[TestParameters.BUFFER_SIZE];
+				while ((nRead = is.read(data, 0, data.length)) != -1) {
+					buffer.write(data, 0, nRead);
+				}
+				buffer.flush();
+				try {
+					is.close();
+					buffer.close();
+				} catch (Exception e) {
+					System.err.println(e.getMessage());
+				}
+				return buffer.toByteArray();
+			} else
+				throw new ChmParsingException("InputStream is null");
+		}
+	}
+}