You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JarPluginRepositoryTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2012-present the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.pf4j;
  17. import org.junit.jupiter.api.Test;
  18. import org.junit.jupiter.api.io.TempDir;
  19. import java.io.IOException;
  20. import java.nio.file.Files;
  21. import java.nio.file.Path;
  22. import java.util.List;
  23. import static org.junit.jupiter.api.Assertions.assertEquals;
  24. import static org.junit.jupiter.api.Assertions.assertFalse;
  25. import static org.junit.jupiter.api.Assertions.assertTrue;
  26. /**
  27. * @author Decebal Suiu
  28. */
  29. public class JarPluginRepositoryTest {
  30. @TempDir
  31. Path pluginsPath;
  32. /**
  33. * Test of {@link JarPluginRepository#deletePluginPath(Path)} method.
  34. */
  35. @Test
  36. public void testDeletePluginPath() throws IOException {
  37. PluginRepository repository = new JarPluginRepository(pluginsPath);
  38. Path plugin1Path = Files.createDirectory(pluginsPath.resolve("plugin-1"));
  39. Path plugin1JarPath = Files.createFile(pluginsPath.resolve("plugin-1.jar"));
  40. assertFalse(repository.deletePluginPath(plugin1Path));
  41. List<Path> pluginsPaths = repository.getPluginsPaths();
  42. assertEquals(1, pluginsPaths.size());
  43. assertTrue(repository.deletePluginPath(plugin1JarPath));
  44. pluginsPaths = repository.getPluginsPaths();
  45. assertEquals(0, pluginsPaths.size());
  46. }
  47. }