o Tried to make testing of an exception simpler,
but unfortunately the AbstractMojoTestCase
does not seem to support @Test(expected =..).
Moved the test to a separate JUnit 4 only test
case where it works.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1729076 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 6570288..fbef70a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -149,6 +149,12 @@
<version>2.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git a/src/test/java/org/apache/maven/plugins/resources/BasicPropertyUtilsTest.java b/src/test/java/org/apache/maven/plugins/resources/BasicPropertyUtilsTest.java
index 608b18d..35473b9 100644
--- a/src/test/java/org/apache/maven/plugins/resources/BasicPropertyUtilsTest.java
+++ b/src/test/java/org/apache/maven/plugins/resources/BasicPropertyUtilsTest.java
@@ -114,25 +114,4 @@
assertNull( prop.getProperty( "does_not_exist" ) );
}
- /**
- * load property test case can be adjusted by modifying the basic.properties and basic_validation properties
- *
- * @throws Exception
- */
- public void testException()
- throws Exception
- {
- boolean failed = false;
-
- try
- {
- Properties prop = PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), true, true );
- }
- catch ( Exception ex )
- {
- failed = true;
- }
-
- assertTrue( failed );
- }
}
diff --git a/src/test/java/org/apache/maven/plugins/resources/PropertyUtilsExceptionTest.java b/src/test/java/org/apache/maven/plugins/resources/PropertyUtilsExceptionTest.java
new file mode 100644
index 0000000..a0c00a9
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/resources/PropertyUtilsExceptionTest.java
@@ -0,0 +1,42 @@
+package org.apache.maven.plugins.resources;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.apache.maven.shared.filtering.PropertyUtils;
+import org.junit.Test;
+
+public class PropertyUtilsExceptionTest
+{
+
+ /**
+ * load property test case can be adjusted by modifying the basic.properties and basic_validation properties
+ *
+ * @throws Exception
+ */
+ @Test( expected = FileNotFoundException.class )
+ public void loadPropertyFileShouldFailWithFileNotFoundException()
+ throws Exception
+ {
+ PropertyUtils.loadPropertyFile( new File( "NON_EXISTENT_FILE" ), true, true );
+ }
+}