From 3aa43594b695dc61261d6aec147a9cfcbf8542d1 Mon Sep 17 00:00:00 2001 From: hujie Date: Thu, 11 Oct 2018 18:53:40 +0800 Subject: [PATCH] CI No environment --- .../plug/engine/PlainAclPlugEngineTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java index 618c87e4..bf3ec8da 100644 --- a/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java +++ b/acl-plug/src/test/java/org/apache/rocketmq/acl/plug/engine/PlainAclPlugEngineTest.java @@ -18,11 +18,14 @@ package org.apache.rocketmq.acl.plug.engine; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; + import org.apache.rocketmq.acl.plug.entity.AccessControl; import org.apache.rocketmq.acl.plug.entity.AuthenticationInfo; import org.apache.rocketmq.acl.plug.entity.AuthenticationResult; @@ -54,11 +57,20 @@ public class PlainAclPlugEngineTest { Map loginInfoMap; @Before - public void init() throws FileNotFoundException, NoSuchFieldException, SecurityException { + public void init() throws NoSuchFieldException, SecurityException, IOException { + Yaml ymal = new Yaml(); String home = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV)); - Yaml ymal = new Yaml(); - String filePath = home + "/conf/transport.yml"; - FileInputStream fis = new FileInputStream(new File(filePath)); + InputStream fis=null; + if(home == null){ + URL url = PlainAclPlugEngineTest.class.getResource("/conf/transport.yml"); + fis = url.openStream(); + url = PlainAclPlugEngineTest.class.getResource("/"); + home = url.toString(); + home = home.substring(0, home.length()-1).replace("file:/", ""); + }else { + String filePath = home + "/conf/transport.yml"; + fis = new FileInputStream(new File(filePath)); + } transport = ymal.loadAs(fis, BorkerAccessControlTransport.class); ControllerParameters controllerParametersEntity = new ControllerParameters(); -- GitLab