# # Copyright (c) 2003 by Benja Fallenstein # # This file is part of Fenfire. # # Fenfire is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fenfire is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General # Public License for more details. # # You should have received a copy of the GNU Lesser General # Public License along with Fenfire; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # import gzz, java def testSimple(): map = gzz.loom.NamespaceMap() assert map.getAbbrev("http://example.com/foo") == \ "http://example.com/foo" assert map.getAbbrev("mailto:foo@example.org") == \ "mailto:foo@example.org" assert map.getAbbrev("urn:x-foo:foo") == "urn:x-foo:foo" map.put("one", "http://example.com/") assert map.getAbbrev("http://example.com/foo") == "one:foo" assert map.getAbbrev("mailto:foo@example.org") == \ "mailto:foo@example.org" assert map.getAbbrev("urn:x-foo:foo") == "urn:x-foo:foo" map.put("two", "mailto:foo@") assert map.getAbbrev("http://example.com/foo") == "one:foo" assert map.getAbbrev("mailto:foo@example.org") == "two:example.org" assert map.getAbbrev("urn:x-foo:foo") == "urn:x-foo:foo" def testFromXML(): map = gzz.loom.NamespaceMap() xml = """ bla """ assert map.getAbbrev("http://example.com/foo") == \ "http://example.com/foo" assert map.getAbbrev("mailto:foo@example.org") == \ "mailto:foo@example.org" assert map.getAbbrev("urn:x-foo:foo") == "urn:x-foo:foo" map.loadMappings(java.io.StringReader(xml)) assert map.getAbbrev("http://example.com/foo") == "one:foo" assert map.getAbbrev("mailto:foo@example.org") == "two:example.org" assert map.getAbbrev("urn:x-foo:foo") == "urn:x-foo:foo"