diff --git a/nflg-wms-admin/src/test/java/com/nflg/wms/admin/SapMetaPrintTest.java b/nflg-wms-admin/src/test/java/com/nflg/wms/admin/SapMetaPrintTest.java index bc7b602c..03de4272 100644 --- a/nflg-wms-admin/src/test/java/com/nflg/wms/admin/SapMetaPrintTest.java +++ b/nflg-wms-admin/src/test/java/com/nflg/wms/admin/SapMetaPrintTest.java @@ -4,21 +4,16 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.sap.conn.jco.*; -import jakarta.annotation.Resource; +import com.sap.conn.jco.ext.DestinationDataEventListener; +import com.sap.conn.jco.ext.DestinationDataProvider; +import com.sap.conn.jco.ext.Environment; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; +import java.util.*; -@SpringBootTest public class SapMetaPrintTest { - @Resource - private JCoRepository repository; - @Test public void ZRFC_MM_SMXT() throws JCoException { printMeta("ZRFC_MM_SMXT"); @@ -118,6 +113,7 @@ public class SapMetaPrintTest { public void ZWM3A11() throws JCoException { printMeta("ZWM3A11"); } + @Test public void ZWM3A12() throws JCoException { printMeta("ZWM3A12"); @@ -159,7 +155,6 @@ public class SapMetaPrintTest { } - public void printMeta(String functionName) throws JCoException { functionName = functionName.toUpperCase(); JCoFunction function = repository.getFunction(functionName); @@ -323,6 +318,50 @@ public class SapMetaPrintTest { } } + private static JCoRepository repository; + + @BeforeAll + static void initOnce() throws JCoException { + Environment.registerDestinationDataProvider(new SimpleDestinationDataProvider(ABAP_AS_POOLED, buildConnectionProperties())); + repository = JCoDestinationManager.getDestination(ABAP_AS_POOLED).getRepository(); + } + + private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; + + private static Properties buildConnectionProperties() { + Properties props = new Properties(); + props.setProperty(DestinationDataProvider.JCO_ASHOST, "192.168.0.24"); + props.setProperty(DestinationDataProvider.JCO_SYSNR, "03"); + props.setProperty(DestinationDataProvider.JCO_CLIENT, "800"); + props.setProperty(DestinationDataProvider.JCO_USER, "mdm_back"); + props.setProperty(DestinationDataProvider.JCO_PASSWD, "sap-mdm"); + props.setProperty(DestinationDataProvider.JCO_LANG, "ZH"); + props.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10"); + props.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "20"); + return props; + } + + private static class SimpleDestinationDataProvider implements DestinationDataProvider { + private final Map destinations = new HashMap<>(); + + public SimpleDestinationDataProvider(String destName, Properties props) { + destinations.put(destName, props); + } + + @Override + public Properties getDestinationProperties(String destinationName) { + return destinations.get(destinationName); + } + + @Override + public void setDestinationDataEventListener(DestinationDataEventListener listener) { + } + + @Override + public boolean supportsEvents() { + return false; + } + } }