Skip to content

Commit

Permalink
Fix Favorites button test
Browse files Browse the repository at this point in the history
Favorites service was deactivated in tests due to non-existing
java.io.tmpdir folder. It's unlikely, but this could happen in
production as well, so make sure that the temp dir exists prior to
initializing the storage service.

(We ignore errors, because the storage service will already log those)

Change-Id: I134ddf0a47e618e0749c60dfc3e44e95cf85f0c5
Signed-off-by: Carsten Reckord <reckord@yatta.de>
  • Loading branch information
creckord committed Sep 3, 2020
1 parent db77ab9 commit 90cec65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.epp.internal.mpc.core.service;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -115,6 +116,7 @@ protected StorageFactory createStorageFactory() {
}

protected IStorage createStorage() {
ensureTmpdirExists();
IStorage storage = getStorageFactory().create(applicationToken,
new FileStorageCache.SingleApplication(this.applicationToken));
credentialsProvider = new EclipseOAuthCredentialsProvider(new MPCOAuthParameters());
Expand All @@ -123,6 +125,20 @@ protected IStorage createStorage() {
return storage;
}

private static void ensureTmpdirExists() {
try {
String tmpdirProperty = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
if (tmpdirProperty != null) {
File tmpDir = new File(tmpdirProperty);
if (!tmpDir.exists()) {
tmpDir.mkdirs();
}
}
} catch (Exception ex) {
//fall-through
}
}

@Override
public synchronized IStorage getStorage() {
if (storage == null) {
Expand Down
Expand Up @@ -210,7 +210,6 @@ public void testPopular() {
@Test
public void testFavorite() {
SWTBotButton favorite = bot.buttonWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, DiscoveryItem.WIDGET_ID_RATING);
bot.sleep(5000);
favorite.click();
SWTBotShell login = bot.shell("Authorizing with Eclipse.org");
login.bot().button("Cancel").click();
Expand Down

0 comments on commit 90cec65

Please sign in to comment.