org.openrdf.model.vocabulary.XMLSchema Java Examples
The following examples show how to use
org.openrdf.model.vocabulary.XMLSchema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 6 votes |
/** * Verify that some value spaces are disjoint. */ public void test_datatypeLiteral_xsd_int_not_double_or_float() { final String lit1 = "4"; final byte[] k0 = fixture.datatypeLiteral2key(XMLSchema.INT, lit1); final byte[] k1 = fixture.datatypeLiteral2key(XMLSchema.FLOAT, lit1); final byte[] k2 = fixture.datatypeLiteral2key(XMLSchema.DOUBLE, lit1); if (log.isInfoEnabled()) { log.info("k0(float:" + lit1 + ") = " + BytesUtil.toString(k0)); log.info("k1(float:" + lit1 + ") = " + BytesUtil.toString(k1)); log.info("k2(double:" + lit1 + ") = " + BytesUtil.toString(k2)); } assertTrue(BytesUtil.compareBytes(k0, k1) != 0); assertTrue(BytesUtil.compareBytes(k0, k2) != 0); }
Example #2
Source File: EntityTypeSerializer.java From attic-polygene-java with Apache License 2.0 | 6 votes |
private void serializeManyAssociationTypes( final EntityDescriptor entityDescriptor, final Graph graph, final URI entityTypeUri ) { ValueFactory values = graph.getValueFactory(); // ManyAssociations entityDescriptor.state().manyAssociations().forEach( manyAssociationType -> { URI associationURI = values.createURI( manyAssociationType.qualifiedName().toURI() ); graph.add( associationURI, Rdfs.DOMAIN, entityTypeUri ); graph.add( associationURI, Rdfs.TYPE, Rdfs.SEQ ); URI associatedURI = values.createURI( manyAssociationType.qualifiedName().toURI() ); graph.add( associationURI, Rdfs.RANGE, associatedURI ); graph.add( associationURI, Rdfs.RANGE, XMLSchema.ANYURI ); } ); }
Example #3
Source File: EntityTypeSerializer.java From attic-polygene-java with Apache License 2.0 | 6 votes |
private void serializeAssociationTypes( final EntityDescriptor entityDescriptor, final Graph graph, final URI entityTypeUri ) { ValueFactory values = graph.getValueFactory(); // Associations entityDescriptor.state().associations().forEach( associationType -> { URI associationURI = values.createURI( associationType.qualifiedName().toURI() ); graph.add( associationURI, Rdfs.DOMAIN, entityTypeUri ); graph.add( associationURI, Rdfs.TYPE, Rdfs.PROPERTY ); URI associatedURI = values.createURI( Classes.toURI( Classes.RAW_CLASS.apply( associationType.type() ) ) ); graph.add( associationURI, Rdfs.RANGE, associatedURI ); graph.add( associationURI, Rdfs.RANGE, XMLSchema.ANYURI ); } ); }
Example #4
Source File: RepositoryConnectionTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testGetStatementsMalformedTypedLiteral() throws Exception { Literal invalidIntegerLiteral = vf.createLiteral("the number four", XMLSchema.INTEGER); try { URI pred = vf.createURI(URN_PRED); testCon.add(bob, pred, invalidIntegerLiteral); RepositoryResult<Statement> statements = testCon.getStatements(bob, pred, null, true); assertNotNull(statements); assertTrue(statements.hasNext()); Statement st = statements.next(); assertTrue(st.getObject() instanceof Literal); assertTrue(st.getObject().equals(invalidIntegerLiteral)); } catch (RepositoryException e) { // shouldn't happen fail(e.getMessage()); } }
Example #5
Source File: EntityTypeSerializer.java From attic-polygene-java with Apache License 2.0 | 6 votes |
public EntityTypeSerializer() { // TODO A ton more types need to be added here dataTypes.put( String.class.getName(), XMLSchema.STRING ); dataTypes.put( Integer.class.getName(), XMLSchema.INT ); dataTypes.put( Boolean.class.getName(), XMLSchema.BOOLEAN ); dataTypes.put( Byte.class.getName(), XMLSchema.BYTE ); dataTypes.put( BigDecimal.class.getName(), XMLSchema.DECIMAL ); dataTypes.put( Double.class.getName(), XMLSchema.DOUBLE ); dataTypes.put( Long.class.getName(), XMLSchema.LONG ); dataTypes.put( Short.class.getName(), XMLSchema.SHORT ); dataTypes.put( Instant.class.getName(), XMLSchema.LONG ); dataTypes.put( OffsetDateTime.class.getName(), XMLSchema.DATETIME ); dataTypes.put( ZonedDateTime.class.getName(), XMLSchema.DATETIME ); dataTypes.put( LocalDateTime.class.getName(), XMLSchema.DATETIME ); dataTypes.put( LocalDate.class.getName(), XMLSchema.DATE ); dataTypes.put( LocalTime.class.getName(), XMLSchema.TIME ); dataTypes.put( Duration.class.getName(), XMLSchema.DURATION ); dataTypes.put( Period.class.getName(), XMLSchema.DURATION ); }
Example #6
Source File: TestSparqlUpdate.java From database with GNU General Public License v2.0 | 6 votes |
/** @since openrdf 2.6.3 */ public void testDeleteInsertWhereLoopingBehavior() throws Exception { log.debug("executing test testDeleteInsertWhereLoopingBehavior"); final StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append(" DELETE { ?x ex:age ?y } INSERT {?x ex:age ?z }"); update.append(" WHERE { "); update.append(" ?x ex:age ?y ."); update.append(" BIND((?y + 1) as ?z) "); update.append(" FILTER( ?y < 46 ) "); update.append(" } "); final URI age = f.createURI(EX_NS, "age"); final Literal originalAgeValue = f.createLiteral("42", XMLSchema.INTEGER); final Literal correctAgeValue = f.createLiteral("43", XMLSchema.INTEGER); final Literal inCorrectAgeValue = f.createLiteral("46", XMLSchema.INTEGER); assertTrue(hasStatement(bob, age, originalAgeValue, true)); m_repo.prepareUpdate(update.toString()).evaluate(); assertFalse(hasStatement(bob, age, originalAgeValue, true)); assertTrue(hasStatement(bob, age, correctAgeValue, true)); assertFalse(hasStatement(bob, age, inCorrectAgeValue, true)); }
Example #7
Source File: LiteralTest.java From anno4j with Apache License 2.0 | 6 votes |
public void testDateTimeMS() throws Exception { TestConcept tester = manager.addDesignation(manager.getObjectFactory().createObject(), TestConcept.class); Resource bNode = (Resource) manager.addObject(tester); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(2001, 6, 4, 12, 8, 56); cal.set(Calendar.MILLISECOND, 27); cal.set(Calendar.ZONE_OFFSET, -7 * 60 * 60 * 1000); try { Literal literal = getValueFactory().createLiteral( "2001-07-04T12:08:56.027-07:00", XMLSchema.DATETIME); manager.add(bNode, dateURI, literal); } catch (RepositoryException e) { throw new ObjectPersistException(e); } Date date = tester.getADate(); assertEquals(cal.getTime(), date); }
Example #8
Source File: LiteralTest.java From anno4j with Apache License 2.0 | 6 votes |
public void testDateTimeS() throws Exception { TestConcept tester = manager.addDesignation(manager.getObjectFactory().createObject(), TestConcept.class); Resource bNode = (Resource) manager.addObject(tester); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(2001, 6, 4, 12, 8, 56); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.ZONE_OFFSET, -7 * 60 * 60 * 1000); try { manager.add(bNode, dateURI, getValueFactory().createLiteral( "2001-07-04T12:08:56-07:00", XMLSchema.DATETIME)); } catch (RepositoryException e) { throw new ObjectPersistException(e); } Date date = tester.getADate(); assertEquals(cal.getTime(), date); }
Example #9
Source File: LiteralTest.java From anno4j with Apache License 2.0 | 6 votes |
public void testDay() throws Exception { TestConcept tester = manager.addDesignation(manager.getObjectFactory().createObject(), TestConcept.class); Resource bNode = (Resource) manager.addObject(tester); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(1970, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); try { manager.add(bNode, dateURI, getValueFactory().createLiteral( "1970-01-01Z", XMLSchema.DATE)); } catch (RepositoryException e) { throw new ObjectPersistException(e); } cal.setTime(tester.getADate()); assertEquals(date, cal.getTime()); }
Example #10
Source File: XMLGregorianCalendarMarshall.java From anno4j with Apache License 2.0 | 6 votes |
public void setDatatype(URI datatype) { if (datatype.equals(XMLSchema.DATETIME)) return; if (datatype.equals(XMLSchema.DATE)) return; if (datatype.equals(XMLSchema.TIME)) return; if (datatype.equals(XMLSchema.GYEARMONTH)) return; if (datatype.equals(XMLSchema.GMONTHDAY)) return; if (datatype.equals(XMLSchema.GYEAR)) return; if (datatype.equals(XMLSchema.GMONTH)) return; if (datatype.equals(XMLSchema.GDAY)) return; throw new IllegalArgumentException(datatype.toString()); }
Example #11
Source File: ComplexSPARQLQueryTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInComparison1() throws Exception { loadTestData("/testdata-query/dataset-ses1913.trig"); StringBuilder query = new StringBuilder(); query.append(" PREFIX : <http://example.org/>\n"); query.append(" SELECT ?y WHERE { :a :p ?y. FILTER(?y in (:c, :d, 1/0 , 1)) } "); TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query.toString()); TupleQueryResult result = tq.evaluate(); assertNotNull(result); assertTrue(result.hasNext()); BindingSet bs = result.next(); Value y = bs.getValue("y"); assertNotNull(y); assertTrue(y instanceof Literal); assertEquals(f.createLiteral("1", XMLSchema.INTEGER), y); }
Example #12
Source File: ComplexSPARQLQueryTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInComparison3() throws Exception { loadTestData("/testdata-query/dataset-ses1913.trig"); StringBuilder query = new StringBuilder(); query.append(" PREFIX : <http://example.org/>\n"); query.append(" SELECT ?y WHERE { :a :p ?y. FILTER(?y in (:c, :d, 1, 1/0)) } "); TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query.toString()); TupleQueryResult result = tq.evaluate(); assertNotNull(result); assertTrue(result.hasNext()); BindingSet bs = result.next(); Value y = bs.getValue("y"); assertNotNull(y); assertTrue(y instanceof Literal); assertEquals(f.createLiteral("1", XMLSchema.INTEGER), y); }
Example #13
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 24: * INLINE_TEXT_LITERALS is false * INLINE_XSD_DATATYPE_LITERALS is true * data entered via SPARQL UPDATE */ public void test_24() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, false /*inlineTextLiterals*/ , true /*inlineXSDDatatypeLiterals*/ ); insertSparql(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertFalse(values[0].getIV().isInline()); // http://s assertTrue(values[1].getIV().isInline()); // 1 assertTrue(values[2].getIV().isInline()); // "2"^^xsd:int assertTrue(values[3].getIV().isInline()); // 3.0 assertTrue(values[4].getIV().isInline()); // "4.0"^^xsd:double assertTrue(values[5].getIV().isInline()); // true assertTrue(values[6].getIV().isInline()); // "false"^^xsd:boolean assertFalse(values[7].getIV().isInline()); // "plain string" assertFalse(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertFalse(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #14
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 18: * INLINE_TEXT_LITERALS is true * INLINE_XSD_DATATYPE_LITERALS is true * data entered via SPARQL UPDATE */ public void test_18() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, true /*inlineTextLiterals*/ , true /*inlineXSDDatatypeLiterals*/); insertSparql(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertTrue(values[0].getIV().isInline()); // http://s assertTrue(values[1].getIV().isInline()); // 1 assertTrue(values[2].getIV().isInline()); // "2"^^xsd:int assertTrue(values[3].getIV().isInline()); // 3.0 assertTrue(values[4].getIV().isInline()); // "4.0"^^xsd:double assertTrue(values[5].getIV().isInline()); // true assertTrue(values[6].getIV().isInline()); // "false"^^xsd:boolean assertTrue(values[7].getIV().isInline()); // "plain string" assertTrue(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertTrue(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #15
Source File: InterceptTest.java From anno4j with Apache License 2.0 | 5 votes |
public void testIllegalArgument() throws Exception { IConcept concept = con.addDesignation( con.getObject("urn:test:concept"), IConcept.class); ValueFactory vf = con.getValueFactory(); Resource subj = concept.getResource(); URI pred = vf.createURI("urn:test:date"); Literal lit = vf.createLiteral("noon", XMLSchema.DATETIME); con.add(subj, pred, lit); try { concept.getDate(); fail(); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("noon")); } }
Example #16
Source File: InterceptTest.java From anno4j with Apache License 2.0 | 5 votes |
public void testCatchIllegalArgument() throws Exception { IConcept concept = con.addDesignation( con.getObject("urn:test:concept"), IConcept.class); ValueFactory vf = con.getValueFactory(); Resource subj = concept.getResource(); URI pred = vf.createURI("urn:test:time"); Literal lit = vf.createLiteral("noon", XMLSchema.DATETIME); con.add(subj, pred, lit); XMLGregorianCalendar zero = DatatypeFactory.newInstance().newXMLGregorianCalendar(); assertEquals(zero, concept.getTime()); }
Example #17
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 23: * {@link Options#INLINE_TEXT_LITERALS} is false * {@link Options#INLINE_XSD_DATATYPE_LITERALS} is true * data loaded from file */ public void test_23() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, false /*inlineTextLiterals*/ , true /*inlineXSDDatatypeLiterals*/ ); loadData(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertFalse(values[0].getIV().isInline()); // http://s assertTrue(values[1].getIV().isInline()); // 1 assertTrue(values[2].getIV().isInline()); // "2"^^xsd:int assertTrue(values[3].getIV().isInline()); // 3.0 assertTrue(values[4].getIV().isInline()); // "4.0"^^xsd:double assertTrue(values[5].getIV().isInline()); // true assertTrue(values[6].getIV().isInline()); // "false"^^xsd:boolean assertFalse(values[7].getIV().isInline()); // "plain string" assertFalse(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertFalse(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #18
Source File: TestTicket1893.java From database with GNU General Public License v2.0 | 5 votes |
/** * case 19: * {@link Options#INLINE_TEXT_LITERALS} is false * {@link Options#INLINE_XSD_DATATYPE_LITERALS} is false * data loaded from file */ public void test_19() throws Exception { final String namespace = "test" + UUID.randomUUID(); final BigdataSailRepositoryConnection cxn = prepareTest(namespace, false /*inlineTextLiterals*/ , false /*inlineXSDDatatypeLiterals*/); loadData(cxn); BigdataValueFactory vf = cxn.getValueFactory(); BigdataValue[] values = new BigdataValue[]{ vf.createURI("http://s"), vf.createLiteral("1", XMLSchema.INTEGER), vf.createLiteral(2), vf.createLiteral("3.0", XMLSchema.DECIMAL), vf.createLiteral(4.0), vf.createLiteral(true), vf.createLiteral(false), vf.createLiteral("plain string"), vf.createLiteral("datatyped string", XMLSchema.STRING), vf.createLiteral("english string", "en"), }; cxn.getTripleStore().getLexiconRelation().addTerms(values, values.length, true /* readOnly */); assertFalse(values[0].getIV().isInline()); // http://s assertFalse(values[1].getIV().isInline()); // 1 assertFalse(values[2].getIV().isInline()); // "2"^^xsd:int assertFalse(values[3].getIV().isInline()); // 3.0 assertFalse(values[4].getIV().isInline()); // "4.0"^^xsd:double assertFalse(values[5].getIV().isInline()); // true assertFalse(values[6].getIV().isInline()); // "false"^^xsd:boolean assertFalse(values[7].getIV().isInline()); // "plain string" assertFalse(values[8].getIV().isInline()); // "datatyped string"^^xsd:string assertFalse(values[9].getIV().isInline()); // "english string"@en endTest(cxn); }
Example #19
Source File: TestBigdataSailRemoteRepository.java From database with GNU General Public License v2.0 | 5 votes |
/** * A bunch of namespace declarations to be used by the tests. * @return */ protected String getNamespaceDeclarations() { final StringBuilder declarations = new StringBuilder(); declarations.append("PREFIX : <" + DEFAULT_PREFIX + "> \n"); declarations.append("PREFIX rdf: <" + RDF.NAMESPACE + "> \n"); declarations.append("PREFIX rdfs: <" + RDFS.NAMESPACE + "> \n"); declarations.append("PREFIX foaf: <" + FOAF.NAMESPACE + "> \n"); declarations.append("PREFIX xsd: <" + XMLSchema.NAMESPACE + "> \n"); declarations.append("PREFIX dc: <" + DC.NAMESPACE + "> \n"); declarations.append("PREFIX ex: <" + "http://example.org/" + "> \n"); declarations.append("\n"); return declarations.toString(); }
Example #20
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 5 votes |
/** * Get a set of useful namespace prefix declarations. * * @return namespace prefix declarations for rdf, rdfs, dc, foaf and ex. */ protected String getNamespaceDeclarations() { StringBuilder declarations = new StringBuilder(); declarations.append("PREFIX rdf: <" + RDF.NAMESPACE + "> \n"); declarations.append("PREFIX rdfs: <" + RDFS.NAMESPACE + "> \n"); declarations.append("PREFIX dc: <" + DC.NAMESPACE + "> \n"); declarations.append("PREFIX foaf: <" + FOAF.NAMESPACE + "> \n"); declarations.append("PREFIX ex: <" + EX_NS + "> \n"); declarations.append("PREFIX xsd: <" + XMLSchema.NAMESPACE + "> \n"); declarations.append("PREFIX bd: <" + BD.NAMESPACE + "> \n"); declarations.append("\n"); return declarations.toString(); }
Example #21
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 5 votes |
public void test_datatypeLiteral_xsd_boolean() { final URI datatype = XMLSchema.BOOLEAN; final String lit1 = "true"; final String lit2 = "false"; final String lit3 = "1"; final String lit4 = "0"; final byte[] k1 = fixture.datatypeLiteral2key(datatype,lit1); final byte[] k2 = fixture.datatypeLiteral2key(datatype,lit2); final byte[] k3 = fixture.datatypeLiteral2key(datatype,lit3); final byte[] k4 = fixture.datatypeLiteral2key(datatype,lit4); if (log.isInfoEnabled()) { log.info("k1(boolean:" + lit1 + ") = " + BytesUtil.toString(k1)); log.info("k2(boolean:" + lit2 + ") = " + BytesUtil.toString(k2)); log.info("k3(boolean:" + lit3 + ") = " + BytesUtil.toString(k3)); log.info("k4(boolean:" + lit4 + ") = " + BytesUtil.toString(k4)); } assertTrue(BytesUtil.compareBytes(k1, k2) != 0); assertTrue(BytesUtil.compareBytes(k1, k2) > 0); /* * Note: if we do not normalize data type values then these are * inequalities. */ assertTrue(BytesUtil.compareBytes(k1, k3) != 0); // true != 1 assertTrue(BytesUtil.compareBytes(k2, k4) != 0); // false != 0 }
Example #22
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 5 votes |
public void test_datatypeLiteral_xsd_int() { final URI datatype = XMLSchema.INT; // Note: leading zeros are ignored in the xsd:int value space. final String lit1 = "-4"; final String lit2 = "005"; final String lit3 = "5"; final String lit4 = "6"; final byte[] k1 = fixture.datatypeLiteral2key(datatype,lit1); final byte[] k2 = fixture.datatypeLiteral2key(datatype,lit2); final byte[] k3 = fixture.datatypeLiteral2key(datatype,lit3); final byte[] k4 = fixture.datatypeLiteral2key(datatype,lit4); if (log.isInfoEnabled()) { log.info("k1(int:" + lit1 + ") = " + BytesUtil.toString(k1)); log.info("k2(int:" + lit2 + ") = " + BytesUtil.toString(k2)); log.info("k2(int:" + lit3 + ") = " + BytesUtil.toString(k3)); log.info("k4(int:" + lit4 + ") = " + BytesUtil.toString(k4)); } assertTrue(BytesUtil.compareBytes(k1, k2) < 0); assertTrue(BytesUtil.compareBytes(k3, k4) < 0); /* * Note: if we do not normalize data type values then these are * inequalities. */ assertTrue(BytesUtil.compareBytes(k2, k3) != 0); // 005 != 5 }
Example #23
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 5 votes |
/** * Verify that the value spaces for long, int, short and byte are disjoint. */ public void test_disjoint_value_space() { assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.LONG, "-1"),// fixture.datatypeLiteral2key(XMLSchema.INT, "-1")// )); assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.LONG, "-1"),// fixture.datatypeLiteral2key(XMLSchema.SHORT, "-1")// )); assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.LONG, "-1"),// fixture.datatypeLiteral2key(XMLSchema.BYTE, "-1")// )); assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.INT, "-1"),// fixture.datatypeLiteral2key(XMLSchema.SHORT, "-1")// )); assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.INT, "-1"),// fixture.datatypeLiteral2key(XMLSchema.BYTE, "-1")// )); assertFalse(BytesUtil.bytesEqual(// fixture.datatypeLiteral2key(XMLSchema.SHORT, "-1"),// fixture.datatypeLiteral2key(XMLSchema.BYTE, "-1")// )); }
Example #24
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 5 votes |
public void test_datatypeLiteral_xsd_float() { final URI datatype = XMLSchema.FLOAT; // Note: leading zeros are ignored in the xsd:int value space. final String lit1 = "-4.0"; final String lit2 = "005"; final String lit3 = "5."; final String lit4 = "5.0"; final String lit5 = "6"; final byte[] k1 = fixture.datatypeLiteral2key(datatype,lit1); final byte[] k2 = fixture.datatypeLiteral2key(datatype,lit2); final byte[] k3 = fixture.datatypeLiteral2key(datatype,lit3); final byte[] k4 = fixture.datatypeLiteral2key(datatype,lit4); final byte[] k5 = fixture.datatypeLiteral2key(datatype,lit5); if (log.isInfoEnabled()) { log.info("k1(float:" + lit1 + ") = " + BytesUtil.toString(k1)); log.info("k2(float:" + lit2 + ") = " + BytesUtil.toString(k2)); log.info("k3(float:" + lit3 + ") = " + BytesUtil.toString(k3)); log.info("k4(float:" + lit3 + ") = " + BytesUtil.toString(k4)); log.info("k5(float:" + lit5 + ") = " + BytesUtil.toString(k5)); } assertTrue(BytesUtil.compareBytes(k1, k2) < 0); assertTrue(BytesUtil.compareBytes(k4, k5) < 0); /* * Note: if we do not normalize data type values then these are * inequalities. */ assertTrue(BytesUtil.compareBytes(k2, k3) != 0); // 005 != 5. assertTrue(BytesUtil.compareBytes(k3, k4) != 0); // 5. != 5.0 }
Example #25
Source File: TestLexiconKeyBuilder.java From database with GNU General Public License v2.0 | 5 votes |
public void test_datatypeLiteral_xsd_double() { final URI datatype = XMLSchema.DOUBLE; // Note: leading zeros are ignored in the xsd:int value space. final String lit1 = "-4.0"; final String lit2 = "005"; final String lit3 = "5."; final String lit4 = "5.0"; final String lit5 = "6"; final byte[] k1 = fixture.datatypeLiteral2key(datatype,lit1); final byte[] k2 = fixture.datatypeLiteral2key(datatype,lit2); final byte[] k3 = fixture.datatypeLiteral2key(datatype,lit3); final byte[] k4 = fixture.datatypeLiteral2key(datatype,lit4); final byte[] k5 = fixture.datatypeLiteral2key(datatype,lit5); if (log.isInfoEnabled()) { log.info("k1(double:" + lit1 + ") = " + BytesUtil.toString(k1)); log.info("k2(double:" + lit2 + ") = " + BytesUtil.toString(k2)); log.info("k3(double:" + lit3 + ") = " + BytesUtil.toString(k3)); log.info("k4(double:" + lit3 + ") = " + BytesUtil.toString(k4)); log.info("k5(double:" + lit5 + ") = " + BytesUtil.toString(k5)); } assertTrue(BytesUtil.compareBytes(k1, k2) < 0); assertTrue(BytesUtil.compareBytes(k4, k5) < 0); /* * Note: if we do not normalize data type values then these are * inequalities. */ assertTrue(BytesUtil.compareBytes(k2, k3) != 0); // 005 != 5. assertTrue(BytesUtil.compareBytes(k3, k4) != 0); // 5. != 5.0 }
Example #26
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 5 votes |
@Test public void testDeleteInsertWhereLoopingBehavior() throws Exception { logger.debug("executing test testDeleteInsertWhereLoopingBehavior"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append(" DELETE { ?x ex:age ?y } INSERT {?x ex:age ?z }"); update.append(" WHERE { "); update.append(" ?x ex:age ?y ."); update.append(" BIND((?y + 1) as ?z) "); update.append(" FILTER( ?y < 46 ) "); update.append(" } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI age = f.createURI(EX_NS, "age"); Literal originalAgeValue = f.createLiteral("42", XMLSchema.INTEGER); Literal correctAgeValue = f.createLiteral("43", XMLSchema.INTEGER); Literal inCorrectAgeValue = f.createLiteral("46", XMLSchema.INTEGER); assertTrue(con.hasStatement(bob, age, originalAgeValue, true)); operation.execute(); assertFalse(con.hasStatement(bob, age, originalAgeValue, true)); assertTrue(con.hasStatement(bob, age, correctAgeValue, true)); assertFalse(con.hasStatement(bob, age, inCorrectAgeValue, true)); }
Example #27
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 5 votes |
@Test public void testInsertWhereWithOptional() throws Exception { logger.debug("executing testInsertWhereWithOptional"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append(" INSERT { ?s ex:age ?incAge } "); // update.append(" DELETE { ?s ex:age ?age } "); update.append(" WHERE { ?s foaf:name ?name . "); update.append(" OPTIONAL {?s ex:age ?age . BIND ((?age + 1) as ?incAge) } "); update.append(" } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI age = f.createURI(EX_NS, "age"); assertFalse(con.hasStatement(alice, age, null, true)); assertTrue(con.hasStatement(bob, age, null, true)); operation.execute(); RepositoryResult<Statement> result = con.getStatements(bob, age, null, true); while (result.hasNext()) { System.out.println(result.next().toString()); } assertTrue(con.hasStatement(bob, age, f.createLiteral("43", XMLSchema.INTEGER), true)); result = con.getStatements(alice, age, null, true); while (result.hasNext()) { System.out.println(result.next()); } assertFalse(con.hasStatement(alice, age, null, true)); }
Example #28
Source File: RDFStoreTest.java From database with GNU General Public License v2.0 | 5 votes |
@Test public void testDecimalRoundTrip() throws Exception { URI subj = new URIImpl(EXAMPLE_NS + PICASSO); URI pred = new URIImpl(EXAMPLE_NS + PAINTS); Literal obj = new NumericLiteralImpl(3, XMLSchema.DECIMAL); testValueRoundTrip(subj, pred, obj); }
Example #29
Source File: RDFStoreTest.java From database with GNU General Public License v2.0 | 5 votes |
@Test public void testInvalidDateTime() throws Exception { // SES-711 Literal date1 = vf.createLiteral("2004-12-20", XMLSchema.DATETIME); Literal date2 = vf.createLiteral("2004-12-20", XMLSchema.DATETIME); assertEquals(date1, date2); }
Example #30
Source File: SPARQLUpdateTestv2.java From database with GNU General Public License v2.0 | 5 votes |
/** * Get a set of useful namespace prefix declarations. * * @return namespace prefix declarations for rdf, rdfs, dc, foaf and ex. */ protected String getNamespaceDeclarations() { StringBuilder declarations = new StringBuilder(); declarations.append("PREFIX rdf: <" + RDF.NAMESPACE + "> \n"); declarations.append("PREFIX rdfs: <" + RDFS.NAMESPACE + "> \n"); declarations.append("PREFIX dc: <" + DC.NAMESPACE + "> \n"); declarations.append("PREFIX foaf: <" + FOAF.NAMESPACE + "> \n"); declarations.append("PREFIX ex: <" + EX_NS + "> \n"); declarations.append("PREFIX xsd: <" + XMLSchema.NAMESPACE + "> \n"); declarations.append("PREFIX bd: <" + BD.NAMESPACE + "> \n"); declarations.append("\n"); return declarations.toString(); }