1 package com.proalpha.pds.tests.paconnector;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.fail;
8 import org.eclipse.core.runtime.CoreException;
9 import org.eclipse.core.runtime.IProgressMonitor;
10 import org.eclipse.core.runtime.Path;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.mockito.Mock;
14 import org.mockito.Mockito;
15 import org.mockito.MockitoAnnotations;
17 import com.openedge.core.runtime.IAVMClient;
18 import com.openedge.core.runtime.IAVMConnection;
19 import com.openedge.core.runtime.IAVMRuntimeConfiguration;
20 import com.openedge.core.runtime.IAVMRuntimeListener;
21 import com.openedge.core.runtime.IPropath;
22 import com.openedge.core.runtime.ProgressCommand;
23 import com.openedge.core.util.Semaphore;
24 import com.openedge.pdt.platform.Proversion;
25 import com.openedge.pdt.project.OEProject;
26 import com.proalpha.pds.exception.ProALPHANotAvailableException;
27 import com.proalpha.pds.paconnector.PaProject;
28 import com.proalpha.pds.paconnector.RunProgramInPa;
32 private String testDir;
33 private IAVMClient avmclient;
36 private OEProject oeProject;
38 private IPropath proPath;
40 private ProgressCommand cmd;
46 MockitoAnnotations.initMocks(
this);
47 avmclient =
new MockedAVMClient();
48 testDir =
new File(
"src/test").getAbsolutePath();
49 Mockito.when(proPath.search(
"paoidebr.p",
true)).thenReturn(
new Path(testDir));
50 Mockito.when(proPath.search(
"adm/support/proc/ds_oea36.p",
true))
51 .thenReturn(
new Path(
new File(
"src/test/ds_oea36.p").getAbsolutePath()));
52 Mockito.when(proPath.search(
"adm/support/proc/ds_oea06.p",
true))
53 .thenReturn(
new Path(
new File(
"src/test/ds_oea06.p").getAbsolutePath()));
54 Mockito.when(cmd.isFinished()).thenReturn(
true);
55 Mockito.when(oeProject.getPropath()).thenReturn(proPath);
56 Mockito.when(oeProject.getRuntime()).thenReturn(avmclient);
57 Mockito.when(paProject.getOeProject()).thenReturn(oeProject);
58 Mockito.when(paProject.getBridgePath()).thenReturn(
new Path(testDir));
62 public void testInitialize() {
66 assertEquals(
"Should be equal",
"UTF-8", paProgram.getpAStartupParam(
"justatest",
"EMPTY"));
75 Mockito.when(proPath.search(
"paoidebr.p",
true)).thenReturn(
null);
81 class MockedAVMClient
implements IAVMClient {
88 public void runProgressCommand(ProgressCommand cmd) {
89 cmd.setResult(
"UTF-8");
90 cmd.setCompletionStatus(1);
94 public void addAVMRuntimeListener(IAVMRuntimeListener arg0) {
98 public void bringToTop() {
102 public void connect(IAVMConnection arg0) {
106 public IAVMRuntimeConfiguration getConfiguration() {
111 public String getName() {
116 public Proversion getProversion() {
121 public Semaphore getRuntimeSemaphore() {
126 public int getWindowThreadId() {
131 public boolean isAvailable() {
136 public boolean isConnected() {
141 public boolean isShared() {
146 public boolean isTTY() {
151 public void removeAVMRuntimeListener(IAVMRuntimeListener arg0) {
155 public void restart(IProgressMonitor arg0)
throws CoreException {
159 public void setRuntimeProcess(Process arg0) {
163 public void start(IProgressMonitor arg0)
throws CoreException {
167 public void stop(IProgressMonitor arg0) {