Package org.apache.xindice.core.meta.inline

Source Code of org.apache.xindice.core.meta.inline.ResourceTypeReaderTest

/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed 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.
*
* CVS $Id: ResourceTypeReaderTest.java,v 1.4 2004/02/08 03:56:47 vgritsenko Exp $
*/

package org.apache.xindice.core.meta.inline;

import org.apache.xindice.core.meta.inline.InlineMetaException;
import org.apache.xindice.core.meta.inline.InlineMetaMap;
import org.apache.xindice.core.meta.inline.ResourceTypeReader;

import junit.framework.TestCase;

/**
* @version CVS $Revision: 1.4 $, $Date: 2004/02/08 03:56:47 $
* @author Gary Shea <shea@gtsdesign.com>
*/
public class ResourceTypeReaderTest extends TestCase {

    public void testResourceTypeReaderRead() throws Exception {

        ResourceTypeReader reader = new ResourceTypeReader();
       
        byte[] binaryData = new byte[] {
            0x03, 0x01, 0x02, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
        byte[] evilData = new byte[] {
            0x03, 0x01, 0x03, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
        byte[] xmlData = new byte[] {
            0x03, 0x01, 0x01, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};

        InlineMetaMap map;

        map = reader.read(binaryData, 2, 1);
        assertEquals(ResourceTypeReader.BINARY, map.get("type"));

        map = reader.read(xmlData, 2, 1);
        assertEquals(ResourceTypeReader.XML, map.get("type"));
       
        try {
            reader.read(evilData, 2, 1);
            fail("failed to throw InlineMetaException on bad type value (3)");
        } catch (InlineMetaException e) {
            // expected exception
        }
    }
}
TOP

Related Classes of org.apache.xindice.core.meta.inline.ResourceTypeReaderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.