Changeset 2660


Ignore:
Timestamp:
03/07/13 09:54:21 (11 years ago)
Author:
keeloo
Message:

Made VloConfig? truly static.

Location:
vlo/branches/vlo-2.13-param
Files:
14 edited

Legend:

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

    r2659 r2660  
    129129     * @return the configuration
    130130     */
    131     public static VloConfig readPackagedConfig() {
     131    public static void readPackagedConfig() {
    132132       
    133133        // set the name of the packaged configuration file
    134134        String fileName = "/VloConfig";
    135135       
    136         config = VloConfig.readConfig (fileName);
     136        VloConfig.readConfig (fileName);
    137137       
    138         return config;
     138        // return config;
    139139    }
    140140   
     
    149149     * @return the configuration
    150150     */
    151     public static VloConfig readConfig(String fileName) {
     151    public static void readConfig(String fileName) {
    152152       
    153153        // may it is safe to first expand the name a litte bit more
     
    159159
    160160        // get the XML file configuration from the file by invoking ...
    161         config = (VloConfig) read(fileName, config);
    162 
    163         return config;
     161        read(fileName, config);
    164162    }
    165163
    166164    /**
    167165     * Read the configuration from an XML file.
     166     *
     167     * Move the following remarks to a general remark in the class description,
     168     * a remark indicating what you could do if you do not want to use the
     169     * packaged configuration.
    168170     *
    169171     * Invoke this method instead of readConfig() if you want to change
     
    177179     * container.
    178180     *     
    179      * @param fileName the name of the file to read the configuration from
    180      *
    181      * @return the configuration
    182      */
    183     public static VloConfig readTestConfig(String fileName) {
    184 
    185         config = VloConfig.readConfig (fileName);
    186        
    187         // modify the configuration here
    188 
    189         return config;
    190     }
     181     */
    191182
    192183    /**
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloContextConfig.java

    r2659 r2660  
    3838     * @return the configuration
    3939     */
    40     public static VloConfig switchToExternalConfig(ServletContext context) {
     40    public static void switchToExternalConfig(ServletContext context) {
    4141       
    4242        if (config == null) {
     
    7171            VloConfig.setSolrUrl(url);
    7272        }
    73        
    74         // return the current configuration, modified or not
    75         return (VloConfig)config;
    7673    }
    7774}
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java

    r2659 r2660  
    7676    }
    7777   
    78     // VLO configuration
    79     VloConfig config;
    80    
    8178    /**
    8279     * Constructor
     
    8481     * @param
    8582     */
    86     public MetadataImporter (VloConfig config){
    87         this.config = config;
     83    public MetadataImporter (){
    8884    }
    8985
     
    405401                // optionally, check for file existence here
    406402               
    407                 // read the configuration defined in the file
    408                 config = VloConfig.readTestConfig(fileName);
     403                // read the configuration from the externally supplied file
     404                VloConfig.readConfig(fileName);
    409405
    410406                // optionally, modify the configuration here
    411407               
    412408                // create and start the importer
    413                 MetadataImporter importer = new MetadataImporter(config);
     409                MetadataImporter importer = new MetadataImporter();
    414410                importer.startImport();
    415411               
    416412                // finished importing
    417413               
    418                 if (config.isPrintMapping()) {
     414                if (VloConfig.isPrintMapping()) {
    419415                    File file = new File("xsdMapping.txt");
    420416                    FacetMappingFactory.printMapping(file);
  • vlo/branches/vlo-2.13-param/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/importer/CMDIParserVTDXMLTest.java

    r2639 r2660  
    1010
    1111public class CMDIParserVTDXMLTest {
    12 
    13     static VloConfig config;
    14     // include the full path in the name of the packaged configuration file
    1512   
    1613    @Before
    1714    public void setUp() {
    18         // application configuration
    19        
    20         String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
    2115
    22         // optionally, check for file existence here
    23 
    24         // read the configuration defined in the file
    25 
    26         config = VloConfig.readConfig(fileName);
     16        // read the configuration from the packaged configuration file
     17        VloConfig.readPackagedConfig();
    2718
    2819        // optionally, modify the configuration here
  • vlo/branches/vlo-2.13-param/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/importer/CountryNamePostProcessorTest.java

    r2639 r2660  
    88public class CountryNamePostProcessorTest {
    99
    10     static VloConfig config;
    11     // include the full path in the name of the packaged configuration file
    12 
    1310    @Before
    1411    public void setUp() {
    15         // application configuration
    1612       
    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);
     13        // read the configuration from the packaged configuration file
     14        VloConfig.readPackagedConfig();
    2415
    2516        // optionally, modify the configuration here
    26 
    27         // apparantly, this does not make the configuration available
    2817    }
    2918   
     
    3827        assertEquals(null, processor.process(null));
    3928    }
    40 
    4129}
  • vlo/branches/vlo-2.13-param/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java

    r2659 r2660  
    2323    }
    2424
    25     // application configuration
    26     static VloConfig config;
    27 
    2825    @BeforeClass
    2926    public static void setup() {
     
    3330        testDir.deleteOnExit();
    3431       
    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);
     32        // read the configuration defined in the packaged configuration file
     33        VloConfig.readPackagedConfig();
    4034
    4135        // optionally, modify the configuration here
  • vlo/branches/vlo-2.13-param/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/importer/LanguageCodePostProcessorTest.java

    r2639 r2660  
    77
    88public class LanguageCodePostProcessorTest {
    9  
    10     // application configuration
    11     static VloConfig config;
    129
    1310    @Before
    1411    public void setUp() {
    1512       
    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);
     13        // read the configuration from the packaged configuration file
     14        VloConfig.readPackagedConfig();
    2115
    2216        // optionally, modify the configuration here
  • vlo/branches/vlo-2.13-param/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/importer/MetadataImporterTest.java

    r2659 r2660  
    236236        final List<SolrInputDocument> result = new ArrayList<SolrInputDocument>();
    237237       
    238         String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
    239        
    240         VloConfig testConfig;
    241        
    242238        /**
    243239         * Problem: at the moment the readTestConfig method is not prepared for
     
    251247         */
    252248
    253         testConfig = VloConfig.readTestConfig(fileName);
    254        
    255         // modify the test configuration a bit
    256        
    257         testConfig = modifyConfig(testConfig, rootFile);
    258        
    259         // ... and also the importer itself
     249        // testConfig = VloConfig.readTestConfig(fileName);
     250       
     251        VloConfig.readPackagedConfig();
     252       
     253        // make specific changes to the configuration
     254       
     255        modifyConfig(rootFile);
    260256       
    261257        MetadataImporter importer;
    262         importer = new MetadataImporter(testConfig) {
     258        importer = new MetadataImporter() {
    263259            @Override
    264260            protected void initSolrServer() throws MalformedURLException {
     
    277273    }
    278274
    279     private VloConfig modifyConfig(VloConfig config, File rootFile) {
     275    private void modifyConfig(File rootFile) {
    280276        DataRoot dataRoot = new DataRoot();
    281277        dataRoot.setDeleteFirst(false);//cannot delete not using real solrServer
     
    284280        dataRoot.setTostrip("");
    285281        dataRoot.setPrefix("http://example.com");
    286         config.setDataRoots(Collections.singletonList(dataRoot));
    287         return config;
     282        VloConfig.setDataRoots(Collections.singletonList(dataRoot));
    288283    }
    289284
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloWebApplication.java

    r2659 r2660  
    2020
    2121    private SearchResultsDao searchResults;
    22 
    23     // application configuration
    24     static VloConfig config;
    2522   
    2623    // flag indicating whether or not the application object lives in a context
     
    4744             */
    4845           
    49             config = VloContextConfig.switchToExternalConfig(servletContext);
     46            VloContextConfig.switchToExternalConfig(servletContext);
    5047        }
    5148
     
    6461
    6562        /**
    66          * Read the application's configuration.
     63         * Read the application's packaged configuration.
    6764         *
    6865         * Because on instantiation a web application cannot said to be living
     
    7269         */
    7370       
    74         config = VloConfig.readPackagedConfig();
     71        VloConfig.readPackagedConfig();
    7572
    7673        // let the {@literal init()} method know that there will be a context
     
    9794     * context associated with this container will be ignored.
    9895     */
    99     public VloWebApplication(VloConfig testConfig) {
     96    public VloWebApplication(Boolean param) {
    10097
    10198        // remember that the application does not live in a web server context
    10299       
    103         inContext = false;
    104        
    105         // set the current configuration to the test configuration
    106 
    107         config = testConfig;
     100        inContext = param;
    108101
    109102        searchResults = new SearchResultsDao();
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/main/webapp/WEB-INF/web.xml

    r2659 r2660  
    1818    <init-param>
    1919      <param-name>configuration</param-name>
    20 <!--      <param-value>development</param-value>-->
     20       <!-- <param-value>development</param-value> -->
    2121       <param-value>deployment</param-value> 
    22       <!-- you can override with -Dwicket.configuration=development -->
     22       <!-- you can override with -Dwicket.configuration=development -->
    2323    </init-param>
    2424  </filter>
     
    2929  </filter-mapping>
    3030
    31 
    3231</web-app>
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/test/java/eu/clarin/cmdi/vlo/SearchPageQueryTest.java

    r2641 r2660  
    1313public class SearchPageQueryTest {
    1414
    15     // application configuration
    16     static VloConfig config;
    17 
    1815    @Before
    1916    public void setup() {
    2017       
    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);
     18        // read the configuration from the packaged configuration file
     19        VloConfig.readPackagedConfig();
    2620
    2721        // optionally, modify the configuration here
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/test/java/eu/clarin/cmdi/vlo/TestFacetedSearchPage.java

    r2659 r2660  
    1010 */
    1111public class TestFacetedSearchPage {
    12    
    13     // application configuration
    14     static VloConfig config;
    1512
    1613    @Before
     
    1916        WicketTester wicketTester;
    2017
    21         // include the full path in the name of the packaged configuration file
    22         String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     18        // read the packaged configuration
     19        VloConfig.readPackagedConfig();
    2320
    24         // read the configuration defined in the file
    25         config = VloConfig.readTestConfig(fileName);
     21        // optionally, modify the configuration here
    2622
    27         // optionally, modify the test configuration here
    28 
    29         wicketTester = new WicketTester(new VloWebApplication(config));
     23        wicketTester = new WicketTester();
    3024    }
    3125
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/test/java/eu/clarin/cmdi/vlo/pages/FacetBoxPanelTest.java

    r2659 r2660  
    1313public class FacetBoxPanelTest {
    1414
    15     static VloConfig testConfig;
    16 
    1715    @Before
    1816    public void setUp() {
     17       
    1918        WicketTester wicketTester;
    2019       
    21         String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     20        // read the configuration from the package configuration file
     21        VloConfig.readPackagedConfig();
    2222       
    23         testConfig = VloConfig.readTestConfig(fileName);
     23        // optionally, modify the configuration here
    2424       
    25         // optionally, modify the test configuration here
    26        
    27         wicketTester = new WicketTester(new VloWebApplication(testConfig));
     25        // run the web application outside a web server container context
     26        wicketTester = new WicketTester(new VloWebApplication(false));
    2827    }
    2928
  • vlo/branches/vlo-2.13-param/vlo_web_app/src/test/java/eu/clarin/cmdi/vlo/pages/ResourceLinkPanelTest.java

    r2659 r2660  
    1111
    1212public class ResourceLinkPanelTest {
    13    
    14     static VloConfig testConfig;
    1513
    1614    public static final String _SAME_STRING = "http://blabla";
     
    2220        WicketTester wicketTester;
    2321
    24         String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     22        // read the configuration from the packaged configuration file
     23        VloConfig.readPackagedConfig();
    2524
    26         testConfig = VloConfig.readTestConfig(fileName);
    27 
    28         // optionally, modify the test configuration here
    29 
    30         wicketTester = new WicketTester(new VloWebApplication(testConfig));
     25        // optionally, modify the configuration here
     26       
     27        // run the web application outside a web server container context
     28        wicketTester = new WicketTester(new VloWebApplication(false));
    3129    }
    3230
Note: See TracChangeset for help on using the changeset viewer.