You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/03/10 15:32:22 UTC
[1/6] jena git commit: JENA-1504: Fix batch handling.
Repository: jena
Updated Branches:
refs/heads/master abce36d81 -> 2ce86cdd7
JENA-1504: Fix batch handling.
Fix new line output.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f3549cab
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f3549cab
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f3549cab
Branch: refs/heads/master
Commit: f3549cabc95113412aa6d7e2e82066f0d836cd1d
Parents: 46e2f56
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Mar 9 18:33:50 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Mar 9 18:35:44 2018 +0000
----------------------------------------------------------------------
.../riot/writer/WriterStreamRDFBatched.java | 67 +++++++++-----------
.../jena/riot/writer/WriterStreamRDFBlocks.java | 30 ++++-----
2 files changed, 44 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f3549cab/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBatched.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBatched.java b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBatched.java
index 87573d5..3572643 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBatched.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBatched.java
@@ -68,75 +68,68 @@ abstract class WriterStreamRDFBatched extends WriterStreamRDFBase
batchQuads = null ;
}
- @Override
- protected final void print(Quad quad) {
- if ( false ) {
- // Merge to a triple stream.
- triple(quad.asTriple()) ;
- return ;
- }
-
- Node g = quad.getGraph() ;
- Node s = quad.getSubject() ;
-
+ private void batch(Node g, Node s, boolean forTriples) {
if ( !Objects.equals(g, currentGraph) || !Objects.equals(s, currentSubject) ) {
- if ( currentSubject != null ) {
- if ( currentGraph == null )
- finishBatchTriples(currentSubject) ;
- else
- finishBatchQuad(currentGraph, currentSubject) ;
- }
- startBatchQuad(g, s) ;
+ finishBatchTriples(currentSubject) ;
+ finishBatchQuad(currentGraph, currentSubject) ;
+ if ( forTriples )
+ startBatchTriple(s);
+ else
+ startBatchQuad(g, s);
currentGraph = g ;
currentSubject = s ;
}
- processQuad(quad) ;
}
@Override
protected final void print(Triple triple) {
Node s = triple.getSubject() ;
- if ( !Objects.equals(s, currentSubject) ) {
- if ( currentSubject != null )
- finishBatchTriples(currentSubject) ;
- startBatchTriple(s) ;
-
- currentGraph = null ;
- currentSubject = s ;
- }
+ batch(null, s, true);
processTriple(triple) ;
}
private void startBatchTriple(Node subject) {
batchTriples = new ArrayList<>() ;
- }
-
- private void processTriple(Triple triple) {
- batchTriples.add(triple) ;
+ this.currentGraph = null;
+ this.currentSubject = subject;
}
private void finishBatchTriples(Node subject) {
- if ( batchTriples != null && batchTriples.size() > 0 ) {
+ if ( batchTriples != null && !batchTriples.isEmpty() ) {
printBatchTriples(currentSubject, batchTriples) ;
batchTriples.clear() ;
}
}
- private void startBatchQuad(Node graph, Node subject) {
- batchQuads = new ArrayList<>() ;
+ private void processTriple(Triple triple) {
+ batchTriples.add(triple) ;
}
- private void processQuad(Quad Quad) {
- batchQuads.add(Quad) ;
+ @Override
+ protected final void print(Quad quad) {
+ Node g = quad.getGraph() ;
+ Node s = quad.getSubject() ;
+ batch(g, s, false);
+ processQuad(quad) ;
+ }
+
+ private void startBatchQuad(Node graph, Node subject) {
+ batchQuads = new ArrayList<>() ;
+ this.currentGraph = graph;
+ this.currentSubject = subject;
}
private void finishBatchQuad(Node graph, Node subject) {
- if ( batchQuads != null && batchQuads.size() > 0 ) {
+ if ( batchQuads != null && !batchQuads.isEmpty() ) {
printBatchQuads(currentGraph, currentSubject, batchQuads) ;
batchQuads.clear() ;
}
}
+ private void processQuad(Quad quad) {
+ batchQuads.add(quad) ;
+ }
+
protected abstract void printBatchQuads(Node g, Node s, List<Quad> batch) ;
protected abstract void printBatchTriples(Node s, List<Triple> batch) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/f3549cab/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBlocks.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBlocks.java b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBlocks.java
index 64b4297..97e179f 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBlocks.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterStreamRDFBlocks.java
@@ -64,7 +64,6 @@ public class WriterStreamRDFBlocks extends WriterStreamRDFBatched
// Quad output
protected Node lastGraph = null ;
protected Node lastSubject = null ;
- protected boolean firstGraph = true ;
protected int currentGraphIndent = 0;
public WriterStreamRDFBlocks(OutputStream output) {
@@ -82,13 +81,13 @@ public class WriterStreamRDFBlocks extends WriterStreamRDFBatched
@Override
protected void printBatchQuads(Node g, Node s, List<Quad> quads) {
if ( g == null )
+ // print as Triples has currentGraph == null.
g = Quad.defaultGraphNodeGenerated ;
if ( Objects.equals(g, lastGraph) ) {
// Same graph, different subject.
out.println(" .") ;
- out.println() ;
} else {
- // Start graph
+ // Different graph
endGraph(g) ;
startGraph(g) ;
lastGraph = g ;
@@ -99,21 +98,24 @@ public class WriterStreamRDFBlocks extends WriterStreamRDFBatched
lastSubject = s ;
}
+ private void startBatch() {
+ // Any output so far? prefixes or a previous graph.
+ if ( out.getRow() > 1 )
+ out.println() ;
+ out.flush();
+ }
+
private void gap(int gap) {
out.print(' ', gap) ;
}
@Override
protected void printBatchTriples(Node s, List<Triple> triples) {
- // Blank line?
- // Not if not prefixes and first batch.
- if ( out.getRow() > 1 )
- out.println() ;
-
+ startBatch();
printBatch(s, triples) ;
// End of cluster.
- out.print(" .") ;
- out.println() ;
+ out.println(" .") ;
+ lastGraph = null;
}
private void printBatch(Node s, List<Triple> triples) {
@@ -158,14 +160,11 @@ public class WriterStreamRDFBlocks extends WriterStreamRDFBatched
protected boolean dftGraph(Node g) { return g == Quad.defaultGraphNodeGenerated ; }
protected void startGraph(Node g) {
+ startBatch();
// Start graph
if ( lastGraph == null ) {
boolean NL_START = (dftGraph(g) ? NL_GDFT_START : NL_GNMD_START) ;
-
- if ( !firstGraph )
- out.println() ;
- firstGraph = false ;
-
+
lastSubject = null ;
if ( !dftGraph(g) ) {
outputNode(g) ;
@@ -218,5 +217,4 @@ public class WriterStreamRDFBlocks extends WriterStreamRDFBatched
protected void setGraphIndent(int x) { currentGraphIndent = x ; }
protected int graphIndent() { return currentGraphIndent ; }
-
}
[3/6] jena git commit: JENA-1480: Use $.getJSON(url,data)
Posted by an...@apache.org.
JENA-1480: Use $.getJSON(url,data)
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0547e978
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0547e978
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0547e978
Branch: refs/heads/master
Commit: 0547e9786478a7cd2acb7d3c292b43e2f32ecbe7
Parents: abce36d
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Mar 10 09:52:42 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Mar 10 09:52:42 2018 +0000
----------------------------------------------------------------------
.../jena-fuseki-core/src/main/webapp/js/app/models/dataset.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/0547e978/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/app/models/dataset.js
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/app/models/dataset.js b/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/app/models/dataset.js
index 9c911c2..1a716a0 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/app/models/dataset.js
+++ b/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/app/models/dataset.js
@@ -205,11 +205,11 @@ define(
model.set( "counts", counts );
};
- $.getJSON( sprintf( "%s?query=%s", self.queryURL(), query1 ) )
+ $.getJSON( self.queryURL(), { query: query1 } )
.done( function( data ) {
updateCount( self, data.results.bindings[0], "default graph" );
- $.getJSON( sprintf( "%s?query=%s", self.queryURL(), query2 ) )
+ $.getJSON( self.queryURL(), { query: query2 } )
.done( function( data ) {
_.each( data.results.bindings, function( binding ) {
if (binding.g) {
[4/6] jena git commit: Merge commit 'refs/pull/379/head' of
https://github.com/apache/jena
Posted by an...@apache.org.
Merge commit 'refs/pull/379/head' of https://github.com/apache/jena
This closes #379.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3d896d96
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3d896d96
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3d896d96
Branch: refs/heads/master
Commit: 3d896d966a8398a6133ef48032d2f1105726868d
Parents: abce36d daf3490
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Mar 10 15:07:38 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Mar 10 15:07:38 2018 +0000
----------------------------------------------------------------------
.../jena/graph/test/TestTypedLiterals.java | 148 ++++++++++++-------
1 file changed, 91 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
[6/6] jena git commit: JENA-1504: Merge commit 'refs/pull/378/head'
of https://github.com/apache/jena
Posted by an...@apache.org.
JENA-1504: Merge commit 'refs/pull/378/head' of https://github.com/apache/jena
This closes #378.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2ce86cdd
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2ce86cdd
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2ce86cdd
Branch: refs/heads/master
Commit: 2ce86cdd73abd596cd9cfc95768a9c7851511411
Parents: 6b6db97 f3549ca
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Mar 10 15:09:13 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Mar 10 15:09:13 2018 +0000
----------------------------------------------------------------------
.../riot/writer/WriterStreamRDFBatched.java | 67 +++++++++-----------
.../jena/riot/writer/WriterStreamRDFBlocks.java | 30 ++++-----
2 files changed, 44 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
[5/6] jena git commit: JENA-1480: Merge commit 'refs/pull/380/head'
of https://github.com/apache/jena
Posted by an...@apache.org.
JENA-1480: Merge commit 'refs/pull/380/head' of https://github.com/apache/jena
This closes #380.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6b6db971
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6b6db971
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6b6db971
Branch: refs/heads/master
Commit: 6b6db971e37da0a4a73c98a271e68afd2e36846a
Parents: 3d896d9 0547e97
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Mar 10 15:08:34 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Mar 10 15:08:34 2018 +0000
----------------------------------------------------------------------
.../jena-fuseki-core/src/main/webapp/js/app/models/dataset.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
[2/6] jena git commit: Refactor tests; don't test for GregorianYear< 0
Posted by an...@apache.org.
Refactor tests; don't test for GregorianYear< 0
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/daf34902
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/daf34902
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/daf34902
Branch: refs/heads/master
Commit: daf349022c2188345ba4630e4e074594b697bda2
Parents: c656cf1
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Mar 9 16:47:57 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Mar 9 20:42:10 2018 +0000
----------------------------------------------------------------------
.../jena/graph/test/TestTypedLiterals.java | 148 ++++++++++++-------
1 file changed, 91 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/daf34902/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
index 3d2c633..57a320d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
@@ -568,7 +568,7 @@ public class TestTypedLiterals extends TestCase {
/**
* Test data/time wrappers
*/
- public void testDateTime() {
+ public void testDateTime_1() {
// Duration
Literal l1 = m.createTypedLiteral("P1Y2M3DT5H6M7.50S", XSDDatatype.XSDduration);
assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype());
@@ -584,32 +584,36 @@ public class TestTypedLiterals extends TestCase {
assertEquals("serialization", "P1Y2M3DT5H6M7.5S", l1.getValue().toString());
assertTrue("equality test", l1.sameValueAs( m.createTypedLiteral("P1Y2M3DT5H6M7.5S", XSDDatatype.XSDduration) ) );
assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y2M2DT5H6M7.5S", XSDDatatype.XSDduration));
-
- l1 = m.createTypedLiteral("P1Y2M3DT5H0M", XSDDatatype.XSDduration);
+ }
+ public void testDateTime_2() {
+ Literal l1 = m.createTypedLiteral("P1Y2M3DT5H0M", XSDDatatype.XSDduration);
assertEquals("serialization", "P1Y2M3DT5H", l1.getValue().toString());
-
- l1 = m.createTypedLiteral("P1Y", XSDDatatype.XSDduration);
+ }
+ public void testDateTime_3() {
+ Literal l1 = m.createTypedLiteral("P1Y", XSDDatatype.XSDduration);
assertEquals("duration data type", XSDDatatype.XSDduration, l1.getDatatype());
assertEquals("duration java type", XSDDuration.class, l1.getValue().getClass());
assertEquals("duration value", 1, ((XSDDuration)l1.getValue()).getYears());
assertEquals("serialization", "P1Y", l1.getValue().toString());
assertTrue("equality test", l1.sameValueAs( m.createTypedLiteral("P1Y", XSDDatatype.XSDduration) ) );
assertTrue("inequality test", l1 != m.createTypedLiteral("P1Y", XSDDatatype.XSDduration));
-
- l1 = m.createTypedLiteral("-P120D", XSDDatatype.XSDduration);
+ }
+ public void testDateTime_4() {
+ Literal l1 = m.createTypedLiteral("-P120D", XSDDatatype.XSDduration);
Literal l2 = m.createTypedLiteral( l1.getValue() );
assertEquals("-P120D", l2.getLexicalForm() );
-
- // Duration equality bug
+ }
+ public void testDateTime_5() {
Literal d1 = m.createTypedLiteral("PT1H1M1S", XSDDatatype.XSDduration);
Literal d2 = m.createTypedLiteral("PT1H1M1.1S", XSDDatatype.XSDduration);
assertTrue("duration compare", !d1.sameValueAs(d2));
XSDDuration dur1 = (XSDDuration)d1.getValue() ;
XSDDuration dur2 = (XSDDuration)d2.getValue() ;
assertEquals("duration compare order", 1, dur2.compare(dur1)) ;
-
+ }
+ public void testDateTime_6() {
// dateTime
- l1 = m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime);
+ Literal l1 = m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime);
XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime data type", XSDDatatype.XSDdateTime, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
@@ -644,11 +648,13 @@ public class TestTypedLiterals extends TestCase {
assertEquals("calendar value", cal, testCal);
assertEquals("equality test", l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime));
-
+ }
+
+ public void testDateTime_7() {
Calendar testCal3 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal3.clear();
testCal3.set(1999, Calendar.JANUARY, 30, 15, 9, 32);
- lc = m.createTypedLiteral(testCal3);
+ Literal lc = m.createTypedLiteral(testCal3);
assertEquals("1999-01-30T15:09:32Z", lc.getLexicalForm());
String urib="rdf://test.com#";
String uri1=urib+"1";
@@ -661,7 +667,9 @@ public class TestTypedLiterals extends TestCase {
Property p = m.getProperty(urip);
XSDDateTime returnedDateTime = (XSDDateTime) r1.getProperty(p).getLiteral().getValue();
assertEquals("deserialized calendar value", testCal3, returnedDateTime.asCalendar());
+ }
+ public void testDateTime_8() {
// dateTime to calendar with milliseconds
Calendar testCal4 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal4.set(1999, 4, 30, 15, 9, 32);
@@ -671,9 +679,23 @@ public class TestTypedLiterals extends TestCase {
doDateTimeTest(testCal4, "1999-05-30T15:09:32.25Z", 32.25);
testCal4.set(Calendar.MILLISECOND, 2);
doDateTimeTest(testCal4, "1999-05-30T15:09:32.002Z", 32.002);
-
+ }
+
+ // Internal helper
+ private void doDateTimeTest(Calendar cal, String lex, double time) {
+ Literal lc4 = m.createTypedLiteral(cal);
+ assertEquals("serialization", lex, lc4.getValue().toString());
+ assertEquals("calendar ms test", m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4 );
+ XSDDateTime dt4 = (XSDDateTime)lc4.getValue();
+ assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001);
+ assertEquals(dt4.asCalendar(), cal);
+ }
+
+ public void testDateTime_9() {
// Years before 1000 : xsd:dateTime requires at least a four digit year.
- int[] years = { -7777, -777, -77, -7, 7, 77, 777 , 7777 } ;
+ // GregorianCalendar does not handle negative years. (.get(YEAR) triggers
+ // complete() which changes -77 into 78 (Java8)).
+ int[] years = { 0, 7, 77, 777 , 7777 } ;
for ( int y : years ) {
Calendar calM1 = Calendar.getInstance();
calM1.set(Calendar.YEAR, y);
@@ -682,28 +704,29 @@ public class TestTypedLiterals extends TestCase {
XSDDateTime xdtM = new XSDDateTime(calM1);
LiteralLabel xdtM_ll = LiteralLabelFactory.createByValue(xdtM, "", XSDDatatype.XSDdateTime);
- assertTrue("Pre-1000 calendar value", xdtM_ll.getLexicalForm().matches("-?[0-9]{4}-.*")) ;
assertTrue("Pre-1000 calendar value", xdtM_ll.isWellFormed()) ;
+ assertTrue("Pre-1000 calendar value", xdtM_ll.getLexicalForm().matches("^[0-9]{4}-.*")) ;
}
// Illegal dateTimes
boolean ok = false;
boolean old = JenaParameters.enableEagerLiteralValidation;
try {
JenaParameters.enableEagerLiteralValidation = true;
- l1 = m.createTypedLiteral(new Date(12345656l), XSDDatatype.XSDdateTime);
+ Literal l1 = m.createTypedLiteral(new Date(12345656l), XSDDatatype.XSDdateTime);
} catch (DatatypeFormatException e) {
ok = true;
} finally {
JenaParameters.enableEagerLiteralValidation = old;
}
assertTrue("Early detection of invalid literals", ok);
-
-
- // date
- l1 = m.createTypedLiteral("1999-05-31", XSDDatatype.XSDdate);
+ }
+
+ // date
+ public void testDateTime_10() {
+ Literal l1 = m.createTypedLiteral("1999-05-31", XSDDatatype.XSDdate);
assertEquals("dateTime data type", XSDDatatype.XSDdate, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 1999, xdt.getYears());
assertEquals("dateTime value", 5, xdt.getMonths());
assertEquals("dateTime value", 31, xdt.getDays());
@@ -711,12 +734,14 @@ public class TestTypedLiterals extends TestCase {
xdt.getHours();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
- // time
- l1 = m.createTypedLiteral("12:56:32", XSDDatatype.XSDtime);
+ }
+
+ // time
+ public void testDateTime_11() {
+ Literal l1 = m.createTypedLiteral("12:56:32", XSDDatatype.XSDtime);
assertEquals("dateTime data type", XSDDatatype.XSDtime, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 12, xdt.getHours());
assertEquals("dateTime value", 56, xdt.getMinutes());
assertEquals("dateTime value", 32, xdt.getFullSeconds());
@@ -724,12 +749,14 @@ public class TestTypedLiterals extends TestCase {
xdt.getDays();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
- // gYearMonth
- l1 = m.createTypedLiteral("1999-05", XSDDatatype.XSDgYearMonth);
+ }
+
+ // gYearMonth
+ public void testDateTime_12() {
+ Literal l1 = m.createTypedLiteral("1999-05", XSDDatatype.XSDgYearMonth);
assertEquals("dateTime data type", XSDDatatype.XSDgYearMonth, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 1999, xdt.getYears());
assertEquals("dateTime value", 5, xdt.getMonths());
try {
@@ -738,10 +765,13 @@ public class TestTypedLiterals extends TestCase {
} catch (IllegalDateTimeFieldException e) {}
// gYear
- l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear);
+ }
+
+ public void testDateTime_13() {
+ Literal l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear);
assertEquals("dateTime data type", XSDDatatype.XSDgYear, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 1999, xdt.getYears());
try {
xdt.getMonths();
@@ -749,21 +779,27 @@ public class TestTypedLiterals extends TestCase {
} catch (IllegalDateTimeFieldException e) {}
// gMonth
- l1 = m.createTypedLiteral("--05--", XSDDatatype.XSDgMonth);
+ }
+
+ public void testDateTime_14() {
+ Literal l1 = m.createTypedLiteral("--05--", XSDDatatype.XSDgMonth);
assertEquals("dateTime data type", XSDDatatype.XSDgMonth, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 5, xdt.getMonths());
try {
xdt.getYears();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
- // gMonthDay
- l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay);
+ }
+
+ // gMonthDay
+ public void testDateTime_15() {
+ Literal l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay);
assertEquals("dateTime data type", XSDDatatype.XSDgMonthDay, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 5, xdt.getMonths());
assertEquals("dateTime value", 25, xdt.getDays());
try {
@@ -771,41 +807,49 @@ public class TestTypedLiterals extends TestCase {
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
- // gDay
- l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay);
+ }
+
+ // gDay
+ public void testDateTime_16() {
+ Literal l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay);
assertEquals("dateTime data type", XSDDatatype.XSDgDay, l1.getDatatype());
assertEquals("dateTime java type", XSDDateTime.class, l1.getValue().getClass());
- xdt = (XSDDateTime)l1.getValue();
+ XSDDateTime xdt = (XSDDateTime)l1.getValue();
assertEquals("dateTime value", 25, xdt.getDays());
try {
xdt.getMonths();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
+ }
+
+ public void testDateTime_17() {
// Creation of datetime from a date object
Calendar ncal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
ncal.set(2003, 11, 8, 10, 50, 42);
ncal.set(Calendar.MILLISECOND, 0);
- l1 = m.createTypedLiteral(ncal);
+ Literal l1 = m.createTypedLiteral(ncal);
assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
assertEquals("DateTime from date", "2003-12-08T10:50:42Z", l1.getValue().toString());
- // Thanks to Greg Shueler for DST patch and test case
- //////some of below code from java.util.GregorianCalendar javadoc///////
- // create a Pacific Standard Time time zone
+ }
+
+ // Thanks to Greg Shueler for DST patch and test case
+ //////some of below code from java.util.GregorianCalendar javadoc///////
+ // create a Pacific Standard Time time zone
+ public void testDateTime_18() {
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "America/Los_Angeles");
// set up rules for daylight savings time
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
-
// create a GregorianCalendar with the Pacific Daylight time zone
- ncal = new GregorianCalendar(pdt);
+ Calendar ncal = new GregorianCalendar(pdt);
ncal.set(2004, 02, 21, 12, 50, 42);//before daylight savings time
ncal.set(Calendar.MILLISECOND, 0);
//System.err.println("cal is: "+ncal);
- l1 = m.createTypedLiteral(ncal);
+ Literal l1 = m.createTypedLiteral(ncal);
assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
assertEquals("DateTime from date", "2004-03-21T20:50:42Z", l1.getValue().toString());
@@ -822,16 +866,6 @@ public class TestTypedLiterals extends TestCase {
}
- // Internal helper
- private void doDateTimeTest(Calendar cal, String lex, double time) {
- Literal lc4 = m.createTypedLiteral(cal);
- assertEquals("serialization", lex, lc4.getValue().toString());
- assertEquals("calendar ms test", m.createTypedLiteral(lex, XSDDatatype.XSDdateTime), lc4 );
- XSDDateTime dt4 = (XSDDateTime)lc4.getValue();
- assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001);
- assertEquals(dt4.asCalendar(), cal);
- }
-
/**
* Test query applied to graphs containing typed values
*/