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

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

/*
* 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: InlineHeaderBuilderTest.java 571944 2007-09-02 10:48:42Z vgritsenko $
*/

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

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

import junit.framework.TestCase;

/**
* @version $Revision: 571944 $, $Date: 2007-09-02 06:48:42 -0400 (Sun, 02 Sep 2007) $
* @author Gary Shea <shea@gtsdesign.com>
*/
public class InlineHeaderBuilderTest extends TestCase {

    public void testInlineHeaderBuilderCreateValue() {
        byte[] metadata = new byte[] {
            0x0a, 0x0b, 0x0c};
        byte[] data = new byte[] {
            0x12, 0x11, 0x10, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};

        Value value = InlineHeaderBuilder.createValue(12, metadata, data, 2, 7);

        /*
         * byte 0 is the total header length
         */
        assertEquals(5, value.byteAt(0));
       
        /*
         * byte 1 is the metadata version
         */
        assertEquals(12, value.byteAt(1));
       
        /*
         * bytes 2-4 are metadata...
         */
        for (int i = 0; i < metadata.length; ++i) {
            assertEquals("i=" + i, metadata[i], value.byteAt(i + 2));
        }
       
        /*
         * bytes 5-11 are record value data.
         */
        for (int i = 0; i < 7; ++i) {
            assertEquals("i=" + i, data[i + 2], value.byteAt(i + 5));
        }
    }
}
TOP

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

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.