Java Code Examples for org.apache.commons.lang.reflect.FieldUtils#readStaticField()
The following examples show how to use
org.apache.commons.lang.reflect.FieldUtils#readStaticField() .
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: RefreshableDataSourceTest.java From das with Apache License 2.0 | 6 votes |
@Test public void test() throws SQLException, IllegalAccessException { DasClient client = DasClientFactory.getClient("MySqlSimple"); SqlBuilder sqlBuilder = SqlBuilder.selectCount().from(Person.PERSON).intoObject(); Number before = client.queryObject(sqlBuilder); DataSourceConfigure oldConfig = DataSourceConfigureLocatorManager.getInstance().getDataSourceConfigure("dal_shard_0"); DataSourceConfigure newConfig = new DataSourceConfigure(oldConfig.getName(), oldConfig.getProperties()); DataSourceConfigureChangeEvent event = new DataSourceConfigureChangeEvent("testEvent", newConfig, oldConfig); ConcurrentHashMap<String, DataSource> dss = (ConcurrentHashMap<String, DataSource>) FieldUtils.readStaticField(DataSourceLocator.class, "cache", true); RefreshableDataSource dataSource = (RefreshableDataSource) dss.get("dal_shard_0"); SingleDataSource oldSingleDataSource = ((AtomicReference<SingleDataSource>)FieldUtils.readField(dataSource, "dataSourceReference", true)).get(); dataSource.configChanged(event); Number after = client.queryObject(sqlBuilder); //verify datasource changed assertNotSame(oldSingleDataSource, ((AtomicReference<SingleDataSource>)FieldUtils.readField(dataSource, "dataSourceReference", true)).get()); //verify new datasource work fine assertEquals(before, after); }
Example 2
Source File: SFTPPutDialogTest.java From hop with Apache License 2.0 | 6 votes |
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if ( props == null ) { throw new IllegalStateException( "Cannot find 'props' field in " + Props.class.getName() ); } Object value = FieldUtils.readStaticField( props, true ); if ( value == null ) { PropsUI mock = mock( PropsUI.class ); FieldUtils.writeStaticField( props, mock, true ); changedPropsUi = true; } else { changedPropsUi = false; } }
Example 3
Source File: TextFileInputDialogTest.java From hop with Apache License 2.0 | 6 votes |
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if ( props == null ) { throw new IllegalStateException( "Cannot find 'props' field in " + Props.class.getName() ); } Object value = FieldUtils.readStaticField( props, true ); if ( value == null ) { PropsUI mock = mock( PropsUI.class ); FieldUtils.writeStaticField( props, mock, true ); changedPropsUi = true; } else { changedPropsUi = false; } }
Example 4
Source File: SFTPPutDialogTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if ( props == null ) { throw new IllegalStateException( "Cannot find 'props' field in " + Props.class.getName() ); } Object value = FieldUtils.readStaticField( props, true ); if ( value == null ) { PropsUI mock = mock( PropsUI.class ); FieldUtils.writeStaticField( props, mock, true ); changedPropsUi = true; } else { changedPropsUi = false; } }
Example 5
Source File: TextFileInputDialogTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if ( props == null ) { throw new IllegalStateException( "Cannot find 'props' field in " + Props.class.getName() ); } Object value = FieldUtils.readStaticField( props, true ); if ( value == null ) { PropsUI mock = mock( PropsUI.class ); FieldUtils.writeStaticField( props, mock, true ); changedPropsUi = true; } else { changedPropsUi = false; } }
Example 6
Source File: SalesforceInputDialogTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if ( props == null ) { throw new IllegalStateException( "Cannot find 'props' field in " + Props.class.getName() ); } Object value = FieldUtils.readStaticField( props, true ); if ( value == null ) { PropsUI mock = mock( PropsUI.class ); FieldUtils.writeStaticField( props, mock, true ); changedPropsUi = true; } else { changedPropsUi = false; } }