Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

java - Do integration test for javax.servlet.Filter / Filter class has no default constructor

I have a problem to feature test a java Servlet Filter. I short description comes here: I have import my customize Filter,that extends javax.servlet.Filter, in context root like that:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <import resource="classpath*:my-filter.xml"/>
</beans>

And defined my filter in web.xml like that:

<filter>
        <filter-name>MyFilter</filter-name>
        <filter-class>com.myproject.MyFilter</filter-class>
        <async-supported>true</async-supported>
</filter>
<filter-mapping>
        <filter-name>MyFilter</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>

I have two question:

  1. I use IntelliJ IDEA as IDE and in my web.xml the following line <filter-class>com.myproject.MyFilter</filter-class> it is an error and since this filter is used in other application, I cannot figure out what the problem is. The error is: com.myproject.MyFilter has no default constructor
  2. how can I do integration test for this servlet. I will use the filter in real and not mock it.

Thanks for any help.

question from:https://stackoverflow.com/questions/65951720/do-integration-test-for-javax-servlet-filter-filter-class-has-no-default-const

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...