Make helper classes in gerrit-acceptance-tests public
Make the helper classes in gerrit-acceptance-tests public so that they can be used from other packages. This allows us to sort the test classes into different packages, e.g. all tests of the REST API could be in one package. Change-Id: Ia03756d40763f159a62974cd4b20693316c9e73b Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -36,7 +36,7 @@ import com.jcraft.jsch.JSch;
|
|||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import com.jcraft.jsch.KeyPair;
|
import com.jcraft.jsch.KeyPair;
|
||||||
|
|
||||||
class AccountCreator {
|
public class AccountCreator {
|
||||||
|
|
||||||
private SchemaFactory<ReviewDb> reviewDbProvider;
|
private SchemaFactory<ReviewDb> reviewDbProvider;
|
||||||
private GroupCache groupCache;
|
private GroupCache groupCache;
|
||||||
@@ -55,7 +55,7 @@ class AccountCreator {
|
|||||||
this.byEmailCache = byEmailCache;
|
this.byEmailCache = byEmailCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestAccount create(String username, String email, String fullName,
|
public TestAccount create(String username, String email, String fullName,
|
||||||
String... groups)
|
String... groups)
|
||||||
throws OrmException, UnsupportedEncodingException, JSchException {
|
throws OrmException, UnsupportedEncodingException, JSchException {
|
||||||
ReviewDb db = reviewDbProvider.open();
|
ReviewDb db = reviewDbProvider.open();
|
||||||
|
|||||||
@@ -24,16 +24,16 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
|
||||||
class RestSession {
|
public class RestSession {
|
||||||
|
|
||||||
private final TestAccount account;
|
private final TestAccount account;
|
||||||
DefaultHttpClient client;
|
DefaultHttpClient client;
|
||||||
|
|
||||||
RestSession(TestAccount account) {
|
public RestSession(TestAccount account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader get(String endPoint) throws IOException {
|
public Reader get(String endPoint) throws IOException {
|
||||||
HttpGet get = new HttpGet("http://localhost:8080/a" + endPoint);
|
HttpGet get = new HttpGet("http://localhost:8080/a" + endPoint);
|
||||||
HttpResponse response = getClient().execute(get);
|
HttpResponse response = getClient().execute(get);
|
||||||
Reader reader = new InputStreamReader(response.getEntity().getContent());
|
Reader reader = new InputStreamReader(response.getEntity().getContent());
|
||||||
@@ -41,7 +41,7 @@ class RestSession {
|
|||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader post(String endPoint) {
|
public Reader post(String endPoint) {
|
||||||
// TODO
|
// TODO
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,16 +23,16 @@ import com.jcraft.jsch.JSch;
|
|||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import com.jcraft.jsch.Session;
|
import com.jcraft.jsch.Session;
|
||||||
|
|
||||||
class SshSession {
|
public class SshSession {
|
||||||
|
|
||||||
private final TestAccount account;
|
private final TestAccount account;
|
||||||
private Session session;
|
private Session session;
|
||||||
|
|
||||||
SshSession(TestAccount account) {
|
public SshSession(TestAccount account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
String exec(String command) throws JSchException, IOException {
|
public String exec(String command) throws JSchException, IOException {
|
||||||
ChannelExec channel = (ChannelExec) getSession().openChannel("exec");
|
ChannelExec channel = (ChannelExec) getSession().openChannel("exec");
|
||||||
try {
|
try {
|
||||||
channel.setCommand(command);
|
channel.setCommand(command);
|
||||||
@@ -47,7 +47,7 @@ class SshSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() {
|
public void close() {
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.disconnect();
|
session.disconnect();
|
||||||
session = null;
|
session = null;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TestAccount {
|
|||||||
this.httpPassword = httpPassword;
|
this.httpPassword = httpPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] privateKey() {
|
public byte[] privateKey() {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
sshKey.writePrivateKey(out);
|
sshKey.writePrivateKey(out);
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user