/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.jasper.servlet;

import java.util.ServiceLoader;

import javax.servlet.ServletContainerInitializer;

import org.junit.Test;

/**
 *
 */
public class TestJasperInitializer {

    @Test
    public void testServiceLoader() {
        ServiceLoader<ServletContainerInitializer> initializers =
                ServiceLoader.load(ServletContainerInitializer.class);
        for (ServletContainerInitializer initializer : initializers) {
            System.out.println(initializer.getClass().getName());
        }
    }
}

@@ -848,26 +848,44 @@
 ava.
-util.ServiceLoader
+io.File;%0Aimport java.util.Collection
 ;%0A%0Ai
@@ -937,43 +937,294 @@
 er;%0A
-%0Aimport org.junit.Test;%0A%0A/**%0A *%0A */
+import javax.servlet.ServletContext;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport org.apache.catalina.core.StandardContext;%0Aimport org.apache.catalina.startup.Tomcat;%0Aimport org.apache.catalina.startup.TomcatBaseTest;%0Aimport org.apache.catalina.startup.WebappServiceLoader;%0A
 %0Apub
@@ -1255,16 +1255,39 @@
 ializer 
+extends TomcatBaseTest 
 %7B%0A%0A    @
@@ -1331,92 +1331,393 @@
 r() 
-%7B%0A        ServiceLoader%3CServletContainerInitializer%3E initializers =%0A                
+throws Exception %7B%0A        Tomcat tomcat = getTomcatInstance();%0A        File appDir = new File(%22test/webapp%22);%0A        // app dir is relative to server home%0A        StandardContext standardContext = (StandardContext) tomcat.addWebapp(null, %22/test%22, appDir.getAbsolutePath());%0A        tomcat.start();%0A%0A        ServletContext context = standardContext.getServletContext();%0A        Webapp
 Serv
@@ -1729,14 +1729,9 @@
 ader
-.load(
+%3C
 Serv
@@ -1757,30 +1757,74 @@
 izer
-.class);%0A        for (
+%3E loader = new WebappServiceLoader%3C%3E(context);%0A        Collection%3C
 Serv
@@ -1846,16 +1846,17 @@
 tializer
+%3E
  initial
@@ -1863,12 +1863,41 @@
 izer
- : i
+s = loader.load(ServletContainerI
 niti
@@ -1906,12 +1906,16 @@
 izer
-s) %7B
+.class);
 %0A   
@@ -1923,75 +1923,140 @@
     
-    System.out.println(initializer.getClass().getName());%0A        %7D
+Assert.assertEquals(1, initializers.size());%0A        Assert.assertTrue(initializers.iterator().next() instanceof JasperInitializer);
 %0A   

Test case should assert SCI is actually loaded