### Eclipse Workspace Patch 1.0
#P org.jboss.ide.eclipse.as.core
Index: jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java
===================================================================
--- jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java	(revision 41665)
+++ jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java	(working copy)
@@ -66,7 +66,6 @@
 
 	public String getDeployFolder(String type) {
 		if( type.equals(DEPLOY_SERVER) ) {
-			// TODO make sure this is correct?! Upstream APIs have this wrong for as7
 			IRuntime rt = getServer().getRuntime();
 			if( rt == null )
 				return null;
@@ -76,10 +75,13 @@
 		return getDeployFolder(this, type);
 	}
 	
-	// Just force it to be in metadata location, for now
 	public String getTempDeployFolder() {
-		IRuntime rt = getServer().getRuntime();
-		IPath p = rt.getLocation().append(AS7_STANDALONE).append(FOLDER_TMP);
-		return ServerUtil.makeGlobal(rt, p).toString();
+		String type = getDeployLocationType();
+		if( DEPLOY_SERVER.equals(type)) {
+			IRuntime rt = getServer().getRuntime();
+			IPath p = rt.getLocation().append(AS7_STANDALONE).append(FOLDER_TMP);
+			return ServerUtil.makeGlobal(rt, p).toString();
+		}
+		return getTempDeployFolder(this, type);
 	}
 }
#P org.jboss.ide.eclipse.as.test
Index: src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
--- src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java	(revision 41665)
+++ src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java	(working copy)
@@ -129,7 +129,11 @@
 	}
 	
 	public static IServer createMockJBoss7Server(String deployLocation, String tempDeployLocation) throws CoreException {
-		IRuntime runtime = RuntimeUtils.createRuntime(IJBossToolingConstants.AS_70, "/", "default");
+		return createMockJBoss7Server("/", deployLocation, tempDeployLocation);
+	}
+
+	public static IServer createMockJBoss7Server(String rtLoc, String deployLocation, String tempDeployLocation) throws CoreException {
+		IRuntime runtime = RuntimeUtils.createRuntime(IJBossToolingConstants.AS_70, rtLoc, "default");
 		IServer s = ServerCreationUtils.createServer2(runtime, IJBossToolingConstants.SERVER_AS_70);
 		IServerWorkingCopy swc = s.createWorkingCopy();
 		swc.setServerConfiguration(null);
@@ -138,7 +142,7 @@
 		IServer server = swc.save(true, null);
 		return server;
 	}
-	
+
 	public static IServer useMockPublishMethod(IServer server) throws CoreException {
 		IServerWorkingCopy wc = server.createWorkingCopy();
 		wc.setAttribute(IDeployableServer.SERVER_MODE, "mock");
Index: src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
===================================================================
--- src/org/jboss/ide/eclipse/as/test/ASTestSuite.java	(revision 41665)
+++ src/org/jboss/ide/eclipse/as/test/ASTestSuite.java	(working copy)
@@ -31,6 +31,7 @@
 import org.jboss.ide.eclipse.as.test.classpath.RuntimeServerModelTest;
 import org.jboss.ide.eclipse.as.test.defects.WebDeployableArtifactUtilDefectTest;
 import org.jboss.ide.eclipse.as.test.projectcreation.TestEar5WithJBossRuntime;
+import org.jboss.ide.eclipse.as.test.publishing.DeployAndTempDeployFolderTest;
 import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512aTest;
 import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512bTest;
 import org.jboss.ide.eclipse.as.test.publishing.JBIDE4184Test;
@@ -73,6 +74,7 @@
         suite.addTestSuite(StringSubstitutionTest.class);
         
         // Publishing tests
+        suite.addTestSuite(DeployAndTempDeployFolderTest.class);
         suite.addTestSuite(BehaviourModelDefectTest.class);
         suite.addTestSuite(WebDeployableArtifactUtilDefectTest.class);
         suite.addTestSuite(MockJSTPublisherTest.class);
Index: src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java
===================================================================
--- src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java	(revision 0)
+++ src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java	(revision 0)
@@ -0,0 +1,64 @@
+package org.jboss.ide.eclipse.as.test.publishing;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
+
+public class DeployAndTempDeployFolderTest extends TestCase {
+	public void tearDown() throws Exception {
+		ServerRuntimeUtils.deleteAllServers();
+		ServerRuntimeUtils.deleteAllRuntimes();
+		ProjectUtility.deleteAllProjects();
+		ASTest.clearStateLocation();
+	}
+
+	private IDeployableServer initAS7Server(String type) throws CoreException {
+		IServer s = ServerRuntimeUtils.createMockJBoss7Server();
+		IServerWorkingCopy wc = s.createWorkingCopy();
+		wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, type);
+		s = wc.save(true, null);
+		IDeployableServer ds = ServerConverter.getDeployableServer(s);
+		return ds;
+	}
+	
+	public void testAS7xServer() throws CoreException {
+		IDeployableServer ds = initAS7Server(IDeployableServer.DEPLOY_SERVER);
+		assertEquals("/standalone/deployments", ds.getDeployFolder());
+		assertEquals("/standalone/tmp", ds.getTempDeployFolder());
+	}
+
+	public void testAS7xMetadata() throws CoreException {
+		IDeployableServer ds = initAS7Server(IDeployableServer.DEPLOY_METADATA);
+		assertTrue(ds.getDeployFolder().endsWith("org.jboss.ide.eclipse.as.core/org.jboss.ide.eclipse.as.70/deploy"));
+		assertTrue(ds.getTempDeployFolder().endsWith("org.jboss.ide.eclipse.as.core/org.jboss.ide.eclipse.as.70/tempDeploy"));
+	}
+	
+	public void testAS7xCustomGlobal() throws CoreException {
+		IServer s = ServerRuntimeUtils.createMockJBoss7Server("/rtHome", "/home/test1", "/home/test2");
+		IServerWorkingCopy wc = s.createWorkingCopy();
+		wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
+		s = wc.save(true, null);
+		IDeployableServer ds = ServerConverter.getDeployableServer(s);
+		assertTrue("/home/test1".equals(ds.getDeployFolder()));
+		assertTrue("/home/test2".equals(ds.getTempDeployFolder()));
+	}
+
+	public void testAS7xCustomRelative() throws CoreException {
+		IServer s = ServerRuntimeUtils.createMockJBoss7Server("/rtHome", "home/test1", "home/test2");
+		IServerWorkingCopy wc = s.createWorkingCopy();
+		wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
+		s = wc.save(true, null);
+		IDeployableServer ds = ServerConverter.getDeployableServer(s);
+		assertTrue("/rtHome/home/test1".equals(ds.getDeployFolder()));
+		assertTrue("/rtHome/home/test2".equals(ds.getTempDeployFolder()));
+	}
+
+	
+}
