@@ -0,0 +1,3361 @@
+/*%0A * Copyright 2016 Datalogics Inc.%0A */%0A%0Apackage com.datalogics.pdf.hsm.samples.util;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.apache.commons.configuration2.Configuration;%0Aimport org.junit.AfterClass;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.nio.file.StandardCopyOption;%0A%0A/**%0A * Unit tests for the SampleConfigurationUtils.%0A */%0Apublic class SampleConfigurationUtilsTest %7B%0A    public static final String TEST_PROPERTIES_FILE = %22test.properties%22;%0A    public static final String PROPERTY_1 = %22property1%22;%0A    public static final String PROPERTY_1_VALUE = %22alpha%22;%0A%0A    @Rule%0A    public ExpectedException expected = ExpectedException.none();%0A%0A    @AfterClass%0A    public static void cleanUp() throws IOException %7B%0A        removePropertiesFileFromAllDirectories();%0A    %7D%0A%0A    /*%0A     * Helper methods%0A     */%0A    private static Path getCurrentWorkingDirectoryPath() %7B%0A        final Path currentDir = Paths.get(System.getProperty(%22user.dir%22));%0A        return currentDir.resolve(TEST_PROPERTIES_FILE);%0A    %7D%0A%0A    private static Path getUserHomeDirectoryPath() %7B%0A        final Path homeDir = Paths.get(System.getProperty(%22user.home%22));%0A        return homeDir.resolve(TEST_PROPERTIES_FILE);%0A    %7D%0A%0A    private static void removePropertiesFileFromAllDirectories() throws IOException %7B%0A        Files.deleteIfExists(getCurrentWorkingDirectoryPath());%0A        Files.deleteIfExists(getUserHomeDirectoryPath());%0A    %7D%0A%0A    private void copyPropertiesFileToCurrentWorkingDirectory() throws IOException %7B%0A        removePropertiesFileFromAllDirectories();%0A%0A        final InputStream properties = this.getClass().getResourceAsStream(TEST_PROPERTIES_FILE);%0A        Files.copy(properties, getCurrentWorkingDirectoryPath(), StandardCopyOption.REPLACE_EXISTING);%0A    %7D%0A%0A    private void copyPropertiesFileToUsersHomeDirectory() throws IOException %7B%0A        removePropertiesFileFromAllDirectories();%0A%0A        final InputStream properties = this.getClass().getResourceAsStream(TEST_PROPERTIES_FILE);%0A        Files.copy(properties, getUserHomeDirectoryPath(), StandardCopyOption.REPLACE_EXISTING);%0A    %7D%0A%0A    /*%0A     * Unit tests%0A     */%0A    @Test%0A    public void findPropertiesFileInCurrentWorkingDirectory() throws IOException %7B%0A        copyPropertiesFileToCurrentWorkingDirectory();%0A        final Configuration testConfiguration = SampleConfigurationUtils.getConfiguration(TEST_PROPERTIES_FILE);%0A        assertEquals(PROPERTY_1 + %22 value was not correct%22, PROPERTY_1_VALUE, testConfiguration.getString(PROPERTY_1));%0A    %7D%0A%0A    @Test%0A    public void findPropertiesFileInUsersHomeDirectory() throws IOException %7B%0A        copyPropertiesFileToUsersHomeDirectory();%0A        final Configuration testConfiguration = SampleConfigurationUtils.getConfiguration(TEST_PROPERTIES_FILE);%0A        assertEquals(PROPERTY_1 + %22 value was not correct%22, PROPERTY_1_VALUE, testConfiguration.getString(PROPERTY_1));%0A    %7D%0A%0A    @Test%0A    public void throwExceptionWhenPropertiesFileIsNotFound() throws IOException %7B%0A        removePropertiesFileFromAllDirectories();%0A        expected.expect(IOException.class);%0A        SampleConfigurationUtils.getConfiguration(TEST_PROPERTIES_FILE);%0A    %7D%0A%7D%0A

Add unit tests for the SampleConfigurationUtils class.