🆕 add spring-boot-test
This commit is contained in:
parent
4840bb86ca
commit
e8b9e9b9b7
|
@ -29,9 +29,6 @@
|
|||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
<artifactId>spring-boot-nebula-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -40,7 +39,7 @@
|
|||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ExpressionUtil {
|
|||
if (paramNames == null || args == null || paramNames.length != args.length) {
|
||||
throw new IllegalArgumentException("Method parameter names and argument values do not match.");
|
||||
}
|
||||
//SPEL解析
|
||||
// SPEL解析
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
for (int i = 0; i < Objects.requireNonNull(paramNames).length; i++) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package com.nebula.web.common.utils;
|
||||
|
||||
/**
|
||||
* @author : wh
|
||||
* @date : 2024/6/1 22:12
|
||||
* @description:
|
||||
*/
|
||||
public class ExpressionUtilTest {
|
||||
|
||||
|
||||
}
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* 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.nebula.web.common.utils;
|
||||
|
||||
import com.nebula.web.common.autoconfigure.NebulaWebCommonAutoConfiguration;
|
||||
|
@ -10,6 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
@ -20,34 +38,34 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
*/
|
||||
@SpringBootTest(classes = SpringBeanUtilsTest.TestConfig.class)
|
||||
public class SpringBeanUtilsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void getBean() {
|
||||
Object bean = SpringBeanUtils.getBean("testBean");
|
||||
assertTrue(bean instanceof TestBean);
|
||||
assertInstanceOf(TestBean.class, bean);
|
||||
TestBean bean1 = SpringBeanUtils.getBean(TestBean.class);
|
||||
assertTrue(Objects.nonNull(bean1));
|
||||
assertThrowsExactly(NoSuchBeanDefinitionException.class, () -> SpringBeanUtils.getBean(NoTestBean.class));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static final class TestBean {
|
||||
}
|
||||
|
||||
|
||||
static final class NoTestBean {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({NebulaWebCommonAutoConfiguration.class})
|
||||
public static class TestConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public TestBean testBean() {
|
||||
return new TestBean();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -27,7 +27,6 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
|
Loading…
Reference in New Issue