當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。