JenaExtensionRegistry extends WrappingRegistry implements ExtensionRegistry { @Override public Extension getExtension(final URI uri) { return new JenaExtension(uri); }  @Override @Reference // (target = "org.fcrepo.apix.registry.contains=org.fcrepo.apix.model.Extension") void setRegistryDelegate(final Registry reg); @Override Extension getExtension(final URI uri); @Override Collection<Extension> getExtensions();  }
@Test public void bindingClassTest() { final String BINDING_CLASS = "test:/binding"; when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_BINDS_TO, BINDING_CLASS))); assertEquals(URI.create(BINDING_CLASS), toTest.getExtension(EXTENSION_URI).bindingClass()); }
@Test public void exposedAtRelativeTest() { final String EXPOSED_AT = "svc:/123()"; when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(EXPOSED_AT, toTest.getExtension(EXTENSION_URI).exposed().exposedAt().toString()); assertEquals(EXPOSED_AT, toTest.getExtension(EXTENSION_URI).exposed().exposedAt().getPath()); }
@Test public void interceptingConsumedServiceTest() { when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_CONSUMES_SERVICE, SERVICE_1_URI) + triple(EXTENSION, PROP_CONSUMES_SERVICE, SERVICE_2_URI))); final Extension extension = toTest.getExtension(EXTENSION_URI); assertEquals(2, extension.exposed().consumed().size()); assertTrue(extension.intercepted().consumed() .containsAll( Arrays.asList(service1.uri(), service2.uri()))); }
@Test public void isExposingTest() { when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_EXPOSES_SERVICE, SERVICE_1_URI))); final Extension extension = toTest.getExtension(EXTENSION_URI); assertTrue(extension.isExposing()); assertFalse(extension.isIntercepting()); }
@Test public void exposedConsumedServiceTest() { when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_CONSUMES_SERVICE, SERVICE_1_URI) + triple(EXTENSION, PROP_CONSUMES_SERVICE, SERVICE_2_URI))); final Extension extension = toTest.getExtension(EXTENSION_URI); assertEquals(2, extension.exposed().consumed().size()); assertTrue(extension.exposed().consumed().containsAll( Arrays.asList(service1.uri(), service2.uri()))); }
@Test public void exposedServiceTest() { when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_EXPOSES_SERVICE, SERVICE_1_URI))); final Extension extension = toTest.getExtension(EXTENSION_URI); assertEquals(service1.uri(), extension.exposed().exposedService()); }
@Test public void exposedResourceScopeTest() { final String EXPOSED_AT = "svc:/123()"; when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(Scope.RESOURCE, toTest.getExtension(EXTENSION_URI).exposed().scope()); }
@Test public void exposedRepositoryScopeTest() { final String EXPOSED_AT = "/svc:/123()"; when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(Scope.REPOSITORY, toTest.getExtension(EXTENSION_URI).exposed().scope()); }
@Test public void exposedExternalScopeTest() { final String EXPOSED_AT = "http: when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(Scope.EXTERNAL, toTest.getExtension(EXTENSION_URI).exposed().scope()); }
@Test public void isInterceptingTest() { when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, triple(EXTENSION, PROP_CONSUMES_SERVICE, SERVICE_1_URI))); final Extension extension = toTest.getExtension(EXTENSION_URI); assertFalse(extension.isExposing()); assertTrue(extension.isIntercepting()); }
@Test public void exposedAtURITest() { final String EXPOSED_AT = "http: when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(EXPOSED_AT, toTest.getExtension(EXTENSION_URI).exposed().exposedAt().toString()); }
@Test public void exposedAtAbsoluteTest() { final String EXPOSED_AT = "/svc:/123()"; when(registryDelegate.get(EXTENSION_URI)).thenReturn(rdfResource(EXTENSION, ltriple(EXTENSION, PROP_EXPOSES_SERVICE_AT, EXPOSED_AT))); assertEquals(EXPOSED_AT, toTest.getExtension(EXTENSION_URI).exposed().exposedAt().toString()); assertEquals(EXPOSED_AT, toTest.getExtension(EXTENSION_URI).exposed().exposedAt().getPath()); }