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

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

/*
* 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.
*
* $Id: ResourceTypeReaderTest.java 511423 2007-02-25 03:21:05Z vgritsenko $
*/

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

import org.apache.xindice.core.data.Value;

import junit.framework.TestCase;

/**
*
* @version $Revision: 511423 $, $Date: 2007-02-24 22:21:05 -0500 (Sat, 24 Feb 2007) $
* @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(new Value(binaryData, 2, 1));
        assertEquals(ResourceTypeReader.BINARY, map.get("type"));

        map = reader.read(new Value(xmlData, 2, 1));
        assertEquals(ResourceTypeReader.XML, map.get("type"));
       
        try {
            reader.read(new Value(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.