Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Leniently handle non-well-formed data and faithfully reproduce it on …
…output
  • Loading branch information
cbeer committed Oct 27, 2014
1 parent 839b3cd commit ae99659
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
@@ -0,0 +1,33 @@
/**
* Copyright 2014 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.integration.rdf;

import org.junit.Test;

import java.io.IOException;

/**
* @author cabeer
*/
public class MiscExamplesIT extends AbstractIntegrationRdfIT {


@Test
public void testSyntacticallyInvalidDate() throws IOException {
createLDPRSAndCheckResponse(getRandomUniquePid(), "<> <info:some/property> \"dunno\"^^<http://www.w3" +
".org/2001/XMLSchema#dateTime>");
}
}
Expand Up @@ -122,7 +122,13 @@ protected Value doBackward(final RDFNode resource) {

final Literal literal = resource.asLiteral();
final RDFDatatype dataType = literal.getDatatype();
final Object rdfValue = literal.getValue();
final Object rdfValue;

if (literal.asNode().getLiteral().isWellFormed()) {
rdfValue = literal.getValue();
} else {
rdfValue = literal.getLexicalForm();
}

if (dataType == null && rdfValue instanceof String
|| (dataType != null && dataType.equals(XSDDatatype.XSDstring))) {
Expand Down
Expand Up @@ -90,6 +90,7 @@ public static Iterable<Object[]> data() {
{ResourceFactory.createTypedLiteral(true)},
{ResourceFactory.createResource("info:x")},
{ResourceFactory.createTypedLiteral("2014-10-24T01:23:45Z", XSDDatatype.XSDdateTime)},
{ResourceFactory.createTypedLiteral("some-invalid-data", XSDDatatype.XSDdateTime)},
// Types outside the JCR type system boundaries:
{ResourceFactory.createTypedLiteral("2014-10-24", XSDDatatype.XSDdate)},
{ResourceFactory.createTypedLiteral("01:02:03", XSDDatatype.XSDtime)},
Expand Down

0 comments on commit ae99659

Please sign in to comment.