/*
 * 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.officeimporter.internal;

import java.util.Properties;

import org.apache.velocity.VelocityContext;
import org.jmock.Expectations;
import org.junit.Assert;
import org.junit.Test;
import org.xwiki.configuration.ConfigurationSource;
import org.xwiki.context.Execution;
import org.xwiki.context.ExecutionContext;
import org.xwiki.script.service.ScriptService;
import org.xwiki.test.AbstractMockingComponentTestCase;
import org.xwiki.test.annotation.AllComponents;
import org.xwiki.velocity.VelocityContextFactory;
import org.xwiki.velocity.VelocityContextInitializer;

/**
 * Unit tests for various {@link VelocityContextInitializer} implementations.
 * 
 * @version $Id$
 * @since 1.9RC2
 */
@AllComponents
public class VelocityContextInitializerTest extends AbstractMockingComponentTestCase
{
    /**
     * Test the presence of velocity bridges.
     * 
     * @throws Exception
     */
    @Test
    public void testVelocityBridges() throws Exception
    {
        registerMockComponent(ScriptService.class, "officeimporter", "importer");
        registerMockComponent(ScriptService.class, "officemanager", "manager");
        final ConfigurationSource configurationSource = registerMockComponent(ConfigurationSource.class);
        getMockery().checking(new Expectations()
        {
            {
                oneOf(configurationSource).getProperty("velocity.tools", Properties.class);
                will(returnValue(new Properties()));
            }
        });

        // Make sure the execution context is not null when velocity bridges are initialized.
        getComponentManager().<Execution> getInstance(Execution.class).setContext(new ExecutionContext());

        VelocityContextFactory factory = getComponentManager().getInstance(VelocityContextFactory.class);
        VelocityContext context = factory.createContext();

        Assert.assertNotNull(context.get("officeimporter"));
        Assert.assertNotNull(context.get("ooconfig"));
        Assert.assertNotNull(context.get("oomanager"));
    }
}

@@ -1284,39 +1284,32 @@
 ki.test.Abstract
-Mocking
 ComponentTestCas
@@ -1315,56 +1315,8 @@
 se;%0A
-import org.xwiki.test.annotation.AllComponents;%0A
 impo
@@ -1427,12 +1427,19 @@
 %0A * 
-Unit
+Integration
  tes
@@ -1503,16 +1503,58 @@
 ntations
+ specific to the Office Importer%0A * module
 .%0A * %0A *
@@ -1593,23 +1593,8 @@
  */%0A
-@AllComponents%0A
 publ
@@ -1653,15 +1653,8 @@
 ract
-Mocking
 Comp
@@ -1677,74 +1677,58 @@
     
-/**%0A     * Test the presence of velocity bridges.%0A     * %0A     * @
+@Override%0A    protected void registerComponents() 
 thro
@@ -1748,82 +1748,46 @@
     
- */
+%7B
 %0A    
-@Test%0A    public void testVelocityBridges() throws Exception%0A    %7B
+    super.registerComponents();%0A
 %0A   
@@ -2295,16 +2295,188 @@
     %7D);%0A
+    %7D%0A%0A    /**%0A     * Test the presence of velocity bridges.%0A     * %0A     * @throws Exception%0A     */%0A    @Test%0A    public void testVelocityBridges() throws Exception%0A    %7B
 %0A       

Fix integration test.