Coverage Report - de.jollyday.datasource.impl.XmlFileDataSource
 
Classes in this File Line Coverage Branch Coverage Complexity
XmlFileDataSource
100%
6/6
N/A
4
 
 1  
 /**
 2  
  * Copyright 2013 Sven Diedrichsen 
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License"); 
 5  
  * you may not use this file except in compliance with the License. 
 6  
  * You may obtain a copy of the License at 
 7  
  * 
 8  
  * http://www.apache.org/licenses/LICENSE-2.0 
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software 
 11  
  * distributed under the License is distributed on an 
 12  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 13  
  * express or implied. See the License for the specific language 
 14  
  * governing permissions and limitations under the License. 
 15  
  */
 16  
 package de.jollyday.datasource.impl;
 17  
 
 18  
 import java.io.InputStream;
 19  
 
 20  
 import de.jollyday.ManagerParameter;
 21  
 import de.jollyday.config.Configuration;
 22  
 import de.jollyday.datasource.ConfigurationDataSource;
 23  
 import de.jollyday.util.XMLUtil;
 24  
 /**
 25  
  * This {@link ConfigurationDataSource} implementation reads XML files as resources
 26  
  * from the classpath.
 27  
  */
 28  77
 public class XmlFileDataSource implements ConfigurationDataSource {
 29  
         /**
 30  
          * XML utility class.
 31  
          */
 32  77
         private XMLUtil xmlUtil = new XMLUtil();
 33  
 
 34  
         @Override
 35  
         public Configuration getConfiguration(ManagerParameter parameter) {
 36  
                 try {
 37  76
                         final InputStream inputStream = parameter.createResourceUrl().openStream();
 38  75
                         return xmlUtil.unmarshallConfiguration(inputStream);
 39  1
                 } catch (Exception e) {
 40  1
                         throw new IllegalStateException("Cannot instantiate configuration.", e);
 41  
                 }
 42  
         }
 43  
         
 44  
 
 45  
 
 46  
 }