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.

DevelopmentPluginRepositoryTest.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.BeforeEach;
  18. import org.junit.jupiter.api.Test;
  19. import org.junit.jupiter.api.io.TempDir;
  20. import java.io.IOException;
  21. import java.nio.file.Files;
  22. import java.nio.file.Path;
  23. import java.util.List;
  24. import static org.junit.jupiter.api.Assertions.assertEquals;
  25. import static org.junit.jupiter.api.Assertions.assertFalse;
  26. /**
  27. * @author Decebal Suiu
  28. */
  29. public class DevelopmentPluginRepositoryTest {
  30. @TempDir
  31. Path pluginsPath;
  32. @BeforeEach
  33. public void setUp() throws IOException {
  34. // standard maven/gradle bin folder - these should be skipped in development mode because the cause errors
  35. Files.createDirectory(pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR));
  36. Files.createDirectory(pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR));
  37. }
  38. @Test
  39. public void testGetPluginArchivesInDevelopmentMode() {
  40. PluginRepository repository = new DevelopmentPluginRepository(pluginsPath);
  41. List<Path> pluginsPaths = repository.getPluginsPaths();
  42. // target and build should be ignored
  43. assertEquals(0, pluginsPaths.size());
  44. assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR));
  45. assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR));
  46. }
  47. private void assertPathDoesNotExists(List<Path> paths, Path path) {
  48. assertFalse(paths.contains(path), "The directory must not contain the file " + path);
  49. }
  50. }