use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class OtpNodeProxyTest method nonManagedRuntimeWorks.
@Test
public void nonManagedRuntimeWorks() {
final RuntimeData data = new RuntimeData(info, "run");
data.setNodeName(runtime.getNodeName());
data.setLongName(false);
data.setCookie("c");
data.setManaged(false);
final OtpNodeProxy runtime2 = new OtpNodeProxy(data);
runtime2.ensureRunning();
final Process process2 = runtime2.getProcess();
assertThat(runtime2.isRunning()).isEqualTo(true);
assertThat(process2).isNull();
final IOtpRpc site = runtime2.getOtpRpc();
OtpErlangObject r;
try {
r = site.call("erlang", "now", "");
} catch (final RpcException e) {
r = null;
}
assertThat(r).isNotNull();
try {
runtime2.dispose();
} catch (final Throwable t) {
ErlLogger.error(t);
}
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
}
expect(runtime2, process2, -1, State.TERMINATED);
assertThat(runtime.state()).isEqualTo(State.RUNNING);
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class OtpNodeProxyTest method exitCodeIsDetected.
@Test
public void exitCodeIsDetected() {
final IOtpRpc site = runtime.getOtpRpc();
try {
site.cast("erlang", "halt", "i", 3);
} catch (final RpcException e1) {
}
expect(runtime, process, 3, State.FAILED);
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class OtpNodeProxyTest method runtimeProcessStartsAndIsAvailableForRpc.
@Test
public void runtimeProcessStartsAndIsAvailableForRpc() {
int val;
try {
val = process.exitValue();
} catch (final IllegalThreadStateException e) {
val = -1;
}
assertThat(val).isEqualTo(-1);
assertThat(runtime.isRunning()).isEqualTo(true);
final IOtpRpc site = runtime.getOtpRpc();
OtpErlangObject r;
try {
r = site.call("erlang", "now", "");
} catch (final RpcException e) {
r = null;
}
assertThat(r).isNotNull();
try {
site.cast("erlang", "halt", "i", 0);
} catch (final RpcException e1) {
}
expect(runtime, process, 0, State.TERMINATED);
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class ErlExternalReferenceEntry method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
if (prebuilt) {
// already done
return true;
}
final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
if (backend != null) {
final List<String> files = ErlangEngine.getInstance().getOpenService().getLibFiles(path.toPortableString());
final List<IErlModule> children = Lists.newArrayListWithCapacity(files.size());
for (final String file : files) {
if (CommonUtils.isErlangFileContentFileName(getName(file))) {
children.add(new ErlModule(this, getName(file), file, null, null));
}
}
setChildren(children);
return true;
}
return false;
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class ErlExternalReferenceEntryList method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
// TODO some code duplication within this function
// ErlLogger.debug("ErlExternalReferenceEntryList.buildStructure %s",
// getName());
final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
final ErlModelCache cache = ErlModelCache.getDefault();
List<ExternalTreeEntry> externalModuleTree = cache.getExternalTree(externalModules);
List<ExternalTreeEntry> externalIncludeTree = cache.getExternalTree(externalIncludes);
if (externalModuleTree == null || externalIncludeTree == null) {
final OtpErlangList pathVars = ErlangEngine.getInstance().getModel().getPathVars();
final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
if (externalModuleTree == null && !externalModules.isEmpty()) {
if (pm != null) {
pm.worked(1);
}
externalModuleTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalModules, pathVars);
}
if (externalIncludeTree == null && !externalIncludes.isEmpty()) {
if (pm != null) {
pm.worked(1);
}
externalIncludeTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalIncludes, pathVars);
}
}
setChildren(null);
final IErlModel model = ErlangEngine.getInstance().getModel();
if (externalModuleTree != null && !externalModuleTree.isEmpty()) {
addExternalEntries(pm, externalModuleTree, model, "modules", null, false);
cache.putExternalTree(externalModules, project, externalModuleTree);
}
if (externalIncludeTree != null && !externalIncludeTree.isEmpty() || !projectIncludes.isEmpty()) {
addExternalEntries(pm, externalIncludeTree, model, "includes", projectIncludes, true);
if (externalIncludeTree != null) {
cache.putExternalTree(externalIncludes, project, externalIncludeTree);
}
}
return true;
}
Aggregations