From 18ef7ce6ab00b0824db11fdf23643ca392edcd2f Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期一, 16 六月 2025 16:44:09 +0800
Subject: [PATCH] art: SAP集成测试代码修改

---
 src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java b/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java
index e120d4f..5463389 100644
--- a/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java
+++ b/src/main/java/org/jeecg/config/sap/SapRfcConnectionManager.java
@@ -3,13 +3,17 @@
 import com.sap.conn.jco.*;
 import com.sap.conn.jco.ext.DestinationDataProvider;
 import com.sap.conn.jco.ext.Environment;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.util.Properties;
 
 @Component
+@Slf4j
 public class SapRfcConnectionManager {
 
     @Value("${sap.rfc.destination}")
@@ -46,7 +50,7 @@
      * @throws JCoException
      */
     @PostConstruct
-    public void init() throws JCoException {
+    public void init() throws Exception {
         Properties connectProperties = new Properties();
         connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, ashost);
         connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, sysnr);
@@ -59,11 +63,31 @@
         connectProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_TIME, idleTimeout);
 
         // 鍒涘缓鍔ㄦ�佺洰鐨勫湴锛堥伩鍏嶄緷璧� SM59 閰嶇疆锛�
-        CustomDestinationDataProvider provider = new CustomDestinationDataProvider();
-        provider.addDestination(destinationName, connectProperties);
+//        CustomDestinationDataProvider provider = new CustomDestinationDataProvider();
+//        provider.addDestination(destinationName, connectProperties);
 
         // 璁剧疆鍏ㄥ眬鐩殑鍦版彁渚涜��
-        Environment.registerDestinationDataProvider(provider);
+//        Environment.registerDestinationDataProvider(provider);
+
+        log.info("properties = " + connectProperties);
+
+        //鐢熸垚閰嶇疆鏂囦欢锛孞CoDestinationManager.getDestination()璋冪敤鏃朵細闇�瑕佽杩炴帴閰嶇疆鏂囦欢锛屽悗缂�鍚嶉渶瑕佷负jcoDestination
+        FileOutputStream fos = null;
+        String suffix = "jcoDestination";
+        File cfg = new File(destinationName + "." + suffix);
+        if (!cfg.exists()) {
+            try {
+                fos = new FileOutputStream(cfg, false);
+                connectProperties.store(fos, "for tests only !");
+                fos.close();
+            } catch (Exception var9) {
+                throw new Exception("Unable to create the destination file " + cfg.getName(), var9);
+            } finally {
+                if (null != fos) {
+                    fos.close();
+                }
+            }
+        }
 
         // 鑾峰彇鐩殑鍦�
         this.destination = JCoDestinationManager.getDestination(destinationName);

--
Gitblit v1.9.3