Skip to content
Permalink
Browse files

Leniently handle non-well-formed data and faithfully reproduce it on …

…output
  • Loading branch information...
cbeer committed Oct 27, 2014
1 parent 839b3cd commit 130f851688b3ef96c1f6424f0042c3fff5f0b31a
@@ -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>");
}
}
@@ -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))) {
@@ -90,6 +90,7 @@ public void test() throws IOException {
{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)},

0 comments on commit 130f851

Please sign in to comment.
You can’t perform that action at this time.