use of org.picocontainer.defaults.DefaultPicoContainer in project intellij-community by JetBrains.
the class ExtensionComponentAdapterTest method testUnknownAttributes.
@Test
public void testUnknownAttributes() {
String name = TestExtensionClassOne.class.getName();
Element element = readElement("<bean implementation=\"123\"/>");
DefaultPicoContainer container = new DefaultPicoContainer();
DefaultPluginDescriptor descriptor = new DefaultPluginDescriptor("test");
new ExtensionComponentAdapter(name, element, container, descriptor, false).getComponentInstance(container);
}
use of org.picocontainer.defaults.DefaultPicoContainer in project intellij-community by JetBrains.
the class ExtensionsImplTest method testTryPicoContainer2.
@Test
public void testTryPicoContainer2() {
DefaultPicoContainer rootContainer = new DefaultPicoContainer();
rootContainer.registerComponentImplementation("component1", MyComponent1.class);
rootContainer.registerComponentImplementation("component1.1", MyComponent1.class);
rootContainer.registerComponentImplementation("component2", MyComponent2.class);
rootContainer.registerComponentImplementation(MyTestComponent.class);
MyInterface1 testInstance = new MyInterface1() {
@Override
public void run() {
}
};
rootContainer.registerComponentInstance(testInstance);
MyTestComponent testComponent = (MyTestComponent) rootContainer.getComponentInstance(MyTestComponent.class);
MyComponent2 component2 = (MyComponent2) rootContainer.getComponentInstance("component2");
MyComponent1 component11 = (MyComponent1) rootContainer.getComponentInstance("component1.1");
MyComponent1 component1 = (MyComponent1) rootContainer.getComponentInstance("component1");
assertEquals(testInstance, component1.testObject);
assertEquals(testInstance, component2.testObject);
assertTrue(Arrays.asList(component2.comp1).contains(component1));
assertTrue(Arrays.asList(component2.comp1).contains(component11));
assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
assertEquals(component2, testComponent.comp2);
}
use of org.picocontainer.defaults.DefaultPicoContainer in project intellij-community by JetBrains.
the class ExtensionsImplTest method testExtensionsWithOrderingUpdate.
@Test
public void testExtensionsWithOrderingUpdate() {
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" id=\"_7\" order=\"LAST\"><text>7</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" id=\"fst\" order=\"FIRST\"><text>1</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" id=\"id\"><text>3</text></extension>"));
ExtensionPoint<TestExtensionClassOne> extensionPoint = extensionsArea.getExtensionPoint("ep1");
TestExtensionClassOne[] extensions = extensionPoint.getExtensions();
assertEquals(3, extensions.length);
assertEquals("1", extensions[0].getText());
assertEquals("3", extensions[1].getText());
assertEquals("7", extensions[2].getText());
TestExtensionClassOne extension = new TestExtensionClassOne("xxx");
extensionPoint.registerExtension(extension);
extensionPoint.unregisterExtension(extension);
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"BEFORE id\"><text>2</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"AFTER id\"><text>4</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"last, after _7\"><text>8</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"after:id, before _7, after fst\"><text>5</text></extension>"));
extensionPoint.registerExtension(new TestExtensionClassOne("6"));
extensions = extensionPoint.getExtensions();
assertEquals(8, extensions.length);
assertEquals("1", extensions[0].getText());
assertEquals("2", extensions[1].getText());
assertEquals("3", extensions[2].getText());
assertTrue("4".equals(extensions[3].getText()) || "5".equals(extensions[3].getText()));
assertTrue("4".equals(extensions[4].getText()) || "5".equals(extensions[4].getText()));
assertEquals("6", extensions[5].getText());
assertEquals("7", extensions[6].getText());
assertEquals("8", extensions[7].getText());
}
use of org.picocontainer.defaults.DefaultPicoContainer in project intellij-community by JetBrains.
the class ExtensionsImplTest method testExtensionsWithOrdering.
@Test
public void testExtensionsWithOrdering() {
ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"LAST\"><text>3</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\" order=\"FIRST\"><text>1</text></extension>"));
extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement("<extension point=\"ep1\"><text>2</text></extension>"));
ExtensionPoint extensionPoint = extensionsArea.getExtensionPoint("ep1");
TestExtensionClassOne[] extensions = (TestExtensionClassOne[]) extensionPoint.getExtensions();
assertEquals(3, extensions.length);
assertEquals("1", extensions[0].getText());
assertEquals("2", extensions[1].getText());
assertEquals("3", extensions[2].getText());
}
use of org.picocontainer.defaults.DefaultPicoContainer in project intellij-community by JetBrains.
the class ExtensionsImplTest method testTryPicoContainer.
@Test
public void testTryPicoContainer() {
DefaultPicoContainer rootContainer = new DefaultPicoContainer();
rootContainer.registerComponentInstance("plugin1", new DefaultPicoContainer(rootContainer));
rootContainer.registerComponentInstance("plugin2", new DefaultPicoContainer(rootContainer));
MutablePicoContainer container1 = (MutablePicoContainer) rootContainer.getComponentInstance("plugin1");
MutablePicoContainer container2 = (MutablePicoContainer) rootContainer.getComponentInstance("plugin2");
container1.registerComponentImplementation("component1", MyComponent1.class);
container1.registerComponentImplementation("component1.1", MyComponent1.class);
container2.registerComponentImplementation("component2", MyComponent2.class);
MyInterface1 testInstance = new MyInterface1() {
@Override
public void run() {
}
};
rootContainer.registerComponentInstance(testInstance);
MyComponent1 component1 = (MyComponent1) container1.getComponentInstance("component1");
assertEquals(testInstance, component1.testObject);
rootContainer.registerComponentInstance("component1", component1);
MyComponent1 component11 = (MyComponent1) container1.getComponentInstance("component1.1");
rootContainer.registerComponentInstance("component11", component11);
MyComponent2 component2 = (MyComponent2) container2.getComponentInstance("component2");
assertEquals(testInstance, component2.testObject);
assertTrue(Arrays.asList(component2.comp1).contains(component1));
assertTrue(Arrays.asList(component2.comp1).contains(component11));
rootContainer.registerComponentInstance("component2", component2);
rootContainer.registerComponentImplementation(MyTestComponent.class);
MyTestComponent testComponent = (MyTestComponent) rootContainer.getComponentInstance(MyTestComponent.class);
assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
assertEquals(component2, testComponent.comp2);
}
Aggregations