本文整理汇总了Java中org.springframework.security.util.FieldUtils类的典型用法代码示例。如果您正苦于以下问题:Java FieldUtils类的具体用法?Java FieldUtils怎么用?Java FieldUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldUtils类属于org.springframework.security.util包,在下文中一共展示了FieldUtils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RepoIndexer
import org.springframework.security.util.FieldUtils; //导入依赖的package包/类
public RepoIndexer(StoringRepo repo) {
if (repo == null) {
throw new IllegalArgumentException("Repo cannot be null");
}
this.repo = repo;
//Unplexus
defaultIndexerEngine = new DefaultIndexerEngine();
FieldUtils.setProtectedFieldValue("indexerEngine", this, defaultIndexerEngine);
DefaultQueryCreator queryCreator = new DefaultQueryCreator();
FieldUtils.setProtectedFieldValue("logger", queryCreator,
new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console"));
FieldUtils.setProtectedFieldValue("queryCreator", this, queryCreator);
FieldUtils.setProtectedFieldValue("searcher", this, new DefaultSearchEngine());
//packer
IncrementalHandler incrementalHandler = new DefaultIncrementalHandler();
FieldUtils.setProtectedFieldValue("logger", incrementalHandler,
new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console"));
packer = new DefaultIndexPacker();
FieldUtils.setProtectedFieldValue("incrementalHandler", packer, incrementalHandler);
FieldUtils.setProtectedFieldValue("logger", packer,
new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_WARN, "console"));
ArtifactoryArtifactContextProducer artifactContextProducer = new ArtifactoryArtifactContextProducer();
scanner = new ArtifactoryContentScanner(artifactContextProducer);
}
示例2: getObjectClassId_NewObjectClassName_ShouldRetrieveFromDataStoreAndPutIntoCache
import org.springframework.security.util.FieldUtils; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void getObjectClassId_NewObjectClassName_ShouldRetrieveFromDataStoreAndPutIntoCache() throws Exception {
// arrange
final String STUBBED_ACL_CLASS_ID = "fake-id";
final String STUBBED_ACL_CLASS_NAME = "com.example.model.StubbedClass";
AclClass stubbedAclClass = new AclClass();
stubbedAclClass.setId(STUBBED_ACL_CLASS_ID);
stubbedAclClass.setClassName(STUBBED_ACL_CLASS_NAME);
QAclClass aclClass = QAclClass.aclClass;
when(mockRepository.findOne(aclClass.className.eq(STUBBED_ACL_CLASS_NAME))).thenReturn(stubbedAclClass);
SimpleCacheAclClassService cacheAclClassService = new SimpleCacheAclClassService(mockRepository);
// action
String objectClassId = cacheAclClassService.getObjectClassId(STUBBED_ACL_CLASS_NAME);
// verify
assertEquals("", STUBBED_ACL_CLASS_ID, objectClassId);
Map<String, String> cache = (Map<String, String>) FieldUtils.getFieldValue(cacheAclClassService, "classNameToIdMap");
assertTrue(cache.containsKey(STUBBED_ACL_CLASS_NAME));
assertTrue(cache.containsValue(STUBBED_ACL_CLASS_ID));
verify(mockRepository).findOne(eq(aclClass.className.eq(STUBBED_ACL_CLASS_NAME)));
}
示例3: getObjectClassName_ValidObjectClassId_ReturnDataFromDatastore
import org.springframework.security.util.FieldUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void getObjectClassName_ValidObjectClassId_ReturnDataFromDatastore() throws Exception {
// arrange
String objectClassId = "1";
AclClass stubClass = new AclClass();
stubClass.setClassName("SampleClass");
stubClass.setId(objectClassId);
when(mockRepository.findOne(objectClassId)).thenReturn(stubClass);
SimpleCacheAclClassService cacheAclClassService = new SimpleCacheAclClassService(mockRepository);
// action
String objectClassName = cacheAclClassService.getObjectClassName(objectClassId);
// verify
assertNotNull(objectClassName);
assertEquals("SampleClass", objectClassName);
Map<String, String> classNameToIdMap = (Map<String, String>)FieldUtils.getFieldValue(cacheAclClassService, "classNameToIdMap");
assertTrue(classNameToIdMap.containsKey("SampleClass"));
assertEquals(classNameToIdMap.get("SampleClass"), "1");
}
示例4: getReader
import org.springframework.security.util.FieldUtils; //导入依赖的package包/类
/**
* @return The shell's {@link ConsoleReader}.
*/
public ConsoleReader getReader() {
// XXX Spring Shell doesn't expose the reader that we need to use to
// read values from a terminal, so use reflection to pull it out.
return (ConsoleReader) FieldUtils.getProtectedFieldValue("reader", shell);
}