Initial Contribution

Signed-off-by: Jan Supol <jan.supol@oracle.com>
diff --git a/tests/integration/servlet-2.5-init-2/pom.xml b/tests/integration/servlet-2.5-init-2/pom.xml
new file mode 100644
index 0000000..b069eff
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.glassfish.jersey.tests.integration</groupId>
+        <artifactId>project</artifactId>
+        <version>2.28-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>servlet-2.5-init-2</artifactId>
+    <packaging>war</packaging>
+    <name>jersey-tests-integration-servlet-2.5-init-2</name>
+
+    <description>Servlet integration test - servlet-2.5-init-2 - configured using package scanning</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
+            <artifactId>jersey-test-framework-provider-external</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+            <plugin>
+              <groupId>org.mortbay.jetty</groupId>
+              <artifactId>jetty-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/CustomFeature.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/CustomFeature.java
new file mode 100644
index 0000000..1f99758
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/CustomFeature.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2;
+
+import javax.ws.rs.core.Feature;
+import javax.ws.rs.core.FeatureContext;
+import javax.ws.rs.ext.Provider;
+
+import org.glassfish.jersey.tests.integration.servlet_25_init_2.ext.Ext1WriterInterceptor;
+import org.glassfish.jersey.tests.integration.servlet_25_init_2.ext.Ext2WriterInterceptor;
+import org.glassfish.jersey.tests.integration.servlet_25_init_2.ext.Ext3WriterInterceptor;
+import org.glassfish.jersey.tests.integration.servlet_25_init_2.ext.Ext4WriterInterceptor;
+
+/**
+ * @author Michal Gajdos
+ */
+@Provider
+public class CustomFeature implements Feature {
+
+    @Override
+    public boolean configure(final FeatureContext context) {
+        context.register(Ext3WriterInterceptor.class, 1000);
+        context.register(Ext2WriterInterceptor.class, 100);
+        context.register(Ext1WriterInterceptor.INSTANCE, 500);
+        context.register(Ext4WriterInterceptor.INSTANCE, 1);
+        return true;
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResource.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResource.java
new file mode 100644
index 0000000..3867cd2
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResource.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+/**
+ * @author Pavel Bucek (pavel.bucek at oracle.com)
+ */
+@Path("helloworld")
+public class HelloWorldResource {
+
+    @GET
+    @Produces("text/plain")
+    public String get() {
+        return "Hello World! " + this.getClass().getPackage().getName();
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext1WriterInterceptor.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext1WriterInterceptor.java
new file mode 100644
index 0000000..1ff8e53
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext1WriterInterceptor.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2.ext;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+/**
+ * @author Michal Gajdos
+ */
+@Provider
+public class Ext1WriterInterceptor implements WriterInterceptor {
+
+    public static final Ext1WriterInterceptor INSTANCE = new Ext1WriterInterceptor();
+
+    @Override
+    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
+        context.setEntity(context.getEntity() + "-ext1");
+        context.proceed();
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext2WriterInterceptor.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext2WriterInterceptor.java
new file mode 100644
index 0000000..80eebfe
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext2WriterInterceptor.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2.ext;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+/**
+ * @author Michal Gajdos
+ */
+@Provider
+public class Ext2WriterInterceptor implements WriterInterceptor {
+
+    @Override
+    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
+        context.setEntity(context.getEntity() + "-ext2");
+        context.proceed();
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext3WriterInterceptor.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext3WriterInterceptor.java
new file mode 100644
index 0000000..885f151
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext3WriterInterceptor.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2.ext;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+/**
+ * @author Michal Gajdos
+ */
+@Provider
+public class Ext3WriterInterceptor implements WriterInterceptor {
+
+    @Override
+    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
+        context.setEntity(context.getEntity() + "-ext3");
+        context.proceed();
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext4WriterInterceptor.java b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext4WriterInterceptor.java
new file mode 100644
index 0000000..d90988a
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/ext/Ext4WriterInterceptor.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2.ext;
+
+import java.io.IOException;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+/**
+ * @author Michal Gajdos
+ */
+@Provider
+public class Ext4WriterInterceptor implements WriterInterceptor {
+
+    public static final Ext4WriterInterceptor INSTANCE = new Ext4WriterInterceptor();
+
+    @Override
+    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
+        context.setEntity(context.getEntity() + "-ext4");
+        context.proceed();
+    }
+}
diff --git a/tests/integration/servlet-2.5-init-2/src/main/webapp/WEB-INF/web.xml b/tests/integration/servlet-2.5-init-2/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..7066c4b
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+    <servlet>
+        <servlet-name>testServlet2</servlet-name>
+        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+        <init-param>
+            <param-name>jersey.config.server.provider.packages</param-name>
+            <param-value>org.glassfish.jersey.tests.integration.servlet_25_init_2</param-value>
+        </init-param>
+        <init-param>
+            <param-name>jersey.config.server.provider.scanning.recursive</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>testServlet2</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+</web-app>
diff --git a/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java
new file mode 100644
index 0000000..89071b3
--- /dev/null
+++ b/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.integration.servlet_25_init_2;
+
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
+import org.glassfish.jersey.test.spi.TestContainerException;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Pavel Bucek (pavel.bucek at oracle.com)
+ */
+public class HelloWorldResourceITCase extends JerseyTest {
+
+    @Override
+    protected ResourceConfig configure() {
+        return new ResourceConfig(HelloWorldResource.class);
+    }
+
+    @Override
+    protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
+        return new ExternalTestContainerFactory();
+    }
+
+    @Test
+    public void testHelloWorld() throws Exception {
+        Response r = target().path("helloworld").request().get();
+        assertEquals(200, r.getStatus());
+        assertEquals("Hello World! " + this.getClass().getPackage().getName() + "-ext4-ext2-ext1-ext3",
+                r.readEntity(String.class));
+    }
+}