001/* 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.migration.foxml; 017 018import java.io.InputStream; 019import java.util.List; 020 021import javax.xml.bind.JAXBException; 022 023import org.junit.Assert; 024import org.junit.Before; 025import org.junit.Test; 026/** 027 * 028 * @author mdurbin 029 * 030 */ 031public class DCTest { 032 033 private DC dcSample1; 034 035 @Before 036 public void setUp() throws JAXBException { 037 final InputStream dcInputStream = this.getClass().getClassLoader().getResourceAsStream("dc-sample1.xml"); 038 dcSample1 = DC.parseDC(dcInputStream); 039 } 040 041 @Test 042 public void testBasicDCParsing() throws JAXBException, IllegalAccessException { 043 Assert.assertEquals("Title 2", dcSample1.title[1]); 044 Assert.assertEquals("Title 1", dcSample1.title[0]); 045 Assert.assertEquals("Creator 2", dcSample1.creator[1]); 046 } 047 048 @Test 049 public void testHelperMethodContract() throws JAXBException, IllegalAccessException { 050 final List<String> uris = dcSample1.getRepresentedElementURIs(); 051 for (final String uri : uris) { 052 Assert.assertFalse(dcSample1.getValuesForURI(uri).isEmpty()); 053 } 054 } 055 056 057 058}