Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 5965ea2

Browse files
committed
Updated as per review comments
1 parent 74da9a4 commit 5965ea2

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

src/test/java/com/mathworks/ci/MatlabBuilderTest.java

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.net.URISyntaxException;
1313
import java.net.URL;
1414
import java.util.List;
15+
import java.util.concurrent.ExecutionException;
1516
import org.junit.After;
1617
import org.junit.Assert;
1718
import org.junit.Before;
@@ -87,9 +88,17 @@ public void testTearDown() {
8788

8889
private String getMatlabroot(String version) throws URISyntaxException {
8990
ClassLoader classLoader = MatlabBuilderTest.class.getClassLoader();
90-
String matlabRoot = new File(
91-
classLoader.getResource("versioninfo/" + version + "/VersionInfo.xml").toURI())
92-
.getAbsolutePath().replace(FileSeperator + "VersionInfo.xml", "");
91+
String matlabRoot;
92+
if (classLoader.getResource("versioninfo/" + version + "/VersionInfo.xml") != null) {
93+
matlabRoot = new File(
94+
classLoader.getResource("versioninfo/" + version + "/VersionInfo.xml").toURI())
95+
.getAbsolutePath().replace(FileSeperator + "VersionInfo.xml", "");
96+
} else {
97+
matlabRoot = new File(
98+
classLoader.getResource("versioninfo/" + "R2017a" + "/VersionInfo.xml").toURI())
99+
.getAbsolutePath().replace(FileSeperator + "VersionInfo.xml", "")
100+
.replace("R2017a", version);
101+
}
93102
return matlabRoot;
94103
}
95104

@@ -290,13 +299,7 @@ public void verifyCustomCommandInvokedForBatchMode() throws Exception {
290299
@Test
291300
public void verifyRunTestAutomaticallyIsDefault() throws Exception {
292301
this.matlabBuilder.setLocalMatlab(getMatlabroot("R2018b"));
293-
RunTestsAutomaticallyOption runOption = new RunTestsAutomaticallyOption();
294-
runOption.setTaCoberturaChkBx(true);
295-
runOption.setTaJunitChkBx(true);
296-
runOption.setTatapChkBx(true);
297-
this.matlabBuilder.setTestRunTypeList(runOption);
298-
project.getBuildersList().add(this.matlabBuilder);
299-
FreeStyleBuild build = project.scheduleBuild2(0).get();
302+
FreeStyleBuild build = getBuildforRunTestAutomatically();
300303
jenkins.assertLogContains("-batch", build);
301304
jenkins.assertLogContains("true,true,true", build);
302305
}
@@ -329,16 +332,10 @@ public void verifyDefaultValueOfgetBooleanByName() throws Exception {
329332

330333
@Test
331334
public void verifyMatlabVersionOlderThanR17a() throws Exception {
332-
this.matlabBuilder.setLocalMatlab(getMatlabroot("R2018b"));
333-
RunTestsAutomaticallyOption runOption = new RunTestsAutomaticallyOption();
334-
runOption.setTaCoberturaChkBx(true);
335-
runOption.setTaJunitChkBx(true);
336-
runOption.setTatapChkBx(true);
337-
this.matlabBuilder.setTestRunTypeList(runOption);
338-
project.getBuildersList().add(this.matlabBuilder);
339-
FreeStyleBuild build = project.scheduleBuild2(0).get();
340-
jenkins.assertLogContains("-batch", build);
341-
jenkins.assertLogContains("true,true,true", build);
335+
this.matlabBuilder.setLocalMatlab(getMatlabroot("R2016b"));
336+
FreeStyleBuild build = getBuildforRunTestAutomatically();
337+
jenkins.assertLogContains("-r", build);
338+
jenkins.assertLogContains("try,exit(", build);
342339
}
343340

344341
/*
@@ -354,12 +351,12 @@ public void verifyEmptyMatlabRootError() throws Exception {
354351
}
355352

356353
/*
357-
* Test To verify UI does not throw any error when valid MATLAB root entered
354+
* Test To verify UI does throw error when in valid MATLAB root entered
358355
*
359356
*/
360357

361358
@Test
362-
public void verifyInvalidValidMatlabRoot() throws Exception {
359+
public void verifyInvalidMatlabRootDisplaysError() throws Exception {
363360
project.getBuildersList().add(this.matlabBuilder);
364361
this.matlabBuilder.setLocalMatlab("/fake/matlab/path");
365362
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
@@ -372,7 +369,7 @@ public void verifyInvalidValidMatlabRoot() throws Exception {
372369
*/
373370

374371
@Test
375-
public void verifyValidMatlabRoot() throws Exception {
372+
public void verifyValidMatlabRootDoesntDisplayError() throws Exception {
376373
project.getBuildersList().add(this.matlabBuilder);
377374
this.matlabBuilder.setLocalMatlab(getMatlabroot("R2018b"));
378375
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
@@ -412,4 +409,19 @@ public void verifyCoberturaError() throws Exception {
412409
String filteredPageText = pageText.replaceFirst(TestMessage.getValue("Builder.invalid.matlab.root.error"), "");
413410
Assert.assertTrue(filteredPageText.contains(TestMessage.getValue("Builder.invalid.matlab.root.error")));
414411
}
412+
413+
/*
414+
* Private helper methods for tests
415+
*/
416+
417+
private FreeStyleBuild getBuildforRunTestAutomatically() throws InterruptedException, ExecutionException {
418+
RunTestsAutomaticallyOption runOption = new RunTestsAutomaticallyOption();
419+
runOption.setTaCoberturaChkBx(true);
420+
runOption.setTaJunitChkBx(true);
421+
runOption.setTatapChkBx(true);
422+
this.matlabBuilder.setTestRunTypeList(runOption);
423+
project.getBuildersList().add(this.matlabBuilder);
424+
FreeStyleBuild build = project.scheduleBuild2(0).get();
425+
return build;
426+
}
415427
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright 2019 The MathWorks, Inc.
2+
#This is dummy file created as resource

0 commit comments

Comments
 (0)