source: vlo/branches/vlo-3.3-oeaw/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/VloConfigMarshallerTest.java @ 6764

Last change on this file since 6764 was 6764, checked in by davor.ostojic@oeaw.ac.at, 9 years ago

test modifications wrt different facets (resTypeOrig, profileName, profileId)

File size: 2.8 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.vlo.config;
18
19import java.io.File;
20import java.io.InputStream;
21import java.io.StringWriter;
22import java.util.Arrays;
23import java.util.Properties;
24import javax.xml.transform.stream.StreamResult;
25import javax.xml.transform.stream.StreamSource;
26import static org.junit.Assert.assertEquals;
27import static org.junit.Assert.assertNotNull;
28import org.junit.Before;
29import org.junit.Test;
30import org.slf4j.Logger;
31import org.slf4j.LoggerFactory;
32
33/**
34 *
35 * @author twagoo
36 */
37public class VloConfigMarshallerTest {
38   
39    private final static String VLO_CONFIG_FILE = "/VloConfig.xml";
40    private final static Logger logger = LoggerFactory.getLogger(VloConfigMarshallerTest.class);
41    private VloConfigMarshaller instance;
42    private Properties testProps;
43   
44    @Before
45    public void setUp() throws Exception {
46        instance = new VloConfigMarshaller();
47        testProps = new Properties();
48        testProps.load(getClass().getResourceAsStream("/vloconfig.properties"));
49    }
50
51    /**
52     * Test of marshal method, of class VloConfigMarshaller.
53     */
54    @Test
55    public void testUnmarshal() throws Exception {
56        InputStream configFile = getClass().getResourceAsStream(VLO_CONFIG_FILE);
57        VloConfig config = instance.unmarshal(new StreamSource(configFile, getClass().getResource(VLO_CONFIG_FILE).toString()));
58        configFile.close();
59       
60        assertNotNull(config);
61        assertEquals(testProps.getProperty("solrUrl"), config.getSolrUrl());
62        assertEquals(16, config.getFacetFields().size());
63    }
64
65    /**
66     * Test of marshal method, of class VloConfigMarshaller.
67     */
68    @Test
69    public void testMarshal() throws Exception {
70        final VloConfig config = new VloConfig();
71        config.setSolrUrl("http://server/solr");
72        config.setDataRoots(Arrays.asList(new DataRoot("originName", new File("rootFile"), "prefix", "toStrip", Boolean.FALSE)));
73        config.setFacetFields(Arrays.asList("collection", "country", "continent"));
74        final StringWriter sw = new StringWriter();
75        instance.marshal(config, new StreamResult(sw));
76        logger.debug(sw.toString());
77    }
78   
79}
Note: See TracBrowser for help on using the repository browser.