fixing imports for moves UriUitls
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 13 Sep 2011 11:13:55 +0000 (11:13 +0000)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 13 Sep 2011 11:13:55 +0000 (11:13 +0000)
cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/dto/assembler/lsid/AssemblerTest.java
cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/OaiPmhViewTest.java

index b01eacd7af054324d5d7489366924a9fec252fa4..bd5359cd11f064f905d72a628429d2c74351fb88 100644 (file)
@@ -74,375 +74,375 @@ import eu.etaxonomy.cdm.remote.dto.tdwg.voc.TaxonConcept;
 
 @SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")
 public class AssemblerTest extends UnitilsJUnit4 {
-       
-       public static final Logger logger = Logger.getLogger(AssemblerTest.class);
-       
-       @SpringBeanByType
-       private Mapper mapper;
-       
-       private Taxon taxon;
-       private IBook sec;
-       private IBook book;
-       private Reference bookSection;
-       private TeamOrPersonBase authorTeam;
-       private NonViralName name;
-       private LSID lsid;
-       private TaxonDescription taxonDescription;
-       ReferenceFactory refFactory = ReferenceFactory.newInstance();
-       
-       @BeforeClass
-       public static void onSetUp() {
-               DefaultTermInitializer defaultTermInitializer = new DefaultTermInitializer();
-               defaultTermInitializer.initialize();
-       }
-       
-       @Before
-       public void setUp() throws Exception {   
-           lsid = new LSID("urn:lsid:example.org:taxonconcepts:1");
-           
-           authorTeam = Person.NewInstance();
-           authorTeam.setTitleCache("authorTeam.titleCache", true);
-           authorTeam.setLsid(new LSID("urn:lsid:dagg.org:agents:2"));
-           
-           name = BotanicalName.NewInstance(null);
-           name.setNameCache("nameCache");
-           INomenclaturalReference nomenclaturalReference = refFactory.newArticle();
-           nomenclaturalReference.setTitleCache("nomenclaturalReference", true);
-           name.setNomenclaturalReference(nomenclaturalReference);
-           name.setNomenclaturalMicroReference("1");
-           name.setAuthorshipCache("authorshipCache");
-           name.setRank(Rank.SPECIES());
-           
-           sec = refFactory.newBook();
-           sec.setAuthorTeam(authorTeam);
-           sec.setTitleCache("sec.titleCache", true);
-           sec.setLsid(new LSID("urn:lsid:example.org:references:1"));
-           
-               taxon = Taxon.NewInstance(name, (Reference)sec);
-               taxon.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
-               taxon.setUpdated(new DateTime(2005, 12, 25, 12, 0, 0, 0));
-               taxon.setTitleCache("titleCache", true);
-               taxon.setLsid(lsid);
-
-               for(int i = 0; i < 10; i++) {
-                       Taxon child = Taxon.NewInstance(name, (Reference)sec);
-                       child.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:" + (2 + i )));
-                       taxon.addTaxonomicChild(child, null,null);
-               }
-
-               
-               taxonDescription = TaxonDescription.NewInstance();
-               taxon.addDescription(taxonDescription);
-               
-               TextData textData = TextData.NewInstance();
-               Language english = Language.NewInstance();
-               english.setIso639_1("en");
-               Language french = Language.NewInstance();
-               french.setIso639_1("fr");
-               textData.getMultilanguageText().put(english, LanguageString.NewInstance("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce justo leo, tempus ultricies bibendum eu, interdum sit amet ipsum. Suspendisse eu odio in sem iaculis euismod. Suspendisse sed metus ante, in sodales risus. In sit amet magna sit amet risus elementum dapibus. Nullam in magna at mauris placerat sagittis. Proin urna nisl, porta at venenatis in, tristique tempus nisl. Proin vel arcu blandit velit vestibulum blandit. In at diam libero, vel malesuada mauris. Duis a enim diam. Donec urna dui, dictum at suscipit vel, consectetur quis est. In venenatis bibendum diam nec laoreet. ", english));
-               textData.getMultilanguageText().put(french, LanguageString.NewInstance("Mauris elementum malesuada orci, non eleifend metus placerat ut. Aenean ornare felis sed lectus cursus id cursus nulla consectetur. Mauris magna justo, placerat id pretium posuere, ultrices et libero. Aliquam erat volutpat. Ut libero diam, interdum commodo fringilla sollicitudin, faucibus vel nisl. Fusce mattis justo interdum enim rhoncus eget sollicitudin dolor lobortis. Morbi mauris odio, tempus eget egestas eu, ornare vel ante. In quis placerat mi. Aliquam blandit tristique dictum. Donec pretium dui lacinia magna ornare eu venenatis ante dignissim. Integer ullamcorper tempus nisl et tincidunt. Curabitur vel nulla eu dolor faucibus porta. Mauris pulvinar est at est porta molestie. Nam varius nunc nec ipsum lacinia non egestas turpis congue. In at ipsum augue. Nulla mollis lobortis mauris ac sagittis. Nullam et facilisis lacus. Nam euismod sapien pellentesque lacus hendrerit dapibus. Aenean blandit rhoncus feugiat.", french));           
-               taxonDescription.addElement(textData);
-               
-               Distribution distribution = Distribution.NewInstance();
-               NamedArea namedArea = NamedArea.NewInstance("Africa", "Africa", "Africa");
-               namedArea.setTitleCache("Africa", true);
-               distribution.setArea(namedArea);
-               distribution.setStatus(PresenceTerm.NATIVE());
-               
-               taxonDescription.addElement(distribution);
-               
-               // ------------------------------------------------------
-               
-               book = refFactory.newBook();
-               book.setTitle("Book.title");
-               book.setAuthorTeam(authorTeam);
-               book.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
-               book.setDatePublished(new TimePeriod(new Partial(DateTimeFieldType.year(), 1800)));
-               book.setEdition("1st Edition");
-               book.setEditor("Editor");
-               book.setIsbn("isbn");
-               book.setPlacePublished("placePublished");
-               book.setPublisher("publisher");
-               book.setReferenceAbstract("referenceAbstract");
-               book.setUri(new URI("http://persitent.books.foo/myBook"));
-               book.setUuid(UUID.randomUUID());
-               book.setVolume("Volume 1");
-               book.addSource(IdentifiableSource.NewInstance("http://persitent.IdentifiableSources.foo/1"));
-               
-               bookSection = refFactory.newBookSection();
-               bookSection.setInReference((Reference)book);
-               bookSection.setPages("999 ff.");
-               bookSection.setTitle("BookSection.title");
-               bookSection.setAuthorTeam(authorTeam);
-               bookSection.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
-               bookSection.setDatePublished(new TimePeriod(new Partial(DateTimeFieldType.year(), 1800)));
-               bookSection.setReferenceAbstract("referenceAbstract");
-               bookSection.setUri(new URI("http://persitent.books.foo/myBookSection"));
-               bookSection.setUuid(UUID.randomUUID());
-               bookSection.addCredit(Credit.NewInstance(authorTeam, "Credits to the authorTeam"));
-               bookSection.addSource(IdentifiableSource.NewInstance("http://persitent.IdentifiableSources.foo/2"));
-       }
-       
-       @Test
-       public void testDeepMapping() {
-               for(int i = 0; i < 3; i++) {
-                       Synonym synonym = Synonym.NewInstance(name,(Reference)sec);
-                       taxon.addSynonym(synonym,new SynonymRelationshipType());
-               }
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
-               
-               assertNotNull("map() should return an object", taxonConcept);
-               assertTrue("map() should return a TaxonConcept",taxonConcept instanceof TaxonConcept);
-
-               assertEquals("IdentifiableEntity.titleCache should be copied into BaseThing.title",taxon.getTitleCache(),taxonConcept.getTitle());
-               assertEquals("IdentifiableEntity.lsid should be copied into BaseThing.identifier",taxon.getLsid().toString(),taxonConcept.getIdentifier().toString());
-               assertEquals("BaseThing.sameAs should refer to the proxy version of the lsid","http://lsid.example.org/" + taxon.getLsid().toString(),taxonConcept.getSameAs());
-               assertEquals("CdmBase.created should be copied into BaseThing.created",new DateTime(2004, 12, 25, 12, 0, 0, 0),taxonConcept.getCreated());
-               assertNotNull("TaxonBase.sec should be mapped into BaseThing.publishedInCitation",taxonConcept.getPublishedInCitation());
-               assertEquals("TaxonBase.sec.titleCache should be mapped into BaseThing.publishedInCitation.title",sec.getTitleCache(),taxonConcept.getPublishedInCitation().getTitle());
-               assertNotNull("TaxonBase.sec.authorTeam should be mapped into TaxonConcept.accordingTo",taxonConcept.getAccordingTo());
-               assertEquals("TaxonBase.sec.authorTeam.titleCache should be mapped into TaxonConcept.accordingTo.title",authorTeam.getTitleCache(),taxonConcept.getAccordingTo().getTitle());
-               assertNotNull("TaxonBase.name should be mapped to TaxonConcept.hasName",taxonConcept.getHasName());
-               assertEquals("NonViralName.nameCache should be mapped to TaxonName.nameComplete",name.getNameCache(),taxonConcept.getHasName().getNameComplete());
-               assertNotNull("Taxon.relationsToThisTaxon should be copied into TaxonConcept.hasRelationship",taxonConcept.getHasRelationship());
-               assertEquals("There should be 13 relations in TaxonConcept.hasRelationship",13,taxonConcept.getHasRelationship().size());
-       }
-       
-       @Test
-       public void testLazyInitializationExceptionWithProxy() throws Exception {
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               IBook proxy = getUninitializedDetachedProxy(Reference.class,(Reference)sec);
-               assert !Hibernate.isInitialized(proxy);
-               Field secField = TaxonBase.class.getDeclaredField("sec");
-               secField.setAccessible(true);
-               secField.set(taxon, proxy);
-               
-               TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
-               assertNull("TaxonBase.sec was uninitialized, so TaxonConcept.publishedInCitation should be null",taxonConcept.getPublishedInCitation());
-               assertNull("TaxonBase.sec was uninitialized, so TaxonConcept.accordingTo should be null",taxonConcept.getAccordingTo());
-       }
-       
-       @Test 
-       public void testLazyInitializationExceptionWithPersistentCollection() throws Exception {
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               Set<TaxonRelationship> proxy = (Set<TaxonRelationship>)getUninitializedPersistentCollection(HashSet.class,(HashSet<TaxonRelationship>)taxon.getRelationsToThisTaxon());
-               assert !Hibernate.isInitialized(proxy);
-               Field relationsToThisTaxonField = Taxon.class.getDeclaredField("relationsToThisTaxon");
-               relationsToThisTaxonField.setAccessible(true);
-               relationsToThisTaxonField.set(taxon, proxy);
-               
-               TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
-               assertTrue("TaxonBase.relationsToThisTaxon was uninitialized, so TaxonConcept.hasRelationship should be null",taxonConcept.getHasRelationship().isEmpty());
-       }
-       
-       @Test
-       public void testSpeciesProfileModelMapping() {
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               SpeciesProfileModel speciesProfileModel = (SpeciesProfileModel)mapper.map(taxonDescription, SpeciesProfileModel.class);
-               assertEquals(speciesProfileModel.getHasInformation().size(),2);
-       }
-       
-       @Test
-       public void testSimpleDarwinCoreMapping() {
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               SimpleDarwinRecord simpleDarwinRecord = mapper.map(taxon, SimpleDarwinRecord.class);
-               mapper.map((NonViralName)taxon.getName(), simpleDarwinRecord);
-               
-               assertNotNull(simpleDarwinRecord.getModified());
-               assertEquals(taxon.getName().getTitleCache(), simpleDarwinRecord.getScientificName());
-               assertEquals(((NonViralName)taxon.getName()).getAuthorshipCache(), simpleDarwinRecord.getScientificNameAuthorship());
-               assertEquals(((NonViralName)taxon.getName()).getCitationString(), simpleDarwinRecord.getNamePublishedIn());
-               assertEquals(Rank.SPECIES().getLabel(), simpleDarwinRecord.getTaxonRank());
-       }
-       
-       @Test
-       public void testOAIDublinCoreMapping() {
-               
-               if(!UriUtils.isInternetAvailable(null)){
-                       // dozer requires access to dozer.sourceforge.net
-                       logger.info("Internet is not available: Skipping test");
-                       return;
-               }
-               
-               OaiDc oaiDcRecordBook = mapper.map(book, OaiDc.class);
-               
-               assertEquals(book.getTitle(), book.getTitle());
-               
-               OaiDc oaiDcRecordBookSection = mapper.map(bookSection, OaiDc.class);
-               assertNotNull(oaiDcRecordBookSection.getRelation());
-       }
-       
-       private <T extends Collection> T getUninitializedPersistentCollection(final Class<T> clazz,final T wrappedCollection) {
-               final Enhancer enhancer = new Enhancer();
-               List<Class> interfaces = new ArrayList<Class>();
-               interfaces.addAll(Arrays.asList(clazz.getInterfaces()));
-               interfaces.add(PersistentCollection.class);
-               enhancer.setSuperclass(clazz);
-               enhancer.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
-               enhancer.setCallback( new MethodInterceptor() {
-                       public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
-                               if("wasInitialized".equals(method.getName())) {
-                                 return false;
-                               } else if(clazz.getDeclaredConstructor().equals(method)){
-                                        return proxy.invoke(obj, args);
-                               } else if("finalize".equals(method.getName())){
-                                        return proxy.invoke(obj, args);
-                               } else if("toString".equals(method.getName())) {
-                                       return wrappedCollection.toString();
-                               } else if("getClass".equals(method.getName())) {
-                                       return proxy.invoke(obj, args);
-                               } else if("hashCode".equals(method.getName())) {
-                                       return wrappedCollection.hashCode();
-                               }else if("initListener".equals(method.getName())) {
-                                       return null;
-                               } else {
-
-                                       throw new LazyInitializationException(null);
-                               }
-                               
-                       }
-               });
-               
-               T proxy = (T)enhancer.create();
-               return proxy;
-       }
-       
-       private <T> T getUninitializedDetachedProxy(final Class<T> clazz,final T wrappedClass) {
-               final Enhancer enhancer = new Enhancer();
-               List<Class> interfaces = new ArrayList<Class>();
-               interfaces.addAll(Arrays.asList(clazz.getInterfaces()));
-               interfaces.add(HibernateProxy.class);
-               enhancer.setSuperclass(clazz);
-               enhancer.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
-               enhancer.setCallback( new MethodInterceptor() {
-                       public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
-                               if("getHibernateLazyInitializer".equals(method.getName())) {
-                                 return new UninitializedLazyInitializer();
-                               } else if(clazz.getDeclaredConstructor().equals(method)){
-                                        return proxy.invoke(obj, args);
-                               } else if("finalize".equals(method.getName())){
-                                        return proxy.invoke(obj, args);
-                               } else if("toString".equals(method.getName())) {
-                                       return wrappedClass.toString();
-                               } else if("getClass".equals(method.getName())) {
-                                       return proxy.invoke(obj, args);
-                               } else if("hashCode".equals(method.getName())) {
-                                       return wrappedClass.hashCode();
-                               } else if("initListener".equals(method.getName())) {
-                                       return null;
-                               } else {
-                                       throw new LazyInitializationException(null);
-                               }
-                               
-                       }
-               });
-               
-               T proxy = (T)enhancer.create();
-               return proxy;
-       }
-       
-       class UninitializedLazyInitializer implements LazyInitializer {
-
-               public  boolean isUninitialized() {
-                       return true;
-               }
-
-               public String getEntityName() {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public Serializable getIdentifier() {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public Object getImplementation() {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public Object getImplementation(SessionImplementor arg0)
-                               throws HibernateException {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public Class getPersistentClass() {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public SessionImplementor getSession() {
-                       // TODO Auto-generated method stub
-                       return null;
-               }
-
-               public void initialize() throws HibernateException {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               public boolean isUnwrap() {
-                       // TODO Auto-generated method stub
-                       return false;
-               }
-
-               public void setIdentifier(Serializable arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               public void setImplementation(Object arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               public void setSession(SessionImplementor arg0)
-                               throws HibernateException {
-                       // TODO Auto-generated method stub
-                       
-               }
-
-               public void setUnwrap(boolean arg0) {
-                       // TODO Auto-generated method stub
-                       
-               }
-               
-       }
-       
-       
-       
+
+    public static final Logger logger = Logger.getLogger(AssemblerTest.class);
+
+    @SpringBeanByType
+    private Mapper mapper;
+
+    private Taxon taxon;
+    private IBook sec;
+    private IBook book;
+    private Reference bookSection;
+    private TeamOrPersonBase authorTeam;
+    private NonViralName name;
+    private LSID lsid;
+    private TaxonDescription taxonDescription;
+    ReferenceFactory refFactory = ReferenceFactory.newInstance();
+
+    @BeforeClass
+    public static void onSetUp() {
+        DefaultTermInitializer defaultTermInitializer = new DefaultTermInitializer();
+        defaultTermInitializer.initialize();
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        lsid = new LSID("urn:lsid:example.org:taxonconcepts:1");
+
+        authorTeam = Person.NewInstance();
+        authorTeam.setTitleCache("authorTeam.titleCache", true);
+        authorTeam.setLsid(new LSID("urn:lsid:dagg.org:agents:2"));
+
+        name = BotanicalName.NewInstance(null);
+        name.setNameCache("nameCache");
+        INomenclaturalReference nomenclaturalReference = refFactory.newArticle();
+        nomenclaturalReference.setTitleCache("nomenclaturalReference", true);
+        name.setNomenclaturalReference(nomenclaturalReference);
+        name.setNomenclaturalMicroReference("1");
+        name.setAuthorshipCache("authorshipCache");
+        name.setRank(Rank.SPECIES());
+
+        sec = refFactory.newBook();
+        sec.setAuthorTeam(authorTeam);
+        sec.setTitleCache("sec.titleCache", true);
+        sec.setLsid(new LSID("urn:lsid:example.org:references:1"));
+
+        taxon = Taxon.NewInstance(name, (Reference)sec);
+        taxon.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
+        taxon.setUpdated(new DateTime(2005, 12, 25, 12, 0, 0, 0));
+        taxon.setTitleCache("titleCache", true);
+        taxon.setLsid(lsid);
+
+        for(int i = 0; i < 10; i++) {
+            Taxon child = Taxon.NewInstance(name, (Reference)sec);
+            child.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:" + (2 + i )));
+            taxon.addTaxonomicChild(child, null,null);
+        }
+
+
+        taxonDescription = TaxonDescription.NewInstance();
+        taxon.addDescription(taxonDescription);
+
+        TextData textData = TextData.NewInstance();
+        Language english = Language.NewInstance();
+        english.setIso639_1("en");
+        Language french = Language.NewInstance();
+        french.setIso639_1("fr");
+        textData.getMultilanguageText().put(english, LanguageString.NewInstance("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce justo leo, tempus ultricies bibendum eu, interdum sit amet ipsum. Suspendisse eu odio in sem iaculis euismod. Suspendisse sed metus ante, in sodales risus. In sit amet magna sit amet risus elementum dapibus. Nullam in magna at mauris placerat sagittis. Proin urna nisl, porta at venenatis in, tristique tempus nisl. Proin vel arcu blandit velit vestibulum blandit. In at diam libero, vel malesuada mauris. Duis a enim diam. Donec urna dui, dictum at suscipit vel, consectetur quis est. In venenatis bibendum diam nec laoreet. ", english));
+        textData.getMultilanguageText().put(french, LanguageString.NewInstance("Mauris elementum malesuada orci, non eleifend metus placerat ut. Aenean ornare felis sed lectus cursus id cursus nulla consectetur. Mauris magna justo, placerat id pretium posuere, ultrices et libero. Aliquam erat volutpat. Ut libero diam, interdum commodo fringilla sollicitudin, faucibus vel nisl. Fusce mattis justo interdum enim rhoncus eget sollicitudin dolor lobortis. Morbi mauris odio, tempus eget egestas eu, ornare vel ante. In quis placerat mi. Aliquam blandit tristique dictum. Donec pretium dui lacinia magna ornare eu venenatis ante dignissim. Integer ullamcorper tempus nisl et tincidunt. Curabitur vel nulla eu dolor faucibus porta. Mauris pulvinar est at est porta molestie. Nam varius nunc nec ipsum lacinia non egestas turpis congue. In at ipsum augue. Nulla mollis lobortis mauris ac sagittis. Nullam et facilisis lacus. Nam euismod sapien pellentesque lacus hendrerit dapibus. Aenean blandit rhoncus feugiat.", french));
+        taxonDescription.addElement(textData);
+
+        Distribution distribution = Distribution.NewInstance();
+        NamedArea namedArea = NamedArea.NewInstance("Africa", "Africa", "Africa");
+        namedArea.setTitleCache("Africa", true);
+        distribution.setArea(namedArea);
+        distribution.setStatus(PresenceTerm.NATIVE());
+
+        taxonDescription.addElement(distribution);
+
+        // ------------------------------------------------------
+
+        book = refFactory.newBook();
+        book.setTitle("Book.title");
+        book.setAuthorTeam(authorTeam);
+        book.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
+        book.setDatePublished(new TimePeriod(new Partial(DateTimeFieldType.year(), 1800)));
+        book.setEdition("1st Edition");
+        book.setEditor("Editor");
+        book.setIsbn("isbn");
+        book.setPlacePublished("placePublished");
+        book.setPublisher("publisher");
+        book.setReferenceAbstract("referenceAbstract");
+        book.setUri(new URI("http://persitent.books.foo/myBook"));
+        book.setUuid(UUID.randomUUID());
+        book.setVolume("Volume 1");
+        book.addSource(IdentifiableSource.NewInstance("http://persitent.IdentifiableSources.foo/1"));
+
+        bookSection = refFactory.newBookSection();
+        bookSection.setInReference((Reference)book);
+        bookSection.setPages("999 ff.");
+        bookSection.setTitle("BookSection.title");
+        bookSection.setAuthorTeam(authorTeam);
+        bookSection.setCreated(new DateTime(2004, 12, 25, 12, 0, 0, 0));
+        bookSection.setDatePublished(new TimePeriod(new Partial(DateTimeFieldType.year(), 1800)));
+        bookSection.setReferenceAbstract("referenceAbstract");
+        bookSection.setUri(new URI("http://persitent.books.foo/myBookSection"));
+        bookSection.setUuid(UUID.randomUUID());
+        bookSection.addCredit(Credit.NewInstance(authorTeam, "Credits to the authorTeam"));
+        bookSection.addSource(IdentifiableSource.NewInstance("http://persitent.IdentifiableSources.foo/2"));
+    }
+
+    @Test
+    public void testDeepMapping() {
+        for(int i = 0; i < 3; i++) {
+            Synonym synonym = Synonym.NewInstance(name,(Reference)sec);
+            taxon.addSynonym(synonym,new SynonymRelationshipType());
+        }
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
+
+        assertNotNull("map() should return an object", taxonConcept);
+        assertTrue("map() should return a TaxonConcept",taxonConcept instanceof TaxonConcept);
+
+        assertEquals("IdentifiableEntity.titleCache should be copied into BaseThing.title",taxon.getTitleCache(),taxonConcept.getTitle());
+        assertEquals("IdentifiableEntity.lsid should be copied into BaseThing.identifier",taxon.getLsid().toString(),taxonConcept.getIdentifier().toString());
+        assertEquals("BaseThing.sameAs should refer to the proxy version of the lsid","http://lsid.example.org/" + taxon.getLsid().toString(),taxonConcept.getSameAs());
+        assertEquals("CdmBase.created should be copied into BaseThing.created",new DateTime(2004, 12, 25, 12, 0, 0, 0),taxonConcept.getCreated());
+        assertNotNull("TaxonBase.sec should be mapped into BaseThing.publishedInCitation",taxonConcept.getPublishedInCitation());
+        assertEquals("TaxonBase.sec.titleCache should be mapped into BaseThing.publishedInCitation.title",sec.getTitleCache(),taxonConcept.getPublishedInCitation().getTitle());
+        assertNotNull("TaxonBase.sec.authorTeam should be mapped into TaxonConcept.accordingTo",taxonConcept.getAccordingTo());
+        assertEquals("TaxonBase.sec.authorTeam.titleCache should be mapped into TaxonConcept.accordingTo.title",authorTeam.getTitleCache(),taxonConcept.getAccordingTo().getTitle());
+        assertNotNull("TaxonBase.name should be mapped to TaxonConcept.hasName",taxonConcept.getHasName());
+        assertEquals("NonViralName.nameCache should be mapped to TaxonName.nameComplete",name.getNameCache(),taxonConcept.getHasName().getNameComplete());
+        assertNotNull("Taxon.relationsToThisTaxon should be copied into TaxonConcept.hasRelationship",taxonConcept.getHasRelationship());
+        assertEquals("There should be 13 relations in TaxonConcept.hasRelationship",13,taxonConcept.getHasRelationship().size());
+    }
+
+    @Test
+    public void testLazyInitializationExceptionWithProxy() throws Exception {
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        IBook proxy = getUninitializedDetachedProxy(Reference.class,(Reference)sec);
+        assert !Hibernate.isInitialized(proxy);
+        Field secField = TaxonBase.class.getDeclaredField("sec");
+        secField.setAccessible(true);
+        secField.set(taxon, proxy);
+
+        TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
+        assertNull("TaxonBase.sec was uninitialized, so TaxonConcept.publishedInCitation should be null",taxonConcept.getPublishedInCitation());
+        assertNull("TaxonBase.sec was uninitialized, so TaxonConcept.accordingTo should be null",taxonConcept.getAccordingTo());
+    }
+
+    @Test
+    public void testLazyInitializationExceptionWithPersistentCollection() throws Exception {
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        Set<TaxonRelationship> proxy = (Set<TaxonRelationship>)getUninitializedPersistentCollection(HashSet.class,(HashSet<TaxonRelationship>)taxon.getRelationsToThisTaxon());
+        assert !Hibernate.isInitialized(proxy);
+        Field relationsToThisTaxonField = Taxon.class.getDeclaredField("relationsToThisTaxon");
+        relationsToThisTaxonField.setAccessible(true);
+        relationsToThisTaxonField.set(taxon, proxy);
+
+        TaxonConcept taxonConcept = (TaxonConcept)mapper.map(taxon, TaxonConcept.class);
+        assertTrue("TaxonBase.relationsToThisTaxon was uninitialized, so TaxonConcept.hasRelationship should be null",taxonConcept.getHasRelationship().isEmpty());
+    }
+
+    @Test
+    public void testSpeciesProfileModelMapping() {
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        SpeciesProfileModel speciesProfileModel = (SpeciesProfileModel)mapper.map(taxonDescription, SpeciesProfileModel.class);
+        assertEquals(speciesProfileModel.getHasInformation().size(),2);
+    }
+
+    @Test
+    public void testSimpleDarwinCoreMapping() {
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        SimpleDarwinRecord simpleDarwinRecord = mapper.map(taxon, SimpleDarwinRecord.class);
+        mapper.map((NonViralName)taxon.getName(), simpleDarwinRecord);
+
+        assertNotNull(simpleDarwinRecord.getModified());
+        assertEquals(taxon.getName().getTitleCache(), simpleDarwinRecord.getScientificName());
+        assertEquals(((NonViralName)taxon.getName()).getAuthorshipCache(), simpleDarwinRecord.getScientificNameAuthorship());
+        assertEquals(((NonViralName)taxon.getName()).getCitationString(), simpleDarwinRecord.getNamePublishedIn());
+        assertEquals(Rank.SPECIES().getLabel(), simpleDarwinRecord.getTaxonRank());
+    }
+
+    @Test
+    public void testOAIDublinCoreMapping() {
+
+        if(!UriUtils.isInternetAvailable(null)){
+            // dozer requires access to dozer.sourceforge.net
+            logger.info("Internet is not available: Skipping test");
+            return;
+        }
+
+        OaiDc oaiDcRecordBook = mapper.map(book, OaiDc.class);
+
+        assertEquals(book.getTitle(), book.getTitle());
+
+        OaiDc oaiDcRecordBookSection = mapper.map(bookSection, OaiDc.class);
+        assertNotNull(oaiDcRecordBookSection.getRelation());
+    }
+
+    private <T extends Collection> T getUninitializedPersistentCollection(final Class<T> clazz,final T wrappedCollection) {
+        final Enhancer enhancer = new Enhancer();
+        List<Class> interfaces = new ArrayList<Class>();
+        interfaces.addAll(Arrays.asList(clazz.getInterfaces()));
+        interfaces.add(PersistentCollection.class);
+        enhancer.setSuperclass(clazz);
+        enhancer.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
+        enhancer.setCallback( new MethodInterceptor() {
+            public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
+                if("wasInitialized".equals(method.getName())) {
+                  return false;
+                } else if(clazz.getDeclaredConstructor().equals(method)){
+                     return proxy.invoke(obj, args);
+                } else if("finalize".equals(method.getName())){
+                     return proxy.invoke(obj, args);
+                } else if("toString".equals(method.getName())) {
+                    return wrappedCollection.toString();
+                } else if("getClass".equals(method.getName())) {
+                    return proxy.invoke(obj, args);
+                } else if("hashCode".equals(method.getName())) {
+                    return wrappedCollection.hashCode();
+                }else if("initListener".equals(method.getName())) {
+                    return null;
+                } else {
+
+                    throw new LazyInitializationException(null);
+                }
+
+            }
+        });
+
+        T proxy = (T)enhancer.create();
+        return proxy;
+    }
+
+    private <T> T getUninitializedDetachedProxy(final Class<T> clazz,final T wrappedClass) {
+        final Enhancer enhancer = new Enhancer();
+        List<Class> interfaces = new ArrayList<Class>();
+        interfaces.addAll(Arrays.asList(clazz.getInterfaces()));
+        interfaces.add(HibernateProxy.class);
+        enhancer.setSuperclass(clazz);
+        enhancer.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
+        enhancer.setCallback( new MethodInterceptor() {
+            public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
+                if("getHibernateLazyInitializer".equals(method.getName())) {
+                  return new UninitializedLazyInitializer();
+                } else if(clazz.getDeclaredConstructor().equals(method)){
+                     return proxy.invoke(obj, args);
+                } else if("finalize".equals(method.getName())){
+                     return proxy.invoke(obj, args);
+                } else if("toString".equals(method.getName())) {
+                    return wrappedClass.toString();
+                } else if("getClass".equals(method.getName())) {
+                    return proxy.invoke(obj, args);
+                } else if("hashCode".equals(method.getName())) {
+                    return wrappedClass.hashCode();
+                } else if("initListener".equals(method.getName())) {
+                    return null;
+                } else {
+                    throw new LazyInitializationException(null);
+                }
+
+            }
+        });
+
+        T proxy = (T)enhancer.create();
+        return proxy;
+    }
+
+    class UninitializedLazyInitializer implements LazyInitializer {
+
+        public  boolean isUninitialized() {
+            return true;
+        }
+
+        public String getEntityName() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Serializable getIdentifier() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object getImplementation() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Object getImplementation(SessionImplementor arg0)
+                throws HibernateException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Class getPersistentClass() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public SessionImplementor getSession() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void initialize() throws HibernateException {
+            // TODO Auto-generated method stub
+
+        }
+
+        public boolean isUnwrap() {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        public void setIdentifier(Serializable arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        public void setImplementation(Object arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+        public void setSession(SessionImplementor arg0)
+                throws HibernateException {
+            // TODO Auto-generated method stub
+
+        }
+
+        public void setUnwrap(boolean arg0) {
+            // TODO Auto-generated method stub
+
+        }
+
+    }
+
+
+
 
 }
index 9a41bad7236f15cdd84ed2a95920391f9d28000c..46c614fba018c2937bd2143fc4a1f18f95ea3e24 100644 (file)
@@ -48,15 +48,15 @@ import eu.etaxonomy.cdm.remote.view.oaipmh.ListSetsView;
 \r
 @SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")\r
 public class OaiPmhViewTest extends UnitilsJUnit4 {\r
-       \r
-       public static final Logger logger = Logger.getLogger(OaiPmhViewTest.class);\r
-       \r
-       @SpringBeanByType\r
-       private Marshaller marshaller;\r
-       \r
-       @SpringBeanByType\r
-       private Mapper mapper;\r
-       \r
+\r
+    public static final Logger logger = Logger.getLogger(OaiPmhViewTest.class);\r
+\r
+    @SpringBeanByType\r
+    private Marshaller marshaller;\r
+\r
+    @SpringBeanByType\r
+    private Mapper mapper;\r
+\r
     private Map<String,Object> model;\r
     private IdentifyView identifyView;\r
     private GetRecordView getRecordView;\r
@@ -66,229 +66,229 @@ public class OaiPmhViewTest extends UnitilsJUnit4 {
     private ListRecordsView listRecordsView;\r
     private MockHttpServletRequest request;\r
     private MockHttpServletResponse response;\r
-    \r
+\r
     private eu.etaxonomy.cdm.remote.view.oaipmh.rdf.GetRecordView rdfGetRecordView;\r
 \r
-       private URI serverURI;\r
-       \r
-       @Before\r
-       public void setUp() throws Exception {\r
-               XMLUnit.setControlParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");\r
-           XMLUnit.setTestParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");\r
-           XMLUnit.setSAXParserFactory("org.apache.xerces.jaxp.SAXParserFactoryImpl");\r
-           XMLUnit.setIgnoreWhitespace(true);\r
-           \r
-               model = new HashMap<String,Object>();\r
-               identifyView = new IdentifyView();\r
-               identifyView.setMarshaller(marshaller);\r
-               \r
-               getRecordView = new GetRecordView();\r
-               getRecordView.setMarshaller(marshaller);\r
-               getRecordView.setMapper(mapper);\r
-               \r
-               rdfGetRecordView = new eu.etaxonomy.cdm.remote.view.oaipmh.rdf.GetRecordView();\r
-               rdfGetRecordView.setMarshaller(marshaller);\r
-               rdfGetRecordView.setMapper(mapper);\r
-               \r
-               listMetadataFormatsView = new ListMetadataFormatsView();\r
-               listMetadataFormatsView.setMarshaller(marshaller);\r
-               \r
-               listSetsView = new ListSetsView();\r
-               listSetsView.setMarshaller(marshaller);\r
-               \r
-               listIdentifiersView = new ListIdentifiersView();\r
-               listIdentifiersView.setMarshaller(marshaller);\r
-               listIdentifiersView.setMapper(mapper);\r
-               \r
-               listRecordsView = new ListRecordsView();\r
-               listRecordsView.setMarshaller(marshaller);\r
-               listRecordsView.setMapper(mapper);\r
-               \r
-               request = new MockHttpServletRequest();\r
-               \r
-               serverURI = new URI("http://memory.loc.gov");\r
-               \r
-               request.setServerName(serverURI.toString());\r
-               request.setServerPort(80);\r
-               response = new MockHttpServletResponse();\r
-       }\r
-       \r
-       @Test\r
-       public void testIdentifyView() throws Exception {       \r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               model.put("repositoryName", "Library of Congress Open Archive Initiative Repository 1");\r
-               model.put("baseURL","http://memory.loc.gov/cgi-bin/oai");\r
-               model.put("protocolVersion","2.0");\r
-               model.put("deletedRecord",DeletedRecord.TRANSIENT);\r
-               model.put("granularity",Granularity.YYYY_MM_DD_THH_MM_SS_Z);\r
-               \r
-               model.put("earliestDatestamp",ISODateTimeFormat.dateTimeParser().parseDateTime("1990-02-01T12:00:00Z"));\r
-               model.put("adminEmail","somebody@loc.gov");\r
-               model.put("description","<oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier  http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\"><scheme>oai</scheme><repositoryIdentifier>lcoa1.loc.gov</repositoryIdentifier><delimiter>:</delimiter><sampleIdentifier>oai:lcoa1.loc.gov:loc.music/musdi.002</sampleIdentifier></oai-identifier>");\r
-\r
-               \r
-               request.setRequestURI("/cgi-bin/oai?verb=Identify");\r
-               \r
-               identifyView.render(model, request, response);\r
-//             String resource = "/eu/etaxonomy/cdm/remote/view/oaipmh/IdentifyView.xml";      \r
+    private URI serverURI;\r
+\r
+    @Before\r
+    public void setUp() throws Exception {\r
+        XMLUnit.setControlParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");\r
+        XMLUnit.setTestParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");\r
+        XMLUnit.setSAXParserFactory("org.apache.xerces.jaxp.SAXParserFactoryImpl");\r
+        XMLUnit.setIgnoreWhitespace(true);\r
+\r
+        model = new HashMap<String,Object>();\r
+        identifyView = new IdentifyView();\r
+        identifyView.setMarshaller(marshaller);\r
+\r
+        getRecordView = new GetRecordView();\r
+        getRecordView.setMarshaller(marshaller);\r
+        getRecordView.setMapper(mapper);\r
+\r
+        rdfGetRecordView = new eu.etaxonomy.cdm.remote.view.oaipmh.rdf.GetRecordView();\r
+        rdfGetRecordView.setMarshaller(marshaller);\r
+        rdfGetRecordView.setMapper(mapper);\r
+\r
+        listMetadataFormatsView = new ListMetadataFormatsView();\r
+        listMetadataFormatsView.setMarshaller(marshaller);\r
+\r
+        listSetsView = new ListSetsView();\r
+        listSetsView.setMarshaller(marshaller);\r
+\r
+        listIdentifiersView = new ListIdentifiersView();\r
+        listIdentifiersView.setMarshaller(marshaller);\r
+        listIdentifiersView.setMapper(mapper);\r
+\r
+        listRecordsView = new ListRecordsView();\r
+        listRecordsView.setMarshaller(marshaller);\r
+        listRecordsView.setMapper(mapper);\r
+\r
+        request = new MockHttpServletRequest();\r
+\r
+        serverURI = new URI("http://memory.loc.gov");\r
+\r
+        request.setServerName(serverURI.toString());\r
+        request.setServerPort(80);\r
+        response = new MockHttpServletResponse();\r
+    }\r
+\r
+    @Test\r
+    public void testIdentifyView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        model.put("repositoryName", "Library of Congress Open Archive Initiative Repository 1");\r
+        model.put("baseURL","http://memory.loc.gov/cgi-bin/oai");\r
+        model.put("protocolVersion","2.0");\r
+        model.put("deletedRecord",DeletedRecord.TRANSIENT);\r
+        model.put("granularity",Granularity.YYYY_MM_DD_THH_MM_SS_Z);\r
+\r
+        model.put("earliestDatestamp",ISODateTimeFormat.dateTimeParser().parseDateTime("1990-02-01T12:00:00Z"));\r
+        model.put("adminEmail","somebody@loc.gov");\r
+        model.put("description","<oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier  http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\"><scheme>oai</scheme><repositoryIdentifier>lcoa1.loc.gov</repositoryIdentifier><delimiter>:</delimiter><sampleIdentifier>oai:lcoa1.loc.gov:loc.music/musdi.002</sampleIdentifier></oai-identifier>");\r
+\r
+\r
+        request.setRequestURI("/cgi-bin/oai?verb=Identify");\r
+\r
+        identifyView.render(model, request, response);\r
+//             String resource = "/eu/etaxonomy/cdm/remote/view/oaipmh/IdentifyView.xml";\r
 //             System.out.println(new String(response.getContentAsByteArray()));\r
 //             XMLAssert.assertXMLEqual(new InputStreamReader(this.getClass().getResourceAsStream(resource)),new StringReader(new String(response.getContentAsByteArray())));\r
-       }\r
-       \r
-       @Test\r
-       public void testGetRecordView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               Taxon taxon = Taxon.NewInstance(null, null);\r
-               taxon.setTitleCache("TitleCache", true);\r
-               taxon.setCreated(new DateTime());\r
-               taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:1"));\r
-               \r
-               AuditEventRecord<Taxon> auditEventRecord = new AuditEventRecordImpl<Taxon>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
-               \r
-               model.put("object", auditEventRecord);\r
-               \r
-               request.setRequestURI("/cgi-bin/oai?verb=GetRecord&identifier=urn:lsid:example.org:taxonconcepts:1&metadataPrefix=oai_dc");\r
-               getRecordView.render(model, request, response);\r
+    }\r
+\r
+    @Test\r
+    public void testGetRecordView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        Taxon taxon = Taxon.NewInstance(null, null);\r
+        taxon.setTitleCache("TitleCache", true);\r
+        taxon.setCreated(new DateTime());\r
+        taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:1"));\r
+\r
+        AuditEventRecord<Taxon> auditEventRecord = new AuditEventRecordImpl<Taxon>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
+\r
+        model.put("object", auditEventRecord);\r
+\r
+        request.setRequestURI("/cgi-bin/oai?verb=GetRecord&identifier=urn:lsid:example.org:taxonconcepts:1&metadataPrefix=oai_dc");\r
+        getRecordView.render(model, request, response);\r
 //             System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-       \r
-       @Test\r
-       public void testRdfGetRecordView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               Taxon taxon = Taxon.NewInstance(null, null);\r
-               taxon.setTitleCache("TitleCache", true);\r
-               taxon.setCreated(new DateTime());\r
-               taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:1"));\r
-               \r
-               AuditEventRecord<Taxon> auditEventRecord = new AuditEventRecordImpl<Taxon>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
-               \r
-               model.put("object", auditEventRecord);\r
-               \r
-               request.setRequestURI("/cgi-bin/oai?verb=GetRecord&identifier=urn:lsid:example.org:taxonconcepts:1&metadataPrefix=rdf");\r
-               rdfGetRecordView.render(model, request, response);\r
-               //System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-       \r
-       @Test\r
-       public void testListMetadataFormatsView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               request.setRequestURI("/cgi-bin/pdataprov?verb=ListMetadataFormats&identifier=oai:perseus.tufts.edu:Perseus:text:1999.02.0119");\r
-               listMetadataFormatsView.render(model, request, response);\r
-               //System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-       \r
-       @Test\r
-       public void testListSetsView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               request.setRequestURI("/OAI-script?verb=ListSets");\r
-               Set<SetSpec> sets = new HashSet<SetSpec>();\r
-       sets.add(SetSpec.TAXON);\r
-       sets.add(SetSpec.SYNONYM);\r
-       model.put("sets",sets);\r
-               listSetsView.render(model, request, response);\r
+    }\r
+\r
+    @Test\r
+    public void testRdfGetRecordView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        Taxon taxon = Taxon.NewInstance(null, null);\r
+        taxon.setTitleCache("TitleCache", true);\r
+        taxon.setCreated(new DateTime());\r
+        taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:1"));\r
+\r
+        AuditEventRecord<Taxon> auditEventRecord = new AuditEventRecordImpl<Taxon>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
+\r
+        model.put("object", auditEventRecord);\r
+\r
+        request.setRequestURI("/cgi-bin/oai?verb=GetRecord&identifier=urn:lsid:example.org:taxonconcepts:1&metadataPrefix=rdf");\r
+        rdfGetRecordView.render(model, request, response);\r
+        //System.out.println(new String(response.getContentAsByteArray()));\r
+    }\r
+\r
+    @Test\r
+    public void testListMetadataFormatsView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        request.setRequestURI("/cgi-bin/pdataprov?verb=ListMetadataFormats&identifier=oai:perseus.tufts.edu:Perseus:text:1999.02.0119");\r
+        listMetadataFormatsView.render(model, request, response);\r
+        //System.out.println(new String(response.getContentAsByteArray()));\r
+    }\r
+\r
+    @Test\r
+    public void testListSetsView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        request.setRequestURI("/OAI-script?verb=ListSets");\r
+        Set<SetSpec> sets = new HashSet<SetSpec>();\r
+        sets.add(SetSpec.TAXON);\r
+        sets.add(SetSpec.SYNONYM);\r
+        model.put("sets",sets);\r
+        listSetsView.render(model, request, response);\r
 //             System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-       \r
-       @Test\r
-       public void testListIdentifiersView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               model.put("metadataPrefix", MetadataPrefix.OAI_DC);\r
-               \r
-               DateTime from = new DateTime(1990,2,1,12,0,0, 0);\r
-               DateTime until = new DateTime();\r
-               model.put("from",from);\r
-               model.put("until", until);\r
-               \r
-               List<AuditEventRecord<TaxonBase>> r = new ArrayList<AuditEventRecord<TaxonBase>>();\r
-               for(int i = 0; i < 10; i++) {\r
-                       TaxonBase taxon = Taxon.NewInstance(null, null);\r
-                       taxon.setTitleCache("TitleCache", true);\r
-                       taxon.setCreated(new DateTime());\r
-                       taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:"+i));\r
-                       if((i % 3) == 0 ) {\r
-                           AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.DEL});\r
-                           r.add(auditEventRecord);\r
-                       } else {\r
-                               AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
-                               r.add(auditEventRecord);\r
-                       }\r
-               }\r
-               Pager<AuditEventRecord<TaxonBase>> results = new DefaultPagerImpl(0, 100, 10,r);\r
-               model.put("pager", results);\r
-               ResumptionToken resumptionToken = new ResumptionToken(results, from, until, MetadataPrefix.OAI_DC, null);\r
+    }\r
+\r
+    @Test\r
+    public void testListIdentifiersView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        model.put("metadataPrefix", MetadataPrefix.OAI_DC);\r
+\r
+        DateTime from = new DateTime(1990,2,1,12,0,0, 0);\r
+        DateTime until = new DateTime();\r
+        model.put("from",from);\r
+        model.put("until", until);\r
+\r
+        List<AuditEventRecord<TaxonBase>> r = new ArrayList<AuditEventRecord<TaxonBase>>();\r
+        for(int i = 0; i < 10; i++) {\r
+            TaxonBase taxon = Taxon.NewInstance(null, null);\r
+            taxon.setTitleCache("TitleCache", true);\r
+            taxon.setCreated(new DateTime());\r
+            taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:"+i));\r
+            if((i % 3) == 0 ) {\r
+                AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.DEL});\r
+                r.add(auditEventRecord);\r
+            } else {\r
+                AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
+                r.add(auditEventRecord);\r
+            }\r
+        }\r
+        Pager<AuditEventRecord<TaxonBase>> results = new DefaultPagerImpl(0, 100, 10,r);\r
+        model.put("pager", results);\r
+        ResumptionToken resumptionToken = new ResumptionToken(results, from, until, MetadataPrefix.OAI_DC, null);\r
         model.put("resumptionToken",resumptionToken);\r
-               listIdentifiersView.render(model, request, response);\r
+        listIdentifiersView.render(model, request, response);\r
 //             System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-       \r
-       @Test\r
-       public void testListRecordsView() throws Exception {\r
-               \r
-               if(!serviceIsAvailable()){\r
-                       return;\r
-               }\r
-               \r
-               model.put("metadataPrefix", MetadataPrefix.OAI_DC);\r
-               \r
-               DateTime from = new DateTime(1990,2,1,12,0,0, 0);\r
-               DateTime until = new DateTime();\r
-               model.put("from",from);\r
-               model.put("until", until);\r
-               \r
-               List<AuditEventRecord<TaxonBase>> r = new ArrayList<AuditEventRecord<TaxonBase>>();\r
-               for(int i = 0; i < 10; i++) {\r
-                       TaxonBase taxon = Taxon.NewInstance(null, null);\r
-                       taxon.setTitleCache("TitleCache", true);\r
-                       taxon.setCreated(new DateTime());\r
-                       taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:"+i));\r
-                       if((i % 3) == 0 ) {\r
-                           AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.DEL});\r
-                           r.add(auditEventRecord);\r
-                       } else {\r
-                               AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
-                               r.add(auditEventRecord);\r
-                       }\r
-               }\r
-               Pager<AuditEventRecord<TaxonBase>> results = new DefaultPagerImpl(0, 100, 10,r);\r
-               model.put("pager", results);\r
-               ResumptionToken resumptionToken = new ResumptionToken(results, from, until, MetadataPrefix.OAI_DC, null);\r
+    }\r
+\r
+    @Test\r
+    public void testListRecordsView() throws Exception {\r
+\r
+        if(!serviceIsAvailable()){\r
+            return;\r
+        }\r
+\r
+        model.put("metadataPrefix", MetadataPrefix.OAI_DC);\r
+\r
+        DateTime from = new DateTime(1990,2,1,12,0,0, 0);\r
+        DateTime until = new DateTime();\r
+        model.put("from",from);\r
+        model.put("until", until);\r
+\r
+        List<AuditEventRecord<TaxonBase>> r = new ArrayList<AuditEventRecord<TaxonBase>>();\r
+        for(int i = 0; i < 10; i++) {\r
+            TaxonBase taxon = Taxon.NewInstance(null, null);\r
+            taxon.setTitleCache("TitleCache", true);\r
+            taxon.setCreated(new DateTime());\r
+            taxon.setLsid(new LSID("urn:lsid:example.org:taxonconcepts:"+i));\r
+            if((i % 3) == 0 ) {\r
+                AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.DEL});\r
+                r.add(auditEventRecord);\r
+            } else {\r
+                AuditEventRecord<TaxonBase> auditEventRecord = new AuditEventRecordImpl<TaxonBase>(new Object[] {taxon, new AuditEvent(),RevisionType.ADD});\r
+                r.add(auditEventRecord);\r
+            }\r
+        }\r
+        Pager<AuditEventRecord<TaxonBase>> results = new DefaultPagerImpl(0, 100, 10,r);\r
+        model.put("pager", results);\r
+        ResumptionToken resumptionToken = new ResumptionToken(results, from, until, MetadataPrefix.OAI_DC, null);\r
         model.put("resumptionToken",resumptionToken);\r
-               listRecordsView.render(model, request, response);\r
-               //System.out.println(new String(response.getContentAsByteArray()));\r
-       }\r
-\r
-       private boolean serviceIsAvailable() {\r
-               if(!UriUtils.isServiceAvailable(serverURI)) {\r
-                       logger.info("Service " + serverURI.toString() + " unavailable");\r
-                       return false;\r
-               } else {\r
-                       return true;\r
-               }\r
-                       \r
-       \r
-       }\r
+        listRecordsView.render(model, request, response);\r
+        //System.out.println(new String(response.getContentAsByteArray()));\r
+    }\r
+\r
+    private boolean serviceIsAvailable() {\r
+        if(!UriUtils.isServiceAvailable(serverURI)) {\r
+            logger.info("Service " + serverURI.toString() + " unavailable");\r
+            return false;\r
+        } else {\r
+            return true;\r
+        }\r
+\r
+\r
+    }\r
 }\r