Author: adietish
Date: 2012-01-17 09:29:41 -0500 (Tue, 17 Jan 2012)
New Revision: 37894
Modified:
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java
Log:
[JBIDE-10479] added test that asserts pom content
Modified:
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java
===================================================================
---
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java 2012-01-17
13:35:33 UTC (rev 37893)
+++
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java 2012-01-17
14:29:41 UTC (rev 37894)
@@ -13,7 +13,10 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -54,7 +57,7 @@
+ "<!--
http://maven.apache.org/guides/mini/guide-building-for-different-environm...
-->\n"
+ "<id>openshift</id>\n"
+ "<build>\n"
- + " <finalName>as22</finalName>\n"
+ + " <finalName>{0}</finalName>\n"
+ " <plugins>\n"
+ " <plugin>\n"
+ " <artifactId>maven-war-plugin</artifactId>\n"
@@ -325,7 +328,7 @@
}
@Test
- public void canAddOpenShiftProfileToComplexPom() throws CoreException {
+ public void canAddOpenShiftProfileToComplexPom() throws CoreException, IOException {
OpenShiftMavenProfile profile = new OpenShiftMavenProfile(complexNonOpenShiftProject,
PLUGIN_ID);
boolean added = profile.addToPom(complexNonOpenShiftProject.getName());
assertTrue(added);
@@ -335,6 +338,16 @@
}
@Test
+ public void addedOpenShiftProfileIsCorrect() throws CoreException, IOException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(complexNonOpenShiftProject,
PLUGIN_ID);
+ boolean added = profile.addToPom(complexNonOpenShiftProject.getName());
+ assertTrue(added);
+ profile.savePom();
+ String pomContent = toString(complexNonOpenShiftProject.getFile(POM_FILENAME));
+ assertTrue(pomContent.indexOf("<id>openshift</id>") >= 0);
+ }
+
+ @Test
public void doesNotAddOpenShiftProfileIfAlreadyPresent() throws CoreException {
OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithOpenShiftProfile,
PLUGIN_ID);
boolean added = profile.addToPom(openShiftProject.getName());
@@ -404,4 +417,13 @@
project.getWorkspace().run(runnable, new NullProgressMonitor());
return project;
}
+
+ private String toString(IFile file) throws CoreException, IOException {
+ StringBuilder builder = new StringBuilder();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
+ for(String line = null; (line = reader.readLine()) != null; ) {
+ builder.append(line);
+ }
+ return builder.toString();
+ }
}