Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Class MyFactory
- package com.pro.ws.trust;
- import javax.xml.bind.JAXBContext;
- import javax.xml.bind.JAXBException;
- public class MyFactory {
- private static JAXBContext jaxbContext = null;
- public static void loadJaxbContext() {
- try {
- jaxbContext = JAXBContext
- .newInstance("com.pro.xml.ws.trust.impl.bindings:com.pro.xml.ws.trust.v14.impl.bindings:com.pro.xml.ws.security.secext.impl.bindings:com.pro.xml.ws.utility.impl.bindings");
- } catch (JAXBException jbe) {
- throw new RuntimeException(jbe.getMessage(), jbe);
- }
- }
- }
- // Class Mytest
- package com.pro.ws.trust;
- public class MyTest {
- public static String justexeecute(){
- return "Hello";
- }
- }
- //Powermock test
- package com.pro.ws.trust;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.mockito.Mockito;
- import org.powermock.api.mockito.PowerMockito;
- import org.powermock.core.classloader.annotations.PowerMockIgnore;
- import org.powermock.core.classloader.annotations.PrepareForTest;
- import org.powermock.modules.junit4.PowerMockRunner;
- @PowerMockIgnore("com.pro.ws.trust.MyFactory")
- //@PrepareForTest(MyTest.class)
- @RunWith(PowerMockRunner.class)
- public class PowermockTest {
- @Test
- public void testSample() {
- try {
- MyFactory.loadJaxbContext();
- PowerMockito.mockStatic(MyTest.class);
- //PowerMockito.when(MyTest.justexeecute()).thenReturn("dummy");
- //System.out.println(MyTest.justexeecute());
- } catch (Exception e) {
- e.printStackTrace();
- // TODO: handle exception
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement