MultiReader implements MetadataReader { @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { FetcherResponse response = fetcherResponse; if (response.getNamespace() == null) response = detect(response); for (MetadataReader metadataReader : METADATA_READERS) if (metadataReader.getClass().getAnnotation(Namespace.class).value().equalsIgnoreCase(response.getNamespace())) return metadataReader.parseServiceMetadata(response); throw new LookupException(String.format("Unknown namespace: %s", response.getNamespace())); }  @Override List<ServiceReference> parseServiceGroup(FetcherResponse fetcherResponse); @Override PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse); FetcherResponse detect(FetcherResponse fetcherResponse);  }
@Test public void busdoxServiceMetadata() throws Exception { ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse( getClass().getResourceAsStream("/busdox-servicemetadata-9908-991825827.xml"))).getContent(); ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0"); try { result.getEndpoint(processIdentifier, START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } }
@Test public void busdoxServiceMetadataMultiProcess() throws Exception { ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse( getClass().getResourceAsStream("/busdox-servicemetadata-9933-061828591.xml"))).getContent(); ProcessIdentifier processIdentifier1 = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii04:ver1.0"); ProcessIdentifier processIdentifier2 = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii46:ver1.0"); try { result.getEndpoint(processIdentifier1, START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } assertNotNull(result.getEndpoint(processIdentifier1, AS2_1_0)); assertEquals( result.getEndpoint(processIdentifier1, AS2_1_0).getCertificate().getSubjectDN().toString(), "O=University of Piraeus Research Center, CN=APP_1000000088, C=GR" ); try { result.getEndpoint(processIdentifier2, START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } assertNotNull(result.getEndpoint(processIdentifier2, AS2_1_0)); assertEquals( result.getEndpoint(processIdentifier2, AS2_1_0).getCertificate().getSubjectDN().toString(), "O=University of Piraeus Research Center, CN=APP_1000000088, C=GR" ); }
@Test public void bdxrServiceMetadata() throws Exception { ServiceMetadata result = reader.parseServiceMetadata( new FetcherResponse(getClass().getResourceAsStream("/bdxr201407-servicemetadata-9908-810418052.xml"))) .getContent(); ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii04:ver1.0"); try { result.getEndpoint(processIdentifier, START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } assertNotNull(result.getEndpoint(processIdentifier, AS2_1_0)); assertEquals( result.getEndpoint(processIdentifier, AS2_1_0).getCertificate().getSubjectDN().toString(), "CN=APP_1000000005, O=DIFI, C=NO" ); }