use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.
the class SpringCloudAppSettingsTest method testSaveToDom4j.
@Test
public void testSaveToDom4j() {
final AppRawConfig app = new AppRawConfig();
app.setSubscriptionId("subscriptionId1");
app.setClusterName("clusterName1");
app.setAppName("appName1");
app.setIsPublic("true");
final Document document = DocumentHelper.createDocument();
final Element root = document.addElement("test");
PomUtils.updateNode(root, ConfigurationUpdater.toMap(app));
final String xml = "<test>" + "<subscriptionId>subscriptionId1</subscriptionId>" + "<clusterName>clusterName1</clusterName>" + "<appName>appName1</appName>" + "<isPublic>true</isPublic></test>";
assertEquals(xml, root.asXML());
app.setIsPublic(null);
}
use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.
the class SpringCloudAppSettingsTest method testSaveToDom4jNullProperty.
@Test
public void testSaveToDom4jNullProperty() {
final AppRawConfig app = new AppRawConfig();
app.setSubscriptionId("subscriptionId1");
app.setClusterName("clusterName1");
app.setAppName("appName1");
final Document document = DocumentHelper.createDocument();
final Element root = document.addElement("test");
PomUtils.updateNode(root, ConfigurationUpdater.toMap(app));
final String xml = "<test>" + "<subscriptionId>subscriptionId1</subscriptionId>" + "<clusterName>clusterName1</clusterName>" + "<appName>appName1</appName>" + "</test>";
assertEquals(xml, root.asXML());
}
use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.
the class PomUtilsTest method testSaveXmlNoBuild.
@Test
public void testSaveXmlNoBuild() throws Exception {
final File pomFile = new File(this.getClass().getClassLoader().getResource("pom-5.xml").getFile());
final File tempFile = Files.createTempFile("azure-spring-cloud-plugin-test", ".xml").toFile();
FileUtils.copyFile(pomFile, tempFile);
final Model model = TestHelper.readMavenModel(tempFile);
final MavenProject project = mock(MavenProject.class);
when(project.getModel()).thenReturn(model);
when(project.getFile()).thenReturn(tempFile);
final AppRawConfig app = new AppRawConfig();
app.setSubscriptionId("subscriptionId1");
app.setClusterName("clusterName1");
app.setAppName("appName1");
app.setIsPublic("true");
final AppDeploymentRawConfig deploy = new AppDeploymentRawConfig();
deploy.setCpu("1");
deploy.setMemoryInGB("2");
deploy.setInstanceCount("3");
deploy.setRuntimeVersion("8");
deploy.setJvmOptions("jvmOptions1");
final PluginDescriptor pd = mock(PluginDescriptor.class);
when(pd.getGroupId()).thenReturn("com.microsoft.azure");
when(pd.getArtifactId()).thenReturn("azure-spring-cloud-maven-plugin");
when(pd.getVersion()).thenReturn("0.1.0.SNAPSHOT");
app.setDeployment(deploy);
ConfigurationUpdater.updateAppConfigToPom(app, project, pd);
final String updatedXml = String.join("\n", Files.readAllLines(tempFile.toPath(), Charset.defaultCharset()));
assertTrue(updatedXml.contains("<maven.compiler.target>1.8\n" + " </maven.compiler.target>"));
assertTrue(updatedXml.contains("<configuration>\n" + " <subscriptionId>subscriptionId1</subscriptionId>\n" + " <clusterName>clusterName1</clusterName>\n" + " <appName>appName1</appName>\n" + " <isPublic>true</isPublic>\n" + " <deployment>\n" + " <cpu>1</cpu>\n" + " <memoryInGB>2</memoryInGB>\n" + " <instanceCount>3</instanceCount>\n" + " <jvmOptions>jvmOptions1</jvmOptions>\n" + " <runtimeVersion>8</runtimeVersion>\n" + " <resources>\n" + " <resource>\n" + " <filtering/>\n" + " <mergeId/>\n" + " <targetPath/>\n" + " <directory>${project.basedir}/target</directory>\n" + " <includes>\n" + " <include>*.jar</include>\n" + " </includes>\n" + " </resource>\n" + " </resources>\n" + " </deployment>\n" + " </configuration>"));
tempFile.delete();
}
use of com.microsoft.azure.maven.springcloud.config.AppRawConfig in project azure-maven-plugins by microsoft.
the class PomUtilsTest method testSaveXml.
@Test
public void testSaveXml() throws Exception {
final File pomFile = new File(this.getClass().getClassLoader().getResource("pom-4.xml").getFile());
final File tempFile = Files.createTempFile("azure-spring-cloud-plugin-test", ".xml").toFile();
FileUtils.copyFile(pomFile, tempFile);
final Model model = TestHelper.readMavenModel(tempFile);
final MavenProject project = mock(MavenProject.class);
when(project.getModel()).thenReturn(model);
when(project.getFile()).thenReturn(tempFile);
final AppRawConfig app = new AppRawConfig();
app.setSubscriptionId("subscriptionId1");
app.setClusterName("clusterName1");
app.setAppName("appName1");
app.setIsPublic("true");
final AppDeploymentRawConfig deploy = new AppDeploymentRawConfig();
deploy.setCpu("1");
deploy.setMemoryInGB("2");
deploy.setInstanceCount("3");
deploy.setRuntimeVersion("8");
deploy.setJvmOptions("jvmOptions1");
final Plugin plugin = model.getBuild().getPlugins().get(0);
final PluginDescriptor pd = mock(PluginDescriptor.class);
when(pd.getGroupId()).thenReturn(plugin.getGroupId());
when(pd.getArtifactId()).thenReturn(plugin.getArtifactId());
when(pd.getVersion()).thenReturn(plugin.getVersion());
app.setDeployment(deploy);
ConfigurationUpdater.updateAppConfigToPom(app, project, pd);
final String updatedXml = String.join("\n", Files.readAllLines(tempFile.toPath(), Charset.defaultCharset()));
assertTrue(updatedXml.contains("<maven.compiler.target>1.8\n" + " </maven.compiler.target>"));
assertTrue(updatedXml.contains("<configuration>\n" + " <subscriptionId>subscriptionId1</subscriptionId>\n" + " <clusterName>clusterName1</clusterName>\n" + " <appName>appName1</appName>\n" + " <isPublic>true</isPublic>\n" + " <deployment>\n" + " <cpu>1</cpu>\n" + " <memoryInGB>2</memoryInGB>\n" + " <instanceCount>3</instanceCount>\n" + " <jvmOptions>jvmOptions1</jvmOptions>\n" + " <runtimeVersion>8</runtimeVersion>\n" + " <resources>\n" + " <resource>\n" + " <filtering/>\n" + " <mergeId/>\n" + " <targetPath/>\n" + " <directory>${project.basedir}/target</directory>\n" + " <includes>\n" + " <include>*.jar</include>\n" + " </includes>\n" + " </resource>\n" + " </resources>\n" + " </deployment>\n" + " </configuration>"));
tempFile.delete();
}
Aggregations