-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid servlet/filter postfix cut for short names during name generation
- Loading branch information
Showing
2 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/test/groovy/ru/vyarus/dropwizard/guice/web/ServletGenNameCollisionTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package ru.vyarus.dropwizard.guice.web | ||
|
||
import io.dropwizard.Application | ||
import io.dropwizard.Configuration | ||
import io.dropwizard.setup.Bootstrap | ||
import io.dropwizard.setup.Environment | ||
import org.eclipse.jetty.servlet.ServletHolder | ||
import ru.vyarus.dropwizard.guice.GuiceBundle | ||
import ru.vyarus.dropwizard.guice.test.spock.UseGuiceyApp | ||
import spock.lang.Specification | ||
|
||
import javax.inject.Inject | ||
import javax.servlet.annotation.WebServlet | ||
import javax.servlet.http.HttpServlet | ||
|
||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 22.08.2016 | ||
*/ | ||
@UseGuiceyApp(GCollApp) | ||
class ServletGenNameCollisionTest extends Specification { | ||
|
||
@Inject | ||
Environment environment | ||
|
||
def "Check servlet name generation"() { | ||
|
||
expect: "OServlet name without postfix cut" | ||
ServletHolder oservlet = environment.getApplicationContext().getServletHandler().getServlet(".oservlet") | ||
oservlet.registration.className == OServlet.name | ||
|
||
and: "Servlet name without postfix cut" | ||
ServletHolder servlet = environment.getApplicationContext().getServletHandler().getServlet(".servlet") | ||
servlet.registration.className == Servlet.name | ||
} | ||
|
||
static class GCollApp extends Application<Configuration> { | ||
@Override | ||
void initialize(Bootstrap<Configuration> bootstrap) { | ||
bootstrap.addBundle(GuiceBundle.builder() | ||
.useWebInstallers() | ||
.extensions(OServlet, Servlet) | ||
.build()) | ||
} | ||
|
||
@Override | ||
void run(Configuration configuration, Environment environment) throws Exception { | ||
|
||
} | ||
} | ||
|
||
@WebServlet("/foo") | ||
static class OServlet extends HttpServlet {} | ||
|
||
@WebServlet("/bar") | ||
static class Servlet extends HttpServlet {} | ||
} |