# HG changeset patch # User Vladimir Kvashin # Date 1322030669 -10800 # Node ID 25e838d8b9971ff118ffcb5ff0e55ad0ad6f5379 # Parent 6376617653fcd3d6a3ec9b7c2744dfb4bf9ee620 fixed #203038 - Exception: Should not be called from UI thread diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemoteMirrorPathProvider.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemoteMirrorPathProvider.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemoteMirrorPathProvider.java Wed Nov 23 09:44:29 2011 +0300 @@ -42,11 +42,14 @@ package org.netbeans.modules.cnd.remote.mapper; +import java.io.IOException; +import java.net.ConnectException; import java.text.ParseException; -import org.netbeans.modules.cnd.remote.support.RemoteUtil; import org.netbeans.modules.cnd.spi.remote.setup.MirrorPathProvider; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.nativeexecution.api.util.MacroExpanderFactory; import org.netbeans.modules.nativeexecution.api.util.MacroExpanderFactory.MacroExpander; import org.netbeans.modules.remote.spi.FileSystemCacheProvider; @@ -70,7 +73,7 @@ } @Override - public String getRemoteMirror(ExecutionEnvironment executionEnvironment) { + public String getRemoteMirror(ExecutionEnvironment executionEnvironment) throws ConnectException, IOException, ConnectionManager.CancellationException { String root; root = System.getProperty("cnd.remote.sync.root." + executionEnvironment.getHost()); //NOI18N if (root != null) { @@ -80,7 +83,12 @@ if (root != null) { return root; } - String home = RemoteUtil.getHomeDirectory(executionEnvironment); + + if (!HostInfoUtils.isHostInfoAvailable(executionEnvironment)) { + throw new ConnectException("No HostInfo available for " + executionEnvironment); + } + String home = HostInfoUtils.getHostInfo(executionEnvironment).getUserDir(); + if (home == null) { return null; } diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemotePathMap.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemotePathMap.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/mapper/RemotePathMap.java Wed Nov 23 09:44:29 2011 +0300 @@ -49,6 +49,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.net.ConnectException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -66,7 +67,9 @@ import org.netbeans.modules.cnd.utils.CndUtils; import org.netbeans.modules.cnd.utils.cache.CndFileUtils; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; import org.netbeans.modules.nativeexecution.api.util.WindowsSupport; +import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbPreferences; import org.openide.util.Utilities; @@ -576,9 +579,17 @@ private void initRemoteBase(boolean addMapping) { if (remoteBase == null) { - remoteBase = getRemoteSyncRoot(super.execEnv); - if (addMapping && remoteBase != null) { - addMappingImpl("/", remoteBase); // NOI18N + try { + remoteBase = getRemoteSyncRoot(super.execEnv); + if (addMapping && remoteBase != null) { + addMappingImpl("/", remoteBase); // NOI18N + } + } catch (ConnectException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (CancellationException ex) { + //don;t report CancellationException } } } @@ -594,7 +605,7 @@ } } - public static String getRemoteSyncRoot(ExecutionEnvironment executionEnvironment) { + public static String getRemoteSyncRoot(ExecutionEnvironment executionEnvironment) throws ConnectException, IOException, CancellationException { for (MirrorPathProvider mpp : Lookup.getDefault().lookupAll(MirrorPathProvider.class)) { String result = mpp.getRemoteMirror(executionEnvironment); if (result != null) { diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteUtil.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteUtil.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/support/RemoteUtil.java Wed Nov 23 09:44:29 2011 +0300 @@ -46,17 +46,13 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import org.netbeans.modules.cnd.api.remote.HostInfoProvider; import org.netbeans.modules.cnd.api.remote.ServerList; import org.netbeans.modules.cnd.api.remote.ServerRecord; import org.netbeans.modules.cnd.api.toolchain.CompilerSetManager; import org.netbeans.modules.cnd.api.toolchain.ui.ToolsCacheManager; import org.netbeans.modules.cnd.remote.server.RemoteServerRecord; -import org.netbeans.modules.cnd.utils.CndUtils; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; -import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus; /** * Misc. utiliy finctions @@ -64,7 +60,6 @@ */ public class RemoteUtil { - private static final Map homeDirs = new LinkedHashMap(); public static final Logger LOGGER = Logger.getLogger("cnd.remote.logger"); //NOI18N public static class PrefixedLogger { @@ -86,50 +81,6 @@ private RemoteUtil() {} -// public static void log(String prefix, Level level, String format, Object... args) { -// if (LOGGER.isLoggable(level)) { -// String text = String.format(format, args); -// LOGGER.log(level, String.format("%s: ", text)); -// } -// } - - /** - * Returns home directory for the given host - * NB: this is a LONG RUNNING method - never call from UI thread - */ - public static String getHomeDirectory(ExecutionEnvironment execEnv) { - CndUtils.assertNonUiThread(); - String dir = null; - // it isn't worth doing smart synchronization here - synchronized(homeDirs) { - // we cache nulls as well - if (homeDirs.containsKey(execEnv)) { - return homeDirs.get(execEnv); - } - } - try { // FIXUP: remove this try/catch as soon as in NPE in execution is fixed - if (Boolean.getBoolean("cnd.emulate.null.home.dir")) { // to emulate returning null //NOI18N - return null; - } - // NB: it's important that /bin/pwd is called since it always reports resolved path - // while shell's pwd result depend on shell - ExitStatus res = ProcessUtils.execute(execEnv, "sh", "-c", "cd; /bin/pwd"); // NOI18N - if (res.isOK()) { - String s = res.output; - if (HostInfoProvider.fileExists(execEnv, s)) { - dir = s; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - synchronized(homeDirs) { - // we cache nulls as well - homeDirs.put(execEnv, dir); - } - return dir; - } - /** * FIXUP: * Need this hack for Cloud stuff: * we have to distinguish "normal", i.e. CND environments diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/sync/FtpSyncWorker.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/FtpSyncWorker.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/FtpSyncWorker.java Wed Nov 23 09:44:29 2011 +0300 @@ -47,6 +47,7 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.io.PrintWriter; +import java.net.ConnectException; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -64,7 +65,9 @@ import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport; import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport.UploadStatus; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; import org.openide.util.Cancellable; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; /** @@ -254,7 +257,16 @@ @Override public boolean startup(Map env2add) { // Later we'll allow user to specify where to copy project files to - String remoteRoot = RemotePathMap.getRemoteSyncRoot(executionEnvironment); + String remoteRoot = null; + try { + remoteRoot = RemotePathMap.getRemoteSyncRoot(executionEnvironment); + } catch (ConnectException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (CancellationException ex) { + // don't report CancellationException + } if (remoteRoot == null) { if (err != null) { err.printf("%s\n", NbBundle.getMessage(getClass(), "MSG_Cant_find_sync_root", ServerList.get(executionEnvironment).toString())); diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/sync/RfsLocalController.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/RfsLocalController.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/RfsLocalController.java Wed Nov 23 09:44:29 2011 +0300 @@ -51,6 +51,7 @@ import java.io.InterruptedIOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.net.ConnectException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -307,7 +308,19 @@ } private boolean initNewFilesDiscovery() { - String remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(execEnv); + String remoteSyncRoot; + try { + remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(execEnv); + } catch (ConnectException ex) { + ex.printStackTrace(); + return false; + } catch (IOException ex) { + ex.printStackTrace(); + return false; + } catch (CancellationException ex) { + // don't report CancellationException + return false; + } ExitStatus res = ProcessUtils.execute(execEnv, "mktemp", "-p", remoteSyncRoot); // NOI18N if (res.isOK()) { timeStampFile = res.output.trim(); diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/remote/sync/ZipSyncWorker.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/ZipSyncWorker.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/sync/ZipSyncWorker.java Wed Nov 23 09:44:29 2011 +0300 @@ -49,6 +49,7 @@ import java.io.InputStreamReader; import java.io.InterruptedIOException; import java.io.PrintWriter; +import java.net.ConnectException; import java.util.ArrayList; import java.util.Collection; import java.util.Map; @@ -68,6 +69,8 @@ import org.netbeans.modules.nativeexecution.api.NativeProcessBuilder; import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport; import org.netbeans.modules.nativeexecution.api.util.CommonTasksSupport.UploadStatus; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; /** @@ -325,7 +328,16 @@ @Override public boolean startup(Map env2add) { // Later we'll allow user to specify where to copy project files to - String remoteRoot = RemotePathMap.getRemoteSyncRoot(executionEnvironment); + String remoteRoot = null; + try { + remoteRoot = RemotePathMap.getRemoteSyncRoot(executionEnvironment); + } catch (ConnectException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (CancellationException ex) { + // don't report CancellationException + } if (remoteRoot == null) { if (err != null) { err.printf("%s\n", NbBundle.getMessage(getClass(), "MSG_Cant_find_sync_root", ServerList.get(executionEnvironment).toString())); diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/cnd/spi/remote/setup/MirrorPathProvider.java --- a/cnd.remote/src/org/netbeans/modules/cnd/spi/remote/setup/MirrorPathProvider.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/cnd/spi/remote/setup/MirrorPathProvider.java Wed Nov 23 09:44:29 2011 +0300 @@ -42,7 +42,10 @@ package org.netbeans.modules.cnd.spi.remote.setup; +import java.io.IOException; +import java.net.ConnectException; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; /** * Allows to redefine places where local->remote and remote->local mirrors are located @@ -58,7 +61,8 @@ * @return remote mirror absolute path * or null in the case this provider can not provide it for the given environment */ - String getRemoteMirror(ExecutionEnvironment executionEnvironment); + String getRemoteMirror(ExecutionEnvironment executionEnvironment) + throws ConnectException, IOException, ConnectionManager.CancellationException; /** * Gets local mirror absolute path. diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/remote/ui/AddToFavoritesAction.java --- a/cnd.remote/src/org/netbeans/modules/remote/ui/AddToFavoritesAction.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/remote/ui/AddToFavoritesAction.java Wed Nov 23 09:44:29 2011 +0300 @@ -44,6 +44,7 @@ import java.awt.Frame; import java.io.IOException; +import java.net.ConnectException; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.SwingUtilities; @@ -153,6 +154,7 @@ } protected abstract FileObject getRoot(ExecutionEnvironment env, FileSystem fs); + /** can return null in the case of problems */ protected abstract String getPath(ExecutionEnvironment env); @Override @@ -285,8 +287,17 @@ @Override protected String getPath(ExecutionEnvironment env) { - String remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(env); - return remoteSyncRoot; + try { + String remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(env); + return remoteSyncRoot; + } catch (ConnectException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (CancellationException ex) { + // don't report CancellationException + } + return null; } } diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/remote/ui/FileSystemRootNode.java --- a/cnd.remote/src/org/netbeans/modules/remote/ui/FileSystemRootNode.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/remote/ui/FileSystemRootNode.java Wed Nov 23 09:44:29 2011 +0300 @@ -43,11 +43,14 @@ package org.netbeans.modules.remote.ui; import java.awt.Image; +import java.io.IOException; +import java.net.ConnectException; import java.util.List; import org.netbeans.modules.cnd.remote.mapper.RemotePathMap; -import org.netbeans.modules.cnd.remote.support.RemoteUtil; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.remote.spi.FileSystemProvider; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; @@ -55,6 +58,7 @@ import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; +import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.lookup.Lookups; @@ -131,29 +135,38 @@ @Override protected Node createNodeForKey(Kind key) { - FileObject fo; - switch (key) { - case DISCONNECTED: + try { + FileObject fo = null; + switch (key) { + case DISCONNECTED: + return new NotConnectedNode(env); + case HOME: + String homeDir = HostInfoUtils.getHostInfo(env).getUserDir(); + fo = rootFileObject.getFileObject(homeDir); + break; + case MIRROR: + String mirror = RemotePathMap.getRemoteSyncRoot(env); + fo = rootFileObject.getFileObject(mirror); + break; + case ROOT: + fo = rootFileObject; + break; + default: + fo = rootFileObject; + break; + } + if (fo != null) { + return new FileSystemNode(env, fo); + } else { return new NotConnectedNode(env); - case HOME: - String homeDir = RemoteUtil.getHomeDirectory(env); - fo = rootFileObject.getFileObject(homeDir); - break; - case MIRROR: - String mirror = RemotePathMap.getRemoteSyncRoot(env); - fo = rootFileObject.getFileObject(mirror); - break; - case ROOT: - fo = rootFileObject; - break; - default: - fo = rootFileObject; - break; + } + } catch (ConnectException ex) { + return new NotConnectedNode(env); + } catch (IOException ex) { + return new NotConnectedNode(env); + } catch (ConnectionManager.CancellationException ex) { + return new NotConnectedNode(env); } - if (fo != null) { - return new FileSystemNode(env, fo); - } - return null; // TODO: error processing } } } diff -r 6376617653fc -r 25e838d8b997 cnd.remote/src/org/netbeans/modules/remote/ui/OpenTerminalAction.java --- a/cnd.remote/src/org/netbeans/modules/remote/ui/OpenTerminalAction.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/src/org/netbeans/modules/remote/ui/OpenTerminalAction.java Wed Nov 23 09:44:29 2011 +0300 @@ -45,6 +45,7 @@ import java.awt.Frame; import java.io.File; import java.io.IOException; +import java.net.ConnectException; import javax.swing.*; import org.netbeans.modules.cnd.api.remote.RemoteFileUtil; import org.netbeans.modules.cnd.remote.mapper.RemotePathMap; @@ -149,7 +150,7 @@ this.place = place; putProperty("noIconInMenu", Boolean.TRUE);// NOI18N } - + /** can return null in the case of issues */ protected abstract String getPath(ExecutionEnvironment env); @Override @@ -263,11 +264,20 @@ @Override protected String getPath(ExecutionEnvironment env) { - String remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(env); - return remoteSyncRoot; + try { + String remoteSyncRoot = RemotePathMap.getRemoteSyncRoot(env); + return remoteSyncRoot; + } catch (ConnectException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (CancellationException ex) { + // don't report CancellationException + } + return null; } } - + private static final class AddOther extends AddPlace { private final Frame mainWindow; diff -r 6376617653fc -r 25e838d8b997 cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/fs/RemoteCodeModelTestCase.java --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/fs/RemoteCodeModelTestCase.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/fs/RemoteCodeModelTestCase.java Wed Nov 23 09:44:29 2011 +0300 @@ -87,7 +87,7 @@ } @Override - protected void clearRemoteSyncRoot() { + protected void clearRemoteSyncRoot() throws Exception { super.clearRemoteSyncRoot(); if (testReconnect) { ConnectionManager.getInstance().disconnect(getTestExecutionEnvironment()); diff -r 6376617653fc -r 25e838d8b997 cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/support/RemoteUtilTestCase.java --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/support/RemoteUtilTestCase.java Tue Nov 22 22:03:16 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2008 Sun Microsystems, Inc. - */ -package org.netbeans.modules.cnd.remote.support; - -import org.netbeans.modules.cnd.remote.test.RemoteTestBase; -import junit.framework.Test; -import org.netbeans.modules.cnd.api.remote.HostInfoProvider; -import org.netbeans.modules.cnd.remote.test.RemoteDevelopmentTest; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; -import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; -import org.netbeans.modules.nativeexecution.test.ForAllEnvironments; - -/** - * There hardly is a way to unit test remote operations. - * This is just an entry point for manual validation. - * - * @author Sergey Grinev - */ -public class RemoteUtilTestCase extends RemoteTestBase { - - public RemoteUtilTestCase(String testName, ExecutionEnvironment execEnv) { - super(testName, execEnv); - } - - @ForAllEnvironments - public void testGetHomeDirectory() throws Exception { - System.out.printf("Testng getHomeDirectory\n"); - ExecutionEnvironment execEnv = getTestExecutionEnvironment(); - long time1 = System.currentTimeMillis(); - String home = RemoteUtil.getHomeDirectory(execEnv); - time1 = System.currentTimeMillis() - time1; - System.out.printf("\tgetHomeDirectory: returned %s for %s; time is %d ms\n", home, execEnv, time1); - assertNotNull(home); - boolean exists = HostInfoProvider.fileExists(execEnv, home); - assertTrue(exists); - } - - @ForAllEnvironments - public void testGetHomeDirectoryCachingNotNull() throws Exception { - System.out.printf("Testng getHomeDirectory caching: returning not null\n"); - ExecutionEnvironment goodEnv = getTestExecutionEnvironment(); - long time1 = System.currentTimeMillis(); - String home = RemoteUtil.getHomeDirectory(goodEnv); - time1 = System.currentTimeMillis() - time1; - System.out.printf("Testng getHomeDirectory: returned %s for %s; time is %d ms\n", home, goodEnv, time1); - assertNotNull(home); - for (int i = 0; i < 10; i++) { - long time2 = System.currentTimeMillis(); - String t = RemoteUtil.getHomeDirectory(goodEnv); - time2 = System.currentTimeMillis() - time2; - System.out.printf("Good, pass %d; time is %d ms\n", i, time2); - assert(time2 < 100); - } - } - - @ForAllEnvironments - public void testGetHomeDirectoryCachingNull() throws Exception { - System.out.printf("Testng getHomeDirectory caching: returning null\n"); - ExecutionEnvironment badEnv = ExecutionEnvironmentFactory.createNew("inexistent/user", "inexistent/host"); - long time1 = System.currentTimeMillis(); - String home = RemoteUtil.getHomeDirectory(badEnv); - time1 = System.currentTimeMillis() - time1; - System.out.printf("Testng getHomeDirectory: returned %s for %s; time is %d ms\n", home, badEnv, time1); - assertNull(home); - for (int i = 0; i < 10; i++) { - long time2 = System.currentTimeMillis(); - String t = RemoteUtil.getHomeDirectory(badEnv); - time2 = System.currentTimeMillis() - time2; - System.out.printf("Bad, pass %d; time is %d ms\n", i, time2); - long max = 100; - assertTrue("getHomeDirectory time should be less than " + time2 + "; but it is" + max, time2 < max); - } - } - - public static Test suite() { - return new RemoteDevelopmentTest(RemoteUtilTestCase.class); - } - -} diff -r 6376617653fc -r 25e838d8b997 cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteDevelopmentTest.java --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteDevelopmentTest.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteDevelopmentTest.java Wed Nov 23 09:44:29 2011 +0300 @@ -53,7 +53,6 @@ import org.netbeans.modules.cnd.remote.mapper.IncludeMappingsTestCase; import org.netbeans.modules.cnd.remote.mapper.MappingsTestCase; import org.netbeans.modules.cnd.remote.support.DownloadTestCase; -import org.netbeans.modules.cnd.remote.support.RemoteUtilTestCase; import org.netbeans.modules.cnd.remote.support.ServerListTestCase; import org.netbeans.modules.cnd.remote.support.TransportTestCase; import org.netbeans.modules.cnd.remote.support.UploadTestCase; @@ -84,7 +83,6 @@ RfsGnuRemoteBuildTestCase.class, RfsSunStudioRemoteBuildTestCase.class, DownloadTestCase.class, - RemoteUtilTestCase.class, ServerListTestCase.class, TransportTestCase.class, UploadTestCase.class, diff -r 6376617653fc -r 25e838d8b997 cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteTestBase.java --- a/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteTestBase.java Tue Nov 22 22:03:16 2011 +0100 +++ b/cnd.remote/test/unit/src/org/netbeans/modules/cnd/remote/test/RemoteTestBase.java Wed Nov 23 09:44:29 2011 +0300 @@ -44,6 +44,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.net.ConnectException; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -71,6 +72,7 @@ import org.netbeans.modules.cnd.remote.sync.ZipSyncFactory; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; import org.netbeans.modules.nativeexecution.test.NativeExecutionTestSupport; import org.netbeans.modules.nativeexecution.test.RcFile; @@ -285,7 +287,7 @@ } } - protected void clearRemoteSyncRoot() { + protected void clearRemoteSyncRoot() throws Exception { String dirToRemove = RemotePathMap.getRemoteSyncRoot(getTestExecutionEnvironment()); boolean isOk = ProcessUtils.execute(getTestExecutionEnvironment(), "sh", "-c", "rm -rf " + dirToRemove + "/*").isOK(); assertTrue("Failed to remove " + dirToRemove, isOk);