### Eclipse Workspace Patch 1.0
#P platform
Index: core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/java/org/xwiki/rendering/RenderingTests.java
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/java/org/xwiki/rendering/RenderingTests.java	(revision 0)
+++ core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/java/org/xwiki/rendering/RenderingTests.java	(revision 0)
@@ -0,0 +1,45 @@
+/*
+ * 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.rendering;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.xwiki.rendering.scaffolding.RenderingTestCase;
+import org.xwiki.rendering.scaffolding.RenderingTestSuite;
+import org.xwiki.test.PlexusTestSetup;
+
+/**
+ * All Rendering integration tests defined in text files using a special format.
+ * 
+ * @version $Id: $
+ * @since 1.9
+ */
+public class RenderingTests extends TestCase
+{
+    public static Test suite() throws Exception
+    {
+        RenderingTestSuite suite = new RenderingTestSuite("Test Message Macro");
+
+        suite.addTestsFromResource("macromessage1", true);
+
+        return new PlexusTestSetup(suite, RenderingTestCase.DEFAULT_MOCK_DESCRIPTORS);
+    }
+}
Index: core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/resources/META-INF/plexus/components.xml	(revision 0)
+++ core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/resources/META-INF/plexus/components.xml	(revision 0)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * 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.
+ *
+-->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.xwiki.rendering.macro.Macro</role>
+      <role-hint>error</role-hint>
+      <implementation>org.xwiki.rendering.internal.macro.message.MessageMacro</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <configuration>
+        <priority>1000</priority>
+      </configuration>
+      <requirements>
+        <requirement>
+          <role>org.xwiki.rendering.macro.Macro</role>
+          <role-hint>box</role-hint>
+          <field-name>boxMacro</field-name>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.xwiki.rendering.macro.Macro</role>
+      <role-hint>warning</role-hint>
+      <implementation>org.xwiki.rendering.internal.macro.message.MessageMacro</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <configuration>
+        <priority>1000</priority>
+      </configuration>
+      <requirements>
+        <requirement>
+          <role>org.xwiki.rendering.macro.Macro</role>
+          <role-hint>box</role-hint>
+          <field-name>boxMacro</field-name>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.xwiki.rendering.macro.Macro</role>
+      <role-hint>info</role-hint>
+      <implementation>org.xwiki.rendering.internal.macro.message.MessageMacro</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <configuration>
+        <priority>1000</priority>
+      </configuration>
+      <requirements>
+        <requirement>
+          <role>org.xwiki.rendering.macro.Macro</role>
+          <role-hint>box</role-hint>
+          <field-name>boxMacro</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+  </components>
+</component-set>
Index: core/xwiki-rendering/xwiki-rendering-macros/pom.xml
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/pom.xml	(revision 20252)
+++ core/xwiki-rendering/xwiki-rendering-macros/pom.xml	(working copy)
@@ -83,6 +83,7 @@
     <module>xwiki-rendering-macro-code</module>
     <module>xwiki-rendering-macro-rss</module>
     <module>xwiki-rendering-macro-useravatar</module>
+    <module>xwiki-rendering-macro-message</module>
   </modules>
 </project>
        
Index: core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/resources/macromessage1.test
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/resources/macromessage1.test	(revision 0)
+++ core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/test/resources/macromessage1.test	(revision 0)
@@ -0,0 +1,83 @@
+.#-----------------------------------------------------
+.input|xwiki/2.0
+.#-----------------------------------------------------
+{{error}}
+Failed to do this action. The correct possibilities are:
+* use another value
+* you don't have right
+* another possibility
+{{/error}}
+.#-----------------------------------------------------
+.expect|event/1.0
+.#-----------------------------------------------------
+beginDocument
+beginMacroMarkerStandalone [error] [] [
+Failed to do this action. The correct possibilities are:
+* use another value
+* you don't have right
+* another possibility
+]
+beginGroup [[class]=[box errormessage]]
+beginParagraph
+onWord [Failed]
+onSpace
+onWord [to]
+onSpace
+onWord [do]
+onSpace
+onWord [this]
+onSpace
+onWord [action]
+onSpecialSymbol [.]
+onSpace
+onWord [The]
+onSpace
+onWord [correct]
+onSpace
+onWord [possibilities]
+onSpace
+onWord [are]
+onSpecialSymbol [:]
+endParagraph
+beginList [BULLETED]
+beginListItem
+onWord [use]
+onSpace
+onWord [another]
+onSpace
+onWord [value]
+endListItem
+beginListItem
+onWord [you]
+onSpace
+onWord [don]
+onSpecialSymbol [']
+onWord [t]
+onSpace
+onWord [have]
+onSpace
+onWord [right]
+endListItem
+beginListItem
+onWord [another]
+onSpace
+onWord [possibility]
+endListItem
+endList [BULLETED]
+endGroup [[class]=[box errormessage]]
+endMacroMarkerStandalone [error] [] [
+Failed to do this action. The correct possibilities are:
+* use another value
+* you don't have right
+* another possibility
+]
+endDocument
+.#-----------------------------------------------------
+.expect|xwiki/2.0
+.#-----------------------------------------------------
+{{error}}
+Failed to do this action. The correct possibilities are:
+* use another value
+* you don't have right
+* another possibility
+{{/error}}
Index: core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/pom.xml
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/pom.xml	(revision 0)
+++ core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/pom.xml	(revision 0)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * 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.
+ *
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>xwiki-core-rendering-macros-parent</artifactId>
+    <groupId>org.xwiki.platform</groupId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>xwiki-core-rendering-macro-message</artifactId>
+  <name>XWiki Platform - Core - Rendering - Macro - Message</name>
+  <version>2.0-SNAPSHOT</version>
+  <description>XWiki Platform - Core - Rendering - Macro - Message</description>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>**/RenderingTests.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.xwiki.platform</groupId>
+      <artifactId>xwiki-core-rendering-macro-box</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    
+  </dependencies>
+</project>
Index: core/xwiki-core/pom.xml
===================================================================
--- core/xwiki-core/pom.xml	(revision 20252)
+++ core/xwiki-core/pom.xml	(working copy)
@@ -632,6 +632,13 @@
     </dependency>
     <dependency>
       <groupId>org.xwiki.platform</groupId>
+      <artifactId>xwiki-core-rendering-macro-message</artifactId>
+      <version>${pom.version}</version>
+      <!-- Only needed at runtime since it's a component implementation -->
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.xwiki.platform</groupId>
       <artifactId>xwiki-core-rendering-macro-useravatar</artifactId>
       <version>${pom.version}</version>
       <!-- Only needed at runtime since it's a component implementation -->
Index: core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/java/org/xwiki/rendering/internal/macro/message/MessageMacro.java
===================================================================
--- core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/java/org/xwiki/rendering/internal/macro/message/MessageMacro.java	(revision 0)
+++ core/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-message/src/main/java/org/xwiki/rendering/internal/macro/message/MessageMacro.java	(revision 0)
@@ -0,0 +1,109 @@
+/*
+ * 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.rendering.internal.macro.message;
+
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.xwiki.rendering.block.Block;
+import org.xwiki.rendering.macro.AbstractMacro;
+import org.xwiki.rendering.macro.Macro;
+import org.xwiki.rendering.macro.MacroExecutionException;
+import org.xwiki.rendering.macro.box.BoxMacroParameters;
+import org.xwiki.rendering.macro.descriptor.DefaultMacroDescriptor;
+import org.xwiki.rendering.transformation.MacroTransformationContext;
+
+/**
+ * Displays a message, which can be an error, a warning or an info note.
+ * 
+ * @version $Id: $
+ * @since 2.0
+ */
+public class MessageMacro extends AbstractMacro<Object>
+{
+    /**
+     * Predefined error message.
+     */
+    public static final String CONTENT_MISSING_ERROR = "The required content is missing.";
+
+    /**
+     * The description of the macro.
+     */
+    private static final String DESCRIPTION = "Displays a message, which can be an error, a warning or an info note.";
+
+    /**
+     * Injected by the component manager.
+     */
+    private Macro<BoxMacroParameters> boxMacro;
+    
+    /**
+     * Create and initialize the descriptor of the macro.
+     */
+    public MessageMacro()
+    {
+        super(new DefaultMacroDescriptor(DESCRIPTION, Object.class));
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.xwiki.rendering.macro.Macro#execute(Object, String, MacroTransformationContext)
+     */
+    public List<Block> execute(Object parameters, String content, MacroTransformationContext context) 
+        throws MacroExecutionException
+    {
+        if (StringUtils.isEmpty(content)) {
+            throw new MacroExecutionException(CONTENT_MISSING_ERROR);
+        }
+        String macroName = context.getCurrentMacroBlock().getName();
+        BoxMacroParameters boxParameters = new BoxMacroParameters();
+        
+        if (macroName.equals("warning")) {
+            boxParameters.setCssClass("warningmessage");
+        } 
+        
+        if (macroName.equals("info")) {
+            boxParameters.setCssClass("infomessage");
+        } 
+
+        if (macroName.equals("error")) {
+            boxParameters.setCssClass("errormessage");
+        } 
+        
+        List<Block> result;
+        if (!context.isInline()) {
+            boxParameters.setTitle(content);
+            result = boxMacro.execute(boxParameters, StringUtils.EMPTY, context);
+        } else {
+            result = boxMacro.execute(boxParameters, content, context);
+        }
+        return result; 
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.xwiki.rendering.macro.Macro#supportsInlineMode()
+     */
+    public boolean supportsInlineMode()
+    {
+        return true;
+    }
+}
