1 17 18 19 20 package org.apache.lenya.cms.publication; 21 22 import junit.framework.TestCase; 23 import junit.textui.TestRunner; 24 25 import org.apache.lenya.cms.PublicationHelper; 26 27 public class DublinCoreTest extends TestCase { 28 29 private static final String AREA = "authoring"; 30 private static final String DOCUMENT_ID = "/tutorial"; 31 private static final String LANGUAGE = "de"; 32 private static final String CREATOR = "test"; 33 34 38 public DublinCoreTest(String arg0) { 39 super(arg0); 40 } 41 42 48 public static void main(String [] args) { 49 args = PublicationHelper.extractPublicationArguments(args); 50 TestRunner.run(DublinCoreTest.class); 51 } 52 53 59 final public void testModifySaveAndReload() 60 throws DocumentBuildException, DocumentException { 61 Publication publication = PublicationHelper.getPublication(); 62 DocumentBuilder builder = new DefaultDocumentBuilder(); 63 Document doc = 64 builder.buildDocument( 65 publication, 66 builder.buildCanonicalUrl( 67 publication, 68 AREA, 69 DOCUMENT_ID, 70 LANGUAGE)); 71 DublinCore dcCore = doc.getDublinCore(); 72 String title = dcCore.getTitle(); 73 String subject = dcCore.getSubject(); 74 String creator = dcCore.getCreator(); 75 String dateIssued = dcCore.getDateIssued(); 76 77 dcCore.setCreator(CREATOR); 78 dcCore.save(); 79 80 Document doc2 = 81 builder.buildDocument( 82 publication, 83 builder.buildCanonicalUrl( 84 publication, 85 AREA, 86 DOCUMENT_ID, 87 LANGUAGE)); 88 89 DublinCore dcCore2 = doc2.getDublinCore(); 90 assertEquals(title, dcCore2.getTitle()); 91 assertEquals(subject, dcCore2.getSubject()); 92 assertEquals(dateIssued, dcCore2.getDateIssued()); 93 assertFalse(creator.equals(dcCore2.getCreator())); 94 assertEquals(CREATOR, dcCore2.getCreator()); 95 } 96 97 98 protected void setUp() throws Exception { 99 if (PublicationHelper.getPublication() == null) { 100 String [] args = 101 { 102 "/home/egli/build/jakarta-tomcat-4.1.21-LE-jdk14/webapps/lenya", 103 "test" }; 104 PublicationHelper.extractPublicationArguments(args); 105 } 106 } 107 } 108 | Popular Tags |