use of org.syncany.operations.plugin.PluginOperationOptions in project syncany by syncany.
the class PluginOperationTest method testPluginInstallUrl.
@Test
public void testPluginInstallUrl() throws Exception {
if (EnvironmentUtil.isWindows()) {
// Test is Unix-specific.
return;
}
File configDir = setupCleanConfigDir();
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.REMOTE);
pluginOptions.setSnapshots(false);
PluginOperationResult pluginResult = client.plugin(pluginOptions);
String pluginDownloadUrl = null;
for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
if (pluginInfo.getRemotePluginInfo().getPluginId().equals("ftp")) {
pluginDownloadUrl = pluginInfo.getRemotePluginInfo().getDownloadUrl();
}
}
pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.INSTALL);
pluginOptions.setPluginId(pluginDownloadUrl);
pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Only one file should be in here: the jar for ftp.
assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);
// Tear down
client.deleteTestData();
TestFileUtil.deleteDirectory(configDir);
System.setProperty("user.home", "/tmp");
}
use of org.syncany.operations.plugin.PluginOperationOptions in project syncany by syncany.
the class PluginOperationTest method testPluginListRemoteOnlyIncludingSnapshots.
@Test
public void testPluginListRemoteOnlyIncludingSnapshots() throws Exception {
// Tests which plugin snapshots are available. This is difficult because
// that will change. So we can only test the bare minimum.
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.REMOTE);
pluginOptions.setSnapshots(true);
PluginOperationResult pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Tear down
client.deleteTestData();
}
use of org.syncany.operations.plugin.PluginOperationOptions in project syncany by syncany.
the class PluginOperationTest method testPluginInstall.
@Test
public void testPluginInstall() throws Exception {
if (EnvironmentUtil.isWindows()) {
// Test is Unix-specific.
return;
}
File configDir = setupCleanConfigDir();
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.INSTALL);
pluginOptions.setPluginId("ftp");
PluginOperationResult pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Only one file should be in here: the jar for ftp.
assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);
// Tear down
client.deleteTestData();
TestFileUtil.deleteDirectory(configDir);
System.setProperty("user.home", "/tmp");
}
use of org.syncany.operations.plugin.PluginOperationOptions in project syncany by syncany.
the class PluginCommand method parseOptions.
@Override
public PluginOperationOptions parseOptions(String[] operationArgs) throws Exception {
PluginOperationOptions operationOptions = new PluginOperationOptions();
OptionParser parser = new OptionParser();
OptionSpec<Void> optionLocal = parser.acceptsAll(asList("L", "local-only"));
OptionSpec<Void> optionRemote = parser.acceptsAll(asList("R", "remote-only"));
OptionSpec<Void> optionSnapshots = parser.acceptsAll(asList("s", "snapshot", "snapshots"));
OptionSpec<Void> optionMinimalOutput = parser.acceptsAll(asList("m", "minimal-output"));
OptionSpec<String> optionApiEndpoint = parser.acceptsAll(asList("a", "api-endpoint")).withRequiredArg();
OptionSet options = parser.parse(operationArgs);
// Files
List<?> nonOptionArgs = options.nonOptionArguments();
if (nonOptionArgs.size() == 0) {
throw new Exception("Invalid syntax, please specify an action (list, install, remove, update).");
}
// <action>
String actionStr = nonOptionArgs.get(0).toString();
PluginOperationAction action = parsePluginAction(actionStr);
operationOptions.setAction(action);
// --minimal-output
minimalOutput = options.has(optionMinimalOutput);
// --snapshots
operationOptions.setSnapshots(options.has(optionSnapshots));
// --api-endpoint
if (options.has(optionApiEndpoint)) {
operationOptions.setApiEndpoint(options.valueOf(optionApiEndpoint));
}
// install|remove <plugin-id>
if (action == PluginOperationAction.INSTALL || action == PluginOperationAction.REMOVE) {
if (nonOptionArgs.size() != 2) {
throw new Exception("Invalid syntax, please specify a plugin ID.");
}
// <plugin-id>
String pluginId = nonOptionArgs.get(1).toString();
operationOptions.setPluginId(pluginId);
} else // --local-only, --remote-only
if (action == PluginOperationAction.LIST) {
if (options.has(optionLocal)) {
operationOptions.setListMode(PluginListMode.LOCAL);
} else if (options.has(optionRemote)) {
operationOptions.setListMode(PluginListMode.REMOTE);
} else {
operationOptions.setListMode(PluginListMode.ALL);
}
// <plugin-id> (optional in 'list' or 'update')
if (nonOptionArgs.size() == 2) {
String pluginId = nonOptionArgs.get(1).toString();
operationOptions.setPluginId(pluginId);
}
} else if (action == PluginOperationAction.UPDATE && nonOptionArgs.size() == 2) {
String pluginId = nonOptionArgs.get(1).toString();
operationOptions.setPluginId(pluginId);
}
return operationOptions;
}
use of org.syncany.operations.plugin.PluginOperationOptions in project syncany by syncany.
the class PluginOperationTest method testPluginListRemoteOnlyReleasesOnly.
@Test
public void testPluginListRemoteOnlyReleasesOnly() throws Exception {
// Tests which plugin releases are available. This is difficult because
// that will change. So we can only test the bare minimum.
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.REMOTE);
pluginOptions.setSnapshots(false);
PluginOperationResult pluginResult = client.plugin(pluginOptions);
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
// Tear down
client.deleteTestData();
}
Aggregations