Problem appears to be solved by changing from java5 (IBM Websphere) to Sun/Oracle Java6.
Up vote 1 down vote favorite share g+ share fb share tw.
I'm new to object mocking, and trying to create unit tests for some legacy code. I'm trying to use powermock for the first time, and encountering a NoClassDefFoundError on line 69 ( DefaultHttpClient mockClient = mock(DefaultHttpClient. Class);) (see trace below).
Can anyone give me a hand and point me in the right direction? @RunWith(PowerMockRunner. Class) @PrepareForTest(LoginClient.
Class) public class LoginClientTest { Properties props = null; @Before public void setUp() throws FileNotFoundException, IOException { props = new Properties(); props. Load(new FileInputStream(". /src/test/resources/LoginClient/default.
Properties")); } /** * Method description * @throws Exception * */ @Test public void loginPositiveTest() throws Exception { DefaultHttpClient mockClient = mock(DefaultHttpClient. Class); HttpResponse mockResponse = mock(HttpResponse. Class); StatusLine mockStatusLine = mock(StatusLine.
Class); Header headers = new BasicHeader2; headers0 = new BasicHeader("Set-Cookie", "COOKIE-DATA"); headers1 = new BasicHeader("Set-Cookie", "COOKIE-DATA-2"); whenNew(DefaultHttpClient. Class).withNoArguments(). ThenReturn(mockClient); when(mockClient.
Execute(isA(HttpUriRequest. Class))). ThenReturn(mockResponse); when(mockResponse.getStatusLine()).
ThenReturn(mockStatusLine); when(mockStatusLine.getStatusCode()). ThenReturn(HttpStatus. SC_OK); when(mockResponse.getAllHeaders()).
ThenReturn(headers); LoginClient client = new LoginClient(); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(props. GetProperty("user"), props. GetProperty("password")); String result = client.
GetCookie(creds.getUserName(), creds.getPassword()); System.out. Println(result); assertNotNull(result); } } java.lang. NoClassDefFoundError: org.apache.http.impl.client.
DefaultHttpClient$$EnhancerByMockitoWithCGLIB$$221fdb68 at sun.reflect. GeneratedSerializationConstructorAccessor6. NewInstance(Unknown Source) at java.lang.reflect.Constructor.
NewInstance(Constructor. Java:521) at org.objenesis.instantiator.sun. SunReflectionFactoryInstantiator.
NewInstance(SunReflectionFactoryInstantiator. Java:40) at org.objenesis.ObjenesisBase. NewInstance(ObjenesisBase.
Java:59) at org.mockito.internal.creation.jmock. ClassImposterizer. CreateProxy(ClassImposterizer.
Java:111) at org.mockito.internal.creation.jmock. ClassImposterizer. Imposterise(ClassImposterizer.
Java:51) at org.powermock.api.mockito.internal.mockcreation.MockCreator. CreateMethodInvocationControl(MockCreator. Java:100) at org.powermock.api.mockito.internal.mockcreation.MockCreator.
Mock(MockCreator. Java:58) at org.powermock.api.mockito.PowerMockito. Mock(PowerMockito.
Java:138) at REDACTED.clients.LoginClientTest. LoginPositiveTest(LoginClientTest. Java:61) at sun.reflect.
NativeMethodAccessorImpl. Invoke0(Native Method) at sun.reflect. NativeMethodAccessorImpl.
Invoke(NativeMethodAccessorImpl. Java:64) at sun.reflect. DelegatingMethodAccessorImpl.
Invoke(DelegatingMethodAccessorImpl. Java:43) at java.lang.reflect.Method. Invoke(Method.
Java:615) at org.junit.internal.runners.TestMethod. Invoke(TestMethod. Java:66) at org.powermock.modules.
Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner. RunTestMethod(PowerMockJUnit44RunnerDelegateImpl.
Java:307) at org.junit.internal.runners. MethodRoadie$2. Run(MethodRoadie.
Java:86) at org.junit.internal.runners.MethodRoadie. RunBeforesThenTestThenAfters(MethodRoadie. Java:94) at org.powermock.modules.
Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner. ExecuteTest(PowerMockJUnit44RunnerDelegateImpl.
Java:294) at org.powermock.modules. Junit4.internal.impl. PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.
ExecuteTestInSuper(PowerMockJUnit47RunnerDelegateImpl. Java:112) at org.powermock.modules. Junit4.internal.impl.
PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner. ExecuteTest(PowerMockJUnit47RunnerDelegateImpl. Java:73) at org.powermock.modules.
Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner. RunBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.
Java:282) at org.junit.internal.runners.MethodRoadie. RunTest(MethodRoadie. Java:84) at org.junit.internal.runners.MethodRoadie.
Run(MethodRoadie. Java:49) at org.powermock.modules. Junit4.internal.impl.
PowerMockJUnit44RunnerDelegateImpl. InvokeTestMethod(PowerMockJUnit44RunnerDelegateImpl. Java:207) at org.powermock.modules.
Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl. RunMethods(PowerMockJUnit44RunnerDelegateImpl.
Java:146) at org.powermock.modules. Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl$1.
Run(PowerMockJUnit44RunnerDelegateImpl. Java:120) at org.junit.internal.runners.ClassRoadie. RunUnprotected(ClassRoadie.
Java:34) at org.junit.internal.runners.ClassRoadie. RunProtected(ClassRoadie. Java:44) at org.powermock.modules.
Junit4.internal.impl. PowerMockJUnit44RunnerDelegateImpl. Run(PowerMockJUnit44RunnerDelegateImpl.
Java:118) at org.powermock.modules. Junit4.common.internal.impl. JUnit4TestSuiteChunkerImpl.
Run(JUnit4TestSuiteChunkerImpl. Java:102) at org.powermock.modules. Junit4.common.internal.impl.
AbstractCommonPowerMockRunner. Run(AbstractCommonPowerMockRunner. Java:53) at org.eclipse.jdt.internal.
Junit4.runner. JUnit4TestReference. Run(JUnit4TestReference.
Java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution. Run(TestExecution. Java:38) at org.eclipse.jdt.internal.junit.runner.
RemoteTestRunner. RunTests(RemoteTestRunner. Java:467) at org.eclipse.jdt.internal.junit.runner.
RemoteTestRunner. RunTests(RemoteTestRunner. Java:683) at org.eclipse.jdt.internal.junit.runner.
RemoteTestRunner. Run(RemoteTestRunner. Java:390) at org.eclipse.jdt.internal.junit.runner.
RemoteTestRunner. Main(RemoteTestRunner. Java:197) mockito powermock link|improve this question asked Jul 26 '11 at 20:57babbitt1148.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.