use of org.syncany.operations.plugin.ExtendedPluginInfo 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.ExtendedPluginInfo in project syncany by syncany.
the class PluginCommand method printResultList.
private void printResultList(PluginOperationResult operationResult) {
if (operationResult.getResultCode() == PluginResultCode.OK) {
List<String[]> tableValues = new ArrayList<String[]>();
tableValues.add(new String[] { "Id", "Name", "Local Version", "Type", "Remote Version", "Updatable", "Provided By" });
int outdatedCount = 0;
int updatableCount = 0;
int thirdPartyCount = 0;
for (ExtendedPluginInfo extPluginInfo : operationResult.getPluginList()) {
PluginInfo pluginInfo = (extPluginInfo.isInstalled()) ? extPluginInfo.getLocalPluginInfo() : extPluginInfo.getRemotePluginInfo();
String localVersionStr = (extPluginInfo.isInstalled()) ? extPluginInfo.getLocalPluginInfo().getPluginVersion() : "";
String installedStr = extPluginInfo.isInstalled() ? (extPluginInfo.canUninstall() ? "User" : "Global") : "";
String remoteVersionStr = (extPluginInfo.isRemoteAvailable()) ? extPluginInfo.getRemotePluginInfo().getPluginVersion() : "";
String thirdPartyStr = (pluginInfo.isPluginThirdParty()) ? "Third Party" : "Syncany Team";
String updatableStr = "";
if (extPluginInfo.isInstalled() && extPluginInfo.isOutdated()) {
if (extPluginInfo.canUninstall()) {
updatableStr = "Auto";
updatableCount++;
} else {
updatableStr = "Manual";
}
outdatedCount++;
}
if (pluginInfo.isPluginThirdParty()) {
thirdPartyCount++;
}
tableValues.add(new String[] { pluginInfo.getPluginId(), pluginInfo.getPluginName(), localVersionStr, installedStr, remoteVersionStr, updatableStr, thirdPartyStr });
}
CliTableUtil.printTable(out, tableValues, "No plugins found.");
if (outdatedCount > 0) {
String isAre = (outdatedCount == 1) ? "is" : "are";
String pluginPlugins = (outdatedCount == 1) ? "plugin" : "plugins";
out.printf("\nUpdates:\nThere %s %d outdated %s, %d of them %s automatically updatable.\n", isAre, outdatedCount, pluginPlugins, updatableCount, isAre);
}
if (thirdPartyCount > 0) {
String pluginPlugins = (thirdPartyCount == 1) ? "plugin" : "plugins";
out.printf("\nThird party plugins:\nPlease note that the Syncany Team does not review or maintain the third-party %s\nlisted above. Please report issues to the corresponding plugin site.\n", pluginPlugins);
}
} else {
out.printf("Listing plugins failed. No connection? Try -d to get more details.\n");
out.println();
}
}
use of org.syncany.operations.plugin.ExtendedPluginInfo in project syncany by syncany.
the class PluginOperationTest method testPluginListLocalOnly.
@Test
public void testPluginListLocalOnly() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient client = new TestClient("A", testConnection);
PluginOperationOptions pluginOptions = new PluginOperationOptions();
pluginOptions.setAction(PluginOperationAction.LIST);
pluginOptions.setListMode(PluginListMode.LOCAL);
// Run
PluginOperationResult pluginResult = client.plugin(pluginOptions);
// for comparison only!
List<Plugin> pluginList = Plugins.list();
// Test
assertNotNull(pluginResult);
assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
assertEquals(pluginList.size(), pluginResult.getPluginList().size());
// local and unreliable_local
assertEquals(EXPECTED_NUM_PLUGINS, pluginResult.getPluginList().size());
for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
assertNull(pluginInfo.getRemotePluginInfo());
assertNotNull(pluginInfo.getLocalPluginInfo());
assertNull(pluginInfo.getLocalPluginInfo().getDownloadUrl());
assertNull(pluginInfo.getLocalPluginInfo().getSha256sum());
assertNotNull(pluginInfo.getLocalPluginInfo().getPluginId());
assertNotNull(pluginInfo.getLocalPluginInfo().getPluginVersion());
// The rest is not important for processing ...
assertNotNull(Plugins.get(pluginInfo.getLocalPluginInfo().getPluginId()));
}
// Tear down
client.deleteTestData();
}
Aggregations