Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #568 from fcrepo4/ldp-constraints
Ldp constraints
- Loading branch information
Showing
13 changed files
with
183 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../test/java/org/fcrepo/http/commons/exceptionhandlers/MalformedRdfExceptionMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* 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.http.commons.exceptionhandlers; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.commons.io.IOUtils; | ||
import org.fcrepo.kernel.exception.MalformedRdfException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import javax.ws.rs.core.Link; | ||
import javax.ws.rs.core.Response; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.fcrepo.kernel.RdfLexicon.CONSTRAINED_BY; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author cabeer | ||
*/ | ||
public class MalformedRdfExceptionMapperTest { | ||
|
||
private MalformedRdfExceptionMapper testObj; | ||
|
||
@Before | ||
public void setUp() { | ||
testObj = new MalformedRdfExceptionMapper(); | ||
|
||
} | ||
@Test | ||
public void testToResponse() throws IOException { | ||
final Response response = testObj.toResponse(new MalformedRdfException("xyz")); | ||
|
||
final Link link = response.getLink(CONSTRAINED_BY.getURI()); | ||
assertEquals(CONSTRAINED_BY.getURI(), link.getRel()); | ||
assertEquals("data", link.getUri().getScheme()); | ||
final String[] split = link.getUri().toString().split(",", 2); | ||
assertEquals("Constraint data appears malformed", 2, split.length); | ||
assertEquals("xyz", IOUtils.toString(Base64.decodeBase64(split[1].getBytes()), "UTF-8")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.