vgritsenko 2004/06/10 07:45:01
Modified: java/tests/src/org/apache/xindice/core/meta MetaTest.java Log: tabs to spaces Revision Changes Path 1.6 +63 -63 xml-xindice/java/tests/src/org/apache/xindice/core/meta/MetaTest.java Index: MetaTest.java =================================================================== RCS file: /home/cvs/xml-xindice/java/tests/src/org/apache/xindice/core/meta/MetaTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MetaTest.java 8 Feb 2004 03:56:47 -0000 1.5 +++ MetaTest.java 10 Jun 2004 14:45:01 -0000 1.6 @@ -32,71 +32,71 @@ /* make sure we can make 2 metadata objects that are identical */ public void testMetaSimpleComparison() { - MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); - MetaData m2 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); - assertEquals(m1.toString(), m2.toString()); + MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); + MetaData m2 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); + assertEquals(m1.toString(), m2.toString()); } /* make sure we can make 2 metadata objects that are different */ public void testMetaComplexCreation() { - MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); - MetaData m2 = new MetaData(MetaData.COLLECTION, "test1", 0, 0); - assertFalse(m1.toString().equals(m2.toString())); - } - - /* make sure we can get and set attributes */ - public void testMetaAttrs() { - MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); - m1.setAttribute("test", "cases"); - String s = (String)m1.getAttribute("test"); - assertEquals(s, "cases"); - - s = (String)m1.getAttribute("not there"); - assertNull(s); + MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); + MetaData m2 = new MetaData(MetaData.COLLECTION, "test1", 0, 0); + assertFalse(m1.toString().equals(m2.toString())); } - - /* make sure we can get and set custom documents */ - public void testMetaCustomDocument() { - MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); - - Document doc_init = m1.getCustomDocument(); - assertNull(doc_init); - - String cust = "<custom_xml>" + - "<mycool>xml document that looks <like />"+ - "whatever i want</mycool>" + - "</custom_xml>"; - Document doc = null; - try { - doc = DOMParser.toDocument(cust); - } catch(Exception e) { - fail("Can't parse xml document! "+e.getMessage()); - } - m1.setCustomDocument(doc); - - Document doc2 = m1.getCustomDocument(); - assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2)); - } - - /* make sure we can create a metadata object from xml - and make sure we can stream it back to xml without any changes */ - public void testMetaFromXml() { - String xml = "<?xml version=\"1.0\"?>\n" + - "<meta xmlns=\"http://apache.org/xindice/metadata\">" + - "<system type=\"doc\">" + - "<attr name=\"created\" value=\"0\" />" + - "<attr name=\"modified\" value=\"0\" />" + - "</system></meta>"; - Document doc = null; - try { - doc = DOMParser.toDocument(xml); - } catch (Exception e) { - fail("Can't parse xml document! "+e.getMessage()); - } - MetaData meta = new MetaData(); - meta.streamFromXML(doc.getDocumentElement(), true); - Document doc2 = new DocumentImpl(); + + /* make sure we can get and set attributes */ + public void testMetaAttrs() { + MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); + m1.setAttribute("test", "cases"); + String s = (String)m1.getAttribute("test"); + assertEquals(s, "cases"); + + s = (String)m1.getAttribute("not there"); + assertNull(s); + } + + /* make sure we can get and set custom documents */ + public void testMetaCustomDocument() { + MetaData m1 = new MetaData(MetaData.UNKNOWN, "test1", 0, 0); + + Document doc_init = m1.getCustomDocument(); + assertNull(doc_init); + + String cust = "<custom_xml>" + + "<mycool>xml document that looks <like />"+ + "whatever i want</mycool>" + + "</custom_xml>"; + Document doc = null; + try { + doc = DOMParser.toDocument(cust); + } catch(Exception e) { + fail("Can't parse xml document! "+e.getMessage()); + } + m1.setCustomDocument(doc); + + Document doc2 = m1.getCustomDocument(); + assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2)); + } + + /* make sure we can create a metadata object from xml + and make sure we can stream it back to xml without any changes */ + public void testMetaFromXml() { + String xml = "<?xml version=\"1.0\"?>\n" + + "<meta xmlns=\"http://apache.org/xindice/metadata\">" + + "<system type=\"doc\">" + + "<attr name=\"created\" value=\"0\" />" + + "<attr name=\"modified\" value=\"0\" />" + + "</system></meta>"; + Document doc = null; + try { + doc = DOMParser.toDocument(xml); + } catch (Exception e) { + fail("Can't parse xml document! "+e.getMessage()); + } + MetaData meta = new MetaData(); + meta.streamFromXML(doc.getDocumentElement(), true); + Document doc2 = new DocumentImpl(); doc2.appendChild(meta.streamToXML(doc2, true)); - assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2)); - } + assertEquals(TextWriter.toString(doc), TextWriter.toString(doc2)); + } }