]> source.dussan.org Git - pf4j.git/commitdiff
Added test for DefaultPluginRepository
authorMário Franco <mario.ffranco@gmail.com>
Mon, 20 Jul 2015 19:57:51 +0000 (20:57 +0100)
committerMário Franco <mario.ffranco@gmail.com>
Mon, 20 Jul 2015 19:57:51 +0000 (20:57 +0100)
README.md
pf4j/src/test/java/ro/fortsoft/pf4j/DefaultPluginRepositoryTest.java [new file with mode: 0644]

index 044bb6ac6997f88823e4cd6c3f8aafca82b598d6..8b9183516203a3dea901fc53b0424c069bbb1137 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@ Plugin Framework for Java (PF4J)
 =====================
 
 [![Travis CI Build Status](https://travis-ci.org/decebals/pf4j.png)](https://travis-ci.org/decebals/pf4j)
+[![Coverage Status](https://coveralls.io/repos/decebals/pf4j/badge.svg?branch=master&service=github)](https://coveralls.io/github/decebals/pf4j?branch=master)
 [![Maven Central](http://img.shields.io/maven-central/v/ro.fortsoft.pf4j/pf4j.svg)](http://search.maven.org/#search|ga|1|pf4j)
 
 A plugin is a way for a third party to extend the functionality of an application. A plugin implements extension points
diff --git a/pf4j/src/test/java/ro/fortsoft/pf4j/DefaultPluginRepositoryTest.java b/pf4j/src/test/java/ro/fortsoft/pf4j/DefaultPluginRepositoryTest.java
new file mode 100644 (file)
index 0000000..5062d3c
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2015 Mario Franco.
+ *
+ * Licensed 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.
+ */
+package ro.fortsoft.pf4j;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import ro.fortsoft.pf4j.util.ZipFileFilter;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Mario Franco
+ */
+public class DefaultPluginRepositoryTest {
+
+    @Rule
+    public TemporaryFolder testFolder = new TemporaryFolder();
+
+    public DefaultPluginRepositoryTest() {
+    }
+
+    @Before
+    public void setUp() throws IOException {
+        testFolder.newFile("plugin-1.zip");
+        testFolder.newFile("plugin-2.zip");
+        testFolder.newFile("plugin-3.zi_");
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of getPluginArchives method, of class DefaultPluginRepository.
+     */
+    @Test
+    public void testGetPluginArchives() {
+
+        DefaultPluginRepository instance = new DefaultPluginRepository(testFolder.getRoot(), new ZipFileFilter());
+
+        List<File> result = instance.getPluginArchives();
+
+        assertEquals(2, result.size());
+        assertEquals(result.get(0).getName(), "plugin-1.zip");
+        assertEquals(result.get(1).getName(), "plugin-2.zip");
+    }
+
+    /**
+     * Test of deletePluginArchive method, of class DefaultPluginRepository.
+     */
+    @Test
+    public void testDeletePluginArchive() {
+        DefaultPluginRepository instance = new DefaultPluginRepository(testFolder.getRoot(), new ZipFileFilter());
+
+        assertEquals(true, instance.deletePluginArchive("/plugin-1"));
+
+        List<File> result = instance.getPluginArchives();
+
+        assertEquals(1, result.size());
+        assertEquals(result.get(0).getName(), "plugin-2.zip");
+
+    }
+
+}