package com.celnet.datadump; import com.alibaba.fastjson.JSONObject; import com.celnet.datadump.mapper.CustomMapper; import com.sforce.async.BulkConnection; import com.sforce.soap.partner.PartnerConnection; import com.sforce.ws.ConnectionException; import com.sforce.ws.ConnectorConfig; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.util.HashMap; import java.util.List; import java.util.Map; @Slf4j public class DataDumpConnetTests { @Resource private CustomMapper customerMapper; /** * 测试目标ORG是否能连接 * @throws Exception */ @Test public void createConnect() throws Exception { try { // //遍历poll,找出code值为TARGET_ORG_URL,TARGET_ORG_USERNAME,TARGET_ORG_PASSWORD的value值 Map map = new HashMap<>(); // Map map = new HashMap<>(); // // for (Map map1 : poll) { // if ("TARGET_ORG_URL".equals(map1.get("code"))) { // map.put("urlFlag", map1.get("value").toString().equals("https://momentum-platform-2421.my.salesforce.com/services/Soap/u/56.0")); // } // if ("TARGET_ORG_USERNAME".equals(map1.get("code"))) { // map.put("usernameFlag", map1.get("value").toString().equals("jassi.w@procision.cn")); // map.put("username1", map1.get("value").toString()); // map.put("username2", "jassi.w@procision.cn"); // } // if ("TARGET_ORG_PASSWORD".equals(map1.get("code"))) { // map.put("passwordFlag", map1.get("value").toString().equals("ncnoisicorp@888")); // } // } //遍历poll,找出code值为TARGET_ORG_URL,TARGET_ORG_USERNAME,TARGET_ORG_PASSWORD的value值 map.put("url", "https://steco-process.my.sfcrmproducts.cn/services/Soap/u/56.0"); map.put("username", "binxu@steco-process.com"); map.put("password", "AAM0902!"); String username = map.get("username").toString(); ConnectorConfig config = new ConnectorConfig(); config.setUsername(username); config.setPassword(map.get("password").toString()); String url = map.get("url").toString(); config.setAuthEndpoint(url); config.setServiceEndpoint(url); config.setConnectionTimeout(60 * 60 * 1000); config.setReadTimeout(60 * 60 * 1000); PartnerConnection connection = new PartnerConnection(config); String orgId = connection.getUserInfo().getOrganizationId(); } catch (ConnectionException e) { e.printStackTrace(); } } }