Hello everyone,
I was looking forward to use the live table component, but it seems that you can only use it with Xwiki 1.9. I have xwiki 1.8, and I was wondering if it is possible to import only this component, instead of having the overhead of updating all xwiki just to use this component.
So, is it possible to import/install this component in version 1.8? If it is, how can I do it?
Thanks in advance!
BR,
Roney Castro
Business Efficiency Trainee
Gemalto
Tel: +55 11 5105-7670 - +55 11 7535-4135
Fax: +55 11 5105-7600
Av. das Nações Unidas, 12495, 8º Andar
05425-070 - São Paulo - SP - Brasil
roney.castro(a)gemalto.com<mailto:roney.castro@gemalto.com>
www.gemalto.com<http://www.gemalto.com>
[cid:image001.jpg@01CA053F.962B5060]
On Wed, Jul 15, 2009 at 15:48, Vincent Massol<vincent(a)massol.net> wrote:
>
> On Jul 15, 2009, at 2:57 PM, tmortagne (SVN) wrote:
>
>> Author: tmortagne
>> Date: 2009-07-15 14:57:40 +0200 (Wed, 15 Jul 2009)
>> New Revision: 21952
>>
>> Added:
>> Â platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> Modified:
>> Â platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/RoleHint.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java
>> Log:
>> XWIKI-4077: Component Manager should generate event when the
>> component is registered instead of initialized
>> XWIKI-4081: Add way to unregister component
>> XWIKI-4082: Add way to directly provide the component instance when
>> register it
>> * fixed some wrong javadoc/codestyle
>> * put back test on Class name instead of reference inside embedded
>> CM implementation
>
> [snip]
>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle              (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle  2009-07-15 12:57:40 UTC (rev 21952)
>> @@ -0,0 +1,7 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +
>> +<fileset-config file-format-version="1.2.0" simple-config="true">
>> + Â <fileset name="all" enabled="true" check-config-name="xwiki"
>> local="false">
>> + Â Â <file-match-pattern match-pattern="." include-pattern="true"/>
>> + Â </fileset>
>> +</fileset-config>
>
> it's back, hehe ;)
crap i did exactly the same mistake and forgot to pout it as ignore.
Would be greate to have to "put this as ignore instead of versionned".
>
> -Vincent
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
On Mon, Jul 13, 2009 at 22:44, Vincent Massol<vincent(a)massol.net> wrote:
> Hi Thomas,
>
> On Jul 13, 2009, at 3:20 PM, tmortagne (SVN) wrote:
>
>> Author: tmortagne
>> Date: 2009-07-13 15:20:03 +0200 (Mon, 13 Jul 2009)
>> New Revision: 21910
>>
>> Added:
>> Â platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> Modified:
>> Â platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java
>> Â platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java
>> Â platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java
>> Â platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java
>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java
>> Â platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java
>> Â platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java
>> Log:
>> XWIKI-4077: Component Manager should generate event when the
>> component is registered instead of initialized
>> XWIKI-4081: Add way to unregister component
>> XWIKI-4082: Add way to directly provide the component instance when
>> register it
>
> General comments:
> - Would be great if you could separate code reformatting from code
> changes. It makes it hard to read (I didn't read the commit fully as a
> consequence).
> - The code style has broken my styles in lots of places (see below for
> some comments, I haven't commented every single place it broke
> voluntary formatting).
>
> I'd like to vote for not applying code style blindly in the future. It
> breaks styles in lots of places and I hate it when I spend a good
> amount of my time to align code properly and it breaks it for
> producing suboptimal styling...
>
>> Modified: platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/
>> java/org/xwiki/cache/tests/AbstractTestCache.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java  2009-07-13 11:47:52 UTC
>> (rev 21909)
>> +++ platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java  2009-07-13 13:20:03 UTC
>> (rev 21910)
>> @@ -25,6 +25,7 @@
>> import org.jmock.Mock;
>> import org.xwiki.cache.CacheFactory;
>> import org.xwiki.cache.CacheManager;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.test.AbstractXWikiComponentTestCase;
>>
>> @@ -81,8 +82,12 @@
>> Â Â Â Â Mock mockConfigurationSource =
>> mock(ConfigurationSource.class);
>>
>> mockConfigurationSource
>> .stubs().method("getProperty").with(eq("cache.defaultCache"),
>> ANYTHING).will(
>> Â Â Â Â Â Â returnValue(this.roleHint));
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> "xwikiproperties",
>> - Â Â Â Â Â Â mockConfigurationSource.proxy());
>> +
>> + Â Â Â Â DefaultComponentDescriptor<ConfigurationSource> descriptor =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<ConfigurationSource>();
>> + Â Â Â Â descriptor.setRole(ConfigurationSource.class);
>> + Â Â Â Â descriptor.setRoleHint("xwikiproperties");
>> + Â Â Â Â getComponentManager().registerComponent(descriptor,
>> (ConfigurationSource) mockConfigurationSource.proxy());
>
> Maybe we'll need to find an easier way. Like creating a component
> descriptor automatically (without dependencies set). I see below that
> it adds a lot of code.
I prefer having a clean api, i we want a helper we can add one
somewhere but the api sould not contains 20 methods doing exactly the
same thing. We could simply add constructors to
DefaultComponentDescriptor.
>
> [snip]
>
>> Â Â }
>>
>> Â Â /**
>> @@ -111,7 +116,7 @@
>> Â Â Â */
>> Â Â public CacheFactory getCacheFactory() throws Exception
>> Â Â {
>> - Â Â Â Â CacheManager cacheManager = (CacheManager)
>> getComponentManager().lookup(CacheManager.class);
>> + Â Â Â Â CacheManager cacheManager =
>> getComponentManager().lookup(CacheManager.class);
>>
>> Â Â Â Â CacheFactory factory = cacheManager.getCacheFactory();
>>
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-api/
>> src/main/java/org/xwiki/component/manager/ComponentEventManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -26,18 +26,26 @@
>> Â * Manages Component Events (when a component instance is created
>> for example). It's recommended that implementations
>> Â * use the Observation module to send the events. We're introducing
>> this level of indirection in order to be able to
>> Â * perform some processing before the events are fired. For example
>> one implementation may want to stack the events
>> - * before sending them.
>> - *
>> + * before sending them.
>> + *
>> Â * @version $Id$
>> Â * @since 2.0M1
>> Â */
>> public interface ComponentEventManager
>> {
>> Â Â /**
>> - Â Â * Notify all listeners that a component with the passed
>> descriptor has been instantiated.
>> + Â Â * Notify all listeners that a component with the passed
>> descriptor has been registered.
>> Â Â Â *
>> - Â Â * @param <T> the component role type
>> Â Â Â * @param descriptor the descriptor for the instantiated component
>> + Â Â * @since 2.0M1
>> Â Â Â */
>> - Â Â <T> void notify(ComponentDescriptor<T> descriptor);
>> + Â Â void notifyComponentRegistered(ComponentDescriptor< ? >
>> descriptor);
>> +
>> + Â Â /**
>> + Â Â * Notify all listeners that a component with the passed
>> descriptor has been unregistered.
>> + Â Â *
>> + Â Â * @param descriptor the descriptor for the instantiated
>> component
>> + Â Â * @since 2.0M1
>> + Â Â */
>> + Â Â void notifyComponentUnregistered(ComponentDescriptor< ? >
>> descriptor);
>
> This doesn't look like it's been added in 2.0M1... ;)
Fixed
>
> [snip]
>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle              (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle  2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -0,0 +1,10 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +
>> +<fileset-config file-format-version="1.2.0" simple-config="true">
>> + Â <fileset name="all" enabled="true" check-config-name="xwiki"
>> local="false">
>> + Â Â <file-match-pattern match-pattern="." include-pattern="true"/>
>> + Â </fileset>
>> + Â <filter name="FilesFromPackage" enabled="true">
>> + Â Â <filter-data value="src/test/java"/>
>> + Â </filter>
>> +</fileset-config>
>
> This seems to have been added by error.
Fixed
>
> [snip]
>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#getComponentDescriptorList(Class)
>> Â Â Â */
>> Â Â @SuppressWarnings("unchecked")
>> Â Â public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> Â Â {
>> - Â Â Â Â synchronized(this) {
>> + Â Â Â Â synchronized (this) {
>> Â Â Â Â Â Â List<ComponentDescriptor<T>> results = new
>> ArrayList<ComponentDescriptor<T>>();
>> Â Â Â Â Â Â for (Map.Entry<RoleHint< ? >, ComponentDescriptor< ? >>
>> entry : this.descriptors.entrySet()) {
>> - Â Â Â Â Â Â Â Â if
>> (entry.getKey().getRole().getName().equals(role.getName())) {
>> + Â Â Â Â Â Â Â Â if (entry.getKey().getRole() == role) {
>
> I'm not sure about this change. I don't know why you've changed it.
>
> I think what you've done may fail if the classes have been loaded from
> a different class loader. Â Have you found a place in the Java spec
> mentioning that equals for Class will always compare the class name
> and not the class refefence?
>
> note: I've seen you've changed this in lots of place so it's important
> to be sure about what you're doing. I had done it this way to be on
> the safe side and so that it'll always work.
Since the idea is that EmbededCM is supposed to be a temporary and
unit test need and we don't have multiple classloader use case yet,
comparing strings look very expensive compared to reference
comparison. Also there was code which does not take care of that like
the one testing for LogEnabled so it can't really work and whithout
explicit comment or unit test I was not sure it was really a strong
goal... I'm reverting the code with some comments.
>
> [snip]
>
>> - Â Â Â Â Â Â Â Â Â Â &&
>> List.class.isAssignableFrom(dependency.getMappingType()))
>> - Â Â Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â if ((dependency.getMappingType() != null) &&
>> List.class.isAssignableFrom(dependency.getMappingType())) {
>> Â Â Â Â Â Â Â Â Â Â fieldValue = lookupList(dependency.getRole());
>> Â Â Â Â Â Â Â Â } else if ((dependency.getMappingType() != null)
>> - Â Â Â Â Â Â Â Â Â Â &&
>> Map.class.isAssignableFrom(dependency.getMappingType()))
>> - Â Â Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â Â Â &&
>> Map.class.isAssignableFrom(dependency.getMappingType())) {
>> Â Â Â Â Â Â Â Â Â Â fieldValue = lookupMap(dependency.getRole());
>> Â Â Â Â Â Â Â Â } else {
>> Â Â Â Â Â Â Â Â Â Â fieldValue = lookup(dependency.getRole(),
>> dependency.getRoleHint());
>> Â Â Â Â Â Â Â Â }
>> -
>> +
>> Â Â Â Â Â Â Â Â // Set the field by introspection
>> Â Â Â Â Â Â Â Â if (fieldValue != null) {
>> Â Â Â Â Â Â Â Â Â Â ReflectionUtils.setFieldValue(instance,
>> dependency.getName(), fieldValue);
>> @@ -313,16 +344,15 @@
>> Â Â Â Â Â Â if
>> (LogEnabled.class.isAssignableFrom(descriptor.getImplementation())) {
>> Â Â Â Â Â Â Â Â ((LogEnabled) instance).enableLogging(new
>> CommonsLoggingLogger(instance.getClass()));
>> Â Â Â Â Â Â }
>> -
>> +
>> Â Â Â Â Â Â // Composable
>> Â Â Â Â Â Â // Only support Composable for classes implementing
>> ComponentManager since for all other components
>> Â Â Â Â Â Â // they should have ComponentManager injected.
>> - Â Â Â Â Â Â if
>> (ComponentManager
>> .class.isAssignableFrom(descriptor.getImplementation())
>> - Â Â Â Â Â Â Â Â &&
>> Composable.class.isAssignableFrom(descriptor.getImplementation()))
>> - Â Â Â Â Â Â {
>> + Â Â Â Â Â Â if
>> (ComponentManager
>> .class.isAssignableFrom(descriptor.getImplementation())
>> + Â Â Â Â Â Â Â Â &&
>> Composable.class.isAssignableFrom(descriptor.getImplementation())) {
>> Â Â Â Â Â Â Â Â ((Composable) instance).compose(this);
>> Â Â Â Â Â Â }
>
> note that these code style changes  are not respecting what we had
> decided, ie that for long lines the wrapped line will be formatted as:
>
>
> if (.....
> Â && .....)
> {
> Â Â whatever
> }
>
>
>
>
>> -
>> +
>> Â Â Â Â Â Â // Initializable
>> Â Â Â Â Â Â if
>> (Initializable
>> .class.isAssignableFrom(descriptor.getImplementation())) {
>> Â Â Â Â Â Â Â Â ((Initializable) instance).initialize();
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/internal/
>> DefaultComponentManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -31,8 +31,8 @@
>> import org.xwiki.component.manager.ComponentRepositoryException;
>>
>> /**
>> - * Wraps the Component Manager in a component so that components
>> requiring the component Manager can
>> - * have it injected automatically.
>> + * Wraps the Component Manager in a component so that components
>> requiring the component Manager can have it injected
>> + * automatically.
>> Â *
>> Â * @version $Id$
>> Â * @since 2.0M1
>> @@ -47,6 +47,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see Composable#compose(ComponentManager)
>> Â Â Â */
>> Â Â public void compose(ComponentManager componentManager)
>> @@ -56,15 +57,17 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#getComponentDescriptor(Class, String)
>> Â Â Â */
>> Â Â public <T> ComponentDescriptor<T>
>> getComponentDescriptor(Class<T> role, String roleHint)
>> Â Â {
>> Â Â Â Â return this.componentManager.getComponentDescriptor(role,
>> roleHint);
>> Â Â }
>> -
>> +
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#getComponentDescriptorList(Class)
>> Â Â Â */
>> Â Â public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> @@ -74,6 +77,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#lookup(Class, String)
>> Â Â Â */
>> Â Â public <T> T lookup(Class<T> role, String roleHint) throws
>> ComponentLookupException
>> @@ -83,6 +87,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#lookup(Class)
>> Â Â Â */
>> Â Â public <T> T lookup(Class<T> role) throws ComponentLookupException
>> @@ -92,6 +97,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#lookupList(Class)
>> Â Â Â */
>> Â Â public <T> List<T> lookupList(Class<T> role) throws
>> ComponentLookupException
>> @@ -101,6 +107,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#lookupMap(Class)
>> Â Â Â */
>> Â Â public <T> Map<String, T> lookupMap(Class<T> role) throws
>> ComponentLookupException
>> @@ -110,6 +117,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#registerComponent(ComponentDescriptor)
>> Â Â Â */
>> Â Â public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor) throws ComponentRepositoryException
>> @@ -119,6 +127,29 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentManager
>> #registerComponent(org.xwiki.component.descriptor.ComponentDescriptor,
>> + Â Â * Â Â Â java.lang.Object)
>> + Â Â */
>
> Is this valid javadoc? I doubt it.
Why this would not be valid ?
Note that this wrapping on each dot is because of the mail, it's not
like that in the real source.
>
>> + Â Â public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor, T componentInstance)
>> + Â Â Â Â throws ComponentRepositoryException
>> + Â Â {
>> +
>> this.componentManager.registerComponent(componentDescriptor,
>> componentInstance);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager.ComponentManager#unregisterComponent(java.lang.Class,
>> java.lang.String)
>> + Â Â */
>> + Â Â public void unregisterComponent(Class< ? > role, String roleHint)
>> + Â Â {
>> + Â Â Â Â this.componentManager.unregisterComponent(role, roleHint);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#release(Object)
>> Â Â Â */
>> Â Â public <T> void release(T component) throws
>> ComponentLifecycleException
>> @@ -128,6 +159,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#hasComponent(Class, String)
>> Â Â Â */
>> Â Â public <T> boolean hasComponent(Class<T> role, String roleHint)
>> @@ -137,6 +169,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#hasComponent(Class)
>> Â Â Â */
>> Â Â public <T> boolean hasComponent(Class<T> role)
>> @@ -146,6 +179,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see
>> ComponentManager#setComponentEventManager(ComponentEventManager)
>> Â Â Â */
>> Â Â public void setComponentEventManager(ComponentEventManager
>> eventManager)
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -23,13 +23,15 @@
>>
>> import org.xwiki.component.descriptor.ComponentDescriptor;
>> import org.xwiki.component.manager.ComponentDescriptorAddedEvent;
>> +import org.xwiki.component.manager.ComponentDescriptorRemovedEvent;
>> import org.xwiki.component.manager.ComponentEventManager;
>> import org.xwiki.observation.ObservationManager;
>> +import org.xwiki.observation.event.Event;
>>
>> /**
>> - * Allow stacking component events and flush them whenever the user
>> of this class wants to. This is used for example
>> - * at application initialization time when we don't want to send
>> events before the Application Context has been
>> - * initialized since components subscribing to these events may
>> want to use the Application Context.
>> + * Allow stacking component events and flush them whenever the user
>> of this class wants to. This is used for example at
>> + * application initialization time when we don't want to send
>> events before the Application Context has been initialized
>> + * since components subscribing to these events may want to use the
>> Application Context.
>> Â *
>> Â * @version $Id$
>> Â * @since 2.0M1
>> @@ -37,48 +39,78 @@
>> public class StackingComponentEventManager implements
>> ComponentEventManager
>> {
>> Â Â private ObservationManager observationManager;
>> -
>> - Â Â private Stack<ComponentDescriptor< ? >> events = new
>> Stack<ComponentDescriptor< ? >>();
>> -
>> +
>> + Â Â private Stack<ComponentEventEntry> events = new
>> Stack<ComponentEventEntry>();
>> +
>> Â Â private boolean shouldStack = true;
>> -
>> +
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> - Â Â * @see ComponentEventManager#notify(ComponentDescriptor)
>> + Â Â *
>> + Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentEventManager
>> #notifyComponentRegistered
>> (org.xwiki.component.descriptor.ComponentDescriptor)
>> Â Â Â */
>> - Â Â public <T> void notify(ComponentDescriptor< T > descriptor)
>> + Â Â public void notifyComponentRegistered(ComponentDescriptor< ? >
>> descriptor)
>> Â Â {
>> - Â Â Â Â if (this.shouldStack) {
>> - Â Â Â Â Â Â synchronized (this) {
>> - Â Â Â Â Â Â Â Â this.events.push(descriptor);
>> - Â Â Â Â Â Â }
>> - Â Â Â Â } else {
>> - Â Â Â Â Â Â notifyInternal(descriptor);
>> - Â Â Â Â }
>> + Â Â Â Â notifyComponentEvent(new
>> ComponentDescriptorAddedEvent(descriptor.getRole(),
>> descriptor.getRoleHint()),
>> + Â Â Â Â Â Â descriptor);
>> Â Â }
>> -
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentEventManager
>> #notifyComponentUnregistered
>> (org.xwiki.component.descriptor.ComponentDescriptor)
>> + Â Â */
>> + Â Â public void notifyComponentUnregistered(ComponentDescriptor< ?
>> > descriptor)
>> + Â Â {
>> + Â Â Â Â notifyComponentEvent(new
>> ComponentDescriptorRemovedEvent(descriptor.getRole(),
>> descriptor.getRoleHint()),
>> + Â Â Â Â Â Â descriptor);
>> + Â Â }
>> +
>> Â Â public synchronized void flushEvents()
>> Â Â {
>> - Â Â Â Â while(!this.events.isEmpty()) {
>> - Â Â Â Â Â Â notifyInternal(events.remove(0));
>> + Â Â Â Â for (ComponentEventEntry entry : this.events) {
>> + Â Â Â Â Â Â sendEvent(entry.event, entry.descriptor);
>> Â Â Â Â }
>> Â Â }
>> -
>> +
>> Â Â public void shouldStack(boolean shouldStack)
>> Â Â {
>> Â Â Â Â this.shouldStack = shouldStack;
>> Â Â }
>> -
>> +
>> Â Â public void setObservationManager(ObservationManager
>> observationManager)
>> Â Â {
>> Â Â Â Â this.observationManager = observationManager;
>> Â Â }
>>
>> - Â Â private void notifyInternal(ComponentDescriptor< ? > descriptor)
>> + Â Â private void notifyComponentEvent(Event event,
>> ComponentDescriptor< ? > descriptor)
>> Â Â {
>> + Â Â Â Â if (this.shouldStack) {
>> + Â Â Â Â Â Â synchronized (this) {
>> + Â Â Â Â Â Â Â Â this.events.push(new ComponentEventEntry(event,
>> descriptor));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â } else {
>> + Â Â Â Â Â Â sendEvent(event, descriptor);
>> + Â Â Â Â }
>> + Â Â }
>> +
>> + Â Â private void sendEvent(Event event, ComponentDescriptor< ? >
>> descriptor)
>> + Â Â {
>> Â Â Â Â if (this.observationManager != null) {
>> - Â Â Â Â Â Â ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent(descriptor.getRole());
>> Â Â Â Â Â Â this.observationManager.notify(event, this, descriptor);
>> Â Â Â Â }
>> Â Â }
>> +
>> + Â Â static class ComponentEventEntry
>> + Â Â {
>> + Â Â Â Â public Event event;
>> +
>> + Â Â Â Â public ComponentDescriptor< ? > descriptor;
>> +
>> + Â Â Â Â public ComponentEventEntry(Event event,
>> ComponentDescriptor< ? > descriptor)
>> + Â Â Â Â {
>> + Â Â Â Â Â Â this.event = event;
>> + Â Â Â Â Â Â this.descriptor = descriptor;
>> + Â Â Â Â }
>> + Â Â }
>> }
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> ___________________________________________________________________
>> Name: svn:keywords
>> Â - Id
>>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-default/
>> src/main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java             (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -0,0 +1,100 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.component.manager;
>> +
>> +import org.xwiki.observation.event.Event;
>> +
>> +/**
>> + * Base class for events about components descriptors.
>> + *
>> + * @version $Id$
>> + * @since 2.0M1
>
> 2.0M2?
Fixed
>
> [snip]
>
>
>
>> + */
>> +public abstract class AbstractComponentDescriptorEvent implements
>> Event
>> +{
>> + Â Â private Class< ? > role;
>> +
>> + Â Â private String roleHint;
>> +
>> + Â Â /**
>> + Â Â * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> + Â Â */
>> + Â Â public AbstractComponentDescriptorEvent()
>> + Â Â {
>> + Â Â Â Â this.role = null;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> + Â Â */
>> + Â Â public AbstractComponentDescriptorEvent(Class< ? > role)
>> + Â Â {
>> + Â Â Â Â this.role = role;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param role the component role/rolehint to watch
>> + Â Â */
>> + Â Â public AbstractComponentDescriptorEvent(Class< ? > role, String
>> roleHint)
>> + Â Â {
>> + Â Â Â Â this.role = role;
>> + Â Â Â Â this.roleHint = roleHint;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @return the component's role being watched or null if all
>> components registrations are watched
>> + Â Â */
>> + Â Â public Class< ? > getRole()
>> + Â Â {
>> + Â Â Â Â return this.role;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @return the component's role hint being watched or null if
>> all role's components registrations are watched
>> + Â Â */
>> + Â Â public String getRoleHint()
>> + Â Â {
>> + Â Â Â Â return this.roleHint;
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see
>> org.xwiki.observation.event.Event#matches(java.lang.Object)
>> + Â Â */
>> + Â Â public boolean matches(Object otherEvent)
>> + Â Â {
>> + Â Â Â Â boolean result = false;
>> +
>> + Â Â Â Â if (otherEvent instanceof AbstractComponentDescriptorEvent) {
>> + Â Â Â Â Â Â // If we're watching all roles return a match
>> + Â Â Â Â Â Â if (getRole() == null) {
>> + Â Â Â Â Â Â Â Â result = true;
>> + Â Â Â Â Â Â } else {
>> + Â Â Â Â Â Â Â Â AbstractComponentDescriptorEvent event =
>> (AbstractComponentDescriptorEvent) otherEvent;
>> + Â Â Â Â Â Â Â Â if (getRole() == event.getRole()) {
>> + Â Â Â Â Â Â Â Â Â Â result = getRoleHint() == null ||
>> getRoleHint().equals(event.getRoleHint());
>> + Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â }
>> + Â Â Â Â }
>> +
>> + Â Â Â Â return result;
>> + Â Â }
>> +}
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> ___________________________________________________________________
>> Name: svn:mime-type
>> Â + text/plain
>> Name: svn:keywords
>> Â + Id
>> Name: svn:eol-style
>> Â + native
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -27,54 +27,45 @@
>> Â * @version $Id$
>> Â * @since 2.0M1
>> Â */
>> -public class ComponentDescriptorAddedEvent implements Event
>> +public class ComponentDescriptorAddedEvent extends
>> AbstractComponentDescriptorEvent
>> {
>> - Â Â private Class< ? > role;
>> -
>> Â Â /**
>> Â Â Â * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> Â Â Â */
>> Â Â public ComponentDescriptorAddedEvent()
>> Â Â {
>> - Â Â Â Â this.role = null;
>> +
>> Â Â }
>> -
>> +
>> Â Â /**
>> Â Â Â * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> Â Â Â */
>> Â Â public ComponentDescriptorAddedEvent(Class< ? > role)
>> Â Â {
>> - Â Â Â Â this.role = role;
>> + Â Â Â Â super(role);
>> Â Â }
>> -
>> +
>> Â Â /**
>> - Â Â * @return the component's role being watched or null if all
>> component registrations are watched
>> + Â Â * @param role the component role/rolehint to watch
>> Â Â Â */
>> - Â Â public Class< ? > getRole()
>> + Â Â public ComponentDescriptorAddedEvent(Class< ? > role, String
>> roleHint)
>> Â Â {
>> - Â Â Â Â return this.role;
>> + Â Â Â Â super(role, roleHint);
>> Â Â }
>> -
>> +
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see Event#matches(Object)
>> Â Â Â */
>> Â Â public boolean matches(Object otherEvent)
>> Â Â {
>> Â Â Â Â boolean result = false;
>> -
>> +
>> Â Â Â Â if
>> (ComponentDescriptorAddedEvent
>> .class.isAssignableFrom(otherEvent.getClass())) {
>> - Â Â Â Â Â Â // If we're watching all roles return a match
>> - Â Â Â Â Â Â if (getRole() == null) {
>> - Â Â Â Â Â Â Â Â result = true;
>> - Â Â Â Â Â Â } else {
>> - Â Â Â Â Â Â Â Â ComponentDescriptorAddedEvent event =
>> (ComponentDescriptorAddedEvent) otherEvent;
>> - Â Â Â Â Â Â Â Â if
>> (getRole().getName().equals(event.getRole().getName())) {
>> - Â Â Â Â Â Â Â Â Â Â result = true;
>> - Â Â Â Â Â Â Â Â }
>> - Â Â Â Â Â Â }
>> + Â Â Â Â Â Â result = super.matches(otherEvent);
>> Â Â Â Â }
>> -
>> - Â Â Â Â return result;
>> +
>> + Â Â Â Â return result;
>> Â Â }
>> }
>>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-default/
>> src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java              (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java  2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -0,0 +1,69 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.component.manager;
>> +
>> +/**
>> + * Event sent to tell that a new Component Descriptor has been
>> unregistered.
>> + *
>> + * @version $Id$
>> + * @since 2.0M2
>> + */
>> +public class ComponentDescriptorRemovedEvent extends
>> AbstractComponentDescriptorEvent
>> +{
>> + Â Â /**
>> + Â Â * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> + Â Â */
>> + Â Â public ComponentDescriptorRemovedEvent()
>> + Â Â {
>> +
>> + Â Â }
>
> This needs a comment to explain why it's empty since empty blocks
> trigger a checkstyle exception.
It's empty because there is nothing to do here and no it's not a
checkstyle error in empty constructors according to the mvn
checkstyle:check.
>
> [snip]
>
>
>
>> +
>> + Â Â /**
>> + Â Â * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> + Â Â */
>> + Â Â public ComponentDescriptorRemovedEvent(Class< ? > role)
>> + Â Â {
>> + Â Â Â Â super(role);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * @param role the component role/rolehint to watch
>> + Â Â */
>> + Â Â public ComponentDescriptorRemovedEvent(Class< ? > role, String
>> roleHint)
>> + Â Â {
>> + Â Â Â Â super(role, roleHint);
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â *
>> + Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager.AbstractComponentDescriptorEvent#matches(java.lang.Object)
>> + Â Â */
>> + Â Â public boolean matches(Object otherEvent)
>> + Â Â {
>> + Â Â Â Â boolean result = false;
>> +
>> + Â Â Â Â if
>> (ComponentDescriptorRemovedEvent
>> .class.isAssignableFrom(otherEvent.getClass())) {
>> + Â Â Â Â Â Â result = super.matches(otherEvent);
>> + Â Â Â Â }
>> +
>> + Â Â Â Â return result;
>> + Â Â }
>> +}
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> ___________________________________________________________________
>> Name: svn:mime-type
>> Â + text/plain
>> Name: svn:keywords
>> Â + Id
>> Name: svn:eol-style
>> Â + native
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java  2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java  2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -26,6 +26,7 @@
>> import org.junit.Test;
>> import org.xwiki.component.descriptor.ComponentDescriptor;
>> import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> +import org.xwiki.component.manager.ComponentLookupException;
>>
>> /**
>> Â * Unit tests for {@link EmbeddableComponentManager}.
>> @@ -38,20 +39,20 @@
>> Â Â public static interface Role
>> Â Â {
>> Â Â }
>> -
>> +
>> Â Â public static class RoleImpl implements Role
>> Â Â {
>> Â Â }
>> -
>> +
>> Â Â public static class OtherRoleImpl implements Role
>> Â Â {
>> Â Â }
>> -
>> +
>> Â Â @Test
>> Â Â public void testGetComponentDescriptorList() throws Exception
>> Â Â {
>> Â Â Â Â EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> -
>> +
>> Â Â Â Â DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> Â Â Â Â d1.setRole(Role.class);
>> Â Â Â Â d1.setRoleHint("hint1");
>> @@ -61,13 +62,13 @@
>> Â Â Â Â d2.setRole(Role.class);
>> Â Â Â Â d2.setRoleHint("hint2");
>> Â Â Â Â ecm.registerComponent(d2);
>> -
>> +
>> Â Â Â Â List<ComponentDescriptor<Role>> cds =
>> ecm.getComponentDescriptorList(Role.class);
>> Â Â Â Â Assert.assertEquals(2, cds.size());
>> Â Â Â Â Assert.assertTrue(cds.contains(d1));
>> Â Â Â Â Assert.assertTrue(cds.contains(d2));
>> Â Â }
>> -
>> +
>> Â Â @Test
>> Â Â public void testRegisterComponentOverExistingOne() throws
>> Exception
>> Â Â {
>> @@ -79,14 +80,50 @@
>> Â Â Â Â ecm.registerComponent(d1);
>>
>> Â Â Â Â Object instance = ecm.lookup(Role.class);
>> - Â Â Â Â Assert.assertEquals(RoleImpl.class.getName(),
>> instance.getClass().getName());
>> -
>> + Â Â Â Â Assert.assertSame(RoleImpl.class, instance.getClass());
>> +
>> Â Â Â Â DefaultComponentDescriptor<Role> d2 = new
>> DefaultComponentDescriptor<Role>();
>> Â Â Â Â d2.setRole(Role.class);
>> Â Â Â Â d2.setImplementation(OtherRoleImpl.class);
>> Â Â Â Â ecm.registerComponent(d2);
>>
>> Â Â Â Â instance = ecm.lookup(Role.class);
>> - Â Â Â Â Assert.assertEquals(OtherRoleImpl.class.getName(),
>> instance.getClass().getName());
>> + Â Â Â Â Assert.assertSame(OtherRoleImpl.class, instance.getClass());
>> Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testRegisterComponentInstance() throws Exception
>> + Â Â {
>> + Â Â Â Â EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> +
>> + Â Â Â Â DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> + Â Â Â Â d1.setRole(Role.class);
>> + Â Â Â Â d1.setImplementation(RoleImpl.class);
>> + Â Â Â Â Role instance = new RoleImpl();
>> + Â Â Â Â ecm.registerComponent(d1, instance);
>> +
>> + Â Â Â Â Assert.assertSame(instance, ecm.lookup(Role.class));
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testUnregisterComponent() throws Exception
>> + Â Â {
>> + Â Â Â Â EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> +
>> + Â Â Â Â DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> + Â Â Â Â d1.setRole(Role.class);
>> + Â Â Â Â d1.setImplementation(RoleImpl.class);
>> + Â Â Â Â ecm.registerComponent(d1);
>> +
>> + Â Â Â Â Assert.assertSame(RoleImpl.class,
>> ecm.lookup(Role.class).getClass());
>> +
>> + Â Â Â Â ecm.unregisterComponent(d1.getRole(), d1.getRoleHint());
>> +
>> + Â Â Â Â try {
>> + Â Â Â Â Â Â ecm.lookup(d1.getRole());
>> + Â Â Â Â Â Â Assert.fail("Should have thrown a
>> ComponentLookupException");
>> + Â Â Â Â } catch (ComponentLookupException e) {
>> + Â Â Â Â Â Â // expected
>> + Â Â Â Â }
>> + Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java     2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java     2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -38,34 +38,36 @@
>> Â Â private static class Dummy
>> Â Â {
>> Â Â }
>> -
>> +
>> Â Â @Test
>> Â Â public void testMatchesAllComponentRoles()
>> Â Â {
>> Â Â Â Â ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent();
>> Â Â Â Â // Note: We use any class for the test but it's supposed to
>> be a component role class.
>> - Â Â Â Â Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class)));
>> + Â Â Â Â Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class, "rolehint")));
>> Â Â }
>>
>> Â Â @Test
>> Â Â public void testMatchesWhenDifferentEvent()
>> Â Â {
>> Â Â Â Â ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent();
>> - Â Â Â Â Assert.assertFalse(event.matches(new Event() {
>> + Â Â Â Â Assert.assertFalse(event.matches(new Event()
>> + Â Â Â Â {
>> Â Â Â Â Â Â public boolean matches(Object otherEvent)
>> Â Â Â Â Â Â {
>> Â Â Â Â Â Â Â Â return false;
>> Â Â Â Â Â Â }
>> Â Â Â Â }));
>> Â Â }
>> -
>> +
>> Â Â @Test
>> Â Â public void testMatchesWhenSpecificRoleSpecified()
>> Â Â {
>> Â Â Â Â // Note: We use any class for the test but it's supposed to
>> be a component role class.
>> Â Â Â Â ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent(Dummy.class);
>> - Â Â Â Â Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class)));
>> + Â Â Â Â Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class, "rolehint")));
>> Â Â Â Â // Use a different class so that it doesn't match
>> - Â Â Â Â Assert.assertFalse(event.matches(new
>> ComponentDescriptorAddedEvent(ComponentDescriptorAddedEvent.class)));
>> + Â Â Â Â Assert.assertFalse(event.matches(new
>> ComponentDescriptorAddedEvent(ComponentDescriptorAddedEvent.class,
>> + Â Â Â Â Â Â "rolehint")));
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/
>> test/AbstractBridgedXWikiComponentTestCase.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java   2009-07-13 11:47:52 UTC
>> (rev 21909)
>> +++ platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java   2009-07-13 13:20:03 UTC
>> (rev 21910)
>> @@ -20,6 +20,7 @@
>> package com.xpn.xwiki.test;
>>
>> import org.jmock.Mock;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.manager.ComponentManager;
>> import org.xwiki.container.Container;
>> import org.xwiki.context.Execution;
>> @@ -67,7 +68,9 @@
>>
>> Â Â Â Â Mock mockCoreConfiguration = mock(CoreConfiguration.class);
>>
>> mockCoreConfiguration
>> .stubs().method("getDefaultDocumentSyntax").will(returnValue("xwiki/
>> 1.0"));
>> -
>> getComponentManager().registerComponent(CoreConfiguration.class,
>> mockCoreConfiguration.proxy());
>> + Â Â Â Â DefaultComponentDescriptor<CoreConfiguration> descriptor =
>> new DefaultComponentDescriptor<CoreConfiguration>();
>> + Â Â Â Â descriptor.setRole(CoreConfiguration.class);
>> + Â Â Â Â getComponentManager().registerComponent(descriptor,
>> (CoreConfiguration) mockCoreConfiguration.proxy());
>> Â Â }
>>
>> Â Â @Override
>>
>> Modified: platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/
>> plexus/manager/PlexusComponentManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java  2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java  2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -52,6 +52,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#hasComponent(Class, String)
>> Â Â Â */
>> Â Â public <T> boolean hasComponent(Class<T> role, String roleHint)
>> @@ -61,6 +62,7 @@
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#hasComponent(Class)
>> Â Â Â */
>> Â Â public <T> boolean hasComponent(Class<T> role)
>> @@ -73,7 +75,8 @@
>> Â Â Â *
>> Â Â Â * @see org.xwiki.component.manager.ComponentManager#lookup(Class)
>> Â Â Â */
>> - Â Â public <T> T lookup(Class< T > role) throws
>> ComponentLookupException
>> + Â Â @SuppressWarnings("unchecked")
>> + Â Â public <T> T lookup(Class<T> role) throws
>> ComponentLookupException
>> Â Â {
>> Â Â Â Â T result;
>> Â Â Â Â try {
>> @@ -90,7 +93,8 @@
>> Â Â Â *
>> Â Â Â * @see
>> org.xwiki.component.manager.ComponentManager#lookup(Class, String)
>> Â Â Â */
>> - Â Â public <T> T lookup(Class< T > role, String roleHint) throws
>> ComponentLookupException
>> + Â Â @SuppressWarnings("unchecked")
>> + Â Â public <T> T lookup(Class<T> role, String roleHint) throws
>> ComponentLookupException
>> Â Â {
>> Â Â Â Â T result;
>> Â Â Â Â try {
>> @@ -108,7 +112,8 @@
>> Â Â Â *
>> Â Â Â * @see
>> org.xwiki.component.manager.ComponentManager#lookupMap(Class)
>> Â Â Â */
>> - Â Â public <T> Map<String, T> lookupMap(Class< T > role) throws
>> ComponentLookupException
>> + Â Â @SuppressWarnings("unchecked")
>> + Â Â public <T> Map<String, T> lookupMap(Class<T> role) throws
>> ComponentLookupException
>> Â Â {
>> Â Â Â Â Map<String, T> result;
>> Â Â Â Â try {
>> @@ -125,7 +130,8 @@
>> Â Â Â *
>> Â Â Â * @see
>> org.xwiki.component.manager.ComponentManager#lookupList(Class)
>> Â Â Â */
>> - Â Â public <T> List< T > lookupList(Class< T > role) throws
>> ComponentLookupException
>> + Â Â @SuppressWarnings("unchecked")
>> + Â Â public <T> List<T> lookupList(Class<T> role) throws
>> ComponentLookupException
>> Â Â {
>> Â Â Â Â List<T> result;
>> Â Â Â Â try {
>> @@ -156,8 +162,7 @@
>> Â Â Â *
>> Â Â Â * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentManager
>> #registerComponent(org.xwiki.component.descriptor.ComponentDescriptor)
>> Â Â Â */
>> - Â Â public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor)
>> - Â Â Â Â throws ComponentRepositoryException
>> + Â Â public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor) throws ComponentRepositoryException
>> Â Â {
>> Â Â Â Â org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd =
>> Â Â Â Â Â Â createPlexusComponentDescriptor(componentDescriptor);
>> @@ -169,22 +174,37 @@
>> Â Â Â Â }
>> Â Â }
>>
>> + Â Â public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor, T componentInstance)
>> + Â Â Â Â throws ComponentRepositoryException
>> + Â Â {
>> + Â Â Â Â // TODO: find what to do here
>> + Â Â Â Â throw new RuntimeException("Not implemented");
>> + Â Â }
>> +
>> + Â Â public void unregisterComponent(Class< ? > role, String roleHint)
>> + Â Â {
>> + Â Â Â Â // TODO: find what to do here
>> + Â Â Â Â throw new RuntimeException("Not implemented");
>> + Â Â }
>> +
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#getComponentDescriptor(Class, String)
>> Â Â Â * @since 2.0M1
>> Â Â Â */
>> - Â Â public <T> ComponentDescriptor<T> getComponentDescriptor(Class<
>> T > role, String roleHint)
>> + Â Â public <T> ComponentDescriptor<T>
>> getComponentDescriptor(Class<T> role, String roleHint)
>> Â Â {
>> - Â Â Â Â return createXWikiComponentDescriptor(
>> -
>> this.plexusContainer.getComponentDescriptor(role.getName(),
>> roleHint));
>> + Â Â Â Â return
>> createXWikiComponentDescriptor
>> (this.plexusContainer.getComponentDescriptor(role.getName(),
>> roleHint));
>> Â Â }
>> -
>> +
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see ComponentManager#getComponentDescriptorList(Class)
>> Â Â Â * @since 2.0M1
>> Â Â Â */
>> + Â Â @SuppressWarnings("unchecked")
>> Â Â public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> Â Â {
>>
>> List<org.codehaus.plexus.component.repository.ComponentDescriptor>
>> pcds =
>> @@ -194,11 +214,13 @@
>> Â Â Â Â for
>> (org.codehaus.plexus.component.repository.ComponentDescriptor pcd :
>> pcds) {
>> Â Â Â Â Â Â results.add((ComponentDescriptor<T>)
>> createXWikiComponentDescriptor(pcd));
>> Â Â Â Â }
>> +
>> Â Â Â Â return results;
>> Â Â }
>>
>> Â Â /**
>> Â Â Â * {@inheritDoc}
>> + Â Â *
>> Â Â Â * @see
>> ComponentManager#setComponentEventManager(ComponentEventManager)
>> Â Â Â */
>> Â Â public void setComponentEventManager(ComponentEventManager
>> eventManager)
>> @@ -206,23 +228,24 @@
>> Â Â Â Â // Do nothing since there's no hook to get Plexus Events.
>> Â Â }
>>
>> + Â Â @SuppressWarnings("unchecked")
>> Â Â private <T> ComponentDescriptor<T> createXWikiComponentDescriptor(
>> Â Â Â Â org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd)
>> Â Â {
>> Â Â Â Â DefaultComponentDescriptor<T> descriptor = null;
>> -
>> +
>> Â Â Â Â if (pcd != null) {
>> Â Â Â Â Â Â descriptor = new DefaultComponentDescriptor<T>();
>> Â Â Â Â Â Â descriptor.setImplementation((Class< ? extends T>)
>> loadClass(pcd.getImplementation()));
>> Â Â Â Â Â Â descriptor.setRoleHint(pcd.getRoleHint());
>> Â Â Â Â Â Â descriptor.setRole((Class<T>) loadClass(pcd.getRole()));
>> -
>> +
>> Â Â Â Â Â Â if ("per-lookup".equals(pcd.getInstantiationStrategy())) {
>>
>> descriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP);
>> Â Â Â Â Â Â } else {
>>
>> descriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
>> Â Â Â Â Â Â }
>> -
>> +
>> Â Â Â Â Â Â // Copy dependencies
>> Â Â Â Â Â Â for (ComponentRequirement requirement :
>> (List<ComponentRequirement>) pcd.getRequirements()) {
>> Â Â Â Â Â Â Â Â DefaultComponentDependency dependency = new
>> DefaultComponentDependency();
>> @@ -230,18 +253,18 @@
>> Â Â Â Â Â Â Â Â dependency.setRoleHint(requirement.getRoleHint());
>>
>> dependency
>> .setMappingType(loadClass(requirement.getFieldMappingType()));
>> Â Â Â Â Â Â Â Â dependency.setName(requirement.getFieldName());
>> -
>> +
>> Â Â Â Â Â Â Â Â // TODO: Handle specific hints when we move to a
>> more recent Plexus version.
>> Â Â Â Â Â Â Â Â // See createPlexusComponentDescriptor
>> Â Â Â Â Â Â Â Â descriptor.addComponentDependency(dependency);
>> Â Â Â Â Â Â }
>> Â Â Â Â }
>> -
>> - Â Â Â Â return descriptor;
>> +
>> + Â Â Â Â return descriptor;
>> Â Â }
>> -
>> +
>> Â Â private
>> org.codehaus.plexus.component.repository.ComponentDescriptor
>> createPlexusComponentDescriptor(
>> - Â Â Â Â ComponentDescriptor<?> componentDescriptor)
>> + Â Â Â Â ComponentDescriptor< ? > componentDescriptor)
>> Â Â {
>> Â Â Â Â org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd =
>> Â Â Â Â Â Â new
>> org.codehaus.plexus.component.repository.ComponentDescriptor();
>> @@ -249,7 +272,7 @@
>> Â Â Â Â pcd.setRole(componentDescriptor.getRole().getName());
>> Â Â Â Â pcd.setRoleHint(componentDescriptor.getRoleHint());
>>
>> pcd
>> .setImplementation(componentDescriptor.getImplementation().getName());
>> -
>> +
>> Â Â Â Â switch (componentDescriptor.getInstantiationStrategy()) {
>> Â Â Â Â Â Â case PER_LOOKUP:
>> Â Â Â Â Â Â Â Â pcd.setInstantiationStrategy("per-lookup");
>> @@ -258,22 +281,19 @@
>> Â Â Â Â Â Â Â Â pcd.setInstantiationStrategy("singleton");
>> Â Â Â Â }
>>
>> - Â Â Â Â Collection<ComponentDependency<?>> componentDependencies =
>> componentDescriptor.getComponentDependencies();
>> - Â Â Â Â for (ComponentDependency<?> dependency :
>> componentDependencies) {
>> + Â Â Â Â Collection<ComponentDependency< ? >> componentDependencies
>> = componentDescriptor.getComponentDependencies();
>> + Â Â Â Â for (ComponentDependency< ? > dependency :
>> componentDependencies) {
>> Â Â Â Â Â Â ComponentRequirement requirement;
>> -
>> +
>> Â Â Â Â Â Â // Handles several hints in case of lists (collections
>> or maps)
>> Â Â Â Â Â Â if
>> (Collection.class.isAssignableFrom(dependency.getMappingType())
>> - Â Â Â Â Â Â Â Â ||
>> Map.class.isAssignableFrom(dependency.getMappingType()))
>> - Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â ||
>> Map.class.isAssignableFrom(dependency.getMappingType())) {
>> Â Â Â Â Â Â Â Â // TODO: Uncomment when we move to a more recent
>> Plexus version which implements
>> Â Â Â Â Â Â Â Â // ComponentRequirementList.
>> Â Â Â Â Â Â Â Â /*
>> - Â Â Â Â Â Â Â Â String[] hints = dependency.getHints();
>> - Â Â Â Â Â Â Â Â if (hints != null && hints.length > 0) {
>> -
>> ((ComponentRequirementList
>> )requirement).setRoleHints(Arrays.asList(hints));
>> - Â Â Â Â Â Â Â Â }
>> - Â Â Â Â Â Â Â Â */
>> + Â Â Â Â Â Â Â Â * String[] hints = dependency.getHints(); if
>> (hints != null && hints.length > 0) {
>> + Â Â Â Â Â Â Â Â *
>> ((ComponentRequirementList
>> )requirement).setRoleHints(Arrays.asList(hints)); }
>> + Â Â Â Â Â Â Â Â */
>> Â Â Â Â Â Â Â Â requirement = new ComponentRequirement();
>> Â Â Â Â Â Â } else {
>> Â Â Â Â Â Â Â Â requirement = new ComponentRequirement();
>> @@ -283,7 +303,7 @@
>> Â Â Â Â Â Â requirement.setRoleHint(dependency.getRoleHint());
>>
>> requirement
>> .setFieldMappingType(dependency.getMappingType().getName());
>> Â Â Â Â Â Â requirement.setFieldName(dependency.getName());
>> -
>> +
>> Â Â Â Â Â Â pcd.addRequirement(requirement);
>> Â Â Â Â }
>>
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/
>> src/test/java/org/xwiki/rendering/internal/parser/
>> XWikiLinkParserTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -20,6 +20,8 @@
>> package org.xwiki.rendering.internal.parser;
>>
>> import org.jmock.Mock;
>> +import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.listener.Link;
>> import org.xwiki.rendering.listener.LinkType;
>> import org.xwiki.rendering.parser.LinkParser;
>> @@ -36,9 +38,15 @@
>> Â Â {
>> Â Â Â Â // Create a Mock WikiModel implementation so that the link
>> parser works in wiki mode
>> Â Â Â Â Mock mockWikiModel = mock(WikiModel.class);
>> - Â Â Â Â getComponentManager().registerComponent(WikiModel.class,
>> mockWikiModel.proxy());
>> - Â Â Â Â LinkParser parser =
>> getComponentManager().lookup(LinkParser.class, "xwiki/2.0");
>>
>> + Â Â Â Â DefaultComponentDescriptor<WikiModel> componentDescriptor =
>> new DefaultComponentDescriptor<WikiModel>();
>> + Â Â Â Â componentDescriptor.setRole(WikiModel.class);
>> +
>> componentDescriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
>> + Â Â Â Â componentDescriptor.setImplementation(null);
>> +
>> +
>> getComponentManager().registerComponent(componentDescriptor,
>> (WikiModel) mockWikiModel.proxy());
>> + Â Â Â Â LinkParser parser =
>> getComponentManager().lookup(LinkParser.class, "xwiki/2.0");
>> +
>> Â Â Â Â Link link = parser.parse("");
>> Â Â Â Â assertEquals("", link.getReference());
>> Â Â Â Â assertEquals("Reference = []", link.toString());
>> @@ -85,7 +93,7 @@
>> Â Â Â Â assertEquals("mailto:john@smith.com", link.getReference());
>> Â Â Â Â assertEquals(LinkType.URI, link.getType());
>> Â Â Â Â assertEquals("Reference = [mailto:john@smith.com]",
>> link.toString());
>> -
>> +
>> Â Â Â Â // Verify image: URI is recognized
>> Â Â Â Â link = parser.parse("image:some:content");
>> Â Â Â Â assertEquals("image:some:content", link.getReference());
>> @@ -97,13 +105,13 @@
>> Â Â Â Â assertEquals("attach:some:content", link.getReference());
>> Â Â Â Â assertEquals(LinkType.URI, link.getType());
>> Â Â Â Â assertEquals("Reference = [attach:some:content]",
>> link.toString());
>> -
>> +
>> Â Â Â Â // Verify that unknown URIs are ignored
>> Â Â Â Â // Note: We consider that myxwiki is the wiki name and http://xwiki.org
>> Â is the page name
>> Â Â Â Â link = parser.parse("mywiki:http://xwiki.org");
>> Â Â Â Â assertEquals("mywiki:http://xwiki.org", link.getReference());
>> Â Â Â Â assertEquals(LinkType.DOCUMENT, link.getType());
>> Â Â Â Â assertEquals("Reference = [mywiki:http://xwiki.org]",
>> link.toString());
>> -
>> +
>> + Â Â }
>> }
>> -}
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -28,6 +28,7 @@
>> import org.jmock.Expectations;
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.script.ScriptContextManager;
>> @@ -61,18 +62,32 @@
>>
>> Â Â Â Â // Document Access Bridge Mock
>> Â Â Â Â final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> - Â Â Â Â context.checking(new Expectations() {{
>> -
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> will(returnValue(true));
>> - Â Â Â Â }});
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> -
>> + Â Â Â Â context.checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> +
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>
> hmmm this is not following the recommended code style for
> expectations. See jmock.org`
>
> Can you please revert all these style changes?
>
> side note: This why I never apply code style blindly. It'll always
> break stuff you've done voluntarily.
>
>
>
>> + Â Â Â Â DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + Â Â Â Â descriptorDAB.setRole(DocumentAccessBridge.class);
>> + Â Â Â Â componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> +
>> Â Â Â Â // Script Context Mock
>> Â Â Â Â final ScriptContextManager mockScriptContextManager =
>> context.mock(ScriptContextManager.class);
>> Â Â Â Â final SimpleScriptContext scriptContext = new
>> SimpleScriptContext();
>> Â Â Â Â scriptContext.setAttribute("var", "value",
>> ScriptContext.ENGINE_SCOPE);
>> - Â Â Â Â context.checking(new Expectations() {{
>> - Â Â Â Â Â Â allowing(mockScriptContextManager).getScriptContext();
>> will(returnValue(scriptContext));
>> - Â Â Â Â }});
>> -
>> componentManager.registerComponent(ScriptContextManager.class,
>> mockScriptContextManager);
>> + Â Â Â Â context.checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> +
>> allowing(mockScriptContextManager).getScriptContext();
>> + Â Â Â Â Â Â Â Â will(returnValue(scriptContext));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â Â Â DefaultComponentDescriptor<ScriptContextManager>
>> descriptorSCM =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<ScriptContextManager>();
>> + Â Â Â Â descriptorSCM.setRole(ScriptContextManager.class);
>> + Â Â Â Â componentManager.registerComponent(descriptorSCM,
>> mockScriptContextManager);
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,7 +24,7 @@
>> import org.junit.Test;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> import org.xwiki.bridge.DocumentNameSerializer;
>> -import org.xwiki.component.embed.EmbeddableComponentManager;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.internal.macro.html.HTMLMacro;
>> import org.xwiki.rendering.macro.Macro;
>> import org.xwiki.rendering.macro.MacroExecutionException;
>> @@ -52,13 +52,19 @@
>> Â Â {
>> Â Â Â Â super.setUp();
>>
>> - Â Â Â Â DocumentAccessBridge dab =
>> this.context.mock(DocumentAccessBridge.class);
>> - Â Â Â Â ((EmbeddableComponentManager)
>> getComponentManager()).registerComponent(DocumentAccessBridge.class,
>> dab);
>> -
>> - Â Â Â Â DocumentNameSerializer dns =
>> this.context.mock(DocumentNameSerializer.class);
>> - Â Â Â Â ((EmbeddableComponentManager)
>> getComponentManager
>> ()).registerComponent(DocumentNameSerializer.class, dns);
>> + Â Â Â Â DocumentAccessBridge mockDocumentAccessBridge =
>> this.context.mock(DocumentAccessBridge.class);
>> + Â Â Â Â DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + Â Â Â Â descriptorDAB.setRole(DocumentAccessBridge.class);
>> + Â Â Â Â getComponentManager().registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> +
>> + Â Â Â Â DocumentNameSerializer mockDocumentNameSerializer =
>> this.context.mock(DocumentNameSerializer.class);
>> + Â Â Â Â DefaultComponentDescriptor<DocumentNameSerializer>
>> descriptorDNS =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentNameSerializer>();
>> + Â Â Â Â descriptorDNS.setRole(DocumentNameSerializer.class);
>> + Â Â Â Â getComponentManager().registerComponent(descriptorDNS,
>> mockDocumentNameSerializer);
>> Â Â }
>> -
>> +
>> Â Â /**
>> Â Â Â * Verify that inline HTML macros with non inline content
>> generate an exception.
>> Â Â Â */
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/
>> internal/macro/IncludeMacroTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java  2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java  2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,6 +24,7 @@
>>
>> import org.jmock.Mock;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.block.Block;
>> import org.xwiki.rendering.internal.macro.include.IncludeMacro;
>> import
>> org.xwiki.rendering.internal.transformation.MacroTransformation;
>> @@ -47,23 +48,25 @@
>> public class IncludeMacroTest extends AbstractRenderingTestCase
>> {
>> Â Â private Mock mockDocumentAccessBridge;
>> -
>> +
>> Â Â @Override
>> Â Â protected void registerComponents() throws Exception
>> Â Â {
>> Â Â Â Â this.mockDocumentAccessBridge =
>> mock(DocumentAccessBridge.class);
>> -
>> getComponentManager().registerComponent(DocumentAccessBridge.class,
>> this.mockDocumentAccessBridge.proxy());
>> +
>> + Â Â Â Â DefaultComponentDescriptor<DocumentAccessBridge> descriptor =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + Â Â Â Â descriptor.setRole(DocumentAccessBridge.class);
>> + Â Â Â Â getComponentManager().registerComponent(descriptor,
>> + Â Â Â Â Â Â (DocumentAccessBridge)
>> this.mockDocumentAccessBridge.proxy());
>> Â Â }
>>
>> Â Â public void testIncludeMacroWithNewContext() throws Exception
>> Â Â {
>> - Â Â Â Â String expected = "beginDocument\n"
>> - Â Â Â Â Â Â + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> - Â Â Â Â Â Â + "beginParagraph\n"
>> - Â Â Â Â Â Â + "onWord [hello]\n"
>> - Â Â Â Â Â Â + "endParagraph\n"
>> - Â Â Â Â Â Â + "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> - Â Â Â Â Â Â + "endDocument";
>> + Â Â Â Â String expected =
>> + Â Â Â Â Â Â "beginDocument\n" + "beginMacroMarkerStandalone
>> [velocity] [] [$myvar]\n" + "beginParagraph\n"
>> + Â Â Â Â Â Â Â Â + "onWord [hello]\n" + "endParagraph\n" +
>> "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> + Â Â Â Â Â Â Â Â + "endDocument";
>
> I much prefer my version. Can you please rollback? Again an example
> why applying code style automatically sucks :)
>
>>
>> Â Â Â Â // Since it's not in the same context, we verify that a
>> Velocity variable set in the including page is not
>> Â Â Â Â // seen in the included page.
>> @@ -88,21 +91,19 @@
>>
>> Â Â Â Â // Create a Macro transformation context with the Macro
>> transformation object defined so that the include
>> Â Â Â Â // macro can transform included page which is using a new
>> context.
>> - Â Â Â Â MacroTransformation macroTransformation =
>> + Â Â Â Â MacroTransformation macroTransformation =
>> Â Â Â Â Â Â (MacroTransformation)
>> getComponentManager().lookup(Transformation.class, "macro");
>> Â Â Â Â MacroTransformationContext context = new
>> MacroTransformationContext();
>> Â Â Â Â context.setMacroTransformation(macroTransformation);
>> -
>> +
>> Â Â Â Â List<Block> blocks = macro.execute(parameters, null, context);
>>
>> Â Â Â Â assertBlocks(expected, blocks);
>> Â Â }
>> -
>> +
>> Â Â public void testIncludeMacroWithCurrentContext() throws Exception
>> Â Â {
>> - Â Â Â Â String expected = "beginDocument\n"
>> - Â Â Â Â Â Â + "onMacroStandalone [someMacro] []\n"
>> - Â Â Â Â Â Â + "endDocument";
>> + Â Â Â Â String expected = "beginDocument\n" + "onMacroStandalone
>> [someMacro] []\n" + "endDocument";
>
> again
>
>>
>> Â Â Â Â IncludeMacro macro = (IncludeMacro)
>> getComponentManager().lookup(Macro.class, "include");
>>
>> mockDocumentAccessBridge
>> .expects(once()).method("isDocumentViewable").will(returnValue(true));
>> @@ -119,7 +120,7 @@
>>
>> Â Â Â Â assertBlocks(expected, blocks);
>> Â Â }
>> -
>> +
>> Â Â public void testIncludeMacroWithNoDocumentSpecified() throws
>> Exception
>> Â Â {
>> Â Â Â Â IncludeMacro macro = (IncludeMacro)
>> getComponentManager().lookup(Macro.class, "include");
>> @@ -129,8 +130,8 @@
>> Â Â Â Â Â Â macro.execute(parameters, null, new
>> MacroTransformationContext());
>> Â Â Â Â Â Â fail("An exception should have been thrown");
>> Â Â Â Â } catch (MacroExecutionException expected) {
>> - Â Â Â Â Â Â assertEquals("You must specify a 'document' parameter
>> pointing to the document to include.",
>> - Â Â Â Â Â Â Â Â expected.getMessage());
>> + Â Â Â Â Â Â assertEquals("You must specify a 'document' parameter
>> pointing to the document to include.", expected
>> + Â Â Â Â Â Â Â Â .getMessage());
>
> again a brilliant example why it sucks... :(
>
> My version is much nicer.
>
>> Â Â Â Â }
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java  2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java  2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -22,11 +22,12 @@
>> import junit.framework.Test;
>> import junit.framework.TestCase;
>>
>> +import org.jmock.Expectations;
>> +import org.jmock.Mockery;
>> +import org.xwiki.bridge.SkinAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> -import org.xwiki.bridge.SkinAccessBridge;
>> -import org.jmock.Mockery;
>> -import org.jmock.Expectations;
>>
>> /**
>> Â * All Rendering integration tests defined in text files using a
>> special format.
>> @@ -39,21 +40,27 @@
>> Â Â public static Test suite() throws Exception
>> Â Â {
>> Â Â Â Â RenderingTestSuite suite = new RenderingTestSuite("Test RSS
>> Macro");
>> -
>> +
>> Â Â Â Â suite.addTestsFromResource("macrorss1", true);
>> Â Â Â Â suite.addTestsFromResource("macrorss2", true);
>>
>> Â Â Â Â ComponentManagerTestSetup setup = new
>> ComponentManagerTestSetup(suite);
>>
>> Â Â Â Â Mockery context = new Mockery();
>> - Â Â Â Â final SkinAccessBridge mockSkinBridge =
>> context.mock(SkinAccessBridge.class);
>> -
>> setup
>> .getComponentManager().registerComponent(SkinAccessBridge.class,
>> mockSkinBridge);
>>
>> - Â Â Â Â context.checking(new Expectations() {{
>> -
>> allowing(mockSkinBridge).getSkinFile(with(any(String.class)));
>> - Â Â Â Â Â Â will(returnValue("/xwiki/skins/albatross/icons/black-
>> rss.png"));
>> - Â Â Â Â }});
>> -
>> + Â Â Â Â final SkinAccessBridge mockSkinAccessBridge =
>> context.mock(SkinAccessBridge.class);
>> + Â Â Â Â DefaultComponentDescriptor<SkinAccessBridge> descriptorSAB
>> = new DefaultComponentDescriptor<SkinAccessBridge>();
>> + Â Â Â Â descriptorSAB.setRole(SkinAccessBridge.class);
>> +
>> setup.getComponentManager().registerComponent(descriptorSAB,
>> mockSkinAccessBridge);
>> +
>> + Â Â Â Â context.checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> +
>> allowing(mockSkinAccessBridge).getSkinFile(with(any(String.class)));
>> + Â Â Â Â Â Â Â Â will(returnValue("/xwiki/skins/albatross/icons/
>> black-rss.png"));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> +
>> Â Â Â Â return setup;
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -25,6 +25,7 @@
>> import org.jmock.Expectations;
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> @@ -45,22 +46,30 @@
>> Â Â Â Â suite.addTestsFromResource("macroscript2", true);
>> Â Â Â Â suite.addTestsFromResource("macroscript3", true);
>> Â Â Â Â suite.addTestsFromResource("macroscript4", true);
>> -
>> +
>> Â Â Â Â ComponentManagerTestSetup testSetup = new
>> ComponentManagerTestSetup(suite);
>> Â Â Â Â setUpMocks(testSetup.getComponentManager());
>>
>> Â Â Â Â return testSetup;
>> Â Â }
>> -
>> +
>> Â Â public static void setUpMocks(EmbeddableComponentManager
>> componentManager)
>> Â Â {
>> Â Â Â Â Mockery context = new Mockery();
>>
>> Â Â Â Â // Document Access Bridge Mock setup
>> Â Â Â Â final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> - Â Â Â Â context.checking(new Expectations() {{
>> -
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> will(returnValue(true));
>> - Â Â Â Â }});
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> + Â Â Â Â context.checking(new Expectations()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> +
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> + Â Â Â Â Â Â Â Â will(returnValue(true));
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> +
>> + Â Â Â Â DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + Â Â Â Â descriptorDAB.setRole(DocumentAccessBridge.class);
>> + Â Â Â Â componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-velocity/src/test/java/org/xwiki/rendering/
>> macro/velocity/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java  2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java  2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,6 +24,7 @@
>>
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> @@ -64,6 +65,9 @@
>>
>> Â Â Â Â // Document Access Bridge Mock
>> Â Â Â Â final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> + Â Â Â Â DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + Â Â Â Â Â Â new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + Â Â Â Â descriptorDAB.setRole(DocumentAccessBridge.class);
>> + Â Â Â Â componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> Â Â }
>> }
>>
>> Modified: platform/core/trunk/xwiki-shared-tests/src/main/java/org/
>> xwiki/test/MockConfigurationSource.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java   2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java   2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -23,8 +23,6 @@
>> import java.util.List;
>> import java.util.Properties;
>>
>> -import org.xwiki.component.descriptor.ComponentDescriptor;
>> -import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.configuration.ConfigurationSource;
>>
>> /**
>>
>> Modified: platform/core/trunk/xwiki-shared-tests/src/main/java/org/
>> xwiki/test/XWikiComponentInitializer.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java  2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java  2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -24,6 +24,7 @@
>> import java.net.MalformedURLException;
>> import java.net.URL;
>>
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.container.ApplicationContext;
>> @@ -32,13 +33,18 @@
>> import org.xwiki.context.ExecutionContext;
>> import org.xwiki.context.ExecutionContextManager;
>>
>> +/**
>> + * Initialize a component manager used in unit tests.
>> + *
>> + * @version $Id$
>> + */
>> public class XWikiComponentInitializer
>> {
>> Â Â private EmbeddableComponentManager componentManager;
>>
>> Â Â /**
>> - Â Â * This method should be called before {@link
>> #initializeExecution()} since some components will require the
>> Container
>> - Â Â * component to be set up (for example to access resource such
>> as the XWikiconfiguration file).
>> + Â Â * This method should be called before {@link
>> #initializeExecution()} since some components will require the
>> + Â Â * Container component to be set up (for example to access
>> resource such as the XWikiconfiguration file).
>> Â Â Â */
>> Â Â public void initializeContainer() throws Exception
>> Â Â {
>> @@ -67,15 +73,24 @@
>> Â Â Â Â Â Â }
>> Â Â Â Â });
>> Â Â }
>> -
>> +
>> Â Â public void initializeConfigurationSource() throws Exception
>> Â Â {
>> Â Â Â Â // Register the mock configuration source for different
>> roles so that tests always use the mock
>> Â Â Â Â ConfigurationSource mockSource = new
>> MockConfigurationSource();
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> mockSource);
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> "xwikiproperties", mockSource);
>> +
>> + Â Â Â Â DefaultComponentDescriptor<ConfigurationSource> descriptor;
>> +
>> + Â Â Â Â descriptor = new
>> DefaultComponentDescriptor<ConfigurationSource>();
>> + Â Â Â Â descriptor.setRole(ConfigurationSource.class);
>> + Â Â Â Â getComponentManager().registerComponent(descriptor,
>> mockSource);
>> +
>> + Â Â Â Â descriptor = new
>> DefaultComponentDescriptor<ConfigurationSource>();
>> + Â Â Â Â descriptor.setRole(ConfigurationSource.class);
>> + Â Â Â Â descriptor.setRoleHint("xwikiproperties");
>> + Â Â Â Â getComponentManager().registerComponent(descriptor,
>> mockSource);
>> Â Â }
>> -
>> +
>> Â Â public void initializeExecution() throws Exception
>> Â Â {
>> Â Â Â Â // Initialize the Execution Context
>> @@ -85,11 +100,11 @@
>> Â Â Â Â ExecutionContext ec = new ExecutionContext();
>>
>> Â Â Â Â // Make sure we push this empty context in the Execution
>> component before we call the initialization
>> - Â Â Â Â // so that we don't get any NPE if some initializer code
>> asks to get the Execution Context. This
>> + Â Â Â Â // so that we don't get any NPE if some initializer code
>> asks to get the Execution Context. This
>> Â Â Â Â // happens for example with the Velocity Execution Context
>> initializer which in turns calls the Velocity
>> Â Â Â Â // Context initializers and some of them look inside the
>> Execution Context.
>> Â Â Â Â execution.setContext(ec);
>> -
>> +
>> Â Â Â Â ecm.initialize(ec);
>> Â Â }
>
> Thanks
> -Vincent
>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
On Tue, Jul 14, 2009 at 09:13, Vincent Massol<vincent(a)massol.net> wrote:
>
> On Jul 14, 2009, at 8:11 AM, Marius Dumitru Florea wrote:
>
>> Vincent Massol wrote:
>>> Hi Thomas,
>>>
>>> On Jul 13, 2009, at 3:20 PM, tmortagne (SVN) wrote:
>>>
>>>> Author: tmortagne
>>>> Date: 2009-07-13 15:20:03 +0200 (Mon, 13 Jul 2009)
>>>> New Revision: 21910
>>
>> [snip]
>>
>>>> Â Â public void testIncludeMacroWithNewContext() throws Exception
>>>> Â Â {
>>>> - Â Â Â Â String expected = "beginDocument\n"
>>>> - Â Â Â Â Â Â + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n"
>>>> - Â Â Â Â Â Â + "beginParagraph\n"
>>>> - Â Â Â Â Â Â + "onWord [hello]\n"
>>>> - Â Â Â Â Â Â + "endParagraph\n"
>>>> - Â Â Â Â Â Â + "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>>>> - Â Â Â Â Â Â + "endDocument";
>>>> + Â Â Â Â String expected =
>>>> + Â Â Â Â Â Â "beginDocument\n" + "beginMacroMarkerStandalone
>>>> [velocity] [] [$myvar]\n" + "beginParagraph\n"
>>>> + Â Â Â Â Â Â Â Â + "onWord [hello]\n" + "endParagraph\n" +
>>>> "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>>>> + Â Â Â Â Â Â Â Â + "endDocument";
>>>
>>> I much prefer my version. Can you please rollback? Again an example
>>> why applying code style automatically sucks :)
>>
>> Why don't you use a StringBuffer?
>
> It's more clear this way (and btw performance wise it's better - see
> my other mail in response to you).
>
> [snip]
>
>>>> Â Â Â Â IncludeMacro macro = (IncludeMacro)
>>>> getComponentManager().lookup(Macro.class, "include");
>>>>
>>>> mockDocumentAccessBridge
>>>> .expects
>>>> (once()).method("isDocumentViewable").will(returnValue(true));
>>>> @@ -119,7 +120,7 @@
>>>>
>>>> Â Â Â Â assertBlocks(expected, blocks);
>>>> Â Â }
>>>> -
>>>> +
>>>> Â Â public void testIncludeMacroWithNoDocumentSpecified() throws
>>>> Exception
>>>> Â Â {
>>>> Â Â Â Â IncludeMacro macro = (IncludeMacro)
>>>> getComponentManager().lookup(Macro.class, "include");
>>>> @@ -129,8 +130,8 @@
>>>> Â Â Â Â Â Â macro.execute(parameters, null, new
>>>> MacroTransformationContext());
>>>> Â Â Â Â Â Â fail("An exception should have been thrown");
>>>> Â Â Â Â } catch (MacroExecutionException expected) {
>>>> - Â Â Â Â Â Â assertEquals("You must specify a 'document' parameter
>>>> pointing to the document to include.",
>>>> - Â Â Â Â Â Â Â Â expected.getMessage());
>>>> + Â Â Â Â Â Â assertEquals("You must specify a 'document' parameter
>>>> pointing to the document to include.", expected
>>>> + Â Â Â Â Â Â Â Â .getMessage());
>>>
>>> again a brilliant example why it sucks... :(
>>
>> Can you store the long string in a separate variable (maybe a
>> StringBuffer if it's really long)?
>
> Marius, I see where you want to go but this will never work. You can't
> modify code so that automatic formatting will always be perfect. If we
> want to automate formatting (like with a SVN hook to automatically
> apply code style - in a first commit for ex) then we'll have to accept
> suboptimal result. The balance of course is vs wrongly formatted code
> which is probably more the norm in our code in general.
>
> I'm just whinning because I'm very strict with my code style and I
> directly format it in a certain way that I find the best and the IDE
> formatting removes my carefully crafted styles... ;)
I usually take care of respecting format in unit tests, i added last
minutes unit tests and forgot it.
For the "runtime code" it's usually more important for me to be sure
the code is always the same for everyone than to have lots of custom
style everywhere. Using Eclipse formater make a lots quicker and
easier to respect the checkstyle and there is not that much use cases
where it's an issue.
>
> If we could improve the IDE styles it could be ok. But I don't think
> Eclipse for ex support things like:
> - put braces on next line for if/for/etc only if the line is longer
> than 120 chars. We could also decide to remove this rule we had voted
> and (which I personally like - my preference has always been braces on
> next line everywhere for increased readability)
I would prefer choosing having the braces on next line (note i was not
here for this vote) than saing it's impossible to use Eclipse
formatter.
> - don't split on "." (as in the example above)
I quickly looked and Eclipse formatter support this very well when you
configure it.
> - don't split for javadoc @see (to be verified this is invalid - I
> seem to recall it is)
Javadoc is splited only when it's longer than 120 characters so there
is no issue
>
>
> Thanks
> -Vincent
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
On Jul 14, 2009, at 11:06 PM, Sergiu Dumitriu (JIRA) wrote:
> More significant HTTP status codes for error responses
> ------------------------------------------------------
>
> Key: XWIKI-4089
> URL: http://jira.xwiki.org/jira/browse/XWIKI-4089
> Project: XWiki Core
> Issue Type: Improvement
> Components: Actions and URLs
> Affects Versions: 2.0 M1
> Reporter: Sergiu Dumitriu
>
>
> Several error messages come with the default 200 HTTP status code,
> indicating success, although the request did not complete normally.
> Besides adding more semantics, this is also more friendly with
> services and AJAX calls.
>
> - access denied -> 403 Forbidden
> - document locked -> 423 Locked
> - invalid action on non-existing document -> 404 Not Found
> - invalid action on wrong document -> 400 Bad Request
> - invalid target for copy and rename -> 409 Conflict
> - template does not exist -> 400 Bad Request
Won't we get default browser error pages instead of our own error pages?
Thanks
-Vincent
The BlogPostSheet contains this line:
#template('tagedit.vm')
which in turn contains a HTML comment (<!-- ... -->) which is turned into this: <!<del> ... </del>>
Is there a way to load the template in a 2.0 syntax without having this conversion.
The BlogPostSheet was wrapped this way (done by the 1.0 to 2.0 Converter):
{{velocity filter="none"}}
{{html clean="false" wiki="true"}}
...
Thanks
Andreas Schaefer
CEO of Madplanet.com Inc.
EMail: andreas.schaefer(a)madplanet.com
schaefera(a)me.com
Twitter: andy_mpc
AIM: schaefera(a)me.com