1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 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 "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.spi.config.support; 17 18 import static de.smartics.properties.test.domain.ValidConfigurationKey.KEY; 19 20 import java.io.IOException; 21 import java.io.InputStream; 22 23 import org.junit.Before; 24 import org.junit.Test; 25 import org.junit.experimental.categories.Category; 26 27 import de.smartics.properties.api.config.domain.ConfigurationLoadingException; 28 import de.smartics.testdoc.annotations.Uut; 29 import de.smartics.testdoc.categories.type.Coverage; 30 31 /** 32 * Tests {@link PropertiesHelper}. 33 */ 34 public class PropertiesHelperTest 35 { 36 // ********************************* Fields ********************************* 37 38 // --- constants ------------------------------------------------------------ 39 40 // --- members -------------------------------------------------------------- 41 42 @Uut 43 private PropertiesHelper uut; 44 45 // ****************************** Inner Classes ***************************** 46 47 // ********************************* Methods ******************************** 48 49 // --- prepare -------------------------------------------------------------- 50 51 @Before 52 public void setUp() 53 { 54 uut = new PropertiesHelper(KEY); 55 } 56 57 // --- helper --------------------------------------------------------------- 58 59 @Test(expected = ConfigurationLoadingException.class) 60 @Category(Coverage.class) 61 public void handlesIoProblems() 62 { 63 final InputStream saboteur = new InputStream() 64 { 65 /** 66 * {@inheritDoc} 67 * 68 * @see java.io.InputStream#read() 69 */ 70 @Override 71 public int read() throws IOException 72 { 73 throw new IOException("I'm a saboteuer!"); 74 } 75 }; 76 77 uut.readProperties("resourceId", saboteur); 78 } 79 80 // --- tests ---------------------------------------------------------------- 81 82 }