本文整理汇总了Java中org.ligoj.app.resource.ServicePluginLocator类的典型用法代码示例。如果您正苦于以下问题:Java ServicePluginLocator类的具体用法?Java ServicePluginLocator怎么用?Java ServicePluginLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServicePluginLocator类属于org.ligoj.app.resource包,在下文中一共展示了ServicePluginLocator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateCatalogFailed
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void updateCatalogFailed() throws Exception {
final ImportCatalogResource resource = new ImportCatalogResource() {
@Override
public ImportCatalogStatus nextStep(final String node, final Consumer<ImportCatalogStatus> stepper) {
return super.nextStep(node, stepper);
}
};
applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
// Replace the locator for the custom provider
resource.locator = Mockito.mock(ServicePluginLocator.class);
final ImportCatalogService service = Mockito.mock(ImportCatalogService.class);
Mockito.when(resource.locator.getResource("service:prov:test", ImportCatalogService.class)).thenReturn(service);
Mockito.doThrow(new IOException()).when(service).updateCatalog("service:prov:test");
final ImportCatalogStatus status = resource.updateCatalog("service:prov:test:account");
Assert.assertEquals(DEFAULT_USER, status.getAuthor());
Assert.assertNull(status.getEnd());
Assert.assertNull(status.getLocation());
Assert.assertEquals("service:prov:test", status.getLocked().getId());
Assert.assertNotNull(status.getStart());
Assert.assertEquals(0, status.getDone());
Assert.assertEquals(0, status.getWorkload());
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:26,代码来源:ImportCatalogResourceTest.java
示例2: applyTerraformError
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
/**
* IOException during the asynchronous execution
*/
@Test
public void applyTerraformError() {
final TerraformResource resource = new TerraformResource() {
@Override
protected File applyTerraform(final Subscription entity, final Terraforming terra, final QuoteVo configuration)
throws IOException, InterruptedException {
throw new IOException();
}
};
super.applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
// Mock to disable inner transactions for this test
resource.resource = Mockito.mock(ProvResource.class);
final ServicePluginLocator locator = Mockito.mock(ServicePluginLocator.class);
// Replace the plugin locator
resource.locator = locator;
Mockito.when(locator.getResource("service:prov:test:account", Terraforming.class)).thenReturn(Mockito.mock(Terraforming.class));
resource.applyTerraform(subscription);
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:25,代码来源:TerraformResourceTest.java
示例3: authenticateSecondaryAccept
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void authenticateSecondaryAccept() throws Exception {
final Authentication authentication = new UsernamePasswordAuthenticationToken("user1", "secret");
final Authentication authentication2 = new UsernamePasswordAuthenticationToken("user1v2", "secret");
final IdentityServicePlugin servicePlugin = Mockito.mock(IdentityServicePlugin.class);
final NodeBasedIamProvider provider = new NodeBasedIamProvider();
provider.configuration = configuration;
provider.servicePluginLocator = Mockito.mock(ServicePluginLocator.class);
Mockito.when(provider.servicePluginLocator.getResource("service:id:ldap:adu", IdentityServicePlugin.class))
.thenReturn(servicePlugin);
Mockito.when(servicePlugin.accept(authentication, "service:id:ldap:adu")).thenReturn(true);
Mockito.when(servicePlugin.authenticate(authentication, "service:id:ldap:adu", false))
.thenReturn(authentication2);
Assert.assertSame(authentication2, provider.authenticate(authentication));
Mockito.verify(provider.servicePluginLocator, VerificationModeFactory.times(0))
.getResource("service:id:ldap:dig", IdentityServicePlugin.class);
}
开发者ID:ligoj,项目名称:plugin-iam-node,代码行数:18,代码来源:NodeBasedIamProviderTest.java
示例4: authenticateSecondaryDontAccept
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void authenticateSecondaryDontAccept() throws Exception {
final Authentication authentication = new UsernamePasswordAuthenticationToken("user1", "secret");
final Authentication authentication2 = new UsernamePasswordAuthenticationToken("user1v2", "secret");
final IdentityServicePlugin servicePluginSecondary = Mockito.mock(IdentityServicePlugin.class);
final IdentityServicePlugin servicePluginPrimary = Mockito.mock(IdentityServicePlugin.class);
final NodeBasedIamProvider provider = new NodeBasedIamProvider();
provider.configuration = configuration;
provider.servicePluginLocator = Mockito.mock(ServicePluginLocator.class);
Mockito.when(provider.servicePluginLocator.getResource("service:id:ldap:adu", IdentityServicePlugin.class))
.thenReturn(servicePluginSecondary);
Mockito.when(servicePluginPrimary.authenticate(authentication, "service:id:ldap:dig", true))
.thenReturn(authentication2);
Mockito.when(
provider.servicePluginLocator.getResourceExpected("service:id:ldap:dig", IdentityServicePlugin.class))
.thenReturn(servicePluginPrimary);
Assert.assertSame(authentication2, provider.authenticate(authentication));
Mockito.verify(servicePluginSecondary, VerificationModeFactory.times(0)).authenticate(authentication,
"service:id:ldap:adu", false);
}
开发者ID:ligoj,项目名称:plugin-iam-node,代码行数:21,代码来源:NodeBasedIamProviderTest.java
示例5: updateCatalog
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void updateCatalog() throws Exception {
final ImportCatalogResource resource = new ImportCatalogResource() {
@Override
public ImportCatalogStatus getTask(@PathParam("node") final String node) {
return getTaskRepository().findBy("locked.id", node);
}
};
applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
// Replace the locator for the custom provider
resource.locator = Mockito.mock(ServicePluginLocator.class);
final ImportCatalogService service = Mockito.mock(ImportCatalogService.class);
Mockito.when(resource.locator.getResource("service:prov:test", ImportCatalogService.class)).thenReturn(service);
final ImportCatalogStatus status = resource.updateCatalog("service:prov:test:account");
Assert.assertEquals(DEFAULT_USER, status.getAuthor());
Assert.assertNull(status.getEnd());
Assert.assertNull(status.getLocation());
Assert.assertEquals("service:prov:test", status.getLocked().getId());
Assert.assertNotNull(status.getStart());
Assert.assertNull(status.getLocation());
Assert.assertEquals(0, status.getDone());
Assert.assertEquals(0, status.getWorkload());
Assert.assertFalse(resource.getTask("service:prov:test").isFinished());
Thread.sleep(100);
Mockito.verify(service).updateCatalog("service:prov:test");
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:31,代码来源:ImportCatalogResourceTest.java
示例6: authenticateNoSecondary
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void authenticateNoSecondary() throws Exception {
final Authentication authentication = new UsernamePasswordAuthenticationToken("user1", "secret");
final Authentication authentication2 = new UsernamePasswordAuthenticationToken("user1v2", "secret");
final NodeBasedIamProvider provider = new NodeBasedIamProvider();
final IdentityServicePlugin servicePlugin = Mockito.mock(IdentityServicePlugin.class);
provider.configuration = configuration;
provider.servicePluginLocator = Mockito.mock(ServicePluginLocator.class);
Mockito.when(
provider.servicePluginLocator.getResourceExpected("service:id:ldap:dig", IdentityServicePlugin.class))
.thenReturn(servicePlugin);
Mockito.when(servicePlugin.authenticate(authentication, "service:id:ldap:dig", true))
.thenReturn(authentication2);
Assert.assertSame(authentication2, provider.authenticate(authentication));
}
开发者ID:ligoj,项目名称:plugin-iam-node,代码行数:16,代码来源:NodeBasedIamProviderTest.java
示例7: getConfiguration
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void getConfiguration() {
final NodeBasedIamProvider provider = new NodeBasedIamProvider();
provider.configuration = configuration;
provider.servicePluginLocator = Mockito.mock(ServicePluginLocator.class);
final IamConfiguration iamConfiguration = Mockito.mock(IamConfiguration.class);
final IamConfigurationProvider servicePlugin = Mockito.mock(IamConfigurationProvider.class);
Mockito.when(servicePlugin.getConfiguration("service:id:ldap:dig")).thenReturn(iamConfiguration);
Mockito.when(provider.servicePluginLocator.getResourceExpected("service:id:ldap:dig",
IamConfigurationProvider.class)).thenReturn(servicePlugin);
Assert.assertSame(iamConfiguration, provider.getConfiguration());
}
开发者ID:ligoj,项目名称:plugin-iam-node,代码行数:14,代码来源:NodeBasedIamProviderTest.java
示例8: findAll
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
@Test
public void findAll() {
final ImportCatalogResource resource = newResource();
// Add importable provider
resource.locator = Mockito.mock(ServicePluginLocator.class);
final ImportCatalogService service = Mockito.mock(ImportCatalogService.class);
Mockito.when(resource.locator.getResource("service:prov:test", ImportCatalogService.class)).thenReturn(service);
// Add not updatable provider node
final Node notImportNode = new Node();
notImportNode.setId("service:prov:any");
notImportNode.setName("Cannot import");
notImportNode.setRefined(nodeRepository.findOneExpected("service:prov"));
nodeRepository.saveAndFlush(notImportNode);
final List<CatalogVo> catalogs = resource.findAll();
Assert.assertEquals(3, catalogs.size());
// This provider does not support catalog update
Assert.assertEquals(0, catalogs.get(0).getStatus().getNbInstancePrices().intValue());
Assert.assertNull(catalogs.get(0).getStatus().getEnd());
Assert.assertNull(catalogs.get(0).getStatus().getStart());
Assert.assertEquals("service:prov:any", catalogs.get(0).getNode().getId());
Assert.assertFalse(catalogs.get(0).isCanImport());
Assert.assertEquals(0, catalogs.get(0).getNbQuotes());
// This provider supports catalog update
Assert.assertNotNull(catalogs.get(1).getStatus());
Assert.assertEquals("service:prov:test", catalogs.get(1).getNode().getId());
Assert.assertTrue(catalogs.get(1).isCanImport());
Assert.assertEquals(2, catalogs.get(1).getNbQuotes());
// This provider does not support catalog update
Assert.assertEquals("service:prov:x", catalogs.get(2).getNode().getId());
Assert.assertFalse(catalogs.get(2).isCanImport());
Assert.assertNull(catalogs.get(2).getStatus().getEnd());
Assert.assertNull(catalogs.get(2).getStatus().getStart());
Assert.assertEquals(1, catalogs.get(2).getNbQuotes());
final ImportCatalogStatus status = catalogs.get(1).getStatus();
Assert.assertEquals(DEFAULT_USER, status.getAuthor());
Assert.assertNull(status.getEnd());
Assert.assertNull(status.getLocation());
Assert.assertEquals("service:prov:test", status.getLocked().getId());
Assert.assertNotNull(status.getStart());
Assert.assertEquals(0, status.getDone());
Assert.assertEquals(0, status.getWorkload());
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:50,代码来源:ImportCatalogResourceTest.java
示例9: newResource
import org.ligoj.app.resource.ServicePluginLocator; //导入依赖的package包/类
private TerraformResource newResource(final Terraforming providerResource, final BiFunction<Subscription, String[], File> toFile,
final boolean dryRun, final String... customArgs) {
final TerraformResource resource = new TerraformResource() {
@Override
protected File toFile(final Subscription subscription, final String file) throws IOException {
return toFile.apply(subscription, new String[] { file });
}
/**
* Prepare the Terraform environment to apply the new environment. Note there is
* no concurrency check.
*/
@Override
protected File applyTerraform(final Subscription entity, final Terraforming terra, final QuoteVo configuration)
throws IOException, InterruptedException {
if (dryRun) {
// Ignore this call
return null;
}
return super.applyTerraform(entity, terra, configuration);
}
};
super.applicationContext.getAutowireCapableBeanFactory().autowireBean(resource);
// Replace the plugin locator
final ServicePluginLocator locator = Mockito.mock(ServicePluginLocator.class);
resource.locator = locator;
// Replace the runner
resource.runner = new TerraformRunnerResource();
super.applicationContext.getAutowireCapableBeanFactory().autowireBean(resource.runner);
Mockito.when(locator.getResource("service:prov:test:account", Terraforming.class)).thenReturn(providerResource);
// Replace the CLI runner
resource.terraformUtils = new TerraformUtils() {
@Override
protected ProcessBuilder newBuilder(String... args) {
return new ProcessBuilder(
ArrayUtils.addAll(new String[] { "java", "-cp", MOCK_PATH.getParent(), "org.ligoj.app.plugin.prov.terraform.Main" },
customArgs.length > 0 ? customArgs : args));
}
};
return resource;
}
开发者ID:ligoj,项目名称:plugin-prov,代码行数:47,代码来源:TerraformResourceTest.java
注:本文中的org.ligoj.app.resource.ServicePluginLocator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论