Skip to content

Commit

Permalink
add support for copying connections for ManagedConcourseServer clients
Browse files Browse the repository at this point in the history
  • Loading branch information
jtnelson committed Jul 2, 2024
1 parent ffd0b4c commit c3eee74
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,19 @@ public Client(String username, String password, String environment) {
this(username, password, environment, 5);
}

/**
* Constructor for {@link #copyConnection()}.
*
* @param clazz
* @param delegate
* @param loader
*/
private Client(Class<?> clazz, Object delegate, ClassLoader loader) {
this.clazz = clazz;
this.delegate = delegate;
this.loader = loader;
}

/**
* Construct a new instance.
*
Expand Down Expand Up @@ -3006,7 +3019,7 @@ public void verifyOrSet(String key, Object value, long record) {

@Override
protected Concourse copyConnection() {
throw new UnsupportedOperationException();
return new Client(clazz, invoke("copyConnection").with(), loader);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.cinchapi.concourse.server.ManagedConcourseServer.ReflectiveClient;
import com.cinchapi.concourse.thrift.Operator;
import com.cinchapi.concourse.util.ConcourseCodebase;
import com.cinchapi.concourse.util.Random;
import com.google.common.collect.ImmutableList;

/**
Expand Down Expand Up @@ -194,4 +195,13 @@ public void testTranslatePageBetweenClientAndServer() {
Assert.assertTrue(true); // lack of Exception means the test passes
}

@Test
public void testCopyClientConnection() {
server.start();
Concourse a = server.connect("admin", "admin",
Random.getSimpleString());
Concourse b = Concourse.copyExistingConnection(a);
Assert.assertEquals(a.getServerEnvironment(), b.getServerEnvironment());
}

}

0 comments on commit c3eee74

Please sign in to comment.