use of com.google.cloud.bigquery.connection.v1.Connection in project jboss-remoting by jboss-remoting.
the class RemoteChannelTest method testRefused.
@Test
public void testRefused() throws Exception {
IoFuture<Connection> futureConnection = endpoint.connect(new URI("remote://localhost:33123"), OptionMap.EMPTY);
try {
futureConnection.awaitInterruptibly(2L, TimeUnit.SECONDS);
if (futureConnection.getStatus() == IoFuture.Status.WAITING) {
futureConnection.cancel();
} else {
safeClose(futureConnection.get());
}
} catch (IOException expected) {
System.out.println("Exception is: " + expected);
System.out.flush();
if (expected.getMessage().toLowerCase(Locale.US).contains("refused")) {
return;
}
}
fail("Expected an IOException with 'refused' in the string");
}
use of com.google.cloud.bigquery.connection.v1.Connection in project jboss-remoting by jboss-remoting.
the class TimeOutConnectionTestCase method doTest.
private void doTest(OptionMap connectionProviderOptions) throws Exception {
try (final ServerSocketChannel channel = ServerSocketChannel.open()) {
channel.configureBlocking(true);
channel.socket().bind(new InetSocketAddress("localhost", 30123));
Thread acceptThread = new Thread(new Accept(channel));
acceptThread.start();
// create endpoint, auth provider, etc, create server
final EndpointBuilder endpointBuilder = Endpoint.builder();
final XnioWorker.Builder workerBuilder = endpointBuilder.buildXnioWorker(Xnio.getInstance());
workerBuilder.setCoreWorkerPoolSize(4).setMaxWorkerPoolSize(4).setWorkerIoThreads(4);
endpointBuilder.setEndpointName("test");
try (Endpoint ep = endpointBuilder.build()) {
endpoint = ep;
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
domainBuilder.addRealm("mainRealm", mainRealm);
domainBuilder.setDefaultRealmName("mainRealm");
final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
// create connect and close endpoint threads
IoFuture<Connection> futureConnection = AuthenticationContext.empty().with(MatchRule.ALL, AuthenticationConfiguration.empty().useName("bob").usePassword("pass")).run(new PrivilegedAction<IoFuture<Connection>>() {
public IoFuture<Connection> run() {
try {
return ep.connect(new URI("remote://localhost:30123"), OptionMap.EMPTY);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
});
assertEquals(Status.WAITING, futureConnection.await(500, TimeUnit.MILLISECONDS));
ep.close();
assertEquals(Status.CANCELLED, futureConnection.getStatus());
acceptThread.join();
} finally {
endpoint = null;
}
}
}
use of com.google.cloud.bigquery.connection.v1.Connection in project jboss-remoting by jboss-remoting.
the class HeartbeatTestCase method testDefaultHeartbeat.
/**
* Test that heartbeat can be set and can be disabled by setting it to 0
*
* @throws Exception
*/
@Test
public void testDefaultHeartbeat() throws Exception {
Channel clientChannel = null;
Channel serverChannel = null;
Closeable streamServer = null;
Connection connection = null;
Registration serviceRegistration = null;
final Endpoint endpoint = Endpoint.builder().setEndpointName("test").build();
NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
domainBuilder.addRealm("mainRealm", mainRealm).build();
domainBuilder.setDefaultRealmName("mainRealm");
domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(HeartbeatTestCase.class.getClassLoader());
final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
builder.setSecurityDomain(domainBuilder.build());
builder.setFactory(saslServerFactory);
builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
final FutureResult<Channel> passer = new FutureResult<Channel>();
serviceRegistration = endpoint.registerService("org.jboss.test", new OpenListener() {
public void channelOpened(final Channel channel) {
passer.setResult(channel);
}
public void registrationTerminated() {
}
}, OptionMap.EMPTY);
IoFuture<Connection> futureConnection = AuthenticationContext.empty().with(MatchRule.ALL, AuthenticationConfiguration.empty().useName("bob").usePassword("pass").setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("SCRAM-SHA-256"))).run(new PrivilegedAction<IoFuture<Connection>>() {
public IoFuture<Connection> run() {
try {
return endpoint.connect(new URI("remote://localhost:30123"), OptionMap.EMPTY);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
});
connection = futureConnection.get();
IoFuture<Channel> futureChannel = connection.openChannel("org.jboss.test", OptionMap.EMPTY);
clientChannel = futureChannel.get();
serverChannel = passer.getIoFuture().get();
assertNotNull(serverChannel);
RemoteConnectionChannel remoteClientChannel = (RemoteConnectionChannel) clientChannel;
assertEquals(RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL, Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "heartbeatInterval"));
RemoteWriteListener clientWriteListener = (RemoteWriteListener) Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "writeListener");
assertNotNull(Utils.getInstanceValue(clientWriteListener, "heartKey"));
afterTest(clientChannel, serverChannel, connection, serviceRegistration);
destroy(endpoint, streamServer);
}
use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.
the class Aadl2InstanceUtil method getIncomingConnection.
/**
* find incoming connection that goes through the feature of the specified component instance
* @param ci Component instance
* @param fi Feature instance
* @return list of connection instances going through the feature
*/
public static EList<ConnectionInstance> getIncomingConnection(ComponentInstance ci, FeatureInstance fi) {
Feature f = fi.getFeature();
EList<ConnectionInstance> result = new BasicEList<ConnectionInstance>();
// allEnclosingConnectionInstances();
Iterable<ConnectionInstance> it = ci.getSystemInstance().getAllConnectionInstances();
for (ConnectionInstance connectionInstance : it) {
ConnectionInstanceEnd dest = connectionInstance.getDestination();
ComponentInstance destci = dest.getContainingComponentInstance();
if (containedIn(destci, ci)) {
EList<ConnectionReference> connreflist = connectionInstance.getConnectionReferences();
for (ConnectionReference connectionReference : connreflist) {
ComponentInstance pci = connectionReference.getContext();
Connection conn = connectionReference.getConnection();
ConnectionEnd ce = conn.getAllSource();
if (pci == ci.getContainingComponentInstance() && ce == f) {
result.add(connectionInstance);
}
}
}
}
return result;
}
use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.
the class Aadl2InstanceUtil method getOutgoingConnection.
/**
* find outgoing connection that goes through the feature of the specified component instance
* @param ci Component instance
* @param fi Feature instance
* @return list of connection instances going through the feature
*/
public static EList<ConnectionInstance> getOutgoingConnection(ComponentInstance ci, FeatureInstance fi) {
Feature f = fi.getFeature();
EList<ConnectionInstance> result = new BasicEList<ConnectionInstance>();
// allEnclosingConnectionInstances();
Iterable<ConnectionInstance> it = ci.getSystemInstance().getAllConnectionInstances();
for (ConnectionInstance connectionInstance : it) {
ConnectionInstanceEnd src = connectionInstance.getSource();
ComponentInstance srcci = src.getContainingComponentInstance();
if (containedIn(srcci, ci)) {
EList<ConnectionReference> connreflist = connectionInstance.getConnectionReferences();
for (ConnectionReference connectionReference : connreflist) {
ComponentInstance pci = connectionReference.getContext();
Connection conn = connectionReference.getConnection();
ConnectionEnd ce = conn.getAllSource();
if (pci == ci.getContainingComponentInstance() && ce == f) {
// add connection if it goes through feature instance
result.add(connectionInstance);
}
}
}
}
return result;
}
Aggregations