/*
 * Copyright 2007 Alin Dreghiciu.
 *
 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 * you may not use  this file  except in  compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed  under the  License is distributed on an "AS IS" BASIS,
 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 * implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ops4j.pax.web.extender.internal;

import javax.servlet.Servlet;
import static org.easymock.EasyMock.*;
import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceListener;
import org.osgi.service.http.HttpService;

public class ActivatorTest
{

    @Test( expected = IllegalArgumentException.class )
    public void startWithNullBundleContext()
        throws Exception
    {
        new Activator().start( null );
    }

    @Test
    public void start()
        throws Exception
    {
        BundleContext context = createMock( BundleContext.class );
        expect( context.createFilter( "(objectClass=" + Servlet.class.getName() + ")" )
        ).andReturn( createMock( Filter.class ) );
        context.addServiceListener(
            (ServiceListener) notNull(),
            eq( "(objectClass=" + Servlet.class.getName() + ")" )
        );
        expect( context.getServiceReferences(
            eq( Servlet.class.getName() ),
            (String) isNull()
        )
        ).andReturn( null );

        expect( context.createFilter( "(objectClass=" + HttpService.class.getName() + ")" )
        ).andReturn( createMock( Filter.class ) );
        context.addServiceListener(
            (ServiceListener) notNull(),
            eq( "(objectClass=" + HttpService.class.getName() + ")" )
        );
        expect( context.getServiceReferences(
            eq( HttpService.class.getName() ),
            (String) isNull()
        )
        ).andReturn( null );

        replay( context );
        new Activator().start( context );
        verify( context );
    }

    @Test( expected = IllegalArgumentException.class )
    public void stopWithNullBundleContext()
        throws Exception
    {
        new Activator().stop( null );
    }

    @Test
    public void stop()
        throws Exception
    {
        BundleContext context = createMock( BundleContext.class );
        replay( context );
        new Activator().stop( context );
        verify( context );
    }

}

@@ -747,16 +747,61 @@
 t.Test;%0A
+import org.ops4j.pax.web.extender.Resources;%0A
 import o
@@ -1736,32 +1736,490 @@
 eturn( null );%0A%0A
+        expect( context.createFilter( %22(objectClass=%22 + Resources.class.getName() + %22)%22 )%0A        ).andReturn( createMock( Filter.class ) );%0A        context.addServiceListener(%0A            (ServiceListener) notNull(),%0A            eq( %22(objectClass=%22 + Resources.class.getName() + %22)%22 )%0A        );%0A        expect( context.getServiceReferences(%0A            eq( Resources.class.getName() ),%0A            (String) isNull()%0A        )%0A        ).andReturn( null );%0A%0A
         expect( 

Support for white-board model for resources