Changeset 4517


Ignore:
Timestamp:
02/14/14 09:37:04 (10 years ago)
Author:
twagoo
Message:

Comments and some refactoring to reduce code duplication on VLO config factories

Location:
vlo/branches/vlo-3.0
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactory.java

    r4510 r4517  
    1717package eu.clarin.cmdi.vlo.config;
    1818
    19 import java.io.IOException;
    2019import java.io.InputStream;
    21 import javax.xml.bind.JAXBException;
    22 import javax.xml.transform.stream.StreamSource;
    2320
    2421/**
     22 * Creates an instance of the default configuration packed with the VLO commons
    2523 *
    2624 * @author twagoo
    2725 */
    28 public class DefaultVloConfigFactory implements VloConfigFactory {
     26public class DefaultVloConfigFactory extends AbstractXmlVloConfigFactory {
    2927
    3028    public static final String DEFAULT_CONFIG_RESOURCE = "/VloConfig.xml";
    31     private final VloConfigMarshaller marshaller;
    3229
    33     public DefaultVloConfigFactory() {
    34         try {
    35             this.marshaller = new VloConfigMarshaller();
    36         } catch (JAXBException ex) {
    37             throw new RuntimeException("Could not instantiate configuration marshaller while constructing configuration factory", ex);
    38         }
    39     }
    40 
    41     public VloConfig newConfig() {
    42         try {
    43             InputStream configResourceStream = getClass().getResourceAsStream(DEFAULT_CONFIG_RESOURCE);
    44             try {
    45                 return marshaller.unmarshal(new StreamSource(configResourceStream));
    46             } catch (JAXBException ex) {
    47                 throw new RuntimeException("Could not read default configuration due to deserialization error", ex);
    48             } finally {
    49                 configResourceStream.close();
    50             }
    51         } catch (IOException ex) {
    52             throw new RuntimeException("Could not close stream to default configuration", ex);
    53         }
     30    /**
     31     *
     32     * @return an input stream for the XML file describing the default VLO
     33     * configuration
     34     */
     35    @Override
     36    protected InputStream getXmlConfigurationInputStream() {
     37        return getClass().getResourceAsStream(DEFAULT_CONFIG_RESOURCE);
    5438    }
    5539}
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/VloConfigFactory.java

    r4507 r4517  
    1717package eu.clarin.cmdi.vlo.config;
    1818
     19import java.io.IOException;
     20
    1921/**
     22 * Interface for objects capable of instantiating a {@link VloConfig} object
    2023 *
    2124 * @author twagoo
     
    2326public interface VloConfigFactory {
    2427
    25     VloConfig newConfig();
     28    /**
     29     *
     30     * @return a new VLO configuration object
     31     * @throws IOException if configuration could be opened, read or closed from
     32     * source
     33     */
     34    VloConfig newConfig() throws IOException;
    2635}
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/VloConfigMarshaller.java

    r4509 r4517  
    2323import javax.xml.transform.Result;
    2424import javax.xml.transform.Source;
     25import javax.xml.transform.stream.StreamResult;
    2526
    2627/**
     28 * Serializes and deserializes {@link VloConfig} objects to/from XML files using
     29 * the Java Architecture for XML Binding (JAXB)
    2730 *
    2831 * @author twagoo
     
    3235    private final JAXBContext jc;
    3336
    34     public VloConfigMarshaller(JAXBContext jc) {
    35         this.jc = jc;
    36     }
    37    
    3837    public VloConfigMarshaller() throws JAXBException {
    3938        this.jc = JAXBContext.newInstance(VloConfig.class);
    4039    }
    4140
    42     public void marshal(VloConfig config, Result result) throws JAXBException {
     41    /**
     42     * Marshals (serializes) an existing configuration to some output location
     43     *
     44     * @param config configuration to marshal
     45     * @param result output result for the marshalling, e.g. a
     46     * {@link StreamResult} for usage with Files, Streams or Writers
     47     * @throws JAXBException
     48     */
     49    public final void marshal(VloConfig config, Result result) throws JAXBException {
    4350        final Marshaller marshaller = jc.createMarshaller();
    4451        marshaller.marshal(config, result);
    4552    }
    4653
    47     public VloConfig unmarshal(Source source) throws JAXBException {
     54    /**
     55     * Unmarshals (deserializes) a configuration file from some source location
     56     *
     57     * @param source the source representing the VLO configuration to unmarshal
     58     * @return the VLO configuration as described by the source
     59     * @throws JAXBException if an error occurs while unmarshalling
     60     */
     61    public final VloConfig unmarshal(Source source) throws JAXBException {
    4862        Unmarshaller unmarshaller = jc.createUnmarshaller();
    4963        return (VloConfig) unmarshaller.unmarshal(source);
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/XmlVloConfigFactory.java

    r4510 r4517  
    2020import java.io.InputStream;
    2121import java.net.URL;
    22 import javax.xml.bind.JAXBException;
    23 import javax.xml.transform.stream.StreamSource;
    2422
    2523/**
     
    2725 * @author twagoo
    2826 */
    29 public class XmlVloConfigFactory implements VloConfigFactory {
     27public class XmlVloConfigFactory extends AbstractXmlVloConfigFactory implements VloConfigFactory {
    3028
    31     private final VloConfigMarshaller marshaller;
    3229    private final URL configLocation;
    3330
    3431    public XmlVloConfigFactory(URL configLocation) {
    3532        this.configLocation = configLocation;
    36         try {
    37             this.marshaller = new VloConfigMarshaller();
    38         } catch (JAXBException ex) {
    39             throw new RuntimeException("Could not instantiate configuration marshaller while constructing configuration factory", ex);
    40         }
    4133    }
    4234
    43     public VloConfig newConfig() {
    44         try {
    45             final InputStream fileStream = configLocation.openStream();
    46             try {
    47                 return marshaller.unmarshal(new StreamSource(fileStream));
    48             } catch (JAXBException ex) {
    49                 throw new RuntimeException("Could not deserialize configuration file", ex);
    50             } finally {
    51                 fileStream.close();
    52             }
    53         } catch (IOException ex) {
    54             throw new RuntimeException("Could not read configuration file", ex);
    55         }
     35    protected InputStream getXmlConfigurationInputStream() throws IOException {
     36        return configLocation.openStream();
    5637    }
    5738}
  • vlo/branches/vlo-3.0/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactoryTest.java

    r4509 r4517  
    1 
    21package eu.clarin.cmdi.vlo.config;
    32
     
    1615 */
    1716public class DefaultVloConfigFactoryTest {
    18    
     17
    1918    public DefaultVloConfigFactoryTest() {
    2019    }
    21    
     20
    2221    private VloConfig config;
    23    
     22
    2423    @Before
    25     public void setUp() {       
     24    public void setUp() throws Exception {
    2625        config = new DefaultVloConfigFactory().newConfig();
    2726    }
     
    2928    /**
    3029     * Test the getDataRoots method.<br><br>
    31      * 
    32      * Use the values defined in the packaged {@literal VloConfig.xml} 
     30     *
     31     * Use the values defined in the packaged {@literal VloConfig.xml}
    3332     * configuration file.
    3433     */
    3534    @Test
    3635    public void testGetDataRoots() {
    37        
     36
    3837        ArrayList<DataRoot> dataRoots;
    39         dataRoots = new ArrayList<DataRoot> ();
    40        
    41         dataRoots.add(new DataRoot("MPI IMDI Archive", 
    42                                     new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
    43                                    "http://catalog.clarin.eu/",
    44                                    "/lat/apache/htdocs/", false));
    45         dataRoots.add(new DataRoot("CMDI Providers"  ,
    46                                     new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
    47                                    "http://catalog.clarin.eu/",
    48                                    "/lat/apache/htdocs/", false));
    49         dataRoots.add(new DataRoot("OLAC Metadata Providers", 
    50                                     new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
    51                                    "http://catalog.clarin.eu/",
    52                                    "/lat/apache/htdocs/", false));
    53        
     38        dataRoots = new ArrayList<DataRoot>();
     39
     40        dataRoots.add(new DataRoot("MPI IMDI Archive",
     41                new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
     42                "http://catalog.clarin.eu/",
     43                "/lat/apache/htdocs/", false));
     44        dataRoots.add(new DataRoot("CMDI Providers",
     45                new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
     46                "http://catalog.clarin.eu/",
     47                "/lat/apache/htdocs/", false));
     48        dataRoots.add(new DataRoot("OLAC Metadata Providers",
     49                new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
     50                "http://catalog.clarin.eu/",
     51                "/lat/apache/htdocs/", false));
     52
    5453        System.out.println("getDataRoots");
    55        
     54
    5655        List<DataRoot> rootsReturned = config.getDataRoots();
    5756        assertArrayEquals(dataRoots.toArray(), rootsReturned.toArray());
     
    6362    @Test
    6463    public void testSetDataRoots() {
    65        
    66         ArrayList<DataRoot> dataRoots = new ArrayList<DataRoot> ();
    67        
    68         dataRoots.add(new DataRoot("MPI IMDI Archive", 
    69                                     new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
    70                                    "http://catalog.clarin.eu/",
    71                                    "/lat/apache/htdocs/", false));
    72         dataRoots.add(new DataRoot("CMDI Providers"  ,
    73                                     new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
    74                                    "http://catalog.clarin.eu/",
    75                                    "/lat/apache/htdocs/", false));
    76         dataRoots.add(new DataRoot("OLAC Metadata Providers", 
    77                                     new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
    78                                    "http://catalog.clarin.eu/",
    79                                    "/lat/apache/htdocs/", false));
    80        
     64
     65        ArrayList<DataRoot> dataRoots = new ArrayList<DataRoot>();
     66
     67        dataRoots.add(new DataRoot("MPI IMDI Archive",
     68                new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
     69                "http://catalog.clarin.eu/",
     70                "/lat/apache/htdocs/", false));
     71        dataRoots.add(new DataRoot("CMDI Providers",
     72                new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
     73                "http://catalog.clarin.eu/",
     74                "/lat/apache/htdocs/", false));
     75        dataRoots.add(new DataRoot("OLAC Metadata Providers",
     76                new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
     77                "http://catalog.clarin.eu/",
     78                "/lat/apache/htdocs/", false));
     79
    8180        System.out.println("setDataRoots");
    8281
    8382        config.setDataRoots(dataRoots);
    84        
    85         List rootsReturned = config.getDataRoots(); 
    86        
    87         assertEquals (dataRoots, rootsReturned);
     83
     84        List rootsReturned = config.getDataRoots();
     85
     86        assertEquals(dataRoots, rootsReturned);
    8887    }
    8988
     
    9392    @Test
    9493    public void testGetPagesInApplicationCache() {
    95        
     94
    9695        System.out.println("getPagesInApplicationCache");
    97        
     96
    9897        int expResult = 40; // as defined in vloconfig.xml
    9998        int result = config.getPagesInApplicationCache();
    100        
     99
    101100        assertEquals(expResult, result);
    102101    }
     
    107106    @Test
    108107    public void testSetPagesInApplicationCache() {
    109        
     108
    110109        System.out.println("setPagesInApplicationCache");
    111        
     110
    112111        int param = 999;
    113        
     112
    114113        config.setPagesInApplicationCache(param);
    115114
    116115        int result = config.getPagesInApplicationCache();
    117        
    118         assertEquals(param, result);
    119     }
    120    
    121    
     116
     117        assertEquals(param, result);
     118    }
     119
    122120    /**
    123121     * Test the getSessionCacheSize method
     
    125123    @Test
    126124    public void testGetSessionCacheSize() {
    127        
     125
    128126        System.out.println("getPagesInApplicationCache");
    129        
     127
    130128        int expResult = 10000; // as defined in vloconfig.xml
    131129        int result = config.getSessionCacheSize();
    132        
     130
    133131        assertEquals(expResult, result);
    134132    }
     
    139137    @Test
    140138    public void testSetSessionCacheSize() {
    141        
     139
    142140        System.out.println("setPagesInApplicationCache");
    143        
     141
    144142        int param = 9999;
    145        
     143
    146144        config.setSessionCacheSize(param);
    147145
    148146        int result = config.getSessionCacheSize();
    149        
    150         assertEquals(param, result);
    151     }
    152    
     147
     148        assertEquals(param, result);
     149    }
     150
    153151    /**
    154152     * Test the getMaxDocsInList method
     
    156154    @Test
    157155    public void testGetMaxDocsInList() {
    158        
     156
    159157        System.out.println("getMaxDocsInList");
    160        
     158
    161159        int expResult = 128;
    162160        int result = config.getMaxDocsInList();
    163        
     161
    164162        assertEquals(expResult, result);
    165163    }
     
    170168    @Test
    171169    public void testSetMaxDocsInList() {
    172        
     170
    173171        System.out.println("setMaxDocsInList");
    174        
     172
    175173        int param = 1000;
    176        
     174
    177175        config.setMaxDocsInList(param);
    178176
    179177        int result = config.getMaxDocsInList();
    180        
    181         assertEquals(param, result);
    182     }
    183    
     178
     179        assertEquals(param, result);
     180    }
     181
    184182    /**
    185183     * Test the getMaxDocsInSolrQueue method
     
    187185    @Test
    188186    public void testGetMaxDocsInSolrQueue() {
    189        
     187
    190188        System.out.println("getMaxDocsInSolrQueue");
    191        
     189
    192190        int expResult = 128;
    193191        int result = config.getMaxDocsInList();
    194        
     192
    195193        assertEquals(expResult, result);
    196194    }
     
    201199    @Test
    202200    public void testSetMaxDocsInSolrQueue() {
    203        
     201
    204202        System.out.println("setMaxDocsInSolrQueue");
    205        
     203
    206204        int param = 1000;
    207        
     205
    208206        config.setMaxDocsInList(param);
    209207
    210208        int result = config.getMaxDocsInList();
    211        
    212         assertEquals(param, result);
    213     }
    214    
     209
     210        assertEquals(param, result);
     211    }
     212
    215213    /**
    216214     * Test the getMaxFileSize method
     
    218216    @Test
    219217    public void testGetMaxFileSize() {
    220        
     218
    221219        System.out.println("getMaxFileSize");
    222        
     220
    223221        int expResult = 10000000;
    224222        int result = config.getMaxFileSize();
    225        
     223
    226224        assertEquals(expResult, result);
    227225    }
     
    232230    @Test
    233231    public void testSetMaxFileSize() {
    234        
     232
    235233        System.out.println("setMaxFileSize");
    236        
     234
    237235        int param = 10000000;
    238        
     236
    239237        config.setMaxFileSize(param);
    240238
    241239        int result = config.getMaxFileSize();
    242        
    243         assertEquals(param, result);
    244     }
    245    
     240
     241        assertEquals(param, result);
     242    }
     243
    246244    /**
    247245     * Test the getHandleResolver method
     
    249247    @Test
    250248    public void testGetUseHandleResolver() {
    251        
     249
    252250        System.out.println("getUseHandleResolver");
    253        
     251
    254252        boolean expResult = false;
    255253        boolean result = config.getUseHandleResolver();
    256        
    257         assertEquals(expResult, result);
    258     }
    259    
     254
     255        assertEquals(expResult, result);
     256    }
     257
    260258    /**
    261259     * Test the setUseHandleResolver method
     
    263261    @Test
    264262    public void testSetUseHandleResolver() {
    265        
     263
    266264        System.out.println("setUseHandleResolver");
    267        
     265
    268266        boolean param = true;
    269        
     267
    270268        config.setUseHandleResolver(param);
    271269
    272270        boolean result = config.getUseHandleResolver();
    273        
     271
    274272        assertEquals(param, result);
    275273    }
     
    280278    @Test
    281279    public void testDeleteAllFirst() {
    282        
     280
    283281        System.out.println("deleteAllFirst");
    284        
     282
    285283        boolean expResult = true;
    286284        boolean result = config.getDeleteAllFirst();
    287        
     285
    288286        assertEquals(expResult, result);
    289287    }
     
    294292    @Test
    295293    public void testSetDeleteAllFirst() {
    296        
     294
    297295        System.out.println("setDeleteAllFirst");
    298        
     296
    299297        boolean param = true;
    300        
     298
    301299        config.setDeleteAllFirst(param);
    302300
    303301        boolean result = config.getDeleteAllFirst();
    304        
     302
    305303        assertEquals(param, result);
    306304    }
     
    311309    @Test
    312310    public void testPrintMapping() {
    313        
     311
    314312        System.out.println("printMapping");
    315        
     313
    316314        boolean expResult = false;
    317315        boolean result = config.printMapping();
    318        
     316
    319317        assertEquals(expResult, result);
    320318    }
     
    326324    public void testSetPrintMapping() {
    327325        System.out.println("setPrintMapping");
    328        
     326
    329327        boolean param = false;
    330        
     328
    331329        config.setPrintMapping(param);
    332330
    333331        boolean result = config.printMapping();
    334        
     332
    335333        assertEquals(param, result);
    336334    }
     
    341339    @Test
    342340    public void testGetVloHomeLink() {
    343        
     341
    344342        System.out.println("getVloHomeLink");
    345        
     343
    346344        String expResult = "http://www.clarin.eu/vlo";
    347345        String result = config.getHomeUrl();
    348        
     346
    349347        assertEquals(expResult, result);
    350348    }
     
    355353    @Test
    356354    public void testSetVloHomeLink() {
    357        
     355
    358356        System.out.println("setVloHomeLink");
    359        
     357
    360358        String param = "http://www.clarin.eu/vlo";
    361        
     359
    362360        config.setHomeUrl(param);
    363361
    364362        String result = config.getHomeUrl();
    365        
     363
    366364        assertEquals(param, result);
    367365    }
     
    372370    @Test
    373371    public void testGetHelpUrl() {
    374        
     372
    375373        System.out.println("getHelpUrl");
    376        
     374
    377375        String expResult = "http://www.clarin.eu/vlo";
    378376        String result = config.getHelpUrl();
    379        
     377
    380378        assertEquals(expResult, result);
    381379    }
     
    386384    @Test
    387385    public void testSetHelpUrl() {
    388        
     386
    389387        System.out.println("setHelpUrl");
    390        
     388
    391389        String param = "http://www.clarin.eu/vlo";
    392        
     390
    393391        config.setHelpUrl(param);
    394392
    395393        String result = config.getHelpUrl();
    396        
     394
    397395        assertEquals(param, result);
    398396    }
     
    403401    @Test
    404402    public void testGetSolrUrl() {
    405        
     403
    406404        System.out.println("getSolrUrl");
    407        
     405
    408406        String expResult = "http://localhost:8080/vlo_solr/";
    409407        String result = config.getSolrUrl();
    410        
     408
    411409        assertEquals(expResult, result);
    412410    }
     
    417415    @Test
    418416    public void testSetSolrUrl() {
    419        
     417
    420418        System.out.println("setSolrUrl");
    421        
     419
    422420        String param = "http://localhost:8084/vlo_solr/";
    423        
     421
    424422        config.setSolrUrl(param);
    425423
    426424        String result = config.getSolrUrl();
    427        
    428         assertEquals(param, result);
    429     }
    430    
     425
     426        assertEquals(param, result);
     427    }
     428
    431429    /**
    432430     * Test the getGetComponentRegistryProfileSchema method
     
    434432    @Test
    435433    public void testGetComponentRegistryProfileSchema() {
    436        
     434
    437435        System.out.println("getComponentRegistryProfileSchema");
    438        
     436
    439437        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/someId/xsd";
    440438        String result = config.getComponentRegistryProfileSchema("someId");
    441        
    442         assertEquals(expResult, result);
    443     }
    444    
     439
     440        assertEquals(expResult, result);
     441    }
     442
    445443    /**
    446444     * Test the getComponentRegistryRESTURL method
     
    448446    @Test
    449447    public void testGetComponentRegistryRESTURL() {
    450        
     448
    451449        System.out.println("getComponentRegistryRESTURL");
    452        
     450
    453451        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/";
    454452        String result = config.getComponentRegistryRESTURL();
    455        
     453
    456454        assertEquals(expResult, result);
    457455    }
     
    462460    @Test
    463461    public void testComponentRegistryRESTURL() {
    464        
     462
    465463        System.out.println("setComponentRegistryRESTURL");
    466        
     464
    467465        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/";
    468        
     466
    469467        config.setComponentRegistryRESTURL(param);
    470468
    471469        String result = config.getComponentRegistryRESTURL();
    472        
    473         assertEquals(param, result);
    474     }
    475    
     470
     471        assertEquals(param, result);
     472    }
     473
    476474    /**
    477475     * Test the getHandleServerUrl method
     
    479477    @Test
    480478    public void testGetHandleServerUrl() {
    481        
     479
    482480        System.out.println("getHandleServerUrl");
    483        
     481
    484482        String expResult = "http://hdl.handle.net/";
    485483        String result = config.getHandleServerUrl();
    486        
     484
    487485        assertEquals(expResult, result);
    488486    }
     
    493491    @Test
    494492    public void testSetHandleServerUrl() {
    495        
     493
    496494        System.out.println("setHandleServerUrl");
    497        
     495
    498496        String param = "http://hdl.handle.net/";
    499        
     497
    500498        config.setHandleServerUrl(param);
    501499
    502500        String result = config.getHandleServerUrl();
    503        
    504         assertEquals(param, result);
    505     }
    506    
     501
     502        assertEquals(param, result);
     503    }
     504
    507505    /**
    508506     * Test the getIMDIBrowserUrl method
     
    510508    @Test
    511509    public void testGetIMDIBrowserUrl() {
    512        
     510
    513511        System.out.println("getIMDIBrowserUrl");
    514        
     512
    515513        String expResult;
    516514        try {
     
    529527    @Test
    530528    public void testSetIMDIBrowserUrl() {
    531        
     529
    532530        System.out.println("setIMDIBrowserUrl");
    533        
     531
    534532        String param = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=";
    535        
     533
    536534        config.setImdiBrowserUrl(param);
    537535
     
    542540            expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + "handle";
    543541        }
    544        
     542
    545543        String result = config.getImdiBrowserUrl("handle");
    546544
    547545        assertEquals(expResult, result);
    548546    }
    549    
     547
    550548    /**
    551549     * Test the getLanguageLinkPrefix method
     
    553551    @Test
    554552    public void testGetLanguageLinkPrefix() {
    555        
     553
    556554        System.out.println("getLanguageLinkPrefix");
    557        
     555
    558556        String expResult = "http://infra.clarin.eu/service/language/info.php?code=";
    559557        String result = config.getLanguageLinkPrefix();
    560        
     558
    561559        assertEquals(expResult, result);
    562560    }
     
    567565    @Test
    568566    public void testSetLanguageLinkPrefix() {
    569        
     567
    570568        System.out.println("setLanguageLinkPrefix");
    571        
     569
    572570        String param = "http://infra.clarin.eu/service/language/info.php?code=";
    573        
     571
    574572        config.setLanguageLinkPrefix(param);
    575573
    576574        String result = config.getLanguageLinkPrefix();
    577        
    578         assertEquals(param, result);
    579     }
    580    
     575
     576        assertEquals(param, result);
     577    }
     578
    581579    /**
    582580     * Test the getFeedbackFromUrl method
     
    584582    @Test
    585583    public void testGetFeedbackFromUrl() {
    586        
     584
    587585        System.out.println("getFeedBackFromUrl");
    588        
     586
    589587        String expResult = "http://www.clarin.eu/node/3759?url=";
    590588        String result = config.getFeedbackFromUrl();
    591        
     589
    592590        assertEquals(expResult, result);
    593591    }
     
    598596    @Test
    599597    public void testSetFeedbackFromUrl() {
    600        
     598
    601599        System.out.println("setFeedbackFromUrl");
    602        
     600
    603601        String param = "http://www.clarin.eu/node/3759?url=";
    604        
     602
    605603        config.setFeedbackFromUrl(param);
    606604
    607605        String result = config.getFeedbackFromUrl();
    608        
    609         assertEquals(param, result);
    610     }
    611    
     606
     607        assertEquals(param, result);
     608    }
     609
    612610    /**
    613611     * Test the getFederatedContentSearchUrl method
     
    615613    @Test
    616614    public void testGetFederatedContentSearchUrl() {
    617        
     615
    618616        System.out.println("getFederatedContentSearchUrl");
    619        
     617
    620618        String expResult = "http://weblicht.sfs.uni-tuebingen.de/Aggregator/";
    621619        String result = config.getFederatedContentSearchUrl();
    622        
     620
    623621        assertEquals(expResult, result);
    624622    }
     
    629627    @Test
    630628    public void testSetFederatedContentSearchUrl() {
    631        
     629
    632630        System.out.println("setFederatedContentSearchUrl");
    633        
     631
    634632        String param = "http://weblicht.sfs.uni-tuebingen.de/Aggregator/";
    635        
     633
    636634        config.setFederatedContentSearchUrl(param);
    637635
    638636        String result = config.getFederatedContentSearchUrl();
    639        
     637
    640638        assertEquals(param, result);
    641639    }
     
    646644    @Test
    647645    public void testGetNationalProjectMapping() {
    648        
     646
    649647        System.out.println("getNationalProjectMapping");
    650        
     648
    651649        String expResult = "/nationalProjectsMapping.xml";
    652650        String result = config.getNationalProjectMapping();
    653        
     651
    654652        assertEquals(expResult, result);
    655653    }
     
    660658    @Test
    661659    public void testSetNationalProjectMapping() {
    662        
     660
    663661        System.out.println("setFNationalProjectMapping");
    664        
     662
    665663        String param = "nationalProjectsMapping.xml";
    666        
     664
    667665        config.setNationalProjectMapping(param);
    668666
    669667        String result = config.getNationalProjectMapping();
    670        
    671         assertEquals(param, result);
    672     }   
     668
     669        assertEquals(param, result);
     670    }
    673671
    674672    /**
     
    677675    @Test
    678676    public void testGetFacetFields() {
    679        
     677
    680678        System.out.println("getFacetFields");
    681        
     679
    682680        String[] expResult = {
    683         "collection",
    684         "language",
    685         "resourceClass",
    686         "modality",
    687         "continent",
    688         "genre",
    689         "country",
    690         "subject",
    691         "organisation",
    692         "format",
    693         "dataProvider",
    694         "nationalProject",
    695         "keywords"};
    696    
     681            "collection",
     682            "language",
     683            "resourceClass",
     684            "modality",
     685            "continent",
     686            "genre",
     687            "country",
     688            "subject",
     689            "organisation",
     690            "format",
     691            "dataProvider",
     692            "nationalProject",
     693            "keywords"};
     694
    697695        String[] result = config.getFacetFields();
    698    
     696
    699697        assertArrayEquals(expResult, result);
    700698    }
     
    705703    @Test
    706704    public void testSetFacetFields() {
    707        
     705
    708706        System.out.println("setFacetFields");
    709        
     707
    710708        String[] expResult = {
    711         "collection",
    712         "language",
    713         "resourceClass",
    714         "modality",
    715         "continent",
    716         "genre",
    717         "country",
    718         "subject",
    719         "organisation",
    720         "format",
    721         "dataProvider",
    722         "nationalProject",
    723         "keywords"};
    724        
     709            "collection",
     710            "language",
     711            "resourceClass",
     712            "modality",
     713            "continent",
     714            "genre",
     715            "country",
     716            "subject",
     717            "organisation",
     718            "format",
     719            "dataProvider",
     720            "nationalProject",
     721            "keywords"};
     722
    725723        config.setFacetFields(expResult);
    726        
     724
    727725        String result[] = config.getFacetFields();
    728726
    729727        assertArrayEquals(expResult, result);
    730728    }
    731    
     729
    732730    /**
    733731     * Test the getCountryComponentUrl method.
     
    735733    @Test
    736734    public void testCountryComponentUrl() {
    737        
     735
    738736        System.out.println("getCountryComponentUrl");
    739        
     737
    740738        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438104/xml";
    741739        String result = config.getCountryComponentUrl();
    742        
     740
    743741        assertEquals(expResult, result);
    744742    }
     
    749747    @Test
    750748    public void testSetCountryComponentUrl() {
    751        
     749
    752750        System.out.println("setCountryComponentUrl");
    753        
     751
    754752        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438104/xml";
    755        
     753
    756754        config.setCountryComponentUrl(param);
    757755
    758756        String result = config.getCountryComponentUrl();
    759        
    760         assertEquals(param, result);
    761     } 
    762    
     757
     758        assertEquals(param, result);
     759    }
     760
    763761    /**
    764762     * Test the getLanguage2LetterCodeComponentUrl method.
     
    766764    @Test
    767765    public void testGetLanguage2LetterCodeComponentUrl() {
    768        
     766
    769767        System.out.println("getLanguage2LetterCodeComponentUrl");
    770        
     768
    771769        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438109/xml";
    772770        String result = config.getLanguage2LetterCodeComponentUrl();
    773        
     771
    774772        assertEquals(expResult, result);
    775773    }
     
    780778    @Test
    781779    public void testSetLanguage2LetterCodeComponentUrl() {
    782        
     780
    783781        System.out.println("setLanguage2LetterCodeComponentUrl");
    784        
     782
    785783        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438109/xml";
    786        
     784
    787785        config.setLanguage2LetterCodeComponentUrl(param);
    788786
    789787        String result = config.getLanguage2LetterCodeComponentUrl();
    790        
    791         assertEquals(param, result);
    792     }
    793    
     788
     789        assertEquals(param, result);
     790    }
     791
    794792    /**
    795793     * Test the getLanguage3LetterCodeComponentUrl.
     
    797795    @Test
    798796    public void testGetLanguage3LetterCodeComponentUrl() {
    799        
     797
    800798        System.out.println("getLanguage3LetterCodeComponentUrl");
    801        
     799
    802800        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438110/xml";
    803801        String result = config.getLanguage3LetterCodeComponentUrl();
    804        
     802
    805803        assertEquals(expResult, result);
    806804    }
     
    811809    @Test
    812810    public void testSetLanguage3LetterCodeComponentUrl() {
    813        
     811
    814812        System.out.println("setLanguage3LetterCodeComponentUrl");
    815        
     813
    816814        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438110/xml";
    817        
     815
    818816        config.setLanguage3LetterCodeComponentUrl(param);
    819817
    820818        String result = config.getLanguage3LetterCodeComponentUrl();
    821        
    822         assertEquals(param, result);
    823     }
    824    
     819
     820        assertEquals(param, result);
     821    }
     822
    825823    /**
    826824     * Test the getSilToISO639CodesUrl method.
     
    828826    @Test
    829827    public void testGetSilToISO639CodesUrl() {
    830        
     828
    831829        System.out.println("getSilToISO639CodesUrl");
    832        
     830
    833831        String expResult = "http://www.clarin.eu/cmd/xslt/sil_to_iso6393.xml";
    834832        String result = config.getSilToISO639CodesUrl();
    835        
     833
    836834        assertEquals(expResult, result);
    837835    }
     
    842840    @Test
    843841    public void testSetSilToISO639CodesUrl() {
    844        
     842
    845843        System.out.println("setSilToISO639CodesUrl");
    846        
     844
    847845        String param = "http://www.clarin.eu/cmd/xslt/sil_to_iso6393.xml";
    848        
     846
    849847        config.setSilToISO639CodesUrl(param);
    850848
    851849        String result = config.getSilToISO639CodesUrl();
    852        
    853         assertEquals(param, result);
    854     }
    855    
     850
     851        assertEquals(param, result);
     852    }
     853
    856854    /**
    857855     * Test the getReverseProxyPrefix method
     
    859857    @Test
    860858    public void testReverseProxyPrefix() {
    861        
     859
    862860        System.out.println("getReverseProxyPrefix");
    863        
     861
    864862        String expResult = "";
    865863        String result = config.getReverseProxyPrefix();
    866        
     864
    867865        assertEquals(expResult, result);
    868866    }
     
    873871    @Test
    874872    public void testSetReverseProxyPrefix() {
    875        
     873
    876874        System.out.println("setReverseProxyPrefix");
    877        
     875
    878876        String param = "vlodev/";
    879        
     877
    880878        config.setReverseProxyPrefix(param);
    881879
    882880        String result = config.getReverseProxyPrefix();
    883        
     881
    884882        assertEquals(param, result);
    885883    }
     
    890888    @Test
    891889    public void testGetCqlEndpointFilter() {
    892        
     890
    893891        System.out.println("getCqlEndpointFilter");
    894        
     892
    895893        String expResult = "http://cqlservlet.mpi.nl/";
    896894        String result = config.getCqlEndpointFilter();
    897        
     895
    898896        assertEquals(expResult, result);
    899897    }
     
    904902    @Test
    905903    public void testSetCqlEndpointFilter() {
    906        
     904
    907905        System.out.println("setCqlEndpointFilter");
    908        
     906
    909907        String param = "http://cqlservlet.mpi.nl/";
    910        
     908
    911909        config.setCqlEndpointFilter(param);
    912910
    913911        String result = config.getCqlEndpointFilter();
    914        
     912
    915913        assertEquals(param, result);
    916914    }
     
    921919    @Test
    922920    public void testGetCqlEndpointAlternative() {
    923        
     921
    924922        System.out.println("getCqlEndpointAlternative");
    925        
     923
    926924        String expResult = "http://cqlservlet.mpi.nl/";
    927925        String result = config.getCqlEndpointAlternative();
    928        
     926
    929927        assertEquals(expResult, result);
    930928    }
     
    935933    @Test
    936934    public void testSetCqlEndpointAlternative() {
    937        
     935
    938936        System.out.println("setCqlEndpointAlternative");
    939        
     937
    940938        String param = "http://cqlservlet.mpi.nl/";
    941        
     939
    942940        config.setCqlEndpointAlternative(param);
    943941
    944942        String result = config.getCqlEndpointAlternative();
    945        
     943
    946944        assertEquals(param, result);
    947945    }
  • vlo/branches/vlo-3.0/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/VloConfigMarshallerTest.java

    r4509 r4517  
    3131
    3232/**
    33  *
     33 * 
    3434 * @author twagoo
    3535 */
  • vlo/branches/vlo-3.0/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXMLTest.java

    r4507 r4517  
    1212   
    1313    @Before
    14     public void setUp() {
    15 
    16         // read the configuration from the packaged configuration file
     14    public void setUp() throws Exception {
     15        // read the configuration from the default configuration file
    1716        new DefaultVloConfigFactory().newConfig();
    18 
    19         // optionally, modify the configuration here
    20 
    21         // apparantly, this does not make the configuration available
    2217    }
    2318
  • vlo/branches/vlo-3.0/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/CountryNamePostProcessorTest.java

    r4507 r4517  
    99
    1010    @Before
    11     public void setUp() {
     11    public void setUp() throws Exception {
    1212       
    1313        // read the configuration from the packaged configuration file
  • vlo/branches/vlo-3.0/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java

    r4509 r4517  
    2828
    2929    @Before
    30     public void setup() {
     30    public void setup() throws Exception {
    3131        final String baseTempPath = System.getProperty("java.io.tmpdir");
    3232        testDir = new File(baseTempPath + File.separator + "testRegistry_" + System.currentTimeMillis());
  • vlo/branches/vlo-3.0/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/LanguageCodePostProcessorTest.java

    r4507 r4517  
    99
    1010    @Before
    11     public void setUp() {
    12        
     11    public void setUp() throws Exception {
     12
    1313        // read the configuration from the packaged configuration file
    1414        new DefaultVloConfigFactory().newConfig();
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloSpringConfig.java

    r4511 r4517  
    2424import eu.clarin.cmdi.vlo.service.impl.SolrFacetFieldsService;
    2525import eu.clarin.cmdi.vlo.service.impl.SolrQueryFactoryImpl;
     26import java.io.IOException;
    2627import org.apache.solr.client.solrj.SolrServer;
    2728import org.apache.solr.client.solrj.impl.HttpSolrServer;
     
    5354    @Bean
    5455    public VloConfig vloConfig() {
    55         return vloConfigFactory().newConfig();
     56        try {
     57            return vloConfigFactory().newConfig();
     58        } catch (IOException ex) {
     59            throw new RuntimeException("Could not read VLO configuration", ex);
     60        }
    5661    }
    57    
     62
    5863    @Bean
    59     public VloConfigFactory vloConfigFactory(){
     64    public VloConfigFactory vloConfigFactory() {
    6065        return new DefaultVloConfigFactory();
    6166    }
     
    7580        return new SolrQueryFactoryImpl(vloConfig());
    7681    }
    77    
     82
    7883    @Bean
    7984    public SolrServer solrServer() {
Note: See TracChangeset for help on using the changeset viewer.