Thoppan / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Mocking servlet , SipServlet / exception creating mock sip / servlet request #317

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a mock of HttpServletRequest / SipServletRequest as    
SipServletRequest  request = createStrictMock(SipServletRequest.class);
2.Exception in test 
java.lang.ClassFormatError: Absent Code attribute in method that is not native 
or abstract in class file javax/servlet/ServletException

What is the expected output? What do you see instead?
Expecting to get a mock servlet request to unit test a servlet

What version of the product are you using? On what operating system?

power  mock 1.4.8 ,easy mock 3.0 , windows vista 
Please provide any additional information below.

Original issue reported on code.google.com by sri.nara...@gmail.com on 16 Mar 2011 at 8:39

GoogleCodeExporter commented 9 years ago

@RunWith(PowerMockRunner.class)
public class TestSipServlet {
    //PowerMockRunner p;

    @Test
    public void testDoRequest1() throws Exception {
        SipServletRequest  request = createStrictMock(SipServletRequest.class);

    }

}

Original comment by sri.nara...@gmail.com on 16 Mar 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Could you please provide a small example project that demonstrates the issue?

Original comment by johan.ha...@gmail.com on 18 Mar 2011 at 10:16

GoogleCodeExporter commented 9 years ago
Hi , including the glassfish servlet dependency solved the problem;
Earlier I have the maven javaee dependency alone;
I am still unclear of why adding glassfish dependency solves the problem.
But it has something to do with the ServletException class ;

---------------------------------------------------------------------
solved by adding the below code in my pom.xml in addition powermock easymock 
dependencies
--------------------------------------------------------------------
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.servlet</artifactId>
            <version>3.0</version>
            <scope>test</scope>
        </dependency>
              <repositories>
        <repository>
            <id>glassfish-repository</id>
            <url>http://download.java.net/maven/glassfish</url>
        </repository>
            </repositories>
-----------------------------------------------------------------------

Original comment by sri.nara...@gmail.com on 18 Mar 2011 at 6:33

GoogleCodeExporter commented 9 years ago
Ok so I'm closing this issue. Still seems quite strange to me that added the 
dependency solved the issue.

Original comment by johan.ha...@gmail.com on 22 Mar 2011 at 10:30