Skip to content

Commit

Permalink
Add test case. (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongZhang authored Sep 26, 2018
1 parent ac5be1d commit ce6e598
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.alipay.sofa.runtime.beans;

import com.alipay.sofa.runtime.spring.configuration.SofaRuntimeAutoConfiguration;
import com.alipay.sofa.runtime.spring.factory.ReferenceFactoryBean;
import com.alipay.sofa.runtime.util.StateMessage;
import org.springframework.aop.TargetSource;
Expand All @@ -37,7 +38,10 @@ protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanN
@Override
protected Object wrapIfNecessary(final Object bean, String beanName, Object cacheKey) {
if (bean instanceof ReferenceFactoryBean) {
StateMessage.setMessage("aop");
StateMessage.setFactoryMessage("aop");
}
if (bean instanceof SofaRuntimeAutoConfiguration) {
StateMessage.setConfigMessage("config");
}
return bean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
* @author qilong.zql
* @since 2.4.1
*/
public class ReferenceFactoryBeanTest extends AbstractTestBase {
public class BeanPostProcessorTest extends AbstractTestBase {
@Test
public void test() {
Assert.isTrue("aop".equals(StateMessage.getMessage()));
Assert.isTrue("aop".equals(StateMessage.getFactoryMessage()));
Assert.isTrue("config".equals(StateMessage.getConfigMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@
* @since 2.4.1
*/
public class StateMessage {
private static String message = "UNDO";
private static String factoryMessage = "UNDO";

public static void setMessage(String message) {
StateMessage.message = message;
private static String configMessage = "UNDO";

public static void setFactoryMessage(String factoryMessage) {
StateMessage.factoryMessage = factoryMessage;
}

public static String getFactoryMessage() {
return StateMessage.factoryMessage;
}

public static String getConfigMessage() {
return configMessage;
}

public static String getMessage() {
return StateMessage.message;
public static void setConfigMessage(String configMessage) {
StateMessage.configMessage = configMessage;
}
}

0 comments on commit ce6e598

Please sign in to comment.