You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by if...@apache.org on 2014/08/04 18:54:57 UTC

git commit: enforced use of TestResources as junit @Rule

Repository: maven-plugin-testing
Updated Branches:
  refs/heads/master 1ac163885 -> 058d763b5


enforced use of TestResources as junit @Rule

Signed-off-by: Igor Fedorenko <if...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/commit/058d763b
Tree: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/tree/058d763b
Diff: http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/diff/058d763b

Branch: refs/heads/master
Commit: 058d763b55bdde6d158a3cbc98c399c0ad3eeb89
Parents: 1ac1638
Author: Igor Fedorenko <if...@apache.org>
Authored: Mon Aug 4 20:54:49 2014 +0400
Committer: Igor Fedorenko <if...@apache.org>
Committed: Mon Aug 4 20:54:49 2014 +0400

----------------------------------------------------------------------
 .../plugin/testing/resources/TestResources.java |  5 +++
 .../testing/resources/TestResourcesTest.java    | 34 ++++++++++++++++++++
 2 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/058d763b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
index c3f41e7..e25f398 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
@@ -73,6 +73,11 @@ public class TestResources
     public File getBasedir( String project )
         throws IOException
     {
+        if ( name == null )
+        {
+            throw new IllegalStateException( getClass().getSimpleName()
+                + " must be a test class field annotated with org.junit.Rule" );
+        }
         File src = new File( projectsDir, project ).getCanonicalFile();
         Assert.assertTrue( "Test project directory does not exist: " + src.getPath(), src.isDirectory() );
         File basedir = new File( workDir, name + "_" + project ).getCanonicalFile();

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/058d763b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/resources/TestResourcesTest.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/resources/TestResourcesTest.java b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/resources/TestResourcesTest.java
new file mode 100644
index 0000000..c7a78e3
--- /dev/null
+++ b/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/resources/TestResourcesTest.java
@@ -0,0 +1,34 @@
+package org.apache.maven.plugin.testing.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 org.junit.Test;
+
+public class TestResourcesTest
+{
+    public TestResources resources = new TestResources();
+
+    @Test( expected = IllegalStateException.class )
+    public void testNoRuleAnnotation()
+        throws Exception
+    {
+        resources.getBasedir( "dummy" );
+    }
+}