|
| 1 | +package com.mathworks.ci.systemTests; |
| 2 | + |
| 3 | +import com.mathworks.ci.MatlabBuildWrapperContent; |
| 4 | +import com.mathworks.ci.MatlabInstallation; |
| 5 | +import com.mathworks.ci.UseMatlabVersionBuildWrapper; |
| 6 | +import com.mathworks.ci.freestyle.RunMatlabCommandBuilder; |
| 7 | +import com.mathworks.ci.freestyle.RunMatlabTestsBuilder; |
| 8 | +import com.mathworks.ci.tools.MatlabInstaller; |
| 9 | +import hudson.model.FreeStyleBuild; |
| 10 | +import hudson.model.FreeStyleProject; |
| 11 | +import hudson.model.Result; |
| 12 | +import hudson.tools.InstallSourceProperty; |
| 13 | +import hudson.tools.ToolInstallation; |
| 14 | +import hudson.tools.ToolInstaller; |
| 15 | +import hudson.tools.ToolProperty; |
| 16 | +import org.junit.*; |
| 17 | +import org.junit.rules.Timeout; |
| 18 | +import org.jvnet.hudson.test.JenkinsRule; |
| 19 | +import com.mathworks.ci.MatlabInstallation; |
| 20 | + |
| 21 | +import java.io.IOException; |
| 22 | +import java.util.ArrayList; |
| 23 | +import java.util.Arrays; |
| 24 | +import java.util.List; |
| 25 | + |
| 26 | +import static org.jvnet.hudson.test.JenkinsRule.NO_PROPERTIES; |
| 27 | + |
| 28 | +public class MPMInstallIT { |
| 29 | + private FreeStyleProject project; |
| 30 | + private RunMatlabCommandBuilder scriptBuilder; |
| 31 | + private UseMatlabVersionBuildWrapper buildWrapper; |
| 32 | + |
| 33 | + @Rule |
| 34 | + public Timeout timeout = Timeout.seconds(0); |
| 35 | + |
| 36 | + @Rule |
| 37 | + public JenkinsRule jenkins = new JenkinsRule(); |
| 38 | + |
| 39 | + @Before |
| 40 | + public void testSetup() throws IOException { |
| 41 | + this.project = jenkins.createFreeStyleProject(); |
| 42 | + this.buildWrapper = new UseMatlabVersionBuildWrapper(); |
| 43 | + this.scriptBuilder = new RunMatlabCommandBuilder(); |
| 44 | + } |
| 45 | + |
| 46 | + @After |
| 47 | + public void testTearDown() { |
| 48 | + this.project = null; |
| 49 | + this.scriptBuilder = null; |
| 50 | + MatlabRootSetup.matlabInstDescriptor = null; |
| 51 | + this.buildWrapper = null; |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void verifyWindowsError() throws Exception { |
| 56 | + List<ToolInstaller> toolInstallers = new ArrayList<>(); |
| 57 | + MatlabInstaller mi = new MatlabInstaller("matlab"); |
| 58 | + mi.setRelease("R2023a"); |
| 59 | + toolInstallers.add(mi); |
| 60 | + |
| 61 | + |
| 62 | +// List<? extends ToolProperty<?>> properties = |
| 63 | + |
| 64 | + List<ToolProperty<ToolInstallation>> gitToolProperties = new ArrayList<>(); |
| 65 | + InstallSourceProperty installSourceProperty = new InstallSourceProperty(toolInstallers); |
| 66 | + gitToolProperties.add(installSourceProperty); |
| 67 | + |
| 68 | + |
| 69 | + MatlabInstallation.DescriptorImpl matlabInstDescriptor = jenkins.getInstance().getDescriptorByType(MatlabInstallation.DescriptorImpl.class); |
| 70 | + MatlabInstallation[] prevInst = getMatlabInstallation(); |
| 71 | + ArrayList<MatlabInstallation> newInst = new ArrayList<>(Arrays.asList(prevInst)); |
| 72 | + |
| 73 | + MatlabInstallation newMatlabInstallation = new MatlabInstallation("MATLAB1", null,gitToolProperties ); |
| 74 | + newInst.add(newMatlabInstallation); |
| 75 | + |
| 76 | + MatlabInstallation[] setInst = new MatlabInstallation[newInst.size()]; |
| 77 | + matlabInstDescriptor.setInstallations(newInst.toArray(setInst)); |
| 78 | + |
| 79 | + MatlabBuildWrapperContent content = new MatlabBuildWrapperContent(newMatlabInstallation.getName(), null); |
| 80 | + buildWrapper.setMatlabBuildWrapperContent(content); |
| 81 | + project.getBuildWrappersList().add(buildWrapper); |
| 82 | + useCommandFreeStyle("version"); |
| 83 | + |
| 84 | + FreeStyleBuild build = project.scheduleBuild2(0).get(); |
| 85 | + |
| 86 | + System.out.println(build.getLog()); |
| 87 | + jenkins.assertLogContains(newMatlabInstallation.getHome(), build); |
| 88 | + jenkins.assertBuildStatus(Result.SUCCESS, build); |
| 89 | + } |
| 90 | + |
| 91 | + @Test |
| 92 | + public void verifyMPMInstall(){ |
| 93 | + |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + public void verifyAddingProducts(){ |
| 98 | + |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void verifyUsingLatest(){ |
| 103 | + |
| 104 | + } |
| 105 | + |
| 106 | + @Test |
| 107 | + public void verifyMPMInPipeline(){ |
| 108 | + |
| 109 | + } |
| 110 | + |
| 111 | + @Test |
| 112 | + public void verifyMPMInScriptedPipeline(){ |
| 113 | + |
| 114 | + } |
| 115 | + |
| 116 | + @Test |
| 117 | + public void verifyMPMInMatrix(){ |
| 118 | + |
| 119 | + } |
| 120 | + |
| 121 | + @Test |
| 122 | + public void verifyMultipleMPMInsatallation(){ |
| 123 | + |
| 124 | + } |
| 125 | + |
| 126 | + |
| 127 | + public static MatlabInstallation[] getMatlabInstallation(){ |
| 128 | + // static method to return all installations |
| 129 | + return MatlabInstallation.getAll(); |
| 130 | + } |
| 131 | + |
| 132 | + public void useCommandFreeStyle(String command) { |
| 133 | + scriptBuilder.setMatlabCommand(TestData.getPropValues("matlab.command")); |
| 134 | + project.getBuildersList().add(scriptBuilder); |
| 135 | + } |
| 136 | + |
| 137 | + |
| 138 | +} |
0 commit comments