Skip to content

Commit

Permalink
Add ut 1221 (#820)
Browse files Browse the repository at this point in the history
* add ut

* add tests

* update test

* update format

* update test

* update jarutils test

* update tests

* update tests

* update web server test

* update tests

* update tests

* update test

* update test

* update tests

* update tests

* update format

* update tests

* update test

* update tests

* update test

* Delete sofa-ark-parent/core/common/C:\temp dir\b\c directory

* update test

* update test

* update tesst

* update test

* update test

* update test

* update test

* update test

* update test

* update test

---------

Co-authored-by: LiuYu <ly109106@alibaba-inc.com>
  • Loading branch information
lylingzhen and LiuYu committed Jan 4, 2024
1 parent ef9584d commit c3192d0
Show file tree
Hide file tree
Showing 17 changed files with 570 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ sofa-ark-parent/support/ark-plugin-maven-plugin/com/alipay/sofa/ark/plugin/mark
sofa-ark-parent/support/ark-plugin-maven-plugin/null.ark.plugin
sofa-ark-parent/support/ark-plugin-maven-plugin/null.ark.plugin.bak
sofa-ark-parent/support/ark-plugin-maven-plugin/xxx.ark.plugin
*/temp dir/*
sofa-ark-parent/core/common/C/\temp dir\b\c/test.txt
2 changes: 0 additions & 2 deletions sofa-ark-parent/core-impl/container/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,5 @@
<artifactId>system-rules</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ private boolean checkDeclaredWithCache(String libraryFile) {
return declaredCacheMap.computeIfAbsent(libraryFile, this::doCheckDeclared);
}

private boolean doCheckDeclared(String jarFilePath) {
boolean doCheckDeclared(String jarFilePath) {

// if from ark plugin, then set as declared
if (isFromPlugin(jarFilePath)) {
return true;
Expand Down Expand Up @@ -497,4 +498,4 @@ private boolean isFromPlugin(String jarFilePath) {
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ public boolean validate(String command) {
return new BizCommand(command).isValidate();
}

private static final String HELP_MESSAGE = "Biz Command Tips:\n"
+ " USAGE: biz [option...] [arguments...]\n"
+ " SAMPLE: biz -m bizIdentityA bizIdentityB.\n"
+ " -h Shows the help message.\n"
+ " -a Shows all biz.\n"
+ " -m Shows the meta info of specified bizIdentity.\n"
+ " -s Shows the service info of specified bizIdentity.\n"
+ " -d Shows the detail info of specified bizIdentity.\n"
+ " -i Install biz of specified bizIdentity or bizUrl.\n"
+ " -u Uninstall biz of specified bizIdentity.\n"
+ " -o Switch biz of specified bizIdentity.\n";
static final String HELP_MESSAGE = "Biz Command Tips:\n"
+ " USAGE: biz [option...] [arguments...]\n"
+ " SAMPLE: biz -m bizIdentityA bizIdentityB.\n"
+ " -h Shows the help message.\n"
+ " -a Shows all biz.\n"
+ " -m Shows the meta info of specified bizIdentity.\n"
+ " -s Shows the service info of specified bizIdentity.\n"
+ " -d Shows the detail info of specified bizIdentity.\n"
+ " -i Install biz of specified bizIdentity or bizUrl.\n"
+ " -u Uninstall biz of specified bizIdentity.\n"
+ " -o Switch biz of specified bizIdentity.\n";

class BizCommand {
private boolean isValidate;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.ark.container.model;

import org.junit.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;

import static org.junit.Assert.*;

public class BizModelTest {

@Test
public void testDoCheckDeclared() throws MalformedURLException {

BizModel bizModel = new BizModel();
assertEquals(new HashSet(), bizModel.setAttribute("a", "b").setAttributes(new HashMap<>())
.getInjectExportPackages());
assertEquals(new HashSet(), bizModel.getInjectPluginDependencies());
bizModel.setCustomBizName("abc");
assertNotNull(bizModel.getAttributes());
assertNull(bizModel.getBizTempWorkDir());
bizModel.toString();

bizModel.setPluginClassPath(new URL[] { new URL("file://b/a.jar!/") });
assertTrue(bizModel.doCheckDeclared("file://b/a.jar!/b.jar"));
assertTrue(bizModel.doCheckDeclared(this.getClass().getClassLoader()
.getResource("test.jar").getPath()));
}
}

0 comments on commit c3192d0

Please sign in to comment.