KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > raidb1 > xml > XmlGenerationScenario


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk
22  * Contributor(s): ______________________.
23  */

24 package org.objectweb.cjdbc.scenario.raidb1.xml;
25
26 import org.objectweb.cjdbc.common.xml.XmlComponent;
27 import org.objectweb.cjdbc.controller.core.ControllerConstants;
28 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase;
29 import org.objectweb.cjdbc.scenario.templates.Raidb1Template;
30
31 /**
32  * This class defines a XmlGenerationScenario class
33  *
34  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
35  */

36 public class XmlGenerationScenario extends Raidb1Template
37 {
38   
39   /**
40    * Test if the xml generated from the virtualdatabase can be used again
41    * to construct the same virtual database.
42    * The test is repeated twice to be sure the xml is consistent
43    * @throws Exception if fails
44    */

45   public void testDatabaseXml() throws Exception JavaDoc
46   {
47     VirtualDatabase vd = controller.getVirtualDatabase("myDB");
48     String JavaDoc xml1 = vd.getXml();
49     xml1 = XmlComponent.XML_VERSION +XmlComponent.DOCTYPE_DB + xml1;
50     controller.removeVirtualDatabase("myDB");
51     System.out.println(xml1);
52     controller.addVirtualDatabases(xml1,"myDB",ControllerConstants.AUTO_ENABLE_TRUE,"");
53     VirtualDatabase vd2 = controller.getVirtualDatabase("myDB");
54     String JavaDoc xml2 = vd2.getXml();
55     xml2 = XmlComponent.XML_VERSION +XmlComponent.DOCTYPE_DB + xml2;
56     System.out.println(xml2);
57     
58     controller.removeVirtualDatabase("myDB");
59     controller.addVirtualDatabases(xml2,"myDB",ControllerConstants.AUTO_ENABLE_TRUE,"");
60     VirtualDatabase vd3 = controller.getVirtualDatabase("myDB");
61     String JavaDoc xml3 = vd3.getXml();
62     xml3 = XmlComponent.XML_VERSION +XmlComponent.DOCTYPE_DB + xml3;
63     
64     assertEquals("Xml files are different",xml3,xml2);
65   }
66 }
67
Popular Tags