001: package com.ibm.emb.test;
002:
003: import javax.emb.MediaConverterSpec;
004: import javax.emb.MediaException;
005:
006: import junit.framework.Test;
007: import junit.framework.TestSuite;
008:
009: import com.ibm.emb.junit.EMBStaticHelper;
010: import com.ibm.emb.junit.EMBTestCaseBase;
011:
012: /**
013: * <pre>
014: *
015: * Line Item: MFB API
016: * Subcategory 1: javax.emb
017: * Subcategory 2: MediaConverterSpec
018: *
019: * This abstract class provides test methods for all Methods described in the interface
020: * MediaConverterSpec.
021: * For testing implementations of this interface one needs to create a Tester
022: * class which extends this abstract class.
023: *
024: * </pre>
025: */
026: public abstract class MediaConverterSpecTest extends EMBTestCaseBase {
027:
028: public MediaConverterSpecTest(String name) throws MediaException {
029: super (name);
030: }
031:
032: /**
033: * stdSuite method of this test class instantiates all tests necesssary to
034: * for the standard compliance tests
035: * @param String complete class Name of the implementor of the abstract test
036: */
037: public static Test stdSuite(String TestCaseImplementor) {
038: TestSuite suite = new TestSuite(TestCaseImplementor);
039: try {
040: Class implementorClass = Class.forName(TestCaseImplementor);
041: java.lang.reflect.Constructor implementorConstructor = implementorClass
042: .getDeclaredConstructor(new Class[] { String.class });
043: suite.addTest((Test) implementorConstructor
044: .newInstance(new String[] { "testEMB041" }));
045: suite.addTest((Test) implementorConstructor
046: .newInstance(new String[] { "testEMB042" }));
047: suite.addTest((Test) implementorConstructor
048: .newInstance(new String[] { "testEMB043" }));
049: } catch (java.lang.reflect.InvocationTargetException ex) {
050: String msg = "error dynamically creating "
051: + TestCaseImplementor + " " + ex.toString();
052: EMBStaticHelper.testTrace(msg);
053: throw new RuntimeException(msg);
054: } catch (ClassNotFoundException ex) {
055: String msg = "Class not found " + TestCaseImplementor + " "
056: + ex.toString();
057: EMBStaticHelper.testTrace(msg);
058: throw new RuntimeException(msg);
059: } catch (NoSuchMethodException ex) {
060: String msg = "No such method in " + TestCaseImplementor
061: + " " + ex.toString();
062: EMBStaticHelper.testTrace(msg);
063: throw new RuntimeException(msg);
064: } catch (InstantiationException ex) {
065: String msg = TestCaseImplementor + " " + ex.toString();
066: EMBStaticHelper.testTrace(msg);
067: throw new RuntimeException(msg);
068: } catch (IllegalAccessException ex) {
069: String msg = TestCaseImplementor + " " + ex.toString();
070: EMBStaticHelper.testTrace(msg);
071: throw new RuntimeException(msg);
072: }
073: return suite;
074: }
075:
076: /**
077: * abstract method to create an instance of MediaConverterSpec this method
078: * needs to be implemented in the test subclass and will create an Instance
079: * of the concrete implementation of the class under test
080: */
081: public abstract MediaConverterSpec createMediaConverterSpec();
082:
083: /**
084: * <pre>
085: *
086: * Testcase Name: getConverter()
087: * Testcase Number: EMB041
088: *
089: * setup:
090: *
091: * test procedure:
092: * 1.call getConverter()
093: * expected result: not null and instance of MediaConverter
094: *
095: * </pre>
096: */
097: public void testEMB041() {
098: //
099: // test 1
100: //
101: MediaConverterSpec testInstance = createMediaConverterSpec();
102: assertNotNull("test1 : ", testInstance);
103: testTrace("test 1 passed");
104:
105: succeed();
106: }
107:
108: /**
109: * <pre>
110: *
111: * Testcase Name: getTargetFileExtension() {
112: * Testcase Number: EMB042
113: *
114: * setup:
115: *
116: * test procedure:
117: * 1.call getTargetFileExtension
118: * expected result: return string without separator characters
119: *
120: * </pre>
121: */
122: public void testEMB042() {
123: //
124: // test 1
125: //
126: MediaConverterSpec testInstance = createMediaConverterSpec();
127: String fileExt = testInstance.getTargetFileExtension();
128: if (fileExt != null) {
129: assertEquals("test 1: ", -1, fileExt.indexOf('\\'));
130: assertEquals("test 1: ", -1, fileExt.indexOf('/'));
131: assertEquals("test 1: ", -1, fileExt.indexOf(':'));
132: assertEquals("test 1: ", -1, fileExt.indexOf(';'));
133: assertEquals("test 1: ", -1, fileExt.indexOf('.'));
134: }
135:
136: testTrace("test 1 passed");
137: succeed();
138: }
139:
140: /**
141: * <pre>
142: *
143: * Testcase Name: getTargetMimeType()
144: * Testcase Number: EMB043
145: *
146: * setup:
147: *
148: * test procedure:
149: * 1.create MediaConverterSpec testInstance and call getTargetMimeType
150: * expected result: string or null
151: *
152: * </pre>
153: */
154: public void testEMB043() {
155: //
156: // test 1
157: //
158: MediaConverterSpec testInstance = createMediaConverterSpec();
159: assertTrue("test 1: ", testInstance.getTargetMimeType() != "");
160: testTrace("test 1 passed");
161: succeed();
162: }
163:
164: }
|