package com.ibm.emb.test.mfb;

// java stuff
import javax.emb.MediaConverterSpec;
import javax.emb.MediaException;

import mfb.converters.JpegToBmpConverterSpec;

import com.ibm.emb.junit.EMBTestRunner;
import com.ibm.emb.test.MediaConverterSpecTest;

public class JpegToBmpConverterSpecTest extends MediaConverterSpecTest {

    /**
     * constructor
     */
    public JpegToBmpConverterSpecTest(String name) throws MediaException {
        super(name);
    }

    /**
     * main method
     */
    public static void main(String args[]) {
        EMBTestRunner.run(JpegToBmpConverterSpecTest.class);
    }

    /**
     * do initialisation here
     */
    protected void setUp() {
    }

    /**
     * freeup resources
     */
    protected void tearDown() {
    }

    /**
     * creates an instance of BmpToJpegConverterSpec with the given Parameters
     * used in super class of BmpToJpegConverterSpectest
     */
    public MediaConverterSpec createMediaConverterSpec() {

        return new JpegToBmpConverterSpec();
    }

    /**
     * <pre>
     * 
     *  
     *   
     *        Testcase Name: JpegToBmpConverterSpec(byte)
     *        Testcase Number: TEMB0102SBA  
     *        
     *        setup: 
     *        
     *        test procedure:
     *        1.iterate over valid color depth (32, 24, 16, 8, 4, 1) 
     *        create JpegToBmpConverterSpec passing color depth
     *        expected result: no exception
     *        
     *        2.iterate over invalid color depth (-1, 0, 2, 64) 
     *        create JpegToBmpConverterSpec passing color depth
     *        expected result: IllegalArgumentException
     *        
     *   
     *  
     * </pre>
     */
    public void testTEMB0102SBA() {
        //
        // test 1
        //
        byte[] colorDepth = {32, 24, 16, 8, 4, 1};

        for (int i = 0; i < colorDepth.length; i++) {
            JpegToBmpConverterSpec testInstance = new JpegToBmpConverterSpec(colorDepth[i]);
        }
        testTrace("test 1 passed");
        //
        // test 2
        //
        colorDepth = new byte[] {-1, 0, 2, 64};

        try {
            for (int i = 0; i < colorDepth.length; i++) {
                JpegToBmpConverterSpec testInstance = new JpegToBmpConverterSpec(colorDepth[i]);
            }
            fail("test 2: Should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            testTrace("test 2 passed");
        } catch (Exception e) {
            fail("test 2: Should throw IllegalArgumentException but threw " + e.toString());
        }

        succeed();
    }
}