MgcpEndpointManager implements MgcpEndpointObserver, MgcpMessageObserver, MgcpMessageSubject { public MgcpEndpoint registerEndpoint(String namespace) throws UnrecognizedMgcpNamespaceException { MgcpEndpointProvider<?> provider = this.providers.get(namespace); if (provider == null) { throw new UnrecognizedMgcpNamespaceException("Namespace " + namespace + " is unrecognized"); } MgcpEndpoint endpoint = provider.provide(); endpoint.observe((MgcpEndpointObserver) this); endpoint.observe((MgcpMessageObserver) this); this.endpoints.put(endpoint.getEndpointId().toString(), endpoint); if (log.isDebugEnabled()) { log.debug("Registered endpoint " + endpoint.getEndpointId().toString() + ". Count: " + this.endpoints.size()); } return endpoint; } MgcpEndpointManager(); void installProvider(MgcpEndpointProvider<?> provider); void uninstallProvider(String namespace); boolean supportsNamespace(String namespace); MgcpEndpoint registerEndpoint(String namespace); MgcpEndpoint getEndpoint(String endpointId); void unregisterEndpoint(String endpointId); @Override void onMessage(InetSocketAddress from, InetSocketAddress to, MgcpMessage message, MessageDirection direction); @Override void observe(MgcpMessageObserver observer); @Override void forget(MgcpMessageObserver observer); @Override void notify(Object originator, InetSocketAddress from, InetSocketAddress to, MgcpMessage message, MessageDirection direction); @Override void onEndpointStateChanged(MgcpEndpoint endpoint, MgcpEndpointState state);  }
@Test(expected = UnrecognizedMgcpNamespaceException.class) public void testRegisterUnknownEndpoint() throws UnrecognizedMgcpNamespaceException { MgcpEndpointManager endpointManager = new MgcpEndpointManager(); endpointManager.registerEndpoint(NAMESPACE_BRIDGE); }