Java Code Examples for org.springframework.test.util.ReflectionTestUtils#invokeMethod()
The following examples show how to use
org.springframework.test.util.ReflectionTestUtils#invokeMethod() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 6 votes |
@Test public void testRetrieveLinks(){ String linksStr = "[" + " {" + " \"href\": \"http://localhost/identity/v2\", " + " \"rel\": \"other\"" + " }," + " {" + " \"href\": \"http://localhost/identity/v3\", " + " \"rel\": \"self\"" + " }" + "]"; JsonNode linkNodes = ReflectionTestUtils.invokeMethod(keystoneClient, "json2Map", linksStr); ReflectionTestUtils.invokeMethod(keystoneClient, "retrieveLinks", linkNodes.elements()); assertEquals("http://localhost/identity/v3", ReflectionTestUtils.getField(keystoneClient, "baseUrl")); }
Example 2
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testComSubDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("abc.test.com"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertEquals(".test.com", name); }
Example 3
Source File: ConfigFileControllerIntegrationTest.java From apollo with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { ReflectionTestUtils.invokeMethod(appNamespaceServiceWithCache, "reset"); someDefaultCluster = ConfigConsts.CLUSTER_NAME_DEFAULT; someAppId = "someAppId"; somePublicAppId = "somePublicAppId"; someCluster = "someCluster"; someNamespace = "someNamespace"; somePublicNamespace = "somePublicNamespace"; someDC = "someDC"; grayClientIp = "1.1.1.1"; nonGrayClientIp = "2.2.2.2"; executorService = Executors.newSingleThreadExecutor(); }
Example 4
Source File: ConfigControllerIntegrationTest.java From apollo with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { ReflectionTestUtils.invokeMethod(appNamespaceServiceWithCache, "reset"); someAppId = "someAppId"; someCluster = "someCluster"; someNamespace = "someNamespace"; somePublicAppId = "somePublicAppId"; somePublicNamespace = "somePublicNamespace"; someDC = "someDC"; someDefaultCluster = ConfigConsts.CLUSTER_NAME_DEFAULT; someClientIp = "1.1.1.1"; executorService = Executors.newSingleThreadExecutor(); }
Example 5
Source File: ConfigIntegrationTest.java From apollo with Apache License 2.0 | 5 votes |
@Override @After public void tearDown() throws Exception { ReflectionTestUtils.invokeMethod(remoteConfigLongPollService, "stopLongPollingRefresh"); recursiveDelete(configDir); super.tearDown(); }
Example 6
Source File: CredHubCredentialsGeneratorTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void passwordParameters() { PasswordParameters params = ReflectionTestUtils .invokeMethod(generator, "passwordParameters", 42, false, false, false, false); assertThat(params.getLength()).isEqualTo(42); assertThat(params.getExcludeUpper()).isTrue(); assertThat(params.getExcludeLower()).isTrue(); assertThat(params.getExcludeNumber()).isTrue(); assertThat(params.getIncludeSpecial()).isFalse(); }
Example 7
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testIpAddress() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("127.0.0.1"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertNull(name); }
Example 8
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testNestedDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("abc.xyu.test.co.uk"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertEquals(".test.co.uk", name); }
Example 9
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testCoUkSubDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("abc.test.co.uk"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertEquals(".test.co.uk", name); }
Example 10
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testCoUkDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("test.co.uk"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertNull(name); //already top-level domain }
Example 11
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testWwwSubDomainCom() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("www.abc.test.com"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertEquals(".test.com", name); }
Example 12
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 5 votes |
@Test public void testBuildLocalTokenParams(){ String requestParams = ReflectionTestUtils.invokeMethod(keystoneClient, "buildLocalTokenParams"); JsonNode auth = ReflectionTestUtils.invokeMethod(keystoneClient, "json2Map", requestParams); assertEquals("password", auth.path("auth").path("identity").path("methods").elements().next().asText()); assertEquals("test", auth.path("auth").path("identity").path("password").path("user").path("name").asText()); assertEquals("test", auth.path("auth").path("identity").path("password").path("user").path("password").asText()); assertEquals("service", auth.path("auth").path("scope").path("project").path("name").asText()); }
Example 13
Source File: NotificationControllerV2IntegrationTest.java From apollo with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { ReflectionTestUtils.invokeMethod(releaseMessageServiceWithCache, "reset"); someAppId = "someAppId"; someCluster = ConfigConsts.CLUSTER_NAME_DEFAULT; defaultNamespace = ConfigConsts.NAMESPACE_APPLICATION; somePublicNamespace = "somePublicNamespace"; executorService = Executors.newSingleThreadExecutor(); typeReference = new ParameterizedTypeReference<List<ApolloConfigNotification>>() { }; }
Example 14
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testComDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("test.com"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertNull(name); //already top-level domain }
Example 15
Source File: OAuth2CookieHelperTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test public void testLocalhostDomain() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("localhost"); String name = ReflectionTestUtils.invokeMethod(cookieHelper, GET_COOKIE_DOMAIN_METHOD, request); Assert.assertNull(name); }
Example 16
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 5 votes |
@Test public void getLocalTokenTest() throws ParseException{ ReflectionTestUtils.invokeMethod(keystoneClient, "getLocalToken"); assertEquals(TEST_LOCAL_TOKEN, ReflectionTestUtils.getField(keystoneClient, "localToken")); assertEquals(dateFormat.parse("2100-06-01T08:16:01.000+0000"), ReflectionTestUtils.getField(keystoneClient, "localTokenExpireDate")); }
Example 17
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 5 votes |
@Test public void testFindEndPoint(){ String endpointsStr = "[{" + " \"status\": \"stable\", " + " \"updated\": \"2019-07-19T00:00:00Z\"," + " \"media-types\": [{" + " \"base\": \"application/json\", " + " \"type\": \"application/vnd.openstack.identity-v3+json\"" + " }]," + " \"id\": \"v2.13\", " + " \"links\": [{" + " \"href\": \"http://localhost/identity/v2\", " + " \"rel\": \"self\"" + " }]}," + " {\"status\": \"current\", " + " \"updated\": \"2019-07-19T00:00:00Z\"," + " \"media-types\": [{" + " \"base\": \"application/json\", " + " \"type\": \"application/vnd.openstack.identity-v3+json\"" + " }]," + " \"id\": \"v3.13\", " + " \"links\": [{" + " \"href\": \"http://localhost/identity/v3\", " + " \"rel\": \"self\"" + " }]}" + "] "; JsonNode auth = ReflectionTestUtils.invokeMethod(keystoneClient, "json2Map", endpointsStr); ReflectionTestUtils.invokeMethod(keystoneClient, "findEndPoint", auth.elements()); assertEquals("http://localhost/identity/v2", ReflectionTestUtils.getField(keystoneClient, "baseUrl")); }
Example 18
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 5 votes |
@Test public void testJson2Map(){ String testJson = "{" + "\"keyA\": \"keya\", " + "\"listB\": [\"b1\", \"b2\", \"b3\"]" + "}"; JsonNode testNode = ReflectionTestUtils.invokeMethod(keystoneClient, "json2Map", testJson); assertEquals("keya", testNode.path("keyA").asText()); assertEquals("b1", testNode.path("listB").elements().next().asText()); }
Example 19
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 4 votes |
@Test public void checkEndpointsTest(){ ReflectionTestUtils.invokeMethod(keystoneClient, "checkEndPoints"); assertEquals("http://localhost/identity/v3", ReflectionTestUtils.getField(keystoneClient, "baseUrl")); }
Example 20
Source File: KeystoneClientTest.java From alcor with Apache License 2.0 | 4 votes |
@Test public void testAssignBaseUrlWithBestEndpoint(){ String endpointsStr = "[{" + " \"status\": \"stable\", " + " \"updated\": \"2019-07-19T00:00:00Z\"," + " \"media-types\": [{" + " \"base\": \"application/json\", " + " \"type\": \"application/vnd.openstack.identity-v3+json\"" + " }]," + " \"id\": \"v2.13\", " + " \"links\": [{" + " \"href\": \"http://localhost/identity/v2\", " + " \"rel\": \"self\"" + " }]}," + " {\"status\": \"current\", " + " \"updated\": \"2019-07-19T00:00:00Z\"," + " \"media-types\": [{" + " \"base\": \"application/json\", " + " \"type\": \"application/vnd.openstack.identity-v3+json\"" + " }]," + " \"id\": \"v3.13\", " + " \"links\": [{" + " \"href\": \"http://localhost/identity/v3\", " + " \"rel\": \"self\"" + " }]}," + " {\"status\": \"unknown\", " + " \"updated\": \"2019-07-19T00:00:00Z\"," + " \"media-types\": [{" + " \"base\": \"application/json\", " + " \"type\": \"application/vnd.openstack.identity-v3+json\"" + " }]," + " \"id\": \"v4.5\", " + " \"links\": [{" + " \"href\": \"http://localhost/identity/v4\", " + " \"rel\": \"self\"" + " }]}" + "] "; JsonNode auth = ReflectionTestUtils.invokeMethod(keystoneClient, "json2Map", endpointsStr); ReflectionTestUtils.invokeMethod(keystoneClient, "assignBaseUrlWithBestEndpoint", auth.elements()); assertEquals("http://localhost/identity/v3", ReflectionTestUtils.getField(keystoneClient, "baseUrl")); }