1 4 package com.openedit.archive.cumulus; 5 6 import java.io.File ; 7 import java.util.ArrayList ; 8 9 import com.openedit.archive.ArchiveTest; 10 import com.openedit.archive.ImageMaker; 11 import com.openedit.modules.search.LuceneHitTracker; 12 import com.openedit.store.Product; 13 import com.openedit.util.FileUtils; 14 15 public class CumulusConvertTest extends ArchiveTest 16 { 17 public CumulusConvertTest(String inArg0) 18 { 19 super(inArg0); 20 } 21 22 public void testConvert() throws Exception 23 { 24 CumulusConverter converter = new CumulusConverter(); 27 converter.setPageManager(getFixture().getPageManager()); 28 converter.convert(getStore(), new ArrayList ()); 29 getStore().clearProducts(); 30 Product product = getStore().getProduct("acfanvent01dottif1078102626"); 31 assertNotNull(product); 32 assertTrue(product.getCatalogs().size() > 0); 33 } 34 public void testIndex() throws Exception 35 { 36 getStore().reindexAll(); 37 LuceneHitTracker hits = getStore().search("category:DigitalColorACHeatingServicesAirConditioningContractors"); 39 assertTrue( hits.getTotal() > 1 ); 40 41 hits = getStore().search("air conditioning"); 42 assertTrue( hits.getTotal() > 1 ); 43 } 44 public void testMedium() throws Exception 45 { 46 File missing = new File ( getStore().getStoreDirectory(),"/products/images/thumb/a/acfanvent01dottif1078102626.jpg"); 47 missing.delete(); 48 49 File med = new File ( getStore().getStoreDirectory(),"/products/images/medium/a/acfanvent01dottif1078102626.jpg"); 50 med.delete(); 51 52 ImageMaker maker = new ImageMaker(); 53 maker.setArchive( getArchive() ); 54 maker.run(); 57 assertTrue( missing.exists()); 58 assertTrue( med.exists()); 59 60 } 61 62 protected void setUp() throws Exception 63 { 64 File etc = new File ( getStore().getRootDirectory().getParentFile(),"etc"); 65 FileUtils util = new FileUtils(); 67 File export = new File (etc,"/export.cre"); 68 File out = new File (getStore().getRootDirectory(),"/testcatalog/upload/export.cre"); 69 util.copyFiles(export,out); 70 File input = new File ( etc, "archivefiles"); 71 File output = new File ( "/tmp/archivefiles"); 72 util.dirCopy(input,output); 73 } 74 75 public void testExtract() throws Exception 76 { 77 CumulusConverter convert = new CumulusConverter(); 78 convert.setPageManager(getFixture().getPageManager()); 79 90 String t = "ddf_ddf"; 91 assertEquals("ddfddf",convert.extractId(t) ); 92 93 t = "ddf&ddf"; 94 assertEquals("ddfddf",convert.extractId(t) ); 95 t = "ddf(ddf"; 96 assertEquals("ddfddf",convert.extractId(t) ); 97 t = "ddf)ddf"; 98 assertEquals("ddfddf",convert.extractId(t) ); 99 t = "ddf.ddf"; 100 assertEquals("ddfddf",convert.extractId(t) ); 101 t = "ddf+ddf"; 102 assertEquals("ddfddf",convert.extractId(t) ); 103 t = "ddf-ddf"; 104 assertEquals("ddfddf",convert.extractId(t) ); 105 } 106 public void testSearchProducts() throws Exception 107 { 108 getStore().reindexAll(); 109 LuceneHitTracker hits = getStore().search("\"AC01.tif\""); 110 assertTrue( hits.getTotal() > 0); 111 112 hits = getStore().search("Conditioning"); 113 assertTrue( hits.getTotal() > 10 ); 114 115 hits = getStore().search("AC01*"); 116 assertTrue( hits.getTotal() > 0); 117 118 hits = getStore().search("conditio*"); 119 assertTrue( hits.getTotal() > 10 ); 120 121 hits = getStore().search("Digital"); 122 assertTrue( hits.getTotal() > 10 ); 123 124 127 } 128 } 129 | Popular Tags |