当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionTestUtils.setField方法代码示例

本文整理汇总了Java中org.springframework.test.util.ReflectionTestUtils.setField方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionTestUtils.setField方法的具体用法?Java ReflectionTestUtils.setField怎么用?Java ReflectionTestUtils.setField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.test.util.ReflectionTestUtils的用法示例。


在下文中一共展示了ReflectionTestUtils.setField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    urlRules = buildURLRules(buildDefaultStatement(PORT, PROTOCOL, URN, "4"));
    stubNamespacedListsHolder = new StubNamespacedListsHolder();
    Config config = new Config();

    ServiceProviderManagerFactory serviceProviderManagerFactory = new ServiceProviderManagerFactory();
    serviceProviderManagerFactory.setConfig(config);
    serviceProviderManagerFactory.setProviderStrategy(new RoundRobinStrategy<>());

    factory = new RedirectorEngineFactory(serviceProviderManagerFactory);

    ReflectionTestUtils.setField(factory, "config", config);
    ReflectionTestUtils.setField(factory, "isStaticDiscoveryNeededForApp", Predicate.isEqual(APP_NAME));
    ReflectionTestUtils.setField(factory, "serializer", serializer);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:17,代码来源:StaticEngineBuiltFromWSModelTest.java

示例2: sendPasswordResetEmailSMTP

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Test
public void sendPasswordResetEmailSMTP() {
    ReflectionTestUtils.setField(sut, "mailEnabled", true);

    String id = "1234567890";
    String email = "[email protected]";
    String subject = "Password recovery";
    String expected = "Hello!\nSomeone has requested a password recovery on this email address. If this was not " +
            "you then just ignore this message. If not then click the link bellow.\n\n" +
            "http://localhost:8080/update-password/" + id;

    sut.sendPasswordResetEmail(id, email);

    ArgumentCaptor<SimpleMailMessage> captor = ArgumentCaptor.forClass(SimpleMailMessage.class);
    verify(sender, times(1)).send(captor.capture());
    SimpleMailMessage message = captor.getValue();


    assertEquals(1, message.getTo().length);
    assertEquals(email, message.getTo()[0]);
    assertEquals(subject, message.getSubject());
    assertEquals(expected, message.getText());
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:24,代码来源:EmailTest.java

示例3: sendOrganizationChangeDenialEmailSMTP

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Test
public void sendOrganizationChangeDenialEmailSMTP() {
    ReflectionTestUtils.setField(sut, "mailEnabled", true);

    String email = "[email protected]";
    String subject = "Your organization change was denied";
    String expected = "Hello!\nYour organization change was denied by an administrator";

    sut.sendDenialEmail(email, "organization change");

    ArgumentCaptor<SimpleMailMessage> captor = ArgumentCaptor.forClass(SimpleMailMessage.class);
    verify(sender, times(1)).send(captor.capture());
    SimpleMailMessage message = captor.getValue();

    assertEquals(1, message.getTo().length);
    assertEquals(email, message.getTo()[0]);
    assertEquals(subject, message.getSubject());
    assertEquals(expected, message.getText());
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:20,代码来源:EmailTest.java

示例4: setUp

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@BeforeClass
    public static void setUp() throws Exception {
        layoutMapper = new LayoutMapper();
        YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
        yamlMapFactoryBean.setResources(new FileSystemResource(LayoutMapperTest.class.getResource("layout.yml").getPath()));
//        String layout = "" +
//                "category:\n" +
//                "  _default_: \"category/_layout\"\n" +
//                "food:\n" +
//                "  detail: \"food/_layout\"\n" +
//                "boo:\n" +
//                "  _default_: \"boo/_layout\"\n" +
//                "  index: \"_boo\"\n" +
//                "  foo:\n" +
//                "    detail: \"boo/_detail\"" +
//                "";
//        yamlMapFactoryBean.setResources(new ByteArrayResource(layout.getBytes("UTF-8")));
        yamlMapFactoryBean.afterPropertiesSet();
        ReflectionTestUtils.setField(layoutMapper, "layout", yamlMapFactoryBean.getObject());
        ReflectionTestUtils.invokeMethod(layoutMapper, "init");
    }
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:22,代码来源:LayoutMapperTest.java

示例5: init

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void init() {
    MockitoAnnotations.initMocks(this);
    ReflectionTestUtils.setField(jwtUtils, "expirationInSecs", EXPIRATION_PERIOD);
    ReflectionTestUtils.setField(jwtUtils, "secret", SECRET_KEY);
    ReflectionTestUtils.setField(jwtUtils, "allowedClockSkewInSecs", ALLOWED_CLOCK_SKEW_IN_SECS);
    ReflectionTestUtils.setField(jwtUtils, "issuer", ISSUER);
    ReflectionTestUtils.setField(jwtUtils, "audience", AUDIENCE);
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:10,代码来源:TestJwtUtils.java

示例6: shouldNotAddACustomerIfCustomerAlreadyExists

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Test
public void shouldNotAddACustomerIfCustomerAlreadyExists() throws Exception {

	// Given
	when(repo.existsById(any(ObjectId.class))).thenReturn(Mono.just(true));
	final ObjectId id = ObjectId.get();
	final Customer customer = Customer.ofType(PERSON).build();
	ReflectionTestUtils.setField(customer, "id", id);

	// When
	// Then
	assertThatThrownBy(() -> controller.addCustomer(customer).block())
		.isInstanceOf(CustomerServiceException.class)
		.hasMessageContaining("Customer already exists");
}
 
开发者ID:dserradji,项目名称:reactive-customer-service,代码行数:16,代码来源:CustomerControllerTest.java

示例7: beforeEachTest

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void beforeEachTest() {
    MockitoAnnotations.initMocks(this);

    producer = new PrivilegeEventProducer(template);
    ReflectionTestUtils.setField(producer, "appName", "test-ms");
    ReflectionTestUtils.setField(producer, "topicName", topicSystemQueue);
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:9,代码来源:PrivilegeEventProducerUnitTest.java

示例8: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    ImageResourceResource imageResourceResource = new ImageResourceResource();
    ReflectionTestUtils.setField(imageResourceResource, "imageResourceRepository", imageResourceRepository);
    this.restImageResourceMockMvc = MockMvcBuilders.standaloneSetup(imageResourceResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:10,代码来源:ImageResourceResourceTest.java

示例9: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    TimeFrameResource timeFrameResource = new TimeFrameResource();
    ReflectionTestUtils.setField(timeFrameResource, "timeFrameService", timeFrameService);
    this.restTimeFrameMockMvc = MockMvcBuilders.standaloneSetup(timeFrameResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:10,代码来源:TimeFrameResourceIntTest.java

示例10: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    SubscriberResource subscriberResource = new SubscriberResource();
    ReflectionTestUtils.setField(subscriberResource, "subscriberService", subscriberService);
    this.restSubscriberMockMvc = MockMvcBuilders.standaloneSetup(subscriberResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:10,代码来源:SubscriberResourceIntTest.java

示例11: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    PostResource postResource = new PostResource();
    ReflectionTestUtils.setField(postResource, "postRepository", postRepository);
    ReflectionTestUtils.setField(postResource, "postMapper", postMapper);
    this.restPostMockMvc = MockMvcBuilders.standaloneSetup(postResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:11,代码来源:PostResourceTest.java

示例12: testGetCanonicalizedResourcePathEncodingException

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link org.ligoj.app.plugin.prov.aws.auth.AWS4SignerBase#getCanonicalizedResourcePath(java.lang.String)}.
 */
@Test(expected = TechnicalException.class)
public void testGetCanonicalizedResourcePathEncodingException() throws Exception {
	final AWS4SignerBase signer = new AWS4SignerForAuthorizationHeader();
	final URLCodec urlCodec = Mockito.mock(URLCodec.class);
	ReflectionTestUtils.setField(signer, "urlCodec", urlCodec);
	Mockito.when(urlCodec.encode(ArgumentMatchers.anyString())).thenThrow(new EncoderException());
	signer.getCanonicalizedResourcePath("/path");
}
 
开发者ID:ligoj,项目名称:plugin-prov-aws,代码行数:13,代码来源:AWS4SignerBaseTest.java

示例13: setUp

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  appNamespaceServiceWithCache = new AppNamespaceServiceWithCache();
  ReflectionTestUtils.setField(appNamespaceServiceWithCache, "appNamespaceRepository",
      appNamespaceRepository);
  ReflectionTestUtils.setField(appNamespaceServiceWithCache, "bizConfig", bizConfig);

  scanInterval = 50;
  scanIntervalTimeUnit = TimeUnit.MILLISECONDS;
  when(bizConfig.appNamespaceCacheRebuildInterval()).thenReturn(scanInterval);
  when(bizConfig.appNamespaceCacheRebuildIntervalTimeUnit()).thenReturn(scanIntervalTimeUnit);
  when(bizConfig.appNamespaceCacheScanInterval()).thenReturn(scanInterval);
  when(bizConfig.appNamespaceCacheScanIntervalTimeUnit()).thenReturn(scanIntervalTimeUnit);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:15,代码来源:AppNamespaceServiceWithCacheTest.java

示例14: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@Before
public void setup() {
    jHipsterProperties = Mockito.mock(JHipsterProperties.class);
    tokenProvider = new TokenProvider(jHipsterProperties);
    ReflectionTestUtils.setField(tokenProvider, "secretKey", secretKey);
    ReflectionTestUtils.setField(tokenProvider, "tokenValidityInMilliseconds", ONE_MINUTE);
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:8,代码来源:TokenProviderTest.java

示例15: setup

import org.springframework.test.util.ReflectionTestUtils; //导入方法依赖的package包/类
@PostConstruct
public void setup() {
    MockitoAnnotations.initMocks(this);
    PhotoLocationExtraImageResource photoLocationExtraImageResource = new PhotoLocationExtraImageResource();
    ReflectionTestUtils.setField(photoLocationExtraImageResource, "photoLocationExtraImageRepository", photoLocationExtraImageRepository);
    this.restPhotoLocationExtraImageMockMvc = MockMvcBuilders.standaloneSetup(photoLocationExtraImageResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setMessageConverters(jacksonMessageConverter).build();
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:10,代码来源:PhotoLocationExtraImageResourceTest.java


注:本文中的org.springframework.test.util.ReflectionTestUtils.setField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。