Source Code Cross Referenced for MetaDataEntityLocalTest.java in  » J2EE » JOnAS-4.8.6 » com » ibm » emb » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » com.ibm.emb.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.ibm.emb.test;
0002:
0003:        import java.io.BufferedReader;
0004:        import java.io.ByteArrayInputStream;
0005:        import java.io.File;
0006:        import java.io.FileNotFoundException;
0007:        import java.io.FileReader;
0008:        import java.io.FileWriter;
0009:        import java.io.IOException;
0010:        import java.rmi.RemoteException;
0011:        import java.util.Date;
0012:
0013:        import javax.ejb.CreateException;
0014:        import javax.ejb.FinderException;
0015:        import javax.ejb.RemoveException;
0016:        import javax.emb.MediaException;
0017:        import javax.emb.MediaFormat;
0018:        import javax.naming.InitialContext;
0019:        import javax.naming.NamingException;
0020:        import javax.rmi.PortableRemoteObject;
0021:        import javax.xml.parsers.ParserConfigurationException;
0022:
0023:        import org.apache.xerces.parsers.DOMParser;
0024:        import org.objectweb.jonas.emb.mfb.formats.image.BmpFormat;
0025:        import org.objectweb.jonas.emb.mfb.formats.image.JpegFormat;
0026:        import org.w3c.dom.Attr;
0027:        import org.w3c.dom.Document;
0028:        import org.w3c.dom.Element;
0029:        import org.w3c.dom.NamedNodeMap;
0030:        import org.w3c.dom.Node;
0031:        import org.w3c.dom.NodeList;
0032:        import org.xml.sax.InputSource;
0033:        import org.xml.sax.SAXException;
0034:
0035:        import com.ibm.emb.junit.EMBStaticHelper;
0036:        import com.ibm.emb.junit.EMBTestCaseBase;
0037:        import com.ibm.emb.meb.test.ejb.MetaDataEntityLocalTestDriver;
0038:        import com.ibm.emb.meb.test.ejb.MetaDataEntityLocalTestDriverHome;
0039:
0040:        /**
0041:         * <pre>
0042:         *
0043:         *  Line Item: MEB API
0044:         *  Subcategory 1: javax.emb
0045:         *  Subcategory 2: MetaDataEntityLocal
0046:         *
0047:         * </pre>
0048:         */
0049:
0050:        public class MetaDataEntityLocalTest extends EMBTestCaseBase {
0051:
0052:            /**
0053:             * Constructor for MetaDataEntityLocalTest.
0054:             * @param name
0055:             */
0056:            public MetaDataEntityLocalTest(String name) throws MediaException {
0057:                super (name);
0058:            }
0059:
0060:            private static String MDEBTESTER_JNDI = "java:comp/env/ejb/MetaDataEntityLocalTestDriverHome";
0061:
0062:            private static String TXUSER_JNDI = "jta/usertransaction";
0063:
0064:            private InitialContext ic;
0065:
0066:            private MetaDataEntityLocalTestDriverHome mdebHome;
0067:
0068:            private MetaDataEntityLocalTestDriver mdebTester = null;
0069:
0070:            /**
0071:             * do initialisation of each individual Test method here this method is
0072:             * called before each individual Test Method
0073:             */
0074:            protected void setUp() throws RemoteException, CreateException {
0075:                if (mdebHome == null) {
0076:                    try {
0077:                        ic = new InitialContext();
0078:                        Object ojb = ic.lookup(MDEBTESTER_JNDI);
0079:                        mdebHome = (MetaDataEntityLocalTestDriverHome) PortableRemoteObject
0080:                                .narrow(ojb,
0081:                                        MetaDataEntityLocalTestDriverHome.class);
0082:                    } catch (NamingException ne) {
0083:                        System.out
0084:                                .println("NamingException thrown during setup. Msg: "
0085:                                        + ne.getMessage());
0086:                    }
0087:                }
0088:                mdebTester = mdebHome.create();
0089:                return;
0090:            }
0091:
0092:            protected void tearDown() throws IOException {
0093:
0094:            }
0095:
0096:            /**
0097:             * recursive function which compares two XML elements
0098:             */
0099:            protected static boolean xmlCompare(Element expected, Element actual) {
0100:                boolean match = false;
0101:
0102:                // check if text matches
0103:                if ((expected.getFirstChild() != null)
0104:                        && (expected.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
0105:                    if ((actual.getFirstChild() != null)
0106:                            && (actual.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
0107:                        if (expected.getFirstChild().getNodeValue().trim()
0108:                                .equals(
0109:                                        actual.getFirstChild().getNodeValue()
0110:                                                .trim())) {
0111:                        } else {
0112:                            return false;
0113:                        }
0114:                    } else {
0115:                        return false;
0116:                    }
0117:                }
0118:
0119:                // check attributes for node
0120:                if (expected.hasAttributes()) {
0121:                    boolean allAttrsFound = true;
0122:                    NamedNodeMap attrs = expected.getAttributes();
0123:                    for (int k = 0; k < attrs.getLength(); k++) {
0124:                        Attr currentAttr = (Attr) attrs.item(k);
0125:                        if (actual.hasAttribute(currentAttr.getName())) {
0126:                            if (currentAttr.getValue().equals(
0127:                                    actual.getAttributeNode(
0128:                                            currentAttr.getName()).getValue())) {
0129:                            } else {
0130:                                return false;
0131:                            }
0132:                        } else {
0133:                            // actual does not have this attribute
0134:                            return false;
0135:                        }
0136:                    }
0137:                }
0138:
0139:                // retrieve all child elements
0140:                NodeList expectedChildren = expected.getChildNodes();
0141:                NodeList actualChildren = actual.getChildNodes();
0142:                if (expectedChildren.getLength() != actualChildren.getLength()) {
0143:                    return false;
0144:                }
0145:
0146:                // for each child, find matching node
0147:                for (int i = 0; i < expectedChildren.getLength(); i++) {
0148:                    if (expectedChildren.item(i).getNodeType() == Node.ELEMENT_NODE) {
0149:                        Element currentElement = (Element) expectedChildren
0150:                                .item(i);
0151:                        NodeList matchingElements = actual
0152:                                .getElementsByTagName(currentElement
0153:                                        .getTagName());
0154:                        for (int j = 0; j < matchingElements.getLength(); j++) {
0155:                            match = xmlCompare(currentElement,
0156:                                    (Element) matchingElements.item(j));
0157:                            if (match) {
0158:                                break;
0159:                            }
0160:                        }
0161:                        if (!match) {
0162:                            return false;
0163:                        }
0164:                    }
0165:                }
0166:                return true;
0167:            }
0168:
0169:            private String retrieveXML(String fileName) throws IOException {
0170:                File xmlFile = new File(embTestConfig.getMediaDir()
0171:                        + File.separatorChar + fileName);
0172:                FileReader xmlFileReader = new FileReader(xmlFile);
0173:                BufferedReader xmlBufferedReader = new BufferedReader(
0174:                        xmlFileReader);
0175:                String temp = xmlBufferedReader.readLine();
0176:                String xmlContent = "";
0177:                while (temp != null) {
0178:                    xmlContent = xmlContent + temp;
0179:                    temp = xmlBufferedReader.readLine();
0180:                }
0181:                xmlBufferedReader.close();
0182:                xmlFileReader.close();
0183:
0184:                return xmlContent;
0185:            }
0186:
0187:            /**
0188:             * <pre>
0189:             *
0190:             *  Testcase Name: addChild(MetaDataEntityLocal)
0191:             *  Testcase Number: EMB148
0192:             *
0193:             *  setup: create meta data entities md1, md2, and md3
0194:             *
0195:             *  test procedure:
0196:             *  1.call md1.addChild(null)
0197:             *    expected result: NullPointerException
0198:             *
0199:             *  2.call md1.addChild(md3)
0200:             *    expected result: no exception
0201:             *    call md1.getChildren() and verify 1 element array containing md3
0202:             *    call md3.getParents() and verify 1 element array containing md1
0203:             *
0204:             *  3.call md2.addChild(md3)
0205:             *    expected result: no exception
0206:             *    call md2.getChildren() and verify 1 element array containing md3
0207:             *    call md1.getChildren() and check that md3 is still in array
0208:             *  	 call md3.getParents() and check that md1 and md2 are listed
0209:             *
0210:             * </pre>
0211:             */
0212:            public void testEMB148() throws IOException, MediaException,
0213:                    CreateException, RemoteException, NamingException,
0214:                    FinderException, RemoveException {
0215:
0216:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0217:
0218:                String md1 = mdebTester.createMetaDataEntityBean();
0219:                String md2 = mdebTester.createMetaDataEntityBean();
0220:                String md3 = mdebTester.createMetaDataEntityBean();
0221:
0222:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0223:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0224:                mdebTester.setMetaDataEntityXML(md3, xmlContent, false);
0225:
0226:                int exception = -1;
0227:                //
0228:                // test 1
0229:                //
0230:                try {
0231:                    exception = mdebTester.addChildExceptions(md1, null);
0232:                } catch (Throwable e) {
0233:                    fail("test 1 threw " + e.toString());
0234:                }
0235:                assertEquals("test 1: Should throw a NullPointerException",
0236:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
0237:                testTrace("test 1 passed");
0238:                //
0239:                // test 2
0240:                //
0241:                mdebTester.addMetaDataChild(md1, md3);
0242:                String[] mdChildren = mdebTester.getMetaDataEntityChildren(md1);
0243:                String[] mdParents = mdebTester.getMetaDataEntityParents(md3);
0244:
0245:                assertEquals("test 2: mdChildren does not contain 1 element",
0246:                        1, mdChildren.length);
0247:                assertEquals("test 2: child is not md3", mdChildren[0], md3);
0248:                assertEquals("test 2: mdParents does not contain 1 element", 1,
0249:                        mdParents.length);
0250:                assertEquals("test 2: parent is not md1", mdParents[0], md1);
0251:                testTrace("test 2 passed");
0252:                //
0253:                // test 3
0254:                //
0255:                mdebTester.addMetaDataChild(md2, md3);
0256:                mdChildren = mdebTester.getMetaDataEntityChildren(md1);
0257:                assertEquals(
0258:                        "test 3: md1.getChildren does not contain 1 element",
0259:                        1, mdChildren.length);
0260:                assertEquals("test 3: child is not md3", mdChildren[0], md3);
0261:
0262:                mdChildren = mdebTester.getMetaDataEntityChildren(md1);
0263:                assertEquals(
0264:                        "test 3: md2.getChildren does not contain 1 element",
0265:                        1, mdChildren.length);
0266:                assertEquals("test 3: child is not md3", mdChildren[0], md3);
0267:
0268:                mdParents = mdebTester.getMetaDataEntityParents(md3);
0269:                if ((mdParents[0].equals(md1) && mdParents[1].equals(md2))
0270:                        || (mdParents[0].equals(md2) && mdParents[1]
0271:                                .equals(md1))) {
0272:                    testTrace("test 3 passed");
0273:                } else {
0274:                    fail("test 3: parents are incorrect");
0275:                }
0276:
0277:                mdebTester.removeMDEBByPK(md1);
0278:                mdebTester.removeMDEBByPK(md2);
0279:                mdebTester.removeMDEBByPK(md3);
0280:                succeed();
0281:
0282:            }
0283:
0284:            /**
0285:             * <pre>
0286:             *
0287:             *  Testcase Name: addMediaEntity(MediaEntityLocal)
0288:             *  Testcase Number: EMB149
0289:             *
0290:             *  setup: create Media entities me1 and me2
0291:             *  		  create meta data entities md1 and md2
0292:             *
0293:             *  test procedure:
0294:             *  1.call md1.addMediaEntity(null)
0295:             *    expected result: NullPointerException
0296:             *
0297:             *  2.call md1.addMediaEntity(me1)
0298:             *    expected result: no exception
0299:             *    call md1.getMediaEntities() and verify me1 is in array
0300:             *
0301:             *  3.call md1.addMediaEntity(me2)
0302:             *    expected result: no exception
0303:             *    call md1.getMediaEntities() and verify two elements in array
0304:             *
0305:             *  4.call md2.addMediaEntity(me1)
0306:             *    expected result: no exception
0307:             *  	 call md2.getMediaEntities() and verify one element in array
0308:             *    call md1.getMediaEntities() and verify two elements in array
0309:             *
0310:             * </pre>
0311:             */
0312:            public void testEMB149() throws IOException, MediaException,
0313:                    CreateException, RemoteException, NamingException,
0314:                    FinderException, RemoveException {
0315:
0316:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0317:                String md1 = mdebTester.createMetaDataEntityBean();
0318:                String md2 = mdebTester.createMetaDataEntityBean();
0319:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0320:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0321:
0322:                String me1 = mdebTester.createMediaEntityBean();
0323:                String me2 = mdebTester.createMediaEntityBean();
0324:
0325:                int exception = -1;
0326:                //
0327:                // test 1
0328:                //
0329:                try {
0330:                    exception = mdebTester.addMediaExceptions(md1, null);
0331:                } catch (Throwable e) {
0332:                    fail("test 1 threw " + e.toString());
0333:                }
0334:                assertEquals("test 1: Should throw a NullPointerException",
0335:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
0336:                testTrace("test 1 passed");
0337:                //
0338:                // test 2
0339:                //
0340:                mdebTester.addMetaDataMedia(md1, me1);
0341:                String[] mediaEntities = mdebTester
0342:                        .getMetaDataEntityMediaEntities(md1);
0343:                assertEquals("test 2: md1 has more than one media entity", 1,
0344:                        mediaEntities.length);
0345:                assertEquals("test 2: media entity is not me1",
0346:                        mediaEntities[0], me1);
0347:                testTrace("test 2 passed");
0348:                //
0349:                // test 3
0350:                //
0351:                mdebTester.addMetaDataMedia(md1, me2);
0352:                mediaEntities = mdebTester.getMetaDataEntityMediaEntities(md1);
0353:                assertEquals("test 3: md1 does not have two media entities", 2,
0354:                        mediaEntities.length);
0355:                assertTrue(
0356:                        "test 3: media entities do not match",
0357:                        (mediaEntities[0].equals(me1) && mediaEntities[1]
0358:                                .equals(me2))
0359:                                || (mediaEntities[0].equals(me2) && mediaEntities[1]
0360:                                        .equals(me1)));
0361:                testTrace("test 3 passed");
0362:                //
0363:                // test 4
0364:                //
0365:                mdebTester.addMetaDataMedia(md2, me1);
0366:                mediaEntities = mdebTester.getMetaDataEntityMediaEntities(md1);
0367:                assertEquals("test 4: md1 does not have two media entities",
0368:                        mediaEntities.length, 2);
0369:                assertTrue(
0370:                        "test 4: media entities do not match",
0371:                        (mediaEntities[0].equals(me1) && mediaEntities[1]
0372:                                .equals(me2))
0373:                                || (mediaEntities[0].equals(me2) && mediaEntities[1]
0374:                                        .equals(me1)));
0375:                mediaEntities = mdebTester.getMetaDataEntityMediaEntities(md2);
0376:                assertEquals("test 4: md2 does not have one media entity", 1,
0377:                        mediaEntities.length);
0378:                assertEquals("test 4: media entity is not me1",
0379:                        mediaEntities[0], me1);
0380:                testTrace("test 4 passed");
0381:
0382:                mdebTester.removeMDEBByPK(md1);
0383:                mdebTester.removeMDEBByPK(md2);
0384:                mdebTester.removeMEBByPK(me1);
0385:                mdebTester.removeMEBByPK(me2);
0386:                succeed();
0387:            }
0388:
0389:            /**
0390:             * <pre>
0391:             *
0392:             *  Testcase Name: getXML()
0393:             *  Testcase Number: EMB159
0394:             *
0395:             *  setup: create meta data entity md1
0396:             *
0397:             *  test procedure:
0398:             *  1.call md1.getXML
0399:             *  	 expected result: no exception and not null
0400:             *  					  verify resulting String matches XML content
0401:             *
0402:             *  2.create meta data entity w/o setting XML content
0403:             *    expected result: ContentAccessException
0404:             *
0405:             * </pre>
0406:             */
0407:            public void testEMB159() throws IOException, FileNotFoundException,
0408:                    SAXException, ParserConfigurationException,
0409:                    CreateException, MediaException, RemoteException,
0410:                    NamingException, FinderException, RemoveException {
0411:
0412:                File xmlFile = new File(embTestConfig.getMediaDir()
0413:                        + File.separatorChar + embTestConfig.getXMLFile1());
0414:                File exportedXMLFile = new File(embTestConfig.getMediaDir()
0415:                        + File.separatorChar + "export" + File.separatorChar
0416:                        + "temp.xml");
0417:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0418:
0419:                String md1 = mdebTester.createMetaDataEntityBean();
0420:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0421:                //
0422:                // test 1
0423:                //
0424:                String retrievedXML = mdebTester.getMetaDataEntityXML(md1);
0425:                assertNotNull("test 1: XML content is null", retrievedXML);
0426:                exportedXMLFile.createNewFile();
0427:                FileWriter xmlFileWriter = new FileWriter(exportedXMLFile);
0428:                xmlFileWriter.write(retrievedXML);
0429:                xmlFileWriter.close();
0430:
0431:                DOMParser parser = new DOMParser();
0432:                parser
0433:                        .setFeature(
0434:                                "http://apache.org/xml/features/dom/include-ignorable-whitespace",
0435:                                true);
0436:                InputSource expectedXML = new InputSource(
0437:                        new ByteArrayInputStream(xmlContent.getBytes()));
0438:                InputSource actualXML = new InputSource(
0439:                        new ByteArrayInputStream(retrievedXML.getBytes()));
0440:
0441:                parser.parse(expectedXML);
0442:                Document xmlDoc1 = parser.getDocument();
0443:                parser.parse(actualXML);
0444:                Document xmlDoc2 = parser.getDocument();
0445:
0446:                Element root1 = xmlDoc1.getDocumentElement();
0447:                Element root2 = xmlDoc2.getDocumentElement();
0448:
0449:                assertTrue("test 1: XML content does not match", xmlCompare(
0450:                        root1, root2));
0451:                testTrace("test 1 passed");
0452:                //
0453:                // test 2
0454:                //
0455:                String md2 = mdebTester.createMetaDataEntityBean();
0456:                int exception = -1;
0457:                try {
0458:                    exception = mdebTester.getXMLExceptions(md2);
0459:                } catch (Throwable e) {
0460:                    fail("test 2 threw " + e.toString());
0461:                }
0462:                assertEquals("test 2: Should throw a ContentAccessException",
0463:                        MetaDataEntityLocalTestDriver.CONTENTACCESS, exception);
0464:                testTrace("test 2 passed");
0465:
0466:                mdebTester.removeMDEBByPK(md1);
0467:                mdebTester.removeMDEBByPK(md2);
0468:
0469:                succeed();
0470:            }
0471:
0472:            /**
0473:             * <pre>
0474:             *
0475:             *  Testcase Name: getLastModified()
0476:             *  Testcase Number: EMB151
0477:             *
0478:             *  setup: create meta data entity md1
0479:             *
0480:             *  test procedure:
0481:             *  1.call getLastModified()
0482:             *    expected result: no exception and not null
0483:             *
0484:             *  2.call getLastModified and remember timestamp
0485:             *    wait 2 seconds and call setName(randomString)
0486:             *    call getLastModified
0487:             *    expected result: timestamp updated
0488:             *
0489:             * </pre>
0490:             */
0491:            public void testEMB151() throws InterruptedException, IOException,
0492:                    MediaException, CreateException, RemoteException,
0493:                    NamingException, FinderException, RemoveException {
0494:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0495:                String md1 = mdebTester.createMetaDataEntityBean();
0496:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0497:                //
0498:                // test 1
0499:                //
0500:                try {
0501:                    mdebTester.getMetaDataEntityLastModified(md1);
0502:                    testTrace("test 1 passed");
0503:                } catch (Exception e) {
0504:                    fail("test 1 threw " + e.toString());
0505:                }
0506:                //
0507:                // test 2
0508:                //
0509:                Date beforeStamp = new Date(mdebTester
0510:                        .getMetaDataEntityLastModified(md1));
0511:                mdebTester.setMetaDataEntityName(md1, EMBStaticHelper
0512:                        .createRandomString(EMBStaticHelper.randomInt(0, 10)));
0513:                Thread.sleep(2 * 1000);
0514:                Date afterStamp = new Date(mdebTester
0515:                        .getMetaDataEntityLastModified(md1));
0516:                assertTrue("test 2: modification date", afterStamp
0517:                        .after(beforeStamp));
0518:                testTrace("test 2 passed");
0519:
0520:                mdebTester.removeMDEBByPK(md1);
0521:                succeed();
0522:            }
0523:
0524:            /**
0525:             * <pre>
0526:             *
0527:             *  Testcase Name: getMediaEntities()
0528:             *  Testcase Number: EMB152
0529:             *
0530:             *  setup: create Media entities me1 and me2
0531:             *  		  create meta data entity md1 and md2
0532:             *
0533:             *  test procedure:
0534:             *  1.call md1.addMediaEntity(me1)
0535:             *    call md1.addMediaEntity(me2)
0536:             *    call md1.getMediaEntities()
0537:             *    expected result: 2 element array containing me1 and me2
0538:             *
0539:             *  2.call md2.getMediaEntities()
0540:             *    expected result: empty array
0541:             *
0542:             * </pre>
0543:             */
0544:            public void testEMB152() throws IOException, CreateException,
0545:                    MediaException, RemoteException, NamingException,
0546:                    FinderException, RemoveException {
0547:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0548:
0549:                String md1 = mdebTester.createMetaDataEntityBean();
0550:                String md2 = mdebTester.createMetaDataEntityBean();
0551:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0552:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0553:
0554:                mdebTester.bindMediaFormat("jpg", new JpegFormat());
0555:                String me1 = mdebTester.createMediaSetName("test1.jpg");
0556:                String me2 = mdebTester.createMediaSetName("test2.jpg");
0557:                //
0558:                // test 1
0559:                //
0560:                mdebTester.addMetaDataMedia(md1, me1);
0561:                mdebTester.addMetaDataMedia(md1, me2);
0562:                String[] meArray = mdebTester
0563:                        .getMetaDataEntityMediaEntities(md1);
0564:                assertEquals("test 1: does not contain 2 elements",
0565:                        meArray.length, 2);
0566:                if ((meArray[0].equals(me1) && meArray[1].equals(me2))
0567:                        || (meArray[0].equals(me2) && meArray[1].equals(me1))) {
0568:                    testTrace("test 1 passed");
0569:                } else {
0570:                    fail("test 1: media entities are incorrect");
0571:                }
0572:                //
0573:                // test 2
0574:                //
0575:                meArray = mdebTester.getMetaDataEntityMediaEntities(md2);
0576:                assertEquals("test 2: md2 has media entities", meArray.length,
0577:                        0);
0578:                testTrace("test 2 passed");
0579:
0580:                mdebTester.removeMDEBByPK(md1);
0581:                mdebTester.removeMDEBByPK(md2);
0582:                mdebTester.removeMEBByPK(me1);
0583:                mdebTester.removeMEBByPK(me2);
0584:                succeed();
0585:            }
0586:
0587:            /**
0588:             * <pre>
0589:             *
0590:             *  Testcase Name: getMediaEntities(MediaFormat, boolean)
0591:             *  Testcase Number: EMB153
0592:             *
0593:             *  setup: create Media entities me1 and me2 from jpg files and me3 from bmp file
0594:             *    	  create meta data entities md1 and md2
0595:             *
0596:             *  test procedure:
0597:             *  1.call md1.getMediaEntities(null, false)
0598:             *    expected result: NullPointerException
0599:             *
0600:             *  2.rebind &quot;jpg&quot; and &quot;bmp&quot; to format registry
0601:             *    call md1.addChild(md2)
0602:             *    call md1.addMediaEntity(me1)
0603:             *    call md2.addMediaEntity(me2)
0604:             *  	 call md2.addMediaEntity(me3)
0605:             *  	 call md1.getMediaEntities(new JpegFormat(), false)
0606:             *  	 expected result: 1 element array containing me1
0607:             *
0608:             *  3.call md1.getMediaEntities(new JpegFormat(), true)
0609:             *    expected result: 2 element array
0610:             *
0611:             *  4.call md1.getMediaEntities(new BmpFormat(), false)
0612:             *    expected result: empty array
0613:             *
0614:             *  5.call md1.getMediaEntities(new BmpFormat(), true)
0615:             *    expected result: 1 element array
0616:             *
0617:             * </pre>
0618:             */
0619:            public void testEMB153() throws IOException, CreateException,
0620:                    MediaException, RemoteException, NamingException,
0621:                    FinderException, RemoveException {
0622:
0623:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0624:
0625:                String md1 = mdebTester.createMetaDataEntityBean();
0626:                String md2 = mdebTester.createMetaDataEntityBean();
0627:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0628:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0629:
0630:                mdebTester.bindMediaFormat("jpg", new JpegFormat());
0631:                mdebTester.bindMediaFormat("bmp", new BmpFormat());
0632:                String me1 = mdebTester.createMediaSetName("test1.jpg");
0633:                String me2 = mdebTester.createMediaSetName("test2.jpg");
0634:                String me3 = mdebTester.createMediaSetName("test3.bmp");
0635:
0636:                mdebTester.addMetaDataChild(md1, md2);
0637:                mdebTester.addMetaDataMedia(md1, me1);
0638:                mdebTester.addMetaDataMedia(md2, me2);
0639:                mdebTester.addMetaDataMedia(md2, me3);
0640:
0641:                int exception = -1;
0642:                //
0643:                // test 1
0644:                //
0645:                MediaFormat nullFormat = null;
0646:                try {
0647:                    exception = mdebTester.getMediaByFormatExceptions(md1,
0648:                            nullFormat, false);
0649:                } catch (Throwable e) {
0650:                    fail("test 1 threw " + e.toString());
0651:                }
0652:                assertEquals("test 1: Should throw a NullPointerException",
0653:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
0654:                testTrace("test 1 passed");
0655:                //
0656:                // test 2
0657:                //
0658:                String[] mediaEntitiesFound = mdebTester
0659:                        .getMetaDataEntityMediaEntities(md1, new JpegFormat(),
0660:                                false);
0661:                assertEquals("test 2: does not contain 1 element", 1,
0662:                        mediaEntitiesFound.length);
0663:                assertEquals("test 2: media does not match",
0664:                        mediaEntitiesFound[0], me1);
0665:                testTrace("test 2 passed");
0666:                //
0667:                // test 3
0668:                //
0669:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0670:                        md1, new JpegFormat(), true);
0671:                assertEquals("test 3: does not contain 1 element", 2,
0672:                        mediaEntitiesFound.length);
0673:                assertTrue(
0674:                        "test 3: media entities do not match",
0675:                        (mediaEntitiesFound[0].equals(me1) && mediaEntitiesFound[1]
0676:                                .equals(me2))
0677:                                || (mediaEntitiesFound[0].equals(me2) && mediaEntitiesFound[1]
0678:                                        .equals(me1)));
0679:                testTrace("test 3 passed");
0680:                //
0681:                // test 4
0682:                //
0683:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0684:                        md1, new BmpFormat(), false);
0685:                assertEquals("test 4: is not empty array", 0,
0686:                        mediaEntitiesFound.length);
0687:                testTrace("test 4 passed");
0688:                //
0689:                // test 5
0690:                //
0691:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0692:                        md1, new BmpFormat(), true);
0693:                assertEquals("test 5: is not empty array", 1,
0694:                        mediaEntitiesFound.length);
0695:                assertEquals("test 3: media does not match",
0696:                        mediaEntitiesFound[0], me3);
0697:                testTrace("test 5 passed");
0698:
0699:                mdebTester.removeMDEBByPK(md1);
0700:                mdebTester.removeMDEBByPK(md2);
0701:                mdebTester.removeMEBByPK(me1);
0702:                mdebTester.removeMEBByPK(me2);
0703:                mdebTester.removeMEBByPK(me3);
0704:
0705:                succeed();
0706:            }
0707:
0708:            /**
0709:             * <pre>
0710:             *
0711:             *  Testcase Name: getMediaEntities(String, boolean)
0712:             *  Testcase Number: EMB154
0713:             *
0714:             *  setup: create Media entities me1 and me2 from jpg files and me3 from bmp file
0715:             *    	  create meta data entities md1 and md2
0716:             *
0717:             *  test procedure:
0718:             *  1.call md1.getMediaEntities(null, false)
0719:             *    expected result: NullPointerException
0720:             *
0721:             *  2.rebind &quot;jpg&quot; and &quot;bmp&quot; to format registry
0722:             *  	 call md1.addChild(md2)
0723:             *  	 call md1.addMediaEntity(me1)
0724:             *    call md2.addMediaEntity(me2)
0725:             *  	 call md2.addMediaEntity(me3)
0726:             *  	 call md1.getMediaEntities(&quot;image/jpeg&quot;, false)
0727:             *    expected result: 1 element array containing me1
0728:             *
0729:             *  3.call md1.getMediaEntities(&quot;image/jpeg&quot;, true)
0730:             *    expected result: 2 element array
0731:             *
0732:             *  4.call md1.getMediaEntities(&quot;image/bmp&quot;, false)
0733:             *    expected result: empty array
0734:             *
0735:             *  5.call md1.getMediaEntities(&quot;image/bmp&quot;, true)
0736:             *    expected result: 1 element array
0737:             *
0738:             * </pre>
0739:             */
0740:            public void testEMB154() throws IOException, MediaException,
0741:                    CreateException, RemoteException, NamingException,
0742:                    FinderException, RemoveException {
0743:
0744:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0745:
0746:                String md1 = mdebTester.createMetaDataEntityBean();
0747:                String md2 = mdebTester.createMetaDataEntityBean();
0748:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0749:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0750:
0751:                mdebTester.bindMediaFormat("jpg", new JpegFormat());
0752:                mdebTester.bindMediaFormat("bmp", new BmpFormat());
0753:                String me1 = mdebTester.createMediaSetName("test1.jpg");
0754:                String me2 = mdebTester.createMediaSetName("test2.jpg");
0755:                String me3 = mdebTester.createMediaSetName("test3.bmp");
0756:
0757:                mdebTester.addMetaDataChild(md1, md2);
0758:                mdebTester.addMetaDataMedia(md1, me1);
0759:                mdebTester.addMetaDataMedia(md2, me2);
0760:                mdebTester.addMetaDataMedia(md2, me3);
0761:
0762:                int exception = -1;
0763:                //
0764:                // test 1
0765:                //
0766:                MediaFormat nullFormat = null;
0767:                try {
0768:                    exception = mdebTester.getMediaByFormatExceptions(md1,
0769:                            nullFormat, false);
0770:                } catch (Throwable e) {
0771:                    fail("test 1 threw " + e.toString());
0772:                }
0773:                assertEquals("test 1: Should throw a NullPointerException",
0774:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
0775:                testTrace("test 1 passed");
0776:                //
0777:                // test 2
0778:                //
0779:                String[] mediaEntitiesFound = mdebTester
0780:                        .getMetaDataEntityMediaEntities(md1, "image/jpeg",
0781:                                false);
0782:                assertEquals("test 2: does not contain 1 element", 1,
0783:                        mediaEntitiesFound.length);
0784:                assertEquals("test 2: media does not match",
0785:                        mediaEntitiesFound[0], me1);
0786:                testTrace("test 2 passed");
0787:                //
0788:                // test 3
0789:                //
0790:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0791:                        md1, "image/jpeg", true);
0792:                assertEquals("test 3: does not contain 1 element", 2,
0793:                        mediaEntitiesFound.length);
0794:                assertTrue(
0795:                        "test 3: media entities do not match",
0796:                        (mediaEntitiesFound[0].equals(me1) && mediaEntitiesFound[1]
0797:                                .equals(me2))
0798:                                || (mediaEntitiesFound[0].equals(me2) && mediaEntitiesFound[1]
0799:                                        .equals(me1)));
0800:                testTrace("test 3 passed");
0801:                //
0802:                // test 4
0803:                //
0804:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0805:                        md1, "image/bmp", false);
0806:                assertEquals("test 4: is not empty array", 0,
0807:                        mediaEntitiesFound.length);
0808:                testTrace("test 4 passed");
0809:                //
0810:                // test 5
0811:                //
0812:                mediaEntitiesFound = mdebTester.getMetaDataEntityMediaEntities(
0813:                        md1, "image/bmp", true);
0814:                assertEquals("test 5: is not empty array", 1,
0815:                        mediaEntitiesFound.length);
0816:                assertEquals("test 3: media does not match",
0817:                        mediaEntitiesFound[0], me3);
0818:                testTrace("test 5 passed");
0819:
0820:                mdebTester.removeMDEBByPK(md1);
0821:                mdebTester.removeMDEBByPK(md2);
0822:                mdebTester.removeMEBByPK(me1);
0823:                mdebTester.removeMEBByPK(me2);
0824:                mdebTester.removeMEBByPK(me3);
0825:
0826:                succeed();
0827:            }
0828:
0829:            /**
0830:             * <pre>
0831:             *
0832:             *  Testcase Name: getChildren()
0833:             *  Testcase Number: EMB150
0834:             *
0835:             *  setup: create meta data entities md1, md2, and md3
0836:             *
0837:             *  test procedure:
0838:             *  1.call md1.addChild(md2), call md1.addChild(md3)
0839:             *    call md1.getChildren()
0840:             *    expected result: 2 element array containing md2 and md3
0841:             *
0842:             *  2.call md2.getChildren()
0843:             *  	 expected result: empty array
0844:             *
0845:             * </pre>
0846:             */
0847:            public void testEMB150() throws IOException, CreateException,
0848:                    MediaException, RemoteException, NamingException,
0849:                    FinderException, RemoveException {
0850:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0851:
0852:                String md1 = mdebTester.createMetaDataEntityBean();
0853:                String md2 = mdebTester.createMetaDataEntityBean();
0854:                String md3 = mdebTester.createMetaDataEntityBean();
0855:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0856:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0857:                mdebTester.setMetaDataEntityXML(md3, xmlContent, false);
0858:
0859:                //
0860:                // test 1
0861:                //
0862:                mdebTester.addMetaDataChild(md1, md2);
0863:                mdebTester.addMetaDataChild(md1, md3);
0864:                boolean md2Found = false;
0865:                boolean md3Found = false;
0866:                String[] children = mdebTester.getMetaDataEntityChildren(md1);
0867:                assertEquals("test 1: md1 does not have 2 children", 2,
0868:                        children.length);
0869:                if ((children[0].equals(md2) && children[1].equals(md3))
0870:                        || (children[0].equals(md3) && children[1].equals(md2))) {
0871:                    testTrace("test 1 passed");
0872:                } else {
0873:                    fail("test 1: children are incorrect");
0874:                }
0875:                //
0876:                // test 2
0877:                //
0878:                children = mdebTester.getMetaDataEntityChildren(md2);
0879:                assertEquals("test 2: md2 has children", children.length, 0);
0880:                testTrace("test 2 passed");
0881:
0882:                mdebTester.removeMDEBByPK(md1);
0883:                mdebTester.removeMDEBByPK(md2);
0884:                mdebTester.removeMDEBByPK(md3);
0885:                succeed();
0886:            }
0887:
0888:            /**
0889:             * <pre>
0890:             *
0891:             *  Testcase Name: getName()
0892:             *  Testcase Number: EMB155
0893:             *
0894:             *  setup: create meta data entity testInstance
0895:             *
0896:             *  test procedure:
0897:             *  1.call testInstance.setName(randomString)
0898:             *    call testInstance.getName()
0899:             *    expected result: randomString
0900:             *
0901:             * </pre>
0902:             */
0903:            public void testEMB155() throws IOException, MediaException,
0904:                    CreateException, RemoteException, NamingException,
0905:                    FinderException, RemoveException {
0906:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0907:                String md1 = mdebTester.createMetaDataEntityBean();
0908:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0909:
0910:                //
0911:                // test 1
0912:                //
0913:                String newName = EMBStaticHelper
0914:                        .createRandomString(EMBStaticHelper.randomInt(0, 10));
0915:                mdebTester.setMetaDataEntityName(md1, newName);
0916:                assertEquals("test 1: name does not match", newName, mdebTester
0917:                        .getMetaDataEntityName(md1));
0918:                testTrace("test 1 passed");
0919:
0920:                mdebTester.removeMDEBByPK(md1);
0921:                succeed();
0922:            }
0923:
0924:            /**
0925:             * Testcase Name: getNextVersion() Testcase Number: EMB156 setup: create
0926:             * meta data entities md1 and md2 test procedure: 1.call
0927:             * md2.setPreviousVersion(md1) expected result: md1.getPreviousVersion is
0928:             * null md1.getNextVersion is md2 2.call md2.getNextVersion() expected
0929:             * result: null md2.getPreviousVersion is md1
0930:             *
0931:             * </pre>
0932:             */
0933:            public void testEMB156() throws IOException, CreateException,
0934:                    MediaException, RemoteException, NamingException,
0935:                    FinderException, RemoveException {
0936:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0937:                String md1 = mdebTester.createMetaDataEntityBean();
0938:                String md2 = mdebTester.createMetaDataEntityBean();
0939:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0940:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0941:
0942:                //
0943:                // test 1
0944:                //
0945:                String tmp = mdebTester.getMetaDataEntityPreviousVersion(md2);
0946:                mdebTester.setMetaDataEntityPreviousVersion(md2, md1);
0947:                assertNull("test 1: previous version is not null", mdebTester
0948:                        .getMetaDataEntityPreviousVersion(md1));
0949:                assertEquals("test 1: next version is not md2", mdebTester
0950:                        .getMetaDataEntityNextVersion(md1), md2);
0951:                testTrace("test 1 passed");
0952:                //
0953:                // test 2
0954:                //
0955:                assertEquals("test 2: previous version is not md1", mdebTester
0956:                        .getMetaDataEntityPreviousVersion(md2), md1);
0957:                assertNull("test 2: next version is not null", mdebTester
0958:                        .getMetaDataEntityNextVersion(md2));
0959:                testTrace("test 2 passed");
0960:
0961:                mdebTester.removeMDEBByPK(md1);
0962:                mdebTester.removeMDEBByPK(md2);
0963:
0964:                succeed();
0965:            }
0966:
0967:            /**
0968:             * <pre>
0969:             *
0970:             *  Testcase Name: getParents()
0971:             *  Testcase Number: EMB157
0972:             *
0973:             *  setup: create meta data entities md1, md2, and md3
0974:             *
0975:             *  test procedure:
0976:             *  1.call md1.getParents()
0977:             *    expected result: empty array
0978:             *
0979:             *  2.call md1.addChild(md3)
0980:             *    call md2.addChild(md3)
0981:             *    call md3.getParents()
0982:             *    expected result: 2 element array containing md1 and md2
0983:             *
0984:             * </pre>
0985:             */
0986:            public void testEMB157() throws IOException, MediaException,
0987:                    CreateException, RemoteException, NamingException,
0988:                    FinderException, RemoveException {
0989:
0990:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
0991:                String md1 = mdebTester.createMetaDataEntityBean();
0992:                String md2 = mdebTester.createMetaDataEntityBean();
0993:                String md3 = mdebTester.createMetaDataEntityBean();
0994:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
0995:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
0996:                mdebTester.setMetaDataEntityXML(md3, xmlContent, false);
0997:
0998:                //
0999:                // test 1
1000:                //
1001:                String[] parents = mdebTester.getMetaDataEntityParents(md1);
1002:                assertEquals("test 1: does not contain 0 element", 0,
1003:                        parents.length);
1004:                testTrace("test 1 passed");
1005:                //
1006:                // test 2
1007:                //
1008:                mdebTester.addMetaDataChild(md1, md3);
1009:                mdebTester.addMetaDataChild(md2, md3);
1010:                parents = mdebTester.getMetaDataEntityParents(md3);
1011:                assertEquals("test 2: does not contain 2 elements", 2,
1012:                        parents.length);
1013:                if ((parents[0].equals(md1) && parents[1].equals(md2))
1014:                        || (parents[0].equals(md2) && parents[1].equals(md1))) {
1015:                    testTrace("test 2 passed");
1016:                } else {
1017:                    fail("test 2: parents are incorrect");
1018:                }
1019:
1020:                mdebTester.removeMDEBByPK(md1);
1021:                mdebTester.removeMDEBByPK(md2);
1022:                mdebTester.removeMDEBByPK(md3);
1023:                succeed();
1024:            }
1025:
1026:            /**
1027:             * <pre>
1028:             *
1029:             *  Testcase Name: getPreviousVersion()
1030:             *  Testcase Number: EMB158
1031:             *
1032:             *  setup: create meta data entities md1 and md2
1033:             *
1034:             *  test procedure:
1035:             *  1.call md2.setPreviousVersion(md1)
1036:             *    call md2.getPreviousVersion()
1037:             *    expected result: md1
1038:             *
1039:             *  2.call md1.getPreviousVersion()
1040:             *    expected result: null
1041:             *
1042:             * </pre>
1043:             */
1044:            public void testEMB158() throws IOException, CreateException,
1045:                    MediaException, RemoteException, NamingException,
1046:                    FinderException, RemoveException {
1047:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1048:                String md1 = mdebTester.createMetaDataEntityBean();
1049:                String md2 = mdebTester.createMetaDataEntityBean();
1050:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1051:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
1052:
1053:                //
1054:                // test 1
1055:                //
1056:                mdebTester.setMetaDataEntityPreviousVersion(md2, md1);
1057:                assertTrue("test 1: previous version is not md1", mdebTester
1058:                        .getMetaDataEntityPreviousVersion(md2).equals(md1));
1059:                testTrace("test 1 passed");
1060:                //
1061:                // test 2
1062:                //
1063:                assertNull("test 2: previous version is not null", mdebTester
1064:                        .getMetaDataEntityPreviousVersion(md1));
1065:                testTrace("test 2 passed");
1066:
1067:                mdebTester.removeMDEBByPK(md1);
1068:                mdebTester.removeMDEBByPK(md2);
1069:
1070:                succeed();
1071:            }
1072:
1073:            /**
1074:             * <pre>
1075:             *
1076:             *  Testcase Name: removeChild(MetaDataEntityLocal)
1077:             *  Testcase Number: EMB160
1078:             *
1079:             *  setup: create meta data entities md1, md2, and md3
1080:             *
1081:             *  test procedure:
1082:             *  1.call md1.removeChild(null)
1083:             *    expected result: NullPointerException
1084:             *
1085:             *  2.call md1.addChild(md3), call getChildren and verify one element
1086:             *    call md2.addChild(md3), call getChildren and verify one element
1087:             *    call md1.removeChild(md3)
1088:             *    expected result: no exception
1089:             *    call md1.getChildren and verify empty array
1090:             *  	 call md2.getChildren and verify one element
1091:             *
1092:             *  3.call md1.removeChild(md3)
1093:             *    expected result: no exception
1094:             *
1095:             * </pre>
1096:             */
1097:            public void testEMB160() throws IOException, MediaException,
1098:                    CreateException, RemoteException, NamingException,
1099:                    FinderException, RemoveException {
1100:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1101:
1102:                String md1 = mdebTester.createMetaDataEntityBean();
1103:                String md2 = mdebTester.createMetaDataEntityBean();
1104:                String md3 = mdebTester.createMetaDataEntityBean();
1105:
1106:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1107:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
1108:                mdebTester.setMetaDataEntityXML(md3, xmlContent, false);
1109:                int exception = -1;
1110:                //
1111:                // test 1
1112:                //
1113:                try {
1114:                    exception = mdebTester.removeChildExceptions(md1, null);
1115:                } catch (Throwable e) {
1116:                    fail("test 1 threw " + e.toString());
1117:                }
1118:                assertEquals("test 1: Should throw a NullPointerException",
1119:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
1120:                testTrace("test 1 passed");
1121:                //
1122:                // test 2
1123:                //
1124:                mdebTester.addMetaDataChild(md1, md3);
1125:                assertEquals("test 2: md1 does not have 1 child", 1, mdebTester
1126:                        .getMetaDataEntityChildren(md1).length);
1127:                assertEquals("test 2: child of md1 is not md3", mdebTester
1128:                        .getMetaDataEntityChildren(md1)[0], md3);
1129:                mdebTester.addMetaDataChild(md2, md3);
1130:                assertEquals("test 2: md1 does not have 1 child", 1, mdebTester
1131:                        .getMetaDataEntityChildren(md2).length);
1132:                assertEquals("test 2: child of md1 is not md3", mdebTester
1133:                        .getMetaDataEntityChildren(md2)[0], md3);
1134:
1135:                mdebTester.removeMetaDataChild(md1, md3);
1136:                assertEquals("test 2: md1 should not have children", 0,
1137:                        mdebTester.getMetaDataEntityChildren(md1).length);
1138:                assertEquals("test 2: md2 does not have 1 child", 1, mdebTester
1139:                        .getMetaDataEntityChildren(md2).length);
1140:                assertEquals("test 2: child of md1 is not md3", mdebTester
1141:                        .getMetaDataEntityChildren(md2)[0], md3);
1142:                testTrace("test 2 passed");
1143:                //
1144:                // test 3
1145:                //
1146:                try {
1147:                    mdebTester.removeMetaDataChild(md1, md3);
1148:                    testTrace("test 3 passed");
1149:                } catch (Exception e) {
1150:                    fail("test 3 threw " + e.toString());
1151:                }
1152:
1153:                mdebTester.removeMDEBByPK(md1);
1154:                mdebTester.removeMDEBByPK(md2);
1155:                mdebTester.removeMDEBByPK(md3);
1156:
1157:                succeed();
1158:            }
1159:
1160:            /**
1161:             * <pre>
1162:             *
1163:             *  Testcase Name: removeMediaEntity(MediaEntityLocal)
1164:             *  Testcase Number: EMB161
1165:             *
1166:             *  setup: create meta data entity md1 and Media entity me1
1167:             *
1168:             *  test procedure:
1169:             *  1.call md1.removeMediaEntity(null)
1170:             *    expected result: NullPointerException
1171:             *
1172:             *  2.call md1.addMediaEntity(me1)
1173:             *    call md1.getMediaEntities and verify one element
1174:             *    call md1.removeMediaEntity(me1)
1175:             *    expected result: no exception, call md1.getMediaEntity to verify empty array
1176:             *
1177:             *  3.call md1.	removeMediaEntity(me1)
1178:             *    expected result: no exception
1179:             *
1180:             * </pre>
1181:             */
1182:            public void testEMB161() throws IOException, MediaException,
1183:                    CreateException, RemoteException, NamingException,
1184:                    FinderException, RemoveException {
1185:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1186:                String md1 = mdebTester.createMetaDataEntityBean();
1187:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1188:                String me1 = mdebTester.createMediaEntityBean();
1189:
1190:                int exception = -1;
1191:                //
1192:                // test 1
1193:                //
1194:                try {
1195:                    exception = mdebTester.removeMediaExceptions(md1, null);
1196:                } catch (Throwable e) {
1197:                    fail("test 1 threw " + e.toString());
1198:                }
1199:                assertEquals("test 1: Should throw a NullPointerException",
1200:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
1201:                testTrace("test 1 passed");
1202:                //
1203:                // test 2
1204:                //
1205:                mdebTester.addMetaDataMedia(md1, me1);
1206:                assertEquals("test 2: media entity not added", 1, mdebTester
1207:                        .getMetaDataEntityMediaEntities(md1).length);
1208:                assertEquals("test 2: wrong media entity", mdebTester
1209:                        .getMetaDataEntityMediaEntities(md1)[0], me1);
1210:                mdebTester.removeMetaDataMedia(md1, me1);
1211:                assertEquals("test 2: meta data has associated media entities",
1212:                        0,
1213:                        mdebTester.getMetaDataEntityMediaEntities(md1).length);
1214:                testTrace("test 2 passed");
1215:                //
1216:                // test 3
1217:                //
1218:                try {
1219:                    mdebTester.removeMetaDataMedia(md1, me1);
1220:                    testTrace("test 3 passed");
1221:                } catch (Exception e) {
1222:                    fail("test 3 threw " + e.toString());
1223:                }
1224:
1225:                mdebTester.removeMDEBByPK(md1);
1226:                mdebTester.removeMEBByPK(me1);
1227:
1228:                succeed();
1229:            }
1230:
1231:            /**
1232:             * <pre>
1233:             *
1234:             *  Testcase Name: setName(String)
1235:             *  Testcase Number: EMB162
1236:             *
1237:             *  setup: create meta data entity md1
1238:             *
1239:             *  test procedure:
1240:             *  1.call md1.setName(null)
1241:             *    expected result: NullPointerException
1242:             *
1243:             *  2.call md1.setName(&quot;&quot;)
1244:             *    call md1.getName()
1245:             *    expected result: empty string
1246:             *
1247:             *  3.call md1.setName(&quot;test&quot;)
1248:             *    call md1.getName()
1249:             *    expected result: &quot;test&quot;
1250:             *
1251:             * </pre>
1252:             */
1253:            public void testEMB162() throws IOException, MediaException,
1254:                    CreateException, RemoteException, NamingException,
1255:                    FinderException, RemoveException {
1256:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1257:                String md1 = mdebTester.createMetaDataEntityBean();
1258:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1259:
1260:                int exception = -1;
1261:                //
1262:                // test 1
1263:                //
1264:                try {
1265:                    exception = mdebTester.setNameExceptions(md1, null);
1266:                } catch (Throwable e) {
1267:                    fail("test 1 threw " + e.toString());
1268:                }
1269:                assertEquals("test 1: Should throw a NullPointerException",
1270:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
1271:                testTrace("test 1 passed");
1272:                //
1273:                // test 2
1274:                //
1275:                mdebTester.setMetaDataEntityName(md1, "");
1276:                assertEquals("test 2: name is not an empty string", "",
1277:                        mdebTester.getMetaDataEntityName(md1));
1278:                testTrace("test 2 passed");
1279:                //
1280:                // test 3
1281:                //
1282:                mdebTester.setMetaDataEntityName(md1, "test");
1283:                assertEquals("test 3: name does not match", "test", mdebTester
1284:                        .getMetaDataEntityName(md1));
1285:                testTrace("test 3 passed");
1286:
1287:                mdebTester.removeMDEBByPK(md1);
1288:
1289:                succeed();
1290:            }
1291:
1292:            /**
1293:             * <pre>
1294:             *
1295:             *  Testcase Name: setPreviousVersion(MetaDataEntityLocal)
1296:             *  Testcase Number: EMB163
1297:             *
1298:             *  setup: create meta data entities md1, md2, and md3
1299:             *
1300:             *  test procedure:
1301:             *  1.call md1.setPreviousVersion(null)
1302:             *    call md1.getPreviousVersion() and md1.getNextVersion()
1303:             *    expected result: both are null
1304:             *
1305:             *  2.call md2.setPreviousVersion(md1)
1306:             *  	 expected result: md1.getPreviousVersion() is null
1307:             *  		      		  md1.getNextVersion() is md2
1308:             *  					  md2.getPreviousVersion() is md1
1309:             *  					  md2.getNextVersion() is null
1310:             *
1311:             *  3.call md2.setPreviousVersion(md1)
1312:             *    expected result: no exception
1313:             *
1314:             *  4.call md3.setPreviousVersion(md1)
1315:             *    expected result: VersionChainIntegrityException
1316:             *
1317:             *  5.call md2.setPreviousVersion(md3)
1318:             *    expected result: VersionChainIntegrityException
1319:             *
1320:             *  6.call md1.setPreviousVersion(md3)
1321:             *    expected result: VersionChainIntegrityException
1322:             *
1323:             *  7.call md3.setPreviousVersion(null)
1324:             *    expected result: no exception
1325:             *
1326:             *  8.call md3.setPreviousVersion(md2)
1327:             *    expected result: md1.getPreviousVersion() is null
1328:             *  					  md1.getNextVersion() is md2
1329:             *  					  md2.getPreviousVersion() is md1
1330:             *  					  md2.getNextVersion() is md3
1331:             *  					  md3.getPreviousVersion() is md2
1332:             *  					  md3.getNextVersion() is null
1333:             *
1334:             *  9.call md2.setPreviousVersion(null)
1335:             *    expected result: VersionChainIntegrityException
1336:             *
1337:             *  10.call md3.setPreviousVersion(null)
1338:             *    expected result: md1.getPreviousVersion() is null
1339:             *   				  md1.getNextVersion() is md2
1340:             *  					  md2.getPreviousVersion() is md1
1341:             *  					  md2.getNextVersion() is null
1342:             *  					  md3.getPreviousVersion() is null
1343:             *  					  md3.getNextVersion() is null
1344:             *
1345:             *  11.call md3.setPreviousVersion(md3)
1346:             *     expected result: VersionChainIntegrityException
1347:             *
1348:             * </pre>
1349:             */
1350:            public void testEMB163() throws IOException, MediaException,
1351:                    CreateException, RemoteException, NamingException,
1352:                    FinderException, RemoveException {
1353:
1354:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1355:
1356:                String md1 = mdebTester.createMetaDataEntityBean();
1357:                String md2 = mdebTester.createMetaDataEntityBean();
1358:                String md3 = mdebTester.createMetaDataEntityBean();
1359:                mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1360:                mdebTester.setMetaDataEntityXML(md2, xmlContent, false);
1361:                mdebTester.setMetaDataEntityXML(md3, xmlContent, false);
1362:
1363:                int exception = -1;
1364:
1365:                //
1366:                // test 1
1367:                //
1368:                try {
1369:                    mdebTester.setMetaDataEntityPreviousVersion(md1, null);
1370:                } catch (Throwable e) {
1371:                    fail("test 1 threw " + e.toString());
1372:                }
1373:                assertNull("test 1: md1.getPreviousVersion is not null",
1374:                        mdebTester.getMetaDataEntityPreviousVersion(md1));
1375:                assertNull("test 1: md1.getNextVersion is not null", mdebTester
1376:                        .getMetaDataEntityNextVersion(md1));
1377:                testTrace("test 1 passed");
1378:                //
1379:                // test 2
1380:                //
1381:                mdebTester.setMetaDataEntityPreviousVersion(md2, md1);
1382:                assertNull("test 2: md1.getPreviousVersion is not null",
1383:                        mdebTester.getMetaDataEntityPreviousVersion(md1));
1384:                assertEquals("test 2: md1.getNextVersion is not md2",
1385:                        mdebTester.getMetaDataEntityNextVersion(md1), md2);
1386:                assertEquals("test 2: md2.getPreviousVersion is not md1",
1387:                        mdebTester.getMetaDataEntityPreviousVersion(md2), md1);
1388:                assertNull("test 2: md2.getNextVersion is not null", mdebTester
1389:                        .getMetaDataEntityNextVersion(md2));
1390:                testTrace("test 2 passed");
1391:                //
1392:                // test 3
1393:                //
1394:                try {
1395:                    mdebTester.setMetaDataEntityPreviousVersion(md2, md1);
1396:                    testTrace("test 3 passed");
1397:                } catch (Throwable e) {
1398:                    fail(" test 3 threw " + e.toString());
1399:                }
1400:                //
1401:                // test 4
1402:                //
1403:                try {
1404:                    exception = mdebTester.setPreviousVersionExceptions(md3,
1405:                            md1);
1406:                } catch (Throwable e) {
1407:                    fail("test 4 threw " + e.toString());
1408:                }
1409:                assertEquals(
1410:                        "test 4: Should throw a VersionChainIntegrityException",
1411:                        MetaDataEntityLocalTestDriver.VERSIONCHAININTEGRITY,
1412:                        exception);
1413:                testTrace("test 4 passed");
1414:                //
1415:                // test 5
1416:                //
1417:                try {
1418:                    exception = mdebTester.setPreviousVersionExceptions(md2,
1419:                            md3);
1420:                } catch (Throwable e) {
1421:                    fail("test 5 threw " + e.toString());
1422:                }
1423:                assertEquals(
1424:                        "test 5: Should throw a VersionChainIntegrityException",
1425:                        MetaDataEntityLocalTestDriver.VERSIONCHAININTEGRITY,
1426:                        exception);
1427:                testTrace("test 5 passed");
1428:                //
1429:                // test 6
1430:                //
1431:                try {
1432:                    exception = mdebTester.setPreviousVersionExceptions(md1,
1433:                            md3);
1434:                } catch (Throwable e) {
1435:                    fail("test 6 threw " + e.toString());
1436:                }
1437:                assertEquals(
1438:                        "test 6: Should throw a VersionChainIntegrityException",
1439:                        MetaDataEntityLocalTestDriver.VERSIONCHAININTEGRITY,
1440:                        exception);
1441:                testTrace("test 6 passed");
1442:                //
1443:                // test 7
1444:                //
1445:                try {
1446:                    mdebTester.setMetaDataEntityPreviousVersion(md3, null);
1447:                    testTrace("test 7 passed");
1448:                } catch (Throwable e) {
1449:                    fail(" test 7 threw " + e.toString());
1450:                }
1451:                //
1452:                // test 8
1453:                //
1454:                mdebTester.setMetaDataEntityPreviousVersion(md3, md2);
1455:                assertNull("test 8: md1.getPreviousVersion is not null",
1456:                        mdebTester.getMetaDataEntityPreviousVersion(md1));
1457:                assertEquals("test 8: md1.getNextVersion is not md2",
1458:                        mdebTester.getMetaDataEntityNextVersion(md1), md2);
1459:                assertEquals("test 8: md2.getPreviousVersion is not md1",
1460:                        mdebTester.getMetaDataEntityPreviousVersion(md2), md1);
1461:                assertEquals("test 8: md2.getNextVersion is not md3",
1462:                        mdebTester.getMetaDataEntityNextVersion(md2), md3);
1463:                assertEquals("test 8: md3.getPreviousVersion is not md2",
1464:                        mdebTester.getMetaDataEntityPreviousVersion(md3), md2);
1465:                assertNull("test 8: md3.getNextVersion is not null", mdebTester
1466:                        .getMetaDataEntityNextVersion(md3));
1467:                testTrace("test 8 passed");
1468:                //
1469:                // test 9
1470:                //
1471:                try {
1472:                    exception = mdebTester.setPreviousVersionExceptions(md2,
1473:                            null);
1474:                } catch (Throwable e) {
1475:                    fail("test 9 threw " + e.toString());
1476:                }
1477:                assertEquals(
1478:                        "test 9: Should throw a VersionChainIntegrityException",
1479:                        MetaDataEntityLocalTestDriver.VERSIONCHAININTEGRITY,
1480:                        exception);
1481:                testTrace("test 9 passed");
1482:                //
1483:                // test 10
1484:                //
1485:                mdebTester.setMetaDataEntityPreviousVersion(md3, null);
1486:                assertNull("test 10: md1.getPreviousVersion is not null",
1487:                        mdebTester.getMetaDataEntityPreviousVersion(md1));
1488:                assertEquals("test 10: md1.getNextVersion is not md2",
1489:                        mdebTester.getMetaDataEntityNextVersion(md1), md2);
1490:                assertEquals("test 10: md2.getPreviousVersion is not md1",
1491:                        mdebTester.getMetaDataEntityPreviousVersion(md2), md1);
1492:                assertNull("test 10: md2.getNextVersion is not null",
1493:                        mdebTester.getMetaDataEntityNextVersion(md2));
1494:                assertNull("test 10: md3.getPreviousVersion is not null",
1495:                        mdebTester.getMetaDataEntityPreviousVersion(md3));
1496:                assertNull("test 10: md3.getNextVersion is not null",
1497:                        mdebTester.getMetaDataEntityNextVersion(md3));
1498:                testTrace("test 10 passed");
1499:                //
1500:                // test 11
1501:                //
1502:                try {
1503:                    exception = mdebTester.setPreviousVersionExceptions(md3,
1504:                            md3);
1505:                } catch (Throwable e) {
1506:                    fail("test 11 threw " + e.toString());
1507:                }
1508:                assertEquals(
1509:                        "test 11: Should throw a VersionChainIntegrityException",
1510:                        MetaDataEntityLocalTestDriver.VERSIONCHAININTEGRITY,
1511:                        exception);
1512:                testTrace("test 11 passed");
1513:
1514:                mdebTester.removeMDEBByPK(md1);
1515:                mdebTester.removeMDEBByPK(md2);
1516:                mdebTester.removeMDEBByPK(md3);
1517:
1518:                succeed();
1519:            }
1520:
1521:            /**
1522:             * <pre>
1523:             *
1524:             *  Testcase Name: setXML(String, boolean)
1525:             *  Testcase Number: EMB164
1526:             *
1527:             *  setup: create meta data entities md1
1528:             *  		  create file containing valid XML schema
1529:             *
1530:             *  test procedure:
1531:             *  1.call md1.setXML(null, false)
1532:             *    expected result: NullPointerException
1533:             *
1534:             *  2.a.call md1.setXML(validXML, true) (reference to DTD)
1535:             *      expected result: no exception, verify md1.getXML() matches XML content
1536:             *    b.call md1.setXML(validXML, true) (reference to schema)
1537:             *      expected result: no exception , verify md1.getXML() matches XML content
1538:             *
1539:             *  3.a.create random String and call setXML(randomString, true)
1540:             *      expected result: MetaDataSyntaxException
1541:             *    b.call setXML(randomString, false)
1542:             *      expected result: MetaDataSyntaxException
1543:             *
1544:             *  4.a.create well formed XML content that does not match DTD
1545:             *      call md1.setXML(xmlContent, true)
1546:             *      expected result: MetaDataValidationException
1547:             *  	 b.create well formed XML content that does follow schema
1548:             *      call md1.setXML(xmlContent, true)
1549:             *      expected result: MetaDataValidationException
1550:             *
1551:             *  5.create XML file with only begin and end tags
1552:             *    call md1.setXML
1553:             *    expected result: no exception
1554:             *
1555:             *  6.call md1.setXML(&quot;&quot;)
1556:             *    expected result: no exception
1557:             *
1558:             *  7.a.call setXML with XML that does not reference any DTD or schema and validate set to true
1559:             *      expected result: MetaDataValidationException
1560:             *    b.repeat test 7a with validate set to false
1561:             *      expected result: no exception
1562:             *
1563:             * </pre>
1564:             */
1565:            public void testEMB164() throws FileNotFoundException, IOException,
1566:                    ParserConfigurationException, IOException, SAXException,
1567:                    CreateException, MediaException, RemoteException,
1568:                    NamingException, FinderException, RemoveException {
1569:
1570:                String xmlContent = retrieveXML(embTestConfig.getXMLFile1());
1571:                String md1 = mdebTester.createMetaDataEntityBean();
1572:                String md2 = mdebTester.createMetaDataEntityBean();
1573:
1574:                File xmlFile = new File(embTestConfig.getMediaDir()
1575:                        + File.separatorChar + embTestConfig.getXMLFile1());
1576:
1577:                int exception = -1;
1578:                //
1579:                // test 1
1580:                //
1581:                try {
1582:                    exception = mdebTester.setXMLExceptions(md1, null, false);
1583:                } catch (Throwable e) {
1584:                    fail("test 1 threw " + e.toString());
1585:                }
1586:                assertEquals("test 1: Should throw a NullPointerException",
1587:                        MetaDataEntityLocalTestDriver.NULLPOINTER, exception);
1588:                testTrace("test 1 passed");
1589:                //
1590:                // test 2a
1591:                //
1592:                mdebTester.setMetaDataEntityXML(md1, xmlContent, true);
1593:                String retrievedXML = mdebTester.getMetaDataEntityXML(md1);
1594:
1595:                DOMParser parser = new DOMParser();
1596:                parser
1597:                        .setFeature(
1598:                                "http://apache.org/xml/features/dom/include-ignorable-whitespace",
1599:                                true);
1600:                InputSource expectedXML = new InputSource(
1601:                        new ByteArrayInputStream(xmlContent.getBytes()));
1602:                InputSource actualXML = new InputSource(
1603:                        new ByteArrayInputStream(retrievedXML.getBytes()));
1604:
1605:                parser.parse(expectedXML);
1606:                Document xmlDoc1 = parser.getDocument();
1607:                parser.parse(actualXML);
1608:                Document xmlDoc2 = parser.getDocument();
1609:
1610:                Element root1 = xmlDoc1.getDocumentElement();
1611:                Element root2 = xmlDoc2.getDocumentElement();
1612:
1613:                assertTrue("test 2a: XML content does not match", xmlCompare(
1614:                        root1, root2));
1615:                testTrace("test 2a passed");
1616:                //
1617:                // test 2b
1618:                xmlContent = retrieveXML(embTestConfig.getXMLFile2());
1619:                mdebTester.setMetaDataEntityXML(md1, xmlContent, true);
1620:                retrievedXML = mdebTester.getMetaDataEntityXML(md1);
1621:
1622:                expectedXML = new InputSource(new ByteArrayInputStream(
1623:                        xmlContent.getBytes()));
1624:                actualXML = new InputSource(new ByteArrayInputStream(
1625:                        retrievedXML.getBytes()));
1626:
1627:                parser.parse(expectedXML);
1628:                xmlDoc1 = parser.getDocument();
1629:                parser.parse(actualXML);
1630:                xmlDoc2 = parser.getDocument();
1631:
1632:                root1 = xmlDoc1.getDocumentElement();
1633:                root2 = xmlDoc2.getDocumentElement();
1634:
1635:                assertTrue("test 2b: XML content does not match", xmlCompare(
1636:                        root1, root2));
1637:                testTrace("test 2b passed");
1638:                //
1639:                // test 3a
1640:                //
1641:                String randomXMLContent = EMBStaticHelper
1642:                        .createRandomString(EMBStaticHelper.randomInt(0, 1024));
1643:                try {
1644:                    exception = mdebTester.setXMLExceptions(md1,
1645:                            randomXMLContent, true);
1646:                } catch (Throwable e) {
1647:                    fail("test 3a threw " + e.toString());
1648:                }
1649:                assertEquals(
1650:                        "test 3a: Should throw a MetaDataSynxtaxException",
1651:                        MetaDataEntityLocalTestDriver.METADATASYNTAX, exception);
1652:                testTrace("test 3a passed");
1653:                //
1654:                // test 3b
1655:                //
1656:                try {
1657:                    exception = mdebTester.setXMLExceptions(md1,
1658:                            randomXMLContent, false);
1659:                } catch (Throwable e) {
1660:                    fail("test 3b threw " + e.toString());
1661:                }
1662:                assertEquals(
1663:                        "test 3b: Should throw a MetaDataSynxtaxException",
1664:                        MetaDataEntityLocalTestDriver.METADATASYNTAX, exception);
1665:                testTrace("test 3b passed");
1666:                //
1667:                // test 4a
1668:                //
1669:                xmlContent = retrieveXML(embTestConfig.getInvalidXMLFile1());
1670:                try {
1671:                    exception = mdebTester.setXMLExceptions(md1, xmlContent,
1672:                            true);
1673:                } catch (Throwable e) {
1674:                    fail("test 4a threw " + e.toString());
1675:                }
1676:                assertEquals(
1677:                        "test 4a: Should throw a MetaDataValidationException",
1678:                        MetaDataEntityLocalTestDriver.METADATAVALIDATION,
1679:                        exception);
1680:                testTrace("test 4a passed");
1681:                //
1682:                // test 4b
1683:                //
1684:                xmlContent = retrieveXML(embTestConfig.getInvalidXMLFile2());
1685:                try {
1686:                    exception = mdebTester.setXMLExceptions(md1, xmlContent,
1687:                            true);
1688:                } catch (Throwable e) {
1689:                    fail("test 4b threw " + e.toString());
1690:                }
1691:                assertEquals(
1692:                        "test 4b: Should throw a MetaDataValidationException",
1693:                        MetaDataEntityLocalTestDriver.METADATAVALIDATION,
1694:                        exception);
1695:                testTrace("test 4b passed");
1696:                //
1697:                // test 5
1698:                //
1699:                xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test></test>";
1700:                try {
1701:                    mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1702:                    testTrace("test 5 passed");
1703:                } catch (Exception e) {
1704:                    fail("test 5 threw " + e.toString());
1705:                }
1706:                //
1707:                // test 6
1708:                //
1709:                try {
1710:                    mdebTester.setMetaDataEntityXML(md1, "", false);
1711:                    testTrace("test 6 passed");
1712:                } catch (Exception e) {
1713:                    fail("test 6 threw " + e.toString());
1714:                }
1715:
1716:                //
1717:                // test 7a
1718:                //
1719:                xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test><name><firstName>John</firstName><lastName>Smith</lastName></name></test>";
1720:                try {
1721:                    exception = mdebTester.setXMLExceptions(md1, xmlContent,
1722:                            true);
1723:                } catch (Throwable e) {
1724:                    fail("test 7a threw " + e.toString());
1725:                }
1726:                assertEquals(
1727:                        "test 7a: Should throw a MetaDataValidationException",
1728:                        MetaDataEntityLocalTestDriver.METADATAVALIDATION,
1729:                        exception);
1730:                testTrace("test 7a passed");
1731:                //
1732:                // test 7b
1733:                //
1734:                try {
1735:                    mdebTester.setMetaDataEntityXML(md1, xmlContent, false);
1736:                } catch (Throwable e) {
1737:                    fail("test 7b threw " + e.toString());
1738:                }
1739:                testTrace("test 7b passed");
1740:
1741:                mdebTester.removeMDEBByPK(md1);
1742:                mdebTester.removeMDEBByPK(md2);
1743:
1744:                succeed();
1745:            }
1746:
1747:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.