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.

AbstractPluginManagerTest.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.pf4j.test.TestExtension;
  19. import org.pf4j.test.TestExtensionPoint;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import static org.junit.jupiter.api.Assertions.assertEquals;
  23. import static org.junit.jupiter.api.Assertions.assertNotEquals;
  24. import static org.mockito.Mockito.CALLS_REAL_METHODS;
  25. import static org.mockito.Mockito.mock;
  26. import static org.mockito.Mockito.when;
  27. /**
  28. * @author Decebal Suiu
  29. */
  30. public class AbstractPluginManagerTest {
  31. @Test
  32. public void getExtensionsByType() {
  33. AbstractPluginManager pluginManager = mock(AbstractPluginManager.class, CALLS_REAL_METHODS);
  34. ExtensionFinder extensionFinder = mock(ExtensionFinder.class);
  35. List<ExtensionWrapper<TestExtensionPoint>> extensionList = new ArrayList<>(1);
  36. extensionList.add(new ExtensionWrapper<>(new ExtensionDescriptor(0, TestExtension.class), new DefaultExtensionFactory()));
  37. when(extensionFinder.find(TestExtensionPoint.class)).thenReturn(extensionList);
  38. pluginManager.extensionFinder = extensionFinder;
  39. List<TestExtensionPoint> extensions = pluginManager.getExtensions(TestExtensionPoint.class);
  40. assertEquals(1, extensions.size());
  41. }
  42. @Test
  43. public void getVersion() {
  44. AbstractPluginManager pluginManager = mock(AbstractPluginManager.class, CALLS_REAL_METHODS);
  45. assertNotEquals("0.0.0", pluginManager.getVersion());
  46. }
  47. }