2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.persist.storage.directory.autodetect;
10 import junit.framework.Assert;
11 import org.junit.Test;
12 import org.junit.matchers.JUnitMatchers;
16 public class FileTypeTest {
19 public void testPlaintext() throws Exception {
20 File file = getResourceAsFile("/test.txt.config");
22 FileType type = FileType.getFileType(file);
23 Assert.assertEquals(FileType.plaintext, type);
28 public void testXml() throws Exception {
29 File file = getResourceAsFile("/test.xml.config");
31 FileType type = FileType.getFileType(file);
32 Assert.assertEquals(FileType.xml, type);
35 @Test(expected = IllegalArgumentException.class)
36 public void testUnknown() throws Exception {
37 File file = getResourceAsFile("/unknown.config");
40 FileType.getFileType(file);
41 } catch (IllegalArgumentException e) {
42 org.junit.Assert.assertThat(e.getMessage(), JUnitMatchers.containsString("File " + file + " is not of permitted storage type"));
47 static File getResourceAsFile(String resource) {
48 String f = FileTypeTest.class.getResource(resource).getFile();