001: package com.ibm.emb.test.mfb;
002:
003: // java stuff
004: import javax.emb.MediaConverterSpec;
005: import javax.emb.MediaException;
006:
007: import mfb.converters.JpegToBmpConverterSpec;
008:
009: import com.ibm.emb.junit.EMBTestRunner;
010: import com.ibm.emb.test.MediaConverterSpecTest;
011:
012: public class JpegToBmpConverterSpecTest extends MediaConverterSpecTest {
013:
014: /**
015: * constructor
016: */
017: public JpegToBmpConverterSpecTest(String name)
018: throws MediaException {
019: super (name);
020: }
021:
022: /**
023: * main method
024: */
025: public static void main(String args[]) {
026: EMBTestRunner.run(JpegToBmpConverterSpecTest.class);
027: }
028:
029: /**
030: * do initialisation here
031: */
032: protected void setUp() {
033: }
034:
035: /**
036: * freeup resources
037: */
038: protected void tearDown() {
039: }
040:
041: /**
042: * creates an instance of BmpToJpegConverterSpec with the given Parameters
043: * used in super class of BmpToJpegConverterSpectest
044: */
045: public MediaConverterSpec createMediaConverterSpec() {
046:
047: return new JpegToBmpConverterSpec();
048: }
049:
050: /**
051: * <pre>
052: *
053: *
054: *
055: * Testcase Name: JpegToBmpConverterSpec(byte)
056: * Testcase Number: TEMB0102SBA
057: *
058: * setup:
059: *
060: * test procedure:
061: * 1.iterate over valid color depth (32, 24, 16, 8, 4, 1)
062: * create JpegToBmpConverterSpec passing color depth
063: * expected result: no exception
064: *
065: * 2.iterate over invalid color depth (-1, 0, 2, 64)
066: * create JpegToBmpConverterSpec passing color depth
067: * expected result: IllegalArgumentException
068: *
069: *
070: *
071: * </pre>
072: */
073: public void testTEMB0102SBA() {
074: //
075: // test 1
076: //
077: byte[] colorDepth = { 32, 24, 16, 8, 4, 1 };
078:
079: for (int i = 0; i < colorDepth.length; i++) {
080: JpegToBmpConverterSpec testInstance = new JpegToBmpConverterSpec(
081: colorDepth[i]);
082: }
083: testTrace("test 1 passed");
084: //
085: // test 2
086: //
087: colorDepth = new byte[] { -1, 0, 2, 64 };
088:
089: try {
090: for (int i = 0; i < colorDepth.length; i++) {
091: JpegToBmpConverterSpec testInstance = new JpegToBmpConverterSpec(
092: colorDepth[i]);
093: }
094: fail("test 2: Should throw IllegalArgumentException");
095: } catch (IllegalArgumentException e) {
096: testTrace("test 2 passed");
097: } catch (Exception e) {
098: fail("test 2: Should throw IllegalArgumentException but threw "
099: + e.toString());
100: }
101:
102: succeed();
103: }
104: }
|