java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=esopCreateTest], {ExactMatcher:fDisplayName=esopCreateTest(com.cmcc.open.ss.util.EsopSynWebServiceActionTest)], {LeadingIdentifierMatcher:fClassName=com.cmcc.open.ss.util.EsopSynWebServiceActionTest,fLeadingIdentifier=esopCreateTest]] from org.junit.internal.requests.ClassRequest@57cd6a32
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:77)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:68)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)java
緣由---->junit 不能用靜態方法,,,static...web
/* * Project: zhejiang-esop-open manager Webapp * * File Created at 2017年11月16日 * * Copyright 2016 CMCC Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * ZYHY Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license. */ package com.cmcc.open.ss.util; import java.io.IOException; import java.io.StringWriter; import java.net.MalformedURLException; import java.util.LinkedList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.namespace.QName; import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.rpc.client.RPCServiceClient; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.cmcc.open.base.utils.TimeUtil; import com.cmcc.open.ss.po.FieldInfo; import com.cmcc.open.ss.po.RecordInfo; import com.cmcc.open.ss.po.enums.EsopStatusEnums; /** * @Type RPCClient.java * @Desc webservice 客戶端調用test * @author huamao * @date 2017年11月16日 上午10:22:28 * @version */ public class EsopSynWebServiceActionTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } public static String serviceUrl = "http://localhost:8080/open_mssportal/services/hyEsopWebService?wsdl"; public static String nameSpace = "http://web.mssportal.open.cmcc.com"; public static String method = "acceptEsop"; //調用方式 public static Object invokeShaohua() throws Exception { String endpoint = serviceUrl; Service service = new Service(); Call call = null; try { call = (Call) service.createCall(); } catch (ServiceException e) { e.printStackTrace(); } try { call.setTargetEndpointAddress(new java.net.URL(endpoint)); } catch (MalformedURLException e) { e.printStackTrace(); } call.setOperationName(new QName("http://web.mssportal.open.cmcc.com", "acceptEsop")); String retXml = (String) call.invoke(new Object[] { "少華 webservice success" }); System.out.println(retXml); return retXml; } /** * * @param serviceUrl * @param nameSpace * @param method * @param params * @param classes * @return * @throws AxisFault */ @SuppressWarnings("rawtypes") public static Object[] invoke(String serviceUrl, String nameSpace, String method, Object[] params, Class[] classes) throws AxisFault { //使用RPC方式調用WebService RPCServiceClient client = new RPCServiceClient(); Options option = client.getOptions(); //指定調用的URL EndpointReference reference = new EndpointReference(serviceUrl); option.setTo(reference); /* * 設置要調用的方法 * http://ws.apache.org/axis2 爲默認的(無package的狀況)命名空間, * 若是有包名,則爲 http://axis2.webservice.elgin.com ,包名倒過來便可 * method爲方法名稱 * */ QName qname = new QName(nameSpace, method); //調用遠程方法,並指定方法參數以及返回值類型 Object[] result = client.invokeBlocking(qname, params, classes); return result; } @Test public static void esopCreateTest() { //junit測試方法呀,不能加static啊。因此會報錯。。去掉就行了。。。 RecordInfo recordInfoMain = new RecordInfo(); List<FieldInfo> list = new LinkedList<>(); //主工單信息 FieldInfo f1 = new FieldInfo("主題", "title", "新裝套餐"); FieldInfo f2 = new FieldInfo("集團編號", "customNo", "5717333262"); FieldInfo f3 = new FieldInfo("集團名稱", "customName", "boss"); FieldInfo f4 = new FieldInfo("客戶經理", "cManagerContact", "張業華"); FieldInfo f5 = new FieldInfo("客戶經理聯繫電話", "cManagerContactPhone", "15268521895"); FieldInfo f6 = new FieldInfo("e55計費號", "mobileNo", "15573265301"); FieldInfo f7 = new FieldInfo("渠道ID", "chnlId", ""); FieldInfo f8 = new FieldInfo("集團訂購編號", "orderId", "7309427400"); FieldInfo f9 = new FieldInfo("企業管理員手機號碼", "contactMobile", "18867105653"); FieldInfo f10 = new FieldInfo("企業管理員姓名", "contactName", "烏雲"); FieldInfo f11 = new FieldInfo("企業管理員郵箱", "contactEmail", "420492899@qq.com"); FieldInfo f12 = new FieldInfo("地市編碼", "cityCode", "573"); FieldInfo f13 = new FieldInfo("縣市編碼", "areaCode", "573002"); FieldInfo f14 = new FieldInfo("業務需求描述", "bRequirementDesc", "測試新裝"); FieldInfo f15 = new FieldInfo("開通時間", "beginDate", "2017-12-01");//新裝必填 FieldInfo f16 = new FieldInfo("計費開通時間", "billingDate", "2017-12-01");//新裝必填 // FieldInfo f17=new FieldInfo("註銷時間", "expDate", "");//註銷必填 // FieldInfo f18=new FieldInfo("操做時間", "doneDate", "");//停復機必填 list.add(f1); list.add(f2); list.add(f3); list.add(f4); list.add(f5); list.add(f6); list.add(f7); list.add(f8); list.add(f9); list.add(f10); list.add(f11); list.add(f12); list.add(f13); list.add(f14); list.add(f15); list.add(f16); recordInfoMain.setFieldInfo(list); //子工單信息 RecordInfo recordInfoSub = new RecordInfo(); List<FieldInfo> listZ = new LinkedList<>(); FieldInfo fz1 = new FieldInfo("子工單號", "subSerialNo", "71001206670563"); FieldInfo fz2 = new FieldInfo("集團訂購產品編號", "groupPrdCode", "600000471376"); FieldInfo fz3 = new FieldInfo("狀態", "state", "1"); FieldInfo fz4 = new FieldInfo("產品生效時間", "prodCycleBillingDate", TimeUtil.getCurrentDate(TimeUtil.TIME_FORMAT2_24)); FieldInfo fz5 = new FieldInfo("產品失效時間", "prodCyclebExpDate", "2099-12-28 15:32:03"); listZ.add(fz1); listZ.add(fz2); listZ.add(fz3); listZ.add(fz4); listZ.add(fz5); recordInfoSub.setFieldInfo(listZ); // 建立輸出流 StringWriter swMain = new StringWriter(); StringWriter swSub = new StringWriter(); String recordInfoMainStr = ""; String recordInfoSubStr = ""; try { // 利用jdk中自帶的轉換類實現 JAXBContext context = JAXBContext.newInstance(RecordInfo.class); Marshaller marshaller = context.createMarshaller(); //設置編碼 marshaller.setProperty(Marshaller.JAXB_ENCODING, "GBK"); //是否要帶 <?xml version="1.0" encoding="GBK" standalone="yes"?> marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); // 格式化xml輸出的格式 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 將對象轉換成輸出流形式的xml marshaller.marshal(recordInfoMain, swMain); recordInfoMainStr = swMain.toString(); marshaller.marshal(recordInfoSub, swSub); recordInfoSubStr = swSub.toString(); } catch (JAXBException e) { e.printStackTrace(); } String opDetail = "<opDetail>" + recordInfoMainStr + recordInfoSubStr + "</opDetail>"; String sheetType = EsopStatusEnums.ESOP_OPERATE_CREATE.getCode(); String req = "{opPerson=系統:CRM訪問ESB帳號, opTime=20171128153135, sheetType=" + sheetType + ", callTime=20171128153135, serSupplier=ZJ_AEP, serCaller=ZJ_BBOSS, serviceType=200, opCorp=杭州移動公司, serialNo=71201711281122554051, callerPwd=, opContact=13957350339, opDepart=12,opDetail=" + opDetail + "}"; // req = req.replaceAll("[\\t\\n\\r]", "");//去除換行符 System.out.println(req); // try { // Object[] result = invoke(serviceUrl, nameSpace, method, new Object[] { req }, // new Class[] { String.class }); // System.out.println(result[0]); // } catch (Exception e) { // e.printStackTrace(); // } } }