Author: rob.stryker(a)jboss.com
Date: 2009-04-02 01:19:55 -0400 (Thu, 02 Apr 2009)
New Revision: 14436
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.classpath
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.project
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/build.properties
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/plugin.properties
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/BuildDeployTest.java
Log:
new test plugin for integrationing
Added: trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.classpath
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.classpath
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.classpath 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.project
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.project
(rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/.project 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.ide.eclipse.as.archives.integration.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/META-INF/MANIFEST.MF 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.jboss.ide.eclipse.as.archives.integration.test
+Bundle-Version: 1.0.0
+Bundle-Activator:
org.jboss.ide.eclipse.as.archives.integration.test.ASArchivesIntegrationTest
+Eclipse-LazyStart: true
+Bundle-ClassPath: jbossasarchivesintegrationtest.jar
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.junit4,
+ org.eclipse.core.resources;bundle-version="3.4.2",
+ org.eclipse.jdt;bundle-version="3.4.2",
+ org.eclipse.jdt.core;bundle-version="3.4.4",
+ org.eclipse.jdt.launching;bundle-version="3.4.1",
+ org.eclipse.wst.server.core;bundle-version="1.1.3",
+ org.jboss.ide.eclipse.as.core;bundle-version="1.0.0",
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="1.0.0",
+ org.jboss.ide.eclipse.archives.core;bundle-version="2.0.0",
+ org.jboss.ide.eclipse.archives.ui;bundle-version="1.0.0",
+ org.eclipse.jface;bundle-version="3.4.2",
+ org.jboss.tools.tests;bundle-version="2.0.0"
Added: trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/build.properties
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/build.properties
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/build.properties 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,6 @@
+bin.includes = META-INF/,\
+ jbossasarchivesintegrationtest.jar,\
+ plugin.properties
+source.jbossasarchivesintegrationtest.jar = src/
+jars.compile.order = jbossasarchivesintegrationtest.jar
+output.jbossasarchivesintegrationtest.jar = bin/
\ No newline at end of file
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/plugin.properties
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/plugin.properties
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/plugin.properties 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.ide.eclipse.as.test
+Bundle-Vendor.0 = JBoss, a division of Red Hat
+Bundle-Name.0 = AS Archives Integration Test Plug-in
\ No newline at end of file
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTest.java 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,70 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.archives.integration.test;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ASArchivesIntegrationTest extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID =
"org.jboss.ide.eclipse.as.archives.integration.test";
+
+ // The shared instance
+ private static ASArchivesIntegrationTest plugin;
+
+ /**
+ * The constructor
+ */
+ public ASArchivesIntegrationTest() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ASArchivesIntegrationTest getDefault() {
+ return plugin;
+ }
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/ASArchivesIntegrationTestSuite.java 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,33 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.archives.integration.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ASArchivesIntegrationTestSuite extends TestSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AS Archives Integration Test Suite");
+ return suite;
+ }
+
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/BuildDeployTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/BuildDeployTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/BuildDeployTest.java 2009-04-02
05:19:55 UTC (rev 14436)
@@ -0,0 +1,313 @@
+package org.jboss.ide.eclipse.as.archives.integration.test;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
+import org.jboss.ide.eclipse.archives.ui.actions.BuildAction;
+import org.jboss.ide.eclipse.archives.webtools.modules.ArchivesModuleModelListener;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.tools.test.util.JobUtils;
+
+public class BuildDeployTest extends TestCase {
+ private static final String VALUE_PREFIX = "value";
+ private static final String OUT_JAR = "out.jar";
+ private static final String FILE_NAME = "a.txt";
+
+ private int index = 0;
+ private IProject project;
+ private IJavaProject javaProject;
+ private IRuntime runtime;
+ private IServer server;
+ private IPath deploy, tempDeploy;
+ private IPath pluginMetadata;
+ private IFile textFile;
+ private IFile textOutputFile;
+ private IFile textBuildArchiveFile;
+ private File textDeployedFile;
+ private IArchive rootArchive;
+ public void testOne() throws Exception {
+ // Builder is off, auto-deploy is off
+ enableAutomaticBuilder(false);
+ createProject();
+ setupServer();
+ addArchives();
+ buildArchive();
+ assertBuiltArchiveContents(index);
+ changeArchivesDeployPrefs(false, server.getId());
+ deploy();
+ assertDeployContents(index);
+
+ // Builder is on, auto-deploy is off
+ enableAutomaticBuilder(true);
+ int count = ++index;
+ setContents(count);
+ assertSourceContents(count);
+ JobUtils.waitForIdle();
+ assertBinContents(count);
+ assertBuiltArchiveContents(count);
+ try {
+ assertDeployContents(count);
+ assertTrue("Deployed File should not have changed", false);
+ } catch( AssertionError ae) {}
+
+
+ // Builder is on, auto-deploy is on
+ changeArchivesDeployPrefs(true, server.getId());
+ count = ++index;
+ setContents(count);
+ assertSourceContents(count);
+ assertBinContents(count);
+ assertBuiltArchiveContents(count);
+ assertDeployContents(count);
+
+ // Builder is off, autodeploy is on
+ count = ++index;
+ setContents(count);
+ assertSourceContents(count);
+ try {
+ assertBinContents(count);
+ assertTrue("Bin File should not have changed", false);
+ } catch( AssertionError ae ) {}
+ try {
+ assertBuiltArchiveContents(count);
+ assertTrue("Built Archive File should not have changed", false);
+ } catch( AssertionError ae ) {}
+ try {
+ assertDeployContents(count);
+ assertTrue("Deployed File should not have changed", false);
+ } catch( AssertionError ae ) {}
+
+ // Builder is off, autodeploy is on, manually call build!
+ callBuild();
+ assertBinContents(count);
+ assertBuiltArchiveContents(count);
+ assertDeployContents(count);
+
+ }
+
+ protected void enableAutomaticBuilder(boolean enabled) throws CoreException {
+ IWorkspaceDescription desc = ResourcesPlugin.getWorkspace().getDescription();
+ desc.setAutoBuilding(enabled);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ }
+
+ protected void createProject() throws CoreException, IOException {
+ javaProject = createJavaProject("P1");
+ project = javaProject.getProject();
+ textFile = project.getFile(new Path(FILE_NAME));
+ textOutputFile = project.getFile(new Path("bin").append(FILE_NAME));
+ String initial = VALUE_PREFIX + index;
+
+ assertFalse(textFile.getLocation().toFile().exists());
+ textFile.create(new ByteArrayInputStream(initial.getBytes()), true, new
NullProgressMonitor());
+ assertTrue(textFile.getLocation().toFile().exists());
+
+ assertFalse(textOutputFile.getLocation().toFile().exists());
+ callBuild();
+ assertTrue(textOutputFile.getLocation().toFile().exists());
+
+ assertContents(textOutputFile.getContents(), index);
+
+ setContents(++index);
+ assertContents(textFile.getContents(), index);
+
+ assertContents(textOutputFile.getContents(), 0);
+ ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new
NullProgressMonitor());
+ assertContents(textOutputFile.getContents(), 1);
+ }
+
+ protected String getContents(InputStream is) throws IOException {
+ BufferedInputStream bis = new BufferedInputStream(is);
+ int l = (int)textOutputFile.getLocation().toFile().length();
+ byte[] bs = new byte[l];
+ l = bis.read(bs, 0, l);
+ bis.close();
+ return new String(bs);
+ }
+
+ protected IJavaProject createJavaProject(String name) {
+ try {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ project.create(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+
+ IProjectDescription description = project.getDescription();
+ String[] natures = description.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = JavaCore.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, new NullProgressMonitor());
+ IJavaProject javaProject = JavaCore.create(project);
+ Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>();
+ entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
+ entries.add(JavaRuntime.getDefaultJREContainerEntry());
+ IClasspathEntry[] entries2 =
+ entries.toArray(new IClasspathEntry[entries.size()]);
+ javaProject.setRawClasspath(entries2, new NullProgressMonitor());
+ return javaProject;
+ } catch( CoreException ce ) {
+ }
+ return null;
+ }
+
+ protected void setupServer() throws CoreException {
+ pluginMetadata = ASArchivesIntegrationTest.getDefault().getStateLocation();
+ pluginMetadata.toFile().mkdirs();
+ pluginMetadata.append("server1").toFile().mkdirs();
+ deploy = pluginMetadata.append("server1").append("1");
+ deploy.toFile().mkdirs();
+ tempDeploy = pluginMetadata.append("server1").append("2");
+ tempDeploy.toFile().mkdirs();
+
+
+ IRuntimeType[] rtTypes = ServerCore.getRuntimeTypes();
+ IRuntimeType rtType = null;
+ for( int i = 0; i < rtTypes.length; i++ ) {
+ if( rtTypes[i].getId().equals("org.jboss.ide.eclipse.as.runtime.stripped"))
+ rtType = rtTypes[i];
+ }
+ assertNotNull(rtType);
+ IRuntimeWorkingCopy rtwc = rtType.createRuntime("temp.rt.id", new
NullProgressMonitor());
+ runtime = rtwc.save(true, new NullProgressMonitor());
+
+ IServerType[] serverTypes = ServerCore.getServerTypes();
+ IServerType serverType = null;
+ for( int i = 0; i < serverTypes.length; i++ ) {
+ if(
serverTypes[i].getId().equals("org.jboss.ide.eclipse.as.systemCopyServer"))
+ serverType = serverTypes[i];
+ }
+ assertNotNull(serverType);
+ IServerWorkingCopy wc = serverType.createServer("tmp.server.id", null, new
NullProgressMonitor());
+ if( wc instanceof ServerWorkingCopy ) {
+ ServerWorkingCopy swc = (ServerWorkingCopy)wc;
+ swc.setName("server1");
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deploy.toOSString());
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeploy.toOSString());
+ swc.setRuntime(runtime);
+ }
+ server = wc.save(true, new NullProgressMonitor());
+
+ // some asserts
+ assertTrue(ServerCore.getRuntimes().length == 1);
+ assertTrue(ServerCore.getServers().length == 1);
+
+ textDeployedFile = deploy.append(OUT_JAR).append(FILE_NAME).toFile();
+ }
+
+ protected void addArchives() {
+ ArchivesModel.instance().registerProject(project.getLocation(), new
NullProgressMonitor());
+ IArchiveModelRootNode root = ArchivesModel.instance().getRoot(project.getLocation());
+ rootArchive = ArchiveNodeFactory.createArchive();
+ rootArchive.setExploded(true);
+ rootArchive.setInWorkspace(true);
+ rootArchive.setName(OUT_JAR);
+ rootArchive.setDestinationPath(null);
+ root.addChild(rootArchive);
+
+ IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
+ fs.setIncludesPattern("**/*txt");
+ fs.setExcludesPattern("**/bin/**, **/*jar*");
+ fs.setInWorkspace(true);
+ fs.setRawSourcePath("/P1");
+ rootArchive.addChild(fs);
+ root.save(new NullProgressMonitor());
+
+ textBuildArchiveFile = project.getFolder(OUT_JAR).getFile(FILE_NAME);
+ }
+
+ protected void changeArchivesDeployPrefs(boolean alwaysPublish, String servers) {
+ rootArchive.setProperty(ArchivesModuleModelListener.DEPLOY_SERVERS, servers);
+ rootArchive.setProperty(ArchivesModuleModelListener.DEPLOY_AFTER_BUILD, new
Boolean(alwaysPublish).toString());
+ final IPath projectPath = rootArchive.getProjectPath();
+ ArchivesModel.instance().save(projectPath, new NullProgressMonitor());
+ }
+
+ protected void buildArchive() {
+ Job j = new BuildAction().run(rootArchive);
+ while(j.getResult() == null ) {
+ try {
+ Thread.sleep(100);
+ } catch( InterruptedException ie) {}
+ }
+ assertTrue(j.getResult().isOK());
+ }
+
+ protected void deploy() {
+ ArchivesModuleModelListener.getInstance().publish(rootArchive, server.getId(),
IServer.PUBLISH_FULL);
+ }
+
+
+ protected void setContents(int val) throws IOException , CoreException{
+ textFile.setContents(new ByteArrayInputStream(new String(VALUE_PREFIX +
(val)).getBytes()), false, false, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ System.out.println("finish setContents");
+ }
+
+ protected void assertContents(InputStream is, int val) throws IOException {
+ String contents = getContents(is);
+ assertEquals(VALUE_PREFIX + val, contents);
+ }
+
+ protected void assertSourceContents(int val) throws IOException, CoreException {
+ assertContents(textFile.getContents(), val);
+ }
+
+ protected void assertBinContents(int val) throws IOException, CoreException {
+ try {
+ Thread.sleep(20000);
+ } catch( InterruptedException ie) {}
+ assertContents(textOutputFile.getContents(), val);
+ }
+
+ protected void assertBuiltArchiveContents(int val) throws IOException, CoreException {
+ assertContents(textBuildArchiveFile.getContents(), val);
+ }
+ protected void assertDeployContents(int val) throws IOException, CoreException {
+ assertContents(new FileInputStream(textDeployedFile), val);
+ }
+
+ protected void callBuild() throws CoreException {
+ ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new
NullProgressMonitor());
+ JobUtils.waitForIdle();
+ }
+}