Changeset 2639


Ignore:
Timestamp:
02/28/13 09:12:48 (11 years ago)
Author:
keeloo
Message:

Repaired web application and importer tests. This included changing the initialisation of the profileSchemaUrl
parameter. Cleaned up code in importer main.

Location:
vlo/branches/vlo-2.13-param/vlo_webapp/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java

    r2627 r2639  
    364364     */
    365365    public String getComponentRegistryProfileSchema(String id) {
    366         return profileSchemaUrl.replace("${PROFILE_ID}", id);
     366        return profileSchemaUrl.replace("{PROFILE_ID}", id);
    367367    }
    368368
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java

    r2627 r2639  
    378378     * @throws IOException
    379379     */
     380    /**
     381     * @param args
     382     * @throws IOException
     383     */
    380384    public static void main(String[] args) throws MalformedURLException, IOException {
    381385
     386        // application configuration
    382387        VloConfig config;
    383 
     388       
     389        // use the Apache cli framework for getting command line parameters
    384390        Options options = new Options();
    385391
    386         // add t option
    387         options.addOption("f", true, "use parameters specified in -f <file>");
     392        /**
     393         * Add a "c" option, the option indicating the specification of an XML
     394         * configuration file
     395         */
     396        options.addOption("c", true, "-c <file> : use parameters specified in <file>");
    388397
    389398        CommandLineParser parser = new PosixParser();
     
    392401            // parse the command line arguments
    393402            CommandLine cmd = parser.parse(options, args);
    394             if (cmd.hasOption("f")) {
    395                 // get the value of the f option
    396 
     403            if (cmd.hasOption("c")) {
     404               
     405                // the "c" option was specified, now get its value
    397406                String fileName;
    398                 fileName = cmd.getOptionValue("f");
     407                fileName = cmd.getOptionValue("c");
    399408               
    400409                // include the full path in the name
    401 
    402410                fileName = VloConfig.class.getResource(fileName).getFile();
    403411
     
    405413               
    406414                // read the configuration defined in the file
    407                
    408415                config = VloConfig.readConfig(fileName);
    409416
    410417                // optionally, modify the configuration here
    411 
     418               
     419                // create and start the importer
    412420                MetadataImporter importer = new MetadataImporter(config);
    413421                importer.startImport();
     422               
     423                // finished importing
     424               
    414425                if (config.isPrintMapping()) {
    415426                    File file = new File("xsdMapping.txt");
     
    420431
    421432        } catch (org.apache.commons.cli.ParseException ex) {
    422             LOG.error("Command line parsing failed.");
    423 
    424             // System.err.println("Command line parsing failed. " + ex.getMessage());
     433           
     434            // caught an exception caused by command line parsing
     435           
     436            String message = "Command line parsing failed. " + ex.getMessage();
     437                   
     438            LOG.error(message);
     439            System.err.println(message);
    425440        }
    426441    }
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/main/resources/VloConfig.xml

    r2627 r2639  
    3636    <vloHomeLink>http://www.clarin.eu/vlo</vloHomeLink>
    3737   
    38     <profileSchemaUrl>http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/</profileSchemaUrl>
     38    <profileSchemaUrl>http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/{PROFILE_ID}/xsd</profileSchemaUrl>
    3939   
    4040    <componentRegistryRESTURL>http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/</componentRegistryRESTURL>
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/SearchPageQueryTest.java

    r2627 r2639  
    11package eu.clarin.cmdi.vlo;
    22
     3import eu.clarin.cmdi.vlo.config.VloConfig;
    34import eu.clarin.cmdi.vlo.pages.SearchPageQuery;
    45import org.apache.solr.client.solrj.response.FacetField;
     
    1213public class SearchPageQueryTest {
    1314
     15    // application configuration
     16    static VloConfig config;
     17
    1418    @Before
    1519    public void setup() {
    16         // Configuration.getInstance().setFacetFields(new String[] { "collection", "continent", "organisation", "genre", "country", "language" });
     20       
     21        // include the full path in the name of the packaged configuration file
     22        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     23
     24        // read the configuration defined in the file
     25        config = VloConfig.readTestConfig(fileName);
     26
     27        // optionally, modify the configuration here
    1728    }
    18    
     29
    1930    @Test
    2031    public void testQueryParse() throws Exception {
     
    2637        assertEquals(10, q.getSolrQuery().getFacetFields().length);
    2738        assertEquals("collection", q.getSolrQuery().getFacetFields()[0]);
    28         assertEquals("continent", q.getSolrQuery().getFacetFields()[1]);
     39        assertEquals("continent", q.getSolrQuery().getFacetFields()[2]);
    2940        assertNull(q.getSolrQuery().getFilterQueries());
    3041
     
    3647        assertEquals("test", q.getSolrQuery().getQuery());
    3748        assertEquals("name,id,description", q.getSolrQuery().getFields());
    38         assertEquals(6, q.getSolrQuery().getFacetFields().length);
     49        assertEquals(10, q.getSolrQuery().getFacetFields().length);
    3950        assertEquals("collection", q.getSolrQuery().getFacetFields()[0]);
    40         assertEquals("continent", q.getSolrQuery().getFacetFields()[1]);
     51        assertEquals("continent", q.getSolrQuery().getFacetFields()[2]);
    4152        assertEquals(1, q.getSolrQuery().getFilterQueries().length);
    4253        assertEquals("country:New\\ Zealand", q.getSolrQuery().getFilterQueries()[0]);
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/TestFacetedSearchPage.java

    r2627 r2639  
    1111public class TestFacetedSearchPage {
    1212   
    13     static VloConfig testConfig;
     13    // application configuration
     14    static VloConfig config;
    1415
    1516    @Before
     
    1819        WicketTester wicketTester;
    1920
     21        // include the full path in the name of the packaged configuration file
    2022        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
    2123
    22         testConfig = VloConfig.readTestConfig(fileName);
     24        // read the configuration defined in the file
     25        config = VloConfig.readTestConfig(fileName);
    2326
    2427        // optionally, modify the test configuration here
    2528
    26         wicketTester = new WicketTester(new VloApplication(testConfig));
     29        wicketTester = new WicketTester(new VloApplication(config));
    2730    }
    2831
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIDataProcessorTest.java

    r2494 r2639  
    11package eu.clarin.cmdi.vlo.importer;
    22
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertNotNull;
    5 import static org.junit.Assert.assertTrue;
    6 
     3import eu.clarin.cmdi.vlo.FacetConstants;
     4import eu.clarin.cmdi.vlo.config.VloConfig;
    75import java.io.File;
    86import java.util.ArrayList;
     
    119import java.util.Iterator;
    1210import java.util.List;
    13 
    1411import org.apache.solr.common.SolrInputDocument;
     12import static org.junit.Assert.assertEquals;
     13import static org.junit.Assert.assertNotNull;
     14import static org.junit.Assert.assertTrue;
     15import org.junit.Before;
    1516import org.junit.Test;
    16 
    17 import eu.clarin.cmdi.vlo.FacetConstants;
    1817
    1918public class CMDIDataProcessorTest extends ImporterTestcase {
     
    2221        return new CMDIParserVTDXML(MetadataImporter.POST_PROCESSORS);
    2322    }
    24 
     23   
    2524    @Test
    2625    public void testCreateCMDIDataFromCorpus() throws Exception {
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXMLTest.java

    r1314 r2639  
    11package eu.clarin.cmdi.vlo.importer;
    2 
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertNull;
    5 
    6 import org.junit.Test;
    72
    83import com.ximpleware.VTDGen;
    94import com.ximpleware.VTDNav;
     5import eu.clarin.cmdi.vlo.config.VloConfig;
     6import static org.junit.Assert.assertEquals;
     7import static org.junit.Assert.assertNull;
     8import org.junit.Before;
     9import org.junit.Test;
    1010
    1111public class CMDIParserVTDXMLTest {
     12
     13    static VloConfig config;
     14    // include the full path in the name of the packaged configuration file
     15   
     16    @Before
     17    public void setUp() {
     18        // application configuration
     19       
     20        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     21
     22        // optionally, check for file existence here
     23
     24        // read the configuration defined in the file
     25
     26        config = VloConfig.readConfig(fileName);
     27
     28        // optionally, modify the configuration here
     29
     30        // apparantly, this does not make the configuration available
     31    }
    1232
    1333    @Test
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/CountryNamePostProcessorTest.java

    r1043 r2639  
    11package eu.clarin.cmdi.vlo.importer;
    22
     3import eu.clarin.cmdi.vlo.config.VloConfig;
    34import static org.junit.Assert.assertEquals;
    4 
     5import org.junit.Before;
    56import org.junit.Test;
    67
     8public class CountryNamePostProcessorTest {
    79
    8 public class CountryNamePostProcessorTest {
     10    static VloConfig config;
     11    // include the full path in the name of the packaged configuration file
     12
     13    @Before
     14    public void setUp() {
     15        // application configuration
     16       
     17        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     18
     19        // optionally, check for file existence here
     20
     21        // read the configuration defined in the file
     22
     23        config = VloConfig.readConfig(fileName);
     24
     25        // optionally, modify the configuration here
     26
     27        // apparantly, this does not make the configuration available
     28    }
    929   
    1030    @Test
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java

    r2627 r2639  
    2323    }
    2424
     25    // application configuration
     26    static VloConfig config;
     27
    2528    @BeforeClass
    2629    public static void setup() {
     
    2932        testDir.mkdir();
    3033        testDir.deleteOnExit();
     34       
     35        // include the full path in the name of the packaged configuration file
     36        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     37
     38        // read the configuration defined in the file
     39        config = VloConfig.readTestConfig(fileName);
     40
     41        // optionally, modify the configuration here
     42       
    3143        VloConfig.get().setComponentRegistryRESTURL("http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/");
    3244    }
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/LanguageCodePostProcessorTest.java

    r1043 r2639  
    11package eu.clarin.cmdi.vlo.importer;
    22
     3import eu.clarin.cmdi.vlo.config.VloConfig;
    34import static org.junit.Assert.assertEquals;
    4 
     5import org.junit.Before;
    56import org.junit.Test;
    67
    78public class LanguageCodePostProcessorTest {
     9 
     10    // application configuration
     11    static VloConfig config;
     12
     13    @Before
     14    public void setUp() {
     15       
     16        // include the full path in the name of the packaged configuration file
     17        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     18
     19        // read the configuration defined in the file
     20        config = VloConfig.readTestConfig(fileName);
     21
     22        // optionally, modify the configuration here
     23    }
    824
    925    @Test
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/MetadataImporterTest.java

    r2604 r2639  
    1414import org.apache.solr.common.SolrInputDocument;
    1515import static org.junit.Assert.assertEquals;
     16import org.junit.Before;
    1617import org.junit.Test;
    1718
Note: See TracChangeset for help on using the changeset viewer.