Browse Source

Externalize some useful classes from testing (#415)

pull/420/head
Decebal Suiu 4 years ago committed by GitHub
parent
commit
02c52acbd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      pf4j/pom.xml
  2. 14
      pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
  3. 4
      pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java
  4. 6
      pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java
  5. 4
      pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java
  6. 6
      pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java
  7. 4
      pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
  8. 2
      pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java
  9. 8
      pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java
  10. 6
      pf4j/src/test/java/org/pf4j/LegacyExtensionFinderTest.java
  11. 2
      pf4j/src/test/java/org/pf4j/LoadPluginsFromMultipleRootsTest.java
  12. 2
      pf4j/src/test/java/org/pf4j/LoadPluginsTest.java
  13. 2
      pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java
  14. 2
      pf4j/src/test/java/org/pf4j/PluginClassLoaderTest.java
  15. 4
      pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java
  16. 4
      pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java
  17. 5
      pf4j/src/test/java/org/pf4j/test/AnotherFailTestPlugin.java
  18. 2
      pf4j/src/test/java/org/pf4j/test/ClassDataProvider.java
  19. 2
      pf4j/src/test/java/org/pf4j/test/DefaultClassDataProvider.java
  20. 5
      pf4j/src/test/java/org/pf4j/test/FailTestExtension.java
  21. 5
      pf4j/src/test/java/org/pf4j/test/FailTestPlugin.java
  22. 2
      pf4j/src/test/java/org/pf4j/test/PluginJar.java
  23. 2
      pf4j/src/test/java/org/pf4j/test/PluginZip.java
  24. 4
      pf4j/src/test/java/org/pf4j/test/TestExtension.java
  25. 4
      pf4j/src/test/java/org/pf4j/test/TestExtensionPoint.java
  26. 7
      pf4j/src/test/java/org/pf4j/test/TestPlugin.java
  27. 6
      pf4j/src/test/java/org/pf4j/test/package-info.java
  28. 2
      pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java

12
pf4j/pom.xml

@ -66,6 +66,18 @@
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<includes>
<inculde>org/pf4j/test/*</inculde>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

14
pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java

@ -22,8 +22,8 @@ import java.util.Comparator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestPlugin;
import org.pf4j.plugin.TestExtensionPoint;
import org.pf4j.test.FailTestPlugin;
import org.pf4j.test.TestExtensionPoint;
import javax.tools.JavaFileObject;
import java.io.IOException;
@ -113,8 +113,8 @@ public class AbstractExtensionFinderTest {
Map<String, Set<String>> entries = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>();
bucket.add("org.pf4j.plugin.TestExtension");
bucket.add("org.pf4j.plugin.FailTestExtension");
bucket.add("org.pf4j.test.TestExtension");
bucket.add("org.pf4j.test.FailTestExtension");
entries.put(null, bucket);
return entries;
@ -138,11 +138,11 @@ public class AbstractExtensionFinderTest {
Map<String, Set<String>> entries = new LinkedHashMap<>();
Set<String> bucket = new HashSet<>();
bucket.add("org.pf4j.plugin.TestExtension");
bucket.add("org.pf4j.plugin.FailTestExtension");
bucket.add("org.pf4j.test.TestExtension");
bucket.add("org.pf4j.test.FailTestExtension");
entries.put("plugin1", bucket);
bucket = new HashSet<>();
bucket.add("org.pf4j.plugin.TestExtension");
bucket.add("org.pf4j.test.TestExtension");
entries.put("plugin2", bucket);
return entries;

4
pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java

@ -16,8 +16,8 @@
package org.pf4j;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.TestExtension;
import org.pf4j.plugin.TestExtensionPoint;
import org.pf4j.test.TestExtension;
import org.pf4j.test.TestExtensionPoint;
import java.util.ArrayList;
import java.util.List;

6
pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java

@ -17,9 +17,9 @@ package org.pf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginJar;
import org.pf4j.plugin.PluginZip;
import org.pf4j.plugin.TestPlugin;
import org.pf4j.test.PluginJar;
import org.pf4j.test.PluginZip;
import org.pf4j.test.TestPlugin;
import java.io.FileOutputStream;
import java.io.IOException;

4
pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java

@ -18,8 +18,8 @@ package org.pf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestExtension;
import org.pf4j.plugin.TestExtension;
import org.pf4j.test.FailTestExtension;
import org.pf4j.test.TestExtension;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

6
pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java

@ -16,9 +16,9 @@
package org.pf4j;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.AnotherFailTestPlugin;
import org.pf4j.plugin.FailTestPlugin;
import org.pf4j.plugin.TestPlugin;
import org.pf4j.test.AnotherFailTestPlugin;
import org.pf4j.test.FailTestPlugin;
import org.pf4j.test.TestPlugin;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;

4
pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java

@ -19,8 +19,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginJar;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginJar;
import org.pf4j.test.PluginZip;
import java.io.IOException;
import java.nio.file.Files;

2
pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java

@ -18,7 +18,7 @@ package org.pf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginZip;
import org.pf4j.util.FileUtils;
import java.io.IOException;

8
pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java

@ -19,10 +19,10 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginJar;
import org.pf4j.plugin.TestExtension;
import org.pf4j.plugin.TestExtensionPoint;
import org.pf4j.plugin.TestPlugin;
import org.pf4j.test.PluginJar;
import org.pf4j.test.TestExtension;
import org.pf4j.test.TestExtensionPoint;
import org.pf4j.test.TestPlugin;
import java.io.IOException;
import java.nio.file.Path;

6
pf4j/src/test/java/org/pf4j/LegacyExtensionFinderTest.java

@ -18,9 +18,9 @@ package org.pf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginJar;
import org.pf4j.plugin.TestExtension;
import org.pf4j.plugin.TestPlugin;
import org.pf4j.test.PluginJar;
import org.pf4j.test.TestExtension;
import org.pf4j.test.TestPlugin;
import java.nio.file.Path;
import java.util.Map;

2
pf4j/src/test/java/org/pf4j/LoadPluginsFromMultipleRootsTest.java

@ -18,7 +18,7 @@ package org.pf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginZip;
import org.pf4j.util.FileUtils;
import java.io.IOException;

2
pf4j/src/test/java/org/pf4j/LoadPluginsTest.java

@ -18,7 +18,7 @@ package org.pf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginZip;
import java.nio.file.Files;
import java.nio.file.Path;

2
pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java

@ -18,7 +18,7 @@ package org.pf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginJar;
import org.pf4j.test.PluginJar;
import java.io.FileOutputStream;
import java.io.IOException;

2
pf4j/src/test/java/org/pf4j/PluginClassLoaderTest.java

@ -20,7 +20,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginZip;
import org.pf4j.util.FileUtils;
import java.io.File;

4
pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java

@ -18,8 +18,8 @@ package org.pf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import org.pf4j.plugin.TestPlugin;
import org.pf4j.test.PluginZip;
import org.pf4j.test.TestPlugin;
import java.io.FileOutputStream;
import java.io.IOException;

4
pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java

@ -16,8 +16,8 @@
package org.pf4j;
import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestExtension;
import org.pf4j.plugin.TestExtension;
import org.pf4j.test.FailTestExtension;
import org.pf4j.test.TestExtension;
import java.io.File;
import java.net.MalformedURLException;

5
pf4j/src/test/java/org/pf4j/plugin/AnotherFailTestPlugin.java → pf4j/src/test/java/org/pf4j/test/AnotherFailTestPlugin.java

@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.Plugin;
/**
* A wrong {@link org.pf4j.Plugin}.
* It's wrong because it doesn't contain a constructor with one parameter ({@link org.pf4j.PluginWrapper} as parameter type).
*
* @author Mario Franco
*/
public class AnotherFailTestPlugin extends Plugin {

2
pf4j/src/test/java/org/pf4j/plugin/ClassDataProvider.java → pf4j/src/test/java/org/pf4j/test/ClassDataProvider.java

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
/**
* Defines the interface for classes that know to supply class data for a class name.

2
pf4j/src/test/java/org/pf4j/plugin/DefaultClassDataProvider.java → pf4j/src/test/java/org/pf4j/test/DefaultClassDataProvider.java

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

5
pf4j/src/test/java/org/pf4j/plugin/FailTestExtension.java → pf4j/src/test/java/org/pf4j/test/FailTestExtension.java

@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.Extension;
/**
* A wrong {@link org.pf4j.Extension}.
* It's wrong because it doesn't contain a constructor with empty parameters (or only the default constructor).
*
* @author Mario Franco
*/
@Extension

5
pf4j/src/test/java/org/pf4j/plugin/FailTestPlugin.java → pf4j/src/test/java/org/pf4j/test/FailTestPlugin.java

@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
/**
* A wrong {@link org.pf4j.Plugin}.
* It's wrong because it doesn't extends {@link org.pf4j.Plugin}.
*
* @author Mario Franco
*/
public class FailTestPlugin {

2
pf4j/src/test/java/org/pf4j/plugin/PluginJar.java → pf4j/src/test/java/org/pf4j/test/PluginJar.java

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.ManifestPluginDescriptorFinder;

2
pf4j/src/test/java/org/pf4j/plugin/PluginZip.java → pf4j/src/test/java/org/pf4j/test/PluginZip.java

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.PropertiesPluginDescriptorFinder;

4
pf4j/src/test/java/org/pf4j/plugin/TestExtension.java → pf4j/src/test/java/org/pf4j/test/TestExtension.java

@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.Extension;
/**
* A simple {@link Extension}. It implements {@link TestExtensionPoint}.
*
* @author Mario Franco
*/
@Extension

4
pf4j/src/test/java/org/pf4j/plugin/TestExtensionPoint.java → pf4j/src/test/java/org/pf4j/test/TestExtensionPoint.java

@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.ExtensionPoint;
/**
* A simple {@link ExtensionPoint} that contains one method ({@link #saySomething()}).
*
* @author Mario Franco
*/
public interface TestExtensionPoint extends ExtensionPoint {

7
pf4j/src/test/java/org/pf4j/plugin/TestPlugin.java → pf4j/src/test/java/org/pf4j/test/TestPlugin.java

@ -13,12 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pf4j.plugin;
package org.pf4j.test;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;
/**
* A simple {@link Plugin}.
*
* In real applications you don't need to create a plugin like this if you are not interested in lifecycle events.
* {@codes PF4J} will automatically create a plugin similar to this (empty / dummy) if no class plugin is specified.
*
* @author Mario Franco
*/
public class TestPlugin extends Plugin {

6
pf4j/src/test/java/org/pf4j/test/package-info.java

@ -0,0 +1,6 @@
/**
* Classes used to test different aspects of PF4J (plugins, extensions points, extensions).
*
* @author Decebal Suiu
*/
package org.pf4j.test;

2
pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java

@ -17,7 +17,7 @@ package org.pf4j.util;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import org.pf4j.test.PluginZip;
import java.nio.file.Files;
import java.nio.file.Path;

Loading…
Cancel
Save