Skip to content

Commit 24df60c

Browse files
committed
Issue #105: Update the test cases for the new log files
1 parent 068817c commit 24df60c

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

dev/com.ibm.microclimate.test/src/com/ibm/microclimate/test/BaseTest.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
import com.ibm.microclimate.core.internal.connection.MicroclimateConnection;
4343
import com.ibm.microclimate.core.internal.connection.MicroclimateConnectionManager;
4444
import com.ibm.microclimate.core.internal.console.MicroclimateConsoleFactory;
45+
import com.ibm.microclimate.core.internal.console.ProjectLogInfo;
4546
import com.ibm.microclimate.core.internal.console.ProjectTemplateInfo;
47+
import com.ibm.microclimate.core.internal.console.SocketConsole;
4648
import com.ibm.microclimate.core.internal.constants.AppState;
4749
import com.ibm.microclimate.core.internal.constants.MCConstants;
4850
import com.ibm.microclimate.core.internal.constants.ProjectType;
@@ -157,35 +159,49 @@ protected void switchMode(StartMode mode) throws Exception {
157159
}
158160

159161
protected void showConsoles() throws Exception {
160-
MicroclimateApplication app = connection.getAppByName(projectName);
161-
if (!app.projectType.isType(ProjectType.TYPE_NODEJS)) {
162-
IConsole buildConsole = MicroclimateConsoleFactory.createBuildConsole(app);
163-
((MCEclipseApplication)app).setAppConsole(buildConsole);
162+
MCEclipseApplication app = (MCEclipseApplication) connection.getAppByName(projectName);
163+
if (connection.checkVersion(1905, "2019_M5_E")) {
164+
for (ProjectLogInfo logInfo : app.getLogInfos()) {
165+
if (app.getConsole(logInfo) == null) {
166+
SocketConsole console = MicroclimateConsoleFactory.createLogFileConsole(app, logInfo);
167+
app.addConsole(console);
168+
}
169+
}
170+
} else {
171+
if (!app.projectType.isType(ProjectType.TYPE_NODEJS)) {
172+
IConsole buildConsole = MicroclimateConsoleFactory.createBuildConsole(app);
173+
((MCEclipseApplication)app).setAppConsole(buildConsole);
174+
}
175+
IConsole appConsole = MicroclimateConsoleFactory.createApplicationConsole(app);
176+
((MCEclipseApplication)app).setAppConsole(appConsole);
164177
}
165-
IConsole appConsole = MicroclimateConsoleFactory.createApplicationConsole(app);
166-
((MCEclipseApplication)app).setAppConsole(appConsole);
167-
// Wait for application log to have content - it is only updated every 20s
168-
TestUtil.wait(new Condition() {
169-
@Override
170-
public boolean test() {
171-
return ((TextConsole)appConsole).getDocument().getLength() > 0;
172-
}
173-
}, 20, 1);
174178
}
175179

176180
protected void checkConsoles() throws Exception {
177181
MicroclimateApplication app = connection.getAppByName(projectName);
178182
Set<String> expectedConsoles = new HashSet<String>();
179183
Set<String> foundConsoles = new HashSet<String>();
180-
if (!app.projectType.isType(ProjectType.TYPE_NODEJS)) {
181-
expectedConsoles.add("Build Log");
184+
if (connection.checkVersion(1905, "2019_M5_E")) {
185+
for (ProjectLogInfo logInfo : app.getLogInfos()) {
186+
expectedConsoles.add(logInfo.logName);
187+
}
188+
} else {
189+
if (!app.projectType.isType(ProjectType.TYPE_NODEJS)) {
190+
expectedConsoles.add("Build Log");
191+
}
192+
expectedConsoles.add("Application Log");
182193
}
183-
expectedConsoles.add("Application Log");
184194
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
185195
for (IConsole console : manager.getConsoles()) {
186196
if (console.getName().contains(projectName)) {
187197
TestUtil.print("Found console: " + console.getName());
188198
assertTrue("The " + console.getName() + " console should be a TextConsole", console instanceof TextConsole);
199+
TestUtil.wait(new Condition() {
200+
@Override
201+
public boolean test() {
202+
return ((TextConsole)console).getDocument().getLength() > 0;
203+
}
204+
}, 20, 1);
189205
assertTrue("The " + console.getName() + " console should not be empty", ((TextConsole)console).getDocument().getLength() > 0);
190206
for (String name : expectedConsoles) {
191207
if (console.getName().contains(name)) {

dev/com.ibm.microclimate.test/src/com/ibm/microclimate/test/util/MicroclimateUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 IBM Corporation and others.
2+
* Copyright (c) 2018, 2019 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -54,7 +54,7 @@ public static void cleanup(MicroclimateConnection connection) throws Exception {
5454
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(app.name);
5555
if (project != null && project.exists()) {
5656
try {
57-
project.delete(IResource.FORCE | IResource. NEVER_DELETE_PROJECT_CONTENT, null);
57+
project.delete(IResource.FORCE | IResource.NEVER_DELETE_PROJECT_CONTENT, null);
5858
} catch (Exception e) {
5959
TestUtil.print("Failed to clean up project: " + project.getName(), e);
6060
}

0 commit comments

Comments
 (0)