diff options
Diffstat (limited to 'unoxml')
-rw-r--r-- | unoxml/prj/build.lst | 4 | ||||
-rw-r--r-- | unoxml/prj/d.lst | 2 | ||||
-rw-r--r-- | unoxml/qa/complex/tests.sce | 1 | ||||
-rw-r--r-- | unoxml/qa/complex/unoxml/RDFRepositoryTest.java (renamed from unoxml/qa/complex/RDFRepositoryTest.java) | 332 | ||||
-rw-r--r-- | unoxml/qa/complex/unoxml/TestDocument.java | 39 | ||||
-rw-r--r-- | unoxml/qa/complex/unoxml/makefile.mk (renamed from unoxml/qa/complex/makefile.mk) | 44 | ||||
-rw-r--r-- | unoxml/qa/complex/unoxml/testdocuments/example.rdf (renamed from unoxml/qa/complex/testdocuments/example.rdf) | 0 | ||||
-rw-r--r-- | unoxml/source/rdf/librdf_services.cxx | 7 | ||||
-rw-r--r-- | unoxml/source/rdf/makefile.mk | 8 | ||||
-rw-r--r-- | unoxml/source/rdf/unordf.component | 43 | ||||
-rw-r--r-- | unoxml/source/service/makefile.mk | 8 | ||||
-rw-r--r-- | unoxml/source/service/services.cxx | 38 | ||||
-rw-r--r-- | unoxml/source/service/unoxml.component | 43 | ||||
-rw-r--r-- | unoxml/source/xpath/xpathapi.hxx | 2 |
14 files changed, 358 insertions, 213 deletions
diff --git a/unoxml/prj/build.lst b/unoxml/prj/build.lst index cc54f6d3ad28..4da29cb9d669 100644 --- a/unoxml/prj/build.lst +++ b/unoxml/prj/build.lst @@ -1,6 +1,8 @@ -ux unoxml : offuh cppuhelper LIBXML2:libxml2 REDLAND:redland tools NULL +ux unoxml : offuh cppuhelper LIBXML2:libxml2 LIBXSLT:libxslt REDLAND:redland tools NULL ux unoxml\source\dom nmake - all ux_dom NULL ux unoxml\source\xpath nmake - all ux_xpath ux_dom NULL ux unoxml\source\events nmake - all ux_events ux_dom NULL ux unoxml\source\service nmake - all ux_service ux_dom ux_xpath ux_events NULL ux unoxml\source\rdf nmake - all ux_librdf NULL + +ux unoxml\qa\complex\unoxml nmake - all ux_complex ux_librdf NULL diff --git a/unoxml/prj/d.lst b/unoxml/prj/d.lst index e2bf5df03b34..4fcedbdba7a2 100644 --- a/unoxml/prj/d.lst +++ b/unoxml/prj/d.lst @@ -1,3 +1,5 @@ ..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%\lib*.so ..\%__SRC%\lib\lib*.dylib %_DEST%\lib%_EXT%\lib*.dylib ..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll +..\%__SRC%\misc\unordf.component %_DEST%\xml%_EXT%\unordf.component +..\%__SRC%\misc\unoxml.component %_DEST%\xml%_EXT%\unoxml.component diff --git a/unoxml/qa/complex/tests.sce b/unoxml/qa/complex/tests.sce deleted file mode 100644 index 20596551f156..000000000000 --- a/unoxml/qa/complex/tests.sce +++ /dev/null @@ -1 +0,0 @@ --o complex.unoxml.RDFRepositoryTest diff --git a/unoxml/qa/complex/RDFRepositoryTest.java b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java index f3f9cbd8ae41..d047ef77440e 100644 --- a/unoxml/qa/complex/RDFRepositoryTest.java +++ b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java @@ -27,21 +27,16 @@ package complex.unoxml; -import complexlib.ComplexTestCase; import helper.StreamSimulator; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.Any; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XEventListener; import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.WrappedTargetRuntimeException; import com.sun.star.beans.XPropertySet; -import com.sun.star.beans.PropertyValue; import com.sun.star.beans.Pair; import com.sun.star.beans.StringPair; import com.sun.star.container.XEnumeration; @@ -52,6 +47,15 @@ import com.sun.star.io.XOutputStream; import com.sun.star.text.XTextRange; import com.sun.star.text.XText; import com.sun.star.rdf.*; +import lib.TestParameters; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; /** * Test case for service com.sun.star.rdf.Repository @@ -60,7 +64,7 @@ import com.sun.star.rdf.*; * * @author mst */ -public class RDFRepositoryTest extends ComplexTestCase +public class RDFRepositoryTest { XComponentContext xContext; String tempDir; @@ -80,112 +84,113 @@ public class RDFRepositoryTest extends ComplexTestCase XLiteral littype; String rdfs = "http://www.w3.org/2000/01/rdf-schema#"; - public String[] getTestMethodNames () - { - return new String[] { "check", "checkSPARQL", "checkRDFa" }; - } + /** + * The test parameters + */ + private static TestParameters param = null; + +// public String[] getTestMethodNames () +// { +// return new String[] { "check", "checkSPARQL", "checkRDFa" }; +// } - public void before() + @Before public void before() { try { - XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF(); - assure("could not create MultiServiceFactory.", xMSF != null); - XPropertySet xPropertySet = (XPropertySet) - UnoRuntime.queryInterface(XPropertySet.class, xMSF); + XMultiServiceFactory xMSF = getMSF(); + param = new TestParameters(); + param.put("ServiceFactory", xMSF); + + assertNotNull("could not create MultiServiceFactory.", xMSF); + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xMSF); Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext"); - xContext = (XComponentContext) - UnoRuntime.queryInterface(XComponentContext.class, defaultCtx); - assure("could not get component context.", xContext != null); + xContext = UnoRuntime.queryInterface(XComponentContext.class, defaultCtx); + assertNotNull("could not get component context.", xContext); tempDir = util.utils.getOfficeTemp/*Dir*/(xMSF); - log.println("tempdir: " + tempDir); + System.out.println("tempdir: " + tempDir); foo = URI.create(xContext, "uri:foo"); - assure("foo", null != foo); + assertNotNull("foo", foo); bar = URI.create(xContext, "uri:bar"); - assure("bar", null != bar); + assertNotNull("bar", bar); baz = URI.create(xContext, "uri:baz"); - assure("baz", null != baz); + assertNotNull("baz", baz); uint = URI.create(xContext, "uri:int"); - assure("uint", null != uint); + assertNotNull("uint", uint); blank = BlankNode.create(xContext, "_:uno"); - assure("blank", null != blank); + assertNotNull("blank", blank); lit = Literal.create(xContext, "i am the literal"); - assure("lit", null != lit); + assertNotNull("lit", lit); litlang = Literal.createWithLanguage(xContext, "i am the literal", "en"); - assure("litlang", null != litlang); + assertNotNull("litlang", litlang); littype = Literal.createWithType(xContext, "42", uint); - assure("littype", null != littype); + assertNotNull("littype", littype); rdfslabel = URI.create(xContext, rdfs + "label"); - assure("rdfslabel", null != rdfslabel); + assertNotNull("rdfslabel", rdfslabel); manifest = URI.create(xContext, "manifest:manifest"); //FIXME - assure("manifest", null != manifest); + assertNotNull("manifest", manifest); uuid = URI.create(xContext, "urn:uuid:224ab023-77b8-4396-a75a-8cecd85b81e3"); - assure("uuid", null != uuid); + assertNotNull("uuid", uuid); base = URI.create(xContext, "base-uri:"); //FIXME - assure("base", null != base); + assertNotNull("base", base); } catch (Exception e) { report(e); } + //FIXME: ? +// xRep = Repository.create(xContext); + System.out.println("Creating service Repository..."); + xRep = UnoRuntime.queryInterface(XDocumentRepository.class, Repository.create(xContext)); + assertNotNull("null", xRep); + System.out.println("...done"); } - public void after() + @After public void after() { xRep = null; } - public void check() + @Test public void check() { try { - - log.println("Creating service Repository..."); - - //FIXME: ? -// xRep = Repository.create(xContext); - xRep = (XDocumentRepository) UnoRuntime.queryInterface( - XDocumentRepository.class, Repository.create(xContext)); - assure("null", null != xRep); - - log.println("...done"); - - log.println("Checking that new repository is really empty..."); - assure("empty: graphs", 0 == xRep.getGraphNames().length); + System.out.println("Checking that new repository is really empty..."); + assertTrue("empty: graphs", 0 == xRep.getGraphNames().length); XEnumeration stmts; stmts = xRep.getStatements(null, null, null); - assure("empty: stmts", !stmts.hasMoreElements()); + assertTrue("empty: stmts", !stmts.hasMoreElements()); - log.println("...done"); + System.out.println("...done"); - log.println("Checking graph creation..."); + System.out.println("Checking graph creation..."); XNamedGraph xFooGraph = xRep.createGraph(foo); - assure("foo graph", null != xFooGraph); + assertNotNull("foo graph", xFooGraph); try { xRep.createGraph(foo); - assure("creating duplicate graph was allowed", false); + assertFalse("creating duplicate graph was allowed", false); } catch (ElementExistException e) { // ignore } try { xRep.createGraph(null); - assure("invalid graph name was allowed", false); + assertFalse("invalid graph name was allowed", false); } catch (IllegalArgumentException e) { // ignore } XURI[] names = xRep.getGraphNames(); - assure("no foo graph in getGraphNames", + assertTrue("no foo graph in getGraphNames", 1 == names.length && eq(names[0], foo)); - assure("no foo graph", null != xRep.getGraph(foo)); + assertNotNull("no foo graph", xRep.getGraph(foo)); stmts = xFooGraph.getStatements(null, null, null); - assure("stmts in foo graph", !stmts.hasMoreElements()); + assertTrue("stmts in foo graph", !stmts.hasMoreElements()); XOutputStream xFooOut = new StreamSimulator(tempDir + "empty.rdf", false, param); @@ -195,94 +200,94 @@ public class RDFRepositoryTest extends ComplexTestCase XInputStream xFooIn = new StreamSimulator(tempDir + "empty.rdf", true, param); xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base); - assure("no bar graph", null != xRep.getGraph(bar)); + assertNotNull("no bar graph", xRep.getGraph(bar)); - log.println("...done"); + System.out.println("...done"); - log.println("Checking graph manipulation..."); + System.out.println("Checking graph manipulation..."); XEnumeration xFooEnum; Statement xFoo_FooBarBaz = new Statement(foo, bar, baz, foo); xFooGraph.addStatement(foo, bar, baz); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(foo,bar,baz)", + assertTrue("addStatement(foo,bar,baz)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz })); Statement xFoo_FooBarBlank = new Statement(foo, bar, blank, foo); xFooGraph.addStatement(foo, bar, blank); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(foo,bar,blank)", + assertTrue("addStatement(foo,bar,blank)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank })); xFooEnum = xRep.getStatements(null, null, null); - assure("addStatement(foo,bar,blank) (global)", + assertTrue("addStatement(foo,bar,blank) (global)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank })); Statement xFoo_BazBarLit = new Statement(baz, bar, lit, foo); xFooGraph.addStatement(baz, bar, lit); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(baz,bar,lit)", + assertTrue("addStatement(baz,bar,lit)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit })); xFooEnum = xFooGraph.getStatements(baz, bar, null); - assure("addStatement(baz,bar,lit) (baz,bar)", + assertTrue("addStatement(baz,bar,lit) (baz,bar)", eq(xFooEnum, new Statement[] { xFoo_BazBarLit })); Statement xFoo_BazBarLitlang = new Statement(baz, bar, litlang, foo); xFooGraph.addStatement(baz, bar, litlang); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(baz,bar,litlang)", + assertTrue("addStatement(baz,bar,litlang)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit, xFoo_BazBarLitlang })); xFooEnum = xFooGraph.getStatements(null, null, baz); - assure("addStatement(baz,bar,litlang) (baz)", + assertTrue("addStatement(baz,bar,litlang) (baz)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz })); Statement xFoo_BazBarLittype = new Statement(baz, bar, littype, foo); xFooGraph.addStatement(baz, bar, littype); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(baz,bar,littype)", + assertTrue("addStatement(baz,bar,littype)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit, xFoo_BazBarLitlang, xFoo_BazBarLittype })); xFooGraph.removeStatements(baz, bar, litlang); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("removeStatement(baz,bar,litlang)", + assertTrue("removeStatement(baz,bar,litlang)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_FooBarBlank, xFoo_BazBarLit, xFoo_BazBarLittype })); xFooGraph.removeStatements(foo, bar, null); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("removeStatement(foo,bar,null)", + assertTrue("removeStatement(foo,bar,null)", eq(xFooEnum, new Statement[] { xFoo_BazBarLit, xFoo_BazBarLittype })); xFooGraph.addStatement(foo, bar, baz); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(foo,bar,baz) (re-add)", + assertTrue("addStatement(foo,bar,baz) (re-add)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_BazBarLit, xFoo_BazBarLittype })); xFooGraph.addStatement(foo, bar, baz); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(foo,bar,baz) (duplicate)", + assertTrue("addStatement(foo,bar,baz) (duplicate)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_BazBarLit, xFoo_BazBarLittype })); xFooGraph.addStatement(xFooGraph, bar, baz); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("addStatement(foo,bar,baz) (triplicate, as graph)", + assertTrue("addStatement(foo,bar,baz) (triplicate, as graph)", eq(xFooEnum, new Statement[] { xFoo_FooBarBaz, xFoo_BazBarLit, xFoo_BazBarLittype })); - log.println("...done"); + System.out.println("...done"); - log.println("Checking graph import/export..."); + System.out.println("Checking graph import/export..."); xFooOut = new StreamSimulator(tempDir + "foo.rdf", false, param); xRep.exportGraph(FileFormat.RDF_XML, xFooOut, foo, base); @@ -291,7 +296,7 @@ public class RDFRepositoryTest extends ComplexTestCase xFooIn = new StreamSimulator(tempDir + "foo.rdf", true, param); try { xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base); - assure("importing existing graph did not fail", false); + assertFalse("importing existing graph did not fail", false); } catch (ElementExistException e) { // ignore } @@ -299,77 +304,77 @@ public class RDFRepositoryTest extends ComplexTestCase xFooIn = new StreamSimulator(tempDir + "foo.rdf", true, param); xRep.importGraph(FileFormat.RDF_XML, xFooIn, baz, base); XNamedGraph xBazGraph = xRep.getGraph(baz); - assure("no baz graph", null != xBazGraph); + assertNotNull("no baz graph", xBazGraph); Statement xBaz_FooBarBaz = new Statement(foo, bar, baz, baz); Statement xBaz_BazBarLit = new Statement(baz, bar, lit, baz); Statement xBaz_BazBarLittype = new Statement(baz, bar, littype, baz); XEnumeration xBazEnum = xBazGraph.getStatements(null, null, null); - assure("importing exported graph", + assertTrue("importing exported graph", eq(xBazEnum, new Statement[] { xBaz_FooBarBaz, xBaz_BazBarLit, xBaz_BazBarLittype })); - log.println("...done"); + System.out.println("...done"); - log.println("Checking graph deletion..."); + System.out.println("Checking graph deletion..."); xFooGraph.clear(); xFooEnum = xFooGraph.getStatements(null, null, null); - assure("clear", eq(xFooEnum, new Statement[] { })); + assertTrue("clear", eq(xFooEnum, new Statement[] { })); xRep.destroyGraph(baz); - assure("baz graph zombie", null == xRep.getGraph(baz)); + assertNull("baz graph zombie", xRep.getGraph(baz)); try { xBazGraph.clear(); - assure("deleted graph not invalid (clear)", false); + assertFalse("deleted graph not invalid (clear)", false); } catch (NoSuchElementException e) { // ignore } try { xBazGraph.addStatement(foo, foo, foo); - assure("deleted graph not invalid (add)", false); + assertFalse("deleted graph not invalid (add)", false); } catch (NoSuchElementException e) { // ignore } try { xBazGraph.removeStatements(null, null, null); - assure("deleted graph not invalid (remove)", false); + assertFalse("deleted graph not invalid (remove)", false); } catch (NoSuchElementException e) { // ignore } try { xBazGraph.getStatements(null, null, null); - assure("deleted graph not invalid (get)", false); + assertFalse("deleted graph not invalid (get)", false); } catch (NoSuchElementException e) { // ignore } - log.println("...done"); + System.out.println("...done"); } catch (Exception e) { report(e); } } - public void checkSPARQL() + @Test public void checkSPARQL() { try { - log.println("Checking SPARQL queries..."); + System.out.println("Checking SPARQL queries..."); - XInputStream xIn = new StreamSimulator( - util.utils.getFullTestDocName("example.rdf"), true, param); + XInputStream xIn = new StreamSimulator(TestDocument.getUrl("example.rdf"), true, param); + // util.utils.getFullTestDocName("example.rdf"), true, param); xRep.importGraph(FileFormat.RDF_XML, xIn, manifest, base); String query; query = "SELECT ?p WHERE { ?p rdf:type pkg:Package . }"; XQuerySelectResult result = xRep.querySelect(mkNss() + query); - assure("query: package-id\n" + query, + assertTrue("query: package-id\n" + query, eq(result, new String[] { "p" }, new XNode[][] { { uuid } })); @@ -377,7 +382,7 @@ public class RDFRepositoryTest extends ComplexTestCase "> WHERE { ?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part ." + " ?part pkg:path ?path . ?part rdf:type odf:ContentFile. }"; result = xRep.querySelect(mkNss() + query); - assure("query: contentfile", + assertTrue("query: contentfile", eq(result, new String[] { "part", "path" }, new XNode[][] { { BlankNode.create(xContext, "whatever"), Literal.create(xContext, "content.xml") } })); @@ -386,7 +391,7 @@ public class RDFRepositoryTest extends ComplexTestCase + "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . " + "?part pkg:path ?path . ?part rdf:type odf:ContentFile. }"; result = xRep.querySelect(mkNss() + query); - assure("query: contentfile\n" + query, + assertTrue("query: contentfile\n" + query, eq(result, new String[] { "pkg", "path" }, new XNode[][] { { uuid , Literal.create(xContext, "content.xml") } })); @@ -395,7 +400,7 @@ public class RDFRepositoryTest extends ComplexTestCase + "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . " + "?part pkg:path ?path . ?part rdf:type odf:StylesFile. }"; result = xRep.querySelect(mkNss() + query); - assure("query: stylesfile\n" + query, + assertTrue("query: stylesfile\n" + query, eq(result, new String[] { "part", "path" }, new XNode[][] { })); @@ -403,7 +408,7 @@ public class RDFRepositoryTest extends ComplexTestCase + "?pkg rdf:type pkg:Package . ?pkg pkg:hasPart ?part . " + "?part pkg:path ?path . ?part rdf:type odf:MetadataFile. }"; result = xRep.querySelect(mkNss() + query); - assure("query: metadatafile\n" + query, + assertTrue("query: metadatafile\n" + query, eq(result, new String[] { "part", "path" }, new XNode[][] { { URI.create(xContext, "http://hospital-employee/doctor"), @@ -424,9 +429,9 @@ public class RDFRepositoryTest extends ComplexTestCase + " pkg:idref ?idref . " + " FILTER (?type = odf:ContentFile || ?type = odf:StylesFile)" + " }"; -//log.println(query); +//System.out.println(query); result = xRep.querySelect(mkNss() + query); - assure("query: example-element-2\n" + query, + assertTrue("query: example-element-2\n" + query, eq(result, new String[] { "path", "idref" }, new XNode[][] { { Literal.create(xContext, "content.xml"), @@ -438,24 +443,24 @@ public class RDFRepositoryTest extends ComplexTestCase lit.getStringValue() + "\" } FROM <" + toS(manifest) + "> WHERE { ?pkg rdf:type pkg:Package . } "; XEnumeration xResultEnum = xRep.queryConstruct(mkNss() + query); - assure("query: construct\n" + query, + assertTrue("query: construct\n" + query, eq(xResultEnum, new Statement[] { x_PkgFooLit })); query = "ASK { ?pkg rdf:type pkg:Package . }"; boolean bResult = xRep.queryAsk(mkNss() + query); - assure("query: ask\n" + query, bResult); + assertTrue("query: ask\n" + query, bResult); - log.println("...done"); + System.out.println("...done"); } catch (Exception e) { report(e); } } - public void checkRDFa() + @Test public void checkRDFa() { try { - log.println("Checking RDFa gunk..."); + System.out.println("Checking RDFa gunk..."); String content = "behold, for i am the content."; XTextRange xTR = new TestRange(content); @@ -463,19 +468,19 @@ public class RDFRepositoryTest extends ComplexTestCase Pair<Statement[], Boolean> result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: not empty (initial)", + assertTrue("RDFa: get: not empty (initial)", 0 == result.First.length); try { xRep.setStatementRDFa(foo, new XURI[] {}, xM, "", null); - assure("RDFa: set: no predicate", false); + assertFalse("RDFa: set: no predicate", false); } catch (IllegalArgumentException e) { // ignore } try { xRep.setStatementRDFa(foo, new XURI[] {bar}, null, "", null); - assure("RDFa: set: null", false); + assertFalse("RDFa: set: null", false); } catch (IllegalArgumentException e) { // ignore } @@ -485,16 +490,16 @@ public class RDFRepositoryTest extends ComplexTestCase xRep.setStatementRDFa(foo, new XURI[] { bar }, xM, "", null); result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: without content", + assertTrue("RDFa: get: without content", !result.Second && (1 == result.First.length) - && eq((Statement)result.First[0], x_FooBarTRLit)); + && eq(result.First[0], x_FooBarTRLit)); //FIXME: do this? xTR.setString(lit.getStringValue()); /* Statement xFooBarLit = new Statement(foo, bar, lit, null); result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: change", + assertTrue("RDFa: get: change", eq((Statement)result.First, xFooBarLit) && null == result.Second); */ @@ -502,17 +507,17 @@ public class RDFRepositoryTest extends ComplexTestCase xRep.setStatementRDFa(foo, new XURI[] { bar }, xM, "42", uint); result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: with content", + assertTrue("RDFa: get: with content", result.Second && (1 == result.First.length) && - eq((Statement)result.First[0], x_FooBarLittype)); + eq(result.First[0], x_FooBarLittype)); //FIXME: do this? xTR.setString(content); /* Statement xFooLabelTRLit = new Statement(foo, rdfslabel, trlit, null); result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: change (label)", + assertTrue("RDFa: get: change (label)", eq((Statement)result.First, xFooBarLittype) && eq((Statement)result.Second, xFooLabelTRLit)); */ @@ -520,7 +525,7 @@ public class RDFRepositoryTest extends ComplexTestCase xRep.removeStatementRDFa((XMetadatable)xTR); result = xRep.getStatementRDFa((XMetadatable)xTR); - assure("RDFa: get: not empty (removed)", + assertTrue("RDFa: get: not empty (removed)", 0 == result.First.length); xRep.setStatementRDFa(foo, new XURI[] { foo, bar, baz }, xM, @@ -529,7 +534,7 @@ public class RDFRepositoryTest extends ComplexTestCase Statement x_FooFooTRLit = new Statement(foo, foo, trlit, null); Statement x_FooBazTRLit = new Statement(foo, baz, trlit, null); result = xRep.getStatementRDFa((XMetadatable) xTR); - assure("RDFa: get: without content (multiple predicates, reinsert)", + assertTrue("RDFa: get: without content (multiple predicates, reinsert)", !result.Second && eq(result.First, new Statement[] { x_FooFooTRLit, x_FooBarTRLit, x_FooBazTRLit })); @@ -537,10 +542,10 @@ public class RDFRepositoryTest extends ComplexTestCase xRep.removeStatementRDFa((XMetadatable)xTR); result = xRep.getStatementRDFa((XMetadatable) xTR); - assure("RDFa: get: not empty (re-removed)", + assertTrue("RDFa: get: not empty (re-removed)", 0 == result.First.length); - log.println("...done"); + System.out.println("...done"); } catch (Exception e) { report(e); @@ -553,36 +558,38 @@ public class RDFRepositoryTest extends ComplexTestCase { if (e instanceof WrappedTargetException) { - log.println("Cause:"); + System.out.println("Cause:"); Exception cause = (Exception) (((WrappedTargetException)e).TargetException); - log.println(cause.toString()); + System.out.println(cause.toString()); report2(cause); } else if (e instanceof WrappedTargetRuntimeException) { - log.println("Cause:"); + System.out.println("Cause:"); Exception cause = (Exception) (((WrappedTargetRuntimeException)e).TargetException); - log.println(cause.toString()); + System.out.println(cause.toString()); report2(cause); } } public void report(Exception e) { - log.println("Exception occurred:"); - e.printStackTrace((java.io.PrintWriter) log); + System.out.println("Exception occurred:"); + e.printStackTrace(); report2(e); - failed(); + fail(); } public static String toS(XNode n) { - if (null == n) return "< null >"; + if (null == n) + { + return "< null >"; + } return n.getStringValue(); } static boolean isBlank(XNode i_node) { - XBlankNode blank = (XBlankNode) UnoRuntime.queryInterface( - XBlankNode.class, i_node); + XBlankNode blank = UnoRuntime.queryInterface(XBlankNode.class, i_node); return blank != null; } @@ -615,7 +622,7 @@ public class RDFRepositoryTest extends ComplexTestCase java.util.Collection c = new java.util.Vector(); while (i_Enum.hasMoreElements()) { Statement s = (Statement) i_Enum.nextElement(); -//log.println("toSeq: " + s.getSubject().getStringValue() + " " + s.getPredicate().getStringValue() + " " + s.getObject().getStringValue() + "."); +//System.out.println("toSeq: " + s.getSubject().getStringValue() + " " + s.getPredicate().getStringValue() + " " + s.getObject().getStringValue() + "."); c.add(s); } // return (Statement[]) c.toArray(); @@ -650,7 +657,10 @@ public class RDFRepositoryTest extends ComplexTestCase { XNode[] left = (XNode[]) i_Left; XNode[] right = (XNode[]) i_Right; - if (left.length != right.length) throw new RuntimeException(); + if (left.length != right.length) + { + throw new RuntimeException(); + } for (int i = 0; i < left.length; ++i) { int eq = (left[i].getStringValue().compareTo( right[i].getStringValue())); @@ -667,10 +677,22 @@ public class RDFRepositoryTest extends ComplexTestCase int eq; Statement left = (Statement) i_Left; Statement right = (Statement) i_Right; - if ((eq = cmp(left.Graph, right.Graph )) != 0) return eq; - if ((eq = cmp(left.Subject, right.Subject )) != 0) return eq; - if ((eq = cmp(left.Predicate, right.Predicate)) != 0) return eq; - if ((eq = cmp(left.Object, right.Object )) != 0) return eq; + if ((eq = cmp(left.Graph, right.Graph )) != 0) + { + return eq; + } + if ((eq = cmp(left.Subject, right.Subject )) != 0) + { + return eq; + } + if ((eq = cmp(left.Predicate, right.Predicate)) != 0) + { + return eq; + } + if ((eq = cmp(left.Object, right.Object )) != 0) + { + return eq; + } return 0; } @@ -693,23 +715,23 @@ public class RDFRepositoryTest extends ComplexTestCase XURI lG = i_Left.Graph; XURI rG = i_Right.Graph; if (!eq(lG, rG)) { - log.println("Graphs differ: " + toS(lG) + " != " + toS(rG)); + System.out.println("Graphs differ: " + toS(lG) + " != " + toS(rG)); return false; } if (!eq(i_Left.Subject, i_Right.Subject)) { - log.println("Subjects differ: " + + System.out.println("Subjects differ: " + i_Left.Subject.getStringValue() + " != " + i_Right.Subject.getStringValue()); return false; } if (!eq(i_Left.Predicate, i_Right.Predicate)) { - log.println("Predicates differ: " + + System.out.println("Predicates differ: " + i_Left.Predicate.getStringValue() + " != " + i_Right.Predicate.getStringValue()); return false; } if (!eq(i_Left.Object, i_Right.Object)) { - log.println("Objects differ: " + + System.out.println("Objects differ: " + i_Left.Object.getStringValue() + " != " + i_Right.Object.getStringValue()); return false; @@ -720,7 +742,7 @@ public class RDFRepositoryTest extends ComplexTestCase static boolean eq(Statement[] i_Result, Statement[] i_Expected) { if (i_Result.length != i_Expected.length) { - log.println("eq: different lengths: " + i_Result.length + " " + + System.out.println("eq: different lengths: " + i_Result.length + " " + i_Expected.length); return false; } @@ -729,7 +751,10 @@ public class RDFRepositoryTest extends ComplexTestCase java.util.Arrays.sort(i_Result, new StmtComp()); java.util.Arrays.sort(expected, new StmtComp()); for (int i = 0; i < expected.length; ++i) { - if (!eq(i_Result[i], expected[i])) return false; + if (!eq(i_Result[i], expected[i])) + { + return false; + } } return true; } @@ -760,11 +785,11 @@ public class RDFRepositoryTest extends ComplexTestCase XEnumeration iter = (XEnumeration) i_Result; XNode[][] bindings = toSeqs(iter); if (vars.length != i_Vars.length) { - log.println("var lengths differ"); + System.out.println("var lengths differ"); return false; } if (bindings.length != i_Bindings.length) { - log.println("binding lengths differ: " + i_Bindings.length + + System.out.println("binding lengths differ: " + i_Bindings.length + " vs " + bindings.length ); return false; } @@ -772,16 +797,16 @@ public class RDFRepositoryTest extends ComplexTestCase java.util.Arrays.sort(i_Bindings, new BindingComp()); for (int i = 0; i < i_Bindings.length; ++i) { if (i_Bindings[i].length != i_Vars.length) { - log.println("TEST ERROR!"); + System.out.println("TEST ERROR!"); throw new Exception(); } if (bindings[i].length != i_Vars.length) { - log.println("binding length and var length differ"); + System.out.println("binding length and var length differ"); return false; } for (int j = 0; j < i_Vars.length; ++j) { if (!eq(bindings[i][j], i_Bindings[i][j])) { - log.println("bindings differ: " + + System.out.println("bindings differ: " + toS(bindings[i][j]) + " != " + toS(i_Bindings[i][j])); return false; } @@ -789,7 +814,7 @@ public class RDFRepositoryTest extends ComplexTestCase } for (int i = 0; i < i_Vars.length; ++i) { if (!vars[i].equals(i_Vars[i])) { - log.println("variable names differ: " + + System.out.println("variable names differ: " + vars[i] + " != " + i_Vars[i]); return false; } @@ -828,7 +853,7 @@ public class RDFRepositoryTest extends ComplexTestCase { return new StringPair(m_Stream, m_XmlId); } public void setMetadataReference(StringPair i_Ref) throws IllegalArgumentException - { m_Stream = (String)i_Ref.First; m_XmlId = (String)i_Ref.Second; } + { m_Stream = i_Ref.First; m_XmlId = i_Ref.Second; } public void ensureMetadataReference() { m_Stream = "content.xml"; m_XmlId = "42"; } @@ -843,5 +868,26 @@ public class RDFRepositoryTest extends ComplexTestCase public String getString() { return m_Text; } public void setString(String i_Str) { m_Text = i_Str; } } + + private XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; + } + + // setup and close connections + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); } diff --git a/unoxml/qa/complex/unoxml/TestDocument.java b/unoxml/qa/complex/unoxml/TestDocument.java new file mode 100644 index 000000000000..bce9510e4d94 --- /dev/null +++ b/unoxml/qa/complex/unoxml/TestDocument.java @@ -0,0 +1,39 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package complex.unoxml; + +import java.io.File; +import org.openoffice.test.OfficeFileUrl; + +final class TestDocument { + public static String getUrl(String name) { + return OfficeFileUrl.getAbsolute(new File("testdocuments", name)); + } + + private TestDocument() {} +} diff --git a/unoxml/qa/complex/makefile.mk b/unoxml/qa/complex/unoxml/makefile.mk index c74cbcb80dcf..136d23a9a232 100644 --- a/unoxml/qa/complex/makefile.mk +++ b/unoxml/qa/complex/unoxml/makefile.mk @@ -25,35 +25,35 @@ # #***********************************************************************/ -PRJ = ..$/.. -TARGET = unoxml_test -PRJNAME = $(TARGET) -PACKAGE = complex$/unoxml +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- +PRJ = ../../.. +PRJNAME = unoxml +TARGET = qa_complex_unoxml -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = RDFRepositoryTest.java \ +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/unoxml +JAVATESTFILES = \ + RDFRepositoryTest.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) +JAVAFILES = $(JAVATESTFILES) \ + TestDocument.java -#----- make a jar from compiled files ------------------------------ +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar jurt.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) -MAXLINELENGTH = 100000 +# Sample how to debug +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y +.END -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Targets ------------------------------------------------------ +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk -.INCLUDE : target.mk +ALLTAR : javatest +.END -run: - +java -cp $(CLASSPATH) org.openoffice.Runner -TestBase java_complex -sce tests.sce -tdoc $(PWD)$/testdocuments diff --git a/unoxml/qa/complex/testdocuments/example.rdf b/unoxml/qa/complex/unoxml/testdocuments/example.rdf index 07ef7f07b6fd..07ef7f07b6fd 100644 --- a/unoxml/qa/complex/testdocuments/example.rdf +++ b/unoxml/qa/complex/unoxml/testdocuments/example.rdf diff --git a/unoxml/source/rdf/librdf_services.cxx b/unoxml/source/rdf/librdf_services.cxx index aaa32a837ae7..efe632944c10 100644 --- a/unoxml/source/rdf/librdf_services.cxx +++ b/unoxml/source/rdf/librdf_services.cxx @@ -73,13 +73,6 @@ extern "C" void * SAL_CALL component_getFactory( implName, serviceManager, registryKey, entries); } -extern "C" sal_Bool SAL_CALL component_writeInfo( - void * serviceManager, void * registryKey) -{ - return ::cppu::component_writeInfoHelper(serviceManager, registryKey, - entries); -} - } // extern "C" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unoxml/source/rdf/makefile.mk b/unoxml/source/rdf/makefile.mk index 3f6d7f445297..1dbcffb8b6ac 100644 --- a/unoxml/source/rdf/makefile.mk +++ b/unoxml/source/rdf/makefile.mk @@ -82,3 +82,11 @@ SHL1STDLIBS= \ .INCLUDE : target.mk + +ALLTAR : $(MISC)/unordf.component + +$(MISC)/unordf.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + unordf.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt unordf.component diff --git a/unoxml/source/rdf/unordf.component b/unoxml/source/rdf/unordf.component new file mode 100644 index 000000000000..a828e7b05d47 --- /dev/null +++ b/unoxml/source/rdf/unordf.component @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="CBlankNode"> + <service name="com.sun.star.rdf.BlankNode"/> + </implementation> + <implementation name="CLiteral"> + <service name="com.sun.star.rdf.Literal"/> + </implementation> + <implementation name="CURI"> + <service name="com.sun.star.rdf.URI"/> + </implementation> + <implementation name="librdf_Repository"> + <service name="com.sun.star.rdf.Repository"/> + </implementation> +</component> diff --git a/unoxml/source/service/makefile.mk b/unoxml/source/service/makefile.mk index 93aec0746323..5fbe62f67ec4 100644 --- a/unoxml/source/service/makefile.mk +++ b/unoxml/source/service/makefile.mk @@ -76,3 +76,11 @@ SHL1STDLIBS= \ .INCLUDE : target.mk + +ALLTAR : $(MISC)/unoxml.component + +$(MISC)/unoxml.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + unoxml.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt unoxml.component diff --git a/unoxml/source/service/services.cxx b/unoxml/source/service/services.cxx index 00cb14c00cc4..38d22b3ace3a 100644 --- a/unoxml/source/service/services.cxx +++ b/unoxml/source/service/services.cxx @@ -61,44 +61,6 @@ component_getImplementationEnvironment(const sal_Char **ppEnvironmentTypeName, u *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; } -sal_Bool SAL_CALL -component_writeInfo(void * /*pServiceManager*/, void* pRegistryKey ) -{ - Reference< XRegistryKey > xKey(reinterpret_cast< XRegistryKey* >(pRegistryKey)); - Reference< XRegistryKey > xNewKey; - OUString aImpl; - - // register DOM service - aImpl = OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - aImpl += CDocumentBuilder::_getImplementationName(); - aImpl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - xNewKey = xKey->createKey(aImpl); - xNewKey->createKey(CDocumentBuilder::_getSupportedServiceNames()[0]); - - // register DOM service - aImpl = OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - aImpl += CSAXDocumentBuilder::_getImplementationName(); - aImpl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - xNewKey = xKey->createKey(aImpl); - xNewKey->createKey(CSAXDocumentBuilder::_getSupportedServiceNames()[0]); - - // register XPath service - aImpl = OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - aImpl += CXPathAPI::_getImplementationName(); - aImpl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - xNewKey = xKey->createKey(aImpl); - xNewKey->createKey(CXPathAPI::_getSupportedServiceNames()[0]); - - // register EventTest service - aImpl = OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - aImpl += CTestListener::_getImplementationName(); - aImpl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - xNewKey = xKey->createKey(aImpl); - xNewKey->createKey(CTestListener::_getSupportedServiceNames()[0]); - - return sal_True; -} - void* SAL_CALL component_getFactory(const sal_Char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/) { diff --git a/unoxml/source/service/unoxml.component b/unoxml/source/service/unoxml.component new file mode 100644 index 000000000000..d8c907e6475b --- /dev/null +++ b/unoxml/source/service/unoxml.component @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.xml.dom.DocumentBuilder"> + <service name="com.sun.star.xml.dom.DocumentBuilder"/> + </implementation> + <implementation name="com.sun.star.comp.xml.dom.SAXDocumentBuilder"> + <service name="com.sun.star.xml.dom.SAXDocumentBuilder"/> + </implementation> + <implementation name="com.sun.star.comp.xml.dom.events.TestListener"> + <service name="com.sun.star.comp.xml.dom.events.TestListener"/> + </implementation> + <implementation name="com.sun.star.comp.xml.xpath.XPathAPI"> + <service name="com.sun.star.xml.xpath.XPathAPI"/> + </implementation> +</component> diff --git a/unoxml/source/xpath/xpathapi.hxx b/unoxml/source/xpath/xpathapi.hxx index 67f744950a3f..4bc57a958014 100644 --- a/unoxml/source/xpath/xpathapi.hxx +++ b/unoxml/source/xpath/xpathapi.hxx @@ -70,7 +70,7 @@ namespace XPath private: nsmap_t m_nsmap; - const Reference < XMultiServiceFactory > m_aFactory; + const Reference< XMultiServiceFactory > m_aFactory; extensions_t m_extensions; public: |