Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 307033
Collapse All | Expand All

(-)src/org/eclipse/hyades/internal/execution/recorder/utilities/RecorderFileUtil.java (-155 / +114 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-190 Link Here
10
 * IBM Corporation - initial API and implementation
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
11
 **********************************************************************/
12
package org.eclipse.hyades.internal.execution.recorder.utilities;
12
package org.eclipse.hyades.internal.execution.recorder.utilities;
13
import java.io.ByteArrayInputStream;
13
14
import java.io.IOException;
14
import java.io.File;
15
import java.util.HashMap;
16
import java.util.Map;
17
15
18
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.core.runtime.NullProgressMonitor;
22
import org.eclipse.core.runtime.Path;
21
23
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.ecore.resource.Resource;
27
import org.eclipse.emf.ecore.resource.ResourceSet;
28
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
29
import org.eclipse.emf.ecore.xmi.XMIResource;
30
import org.eclipse.hyades.models.trace.TRCSourceInfo;
31
import org.eclipse.hyades.models.trace.impl.TraceFactoryImpl;
32
/**
22
/**
33
 * @author amathur
23
 * <p>Utilities for recording files.</p>
34
 * @author Jerome Bozier
24
 * 
35
 * @version November 17, 2009
25
 * 
36
 *
26
 * @author  Ashish Mathur
37
 * To change the template for this generated type comment go to
27
 * @author  Jerome Bozier
38
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
28
 * @author  Paul Slauenwhite
29
 * @version March 25, 2010
30
 * @since   September 23, 2005
39
 */
31
 */
40
public class RecorderFileUtil {
32
public class RecorderFileUtil {
41
	
33
42
	public static IFile createTraceFile(String filepath) throws CoreException 
34
	/**
43
	{
35
	 * <p>Determines if the {@link IFile} exists in the workspace or local file system.</p>
44
		
36
	 * 
45
		String recFilePath = filepath;
37
	 * @param iFile The {@link IFile} to be checked.
46
		IFile file = null;
38
	 * @return <code>true</code> if the {@link IFile} exists in the workspace or local file system, otherwise <code>false</code>.
47
		try 
39
	 */
48
		{
40
	public static boolean fileExists(IFile iFile){
49
			if (!recFilePath.endsWith(".rec")) { //$NON-NLS-1$
41
50
				recFilePath += ".rec"; //$NON-NLS-1$
42
		//Workspace file check: 
51
			}
43
		if (iFile.exists()){
52
			
44
			return true;
53
			file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(recFilePath));
54
			
55
			if(file.exists())
56
			{
57
				file.delete(true,true,null);
58
			}
59
			
60
			file.create(new ByteArrayInputStream(new byte[] {}), true, new NullProgressMonitor());
61
			
62
			
63
			
64
		}
45
		}
65
		catch (RuntimeException e) {
46
66
			e.printStackTrace();
47
		//File system file check: 
48
		else{
49
50
			IPath iFilePath = iFile.getLocation();
51
52
			if (iFilePath != null){
53
				return (iFilePath.toFile().exists());
54
			}
67
		}
55
		}
68
56
69
		return file;
57
		return false;
70
	}
58
	}
71
	
59
	
72
	public static IFile createTraceModel(String recModelPath, String recFilePath) {
60
	/**
73
		Map RESOURCE_OPTIONS = new HashMap();
61
	 * <p>Deletes the recording {@link IFile} if it exists in the workspace or local file system.</p>
74
		RESOURCE_OPTIONS.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
62
	 * 
75
		RESOURCE_OPTIONS.put(XMIResource.OPTION_SKIP_ESCAPE, Boolean.FALSE);
63
	 * <p>If the recording {@link IFile} was successfully deleted, the recording {@link IFile}'s parent container is refreshed.</p> 
76
		RESOURCE_OPTIONS.put(XMIResource.OPTION_ENCODING, "UTF-8");
64
	 * 
77
		TRCSourceInfo si = TraceFactoryImpl.eINSTANCE.createTRCSourceInfo();
65
	 * <p>If the recording {@link IFile} ends with the <code>.recmodel</code> file extension, the recording model {@link IFile}
78
		//URI testSuiteURI = EcoreUtil.getURI(tpfSuite);
66
	 * (<code>*.recmodel</code>) is deleted and the recording {@link IFile}'s parent container is refreshed.</p> 
79
		//URI uri = tpfSuite.eResource().getURI().trimFileExtension();
67
	 * 
80
		
68
	 * @param iFile The recording {@link IFile} to be deleted.
81
		if (recModelPath.endsWith(".rec")) { //$NON-NLS-1$
69
	 * @return <code>true</code> if the recording {@link IFile} and possible recording model {@link IFile} were successfully deleted, otherwise <code>false</code>.
82
			recModelPath += "model"; //$NON-NLS-1$
70
	 */
83
		}
71
	public static boolean deleteRecordingFile(IFile recordingFile){
84
		else if (!recModelPath.endsWith(".recmodel")) { //$NON-NLS-1$
85
			recModelPath += ".recmodel"; //$NON-NLS-1$
86
		}
87
		
88
72
89
		URI modelURI = URI.createPlatformResourceURI(recModelPath,true);
73
		boolean isSuccessful = false;
90
		si.setLocation(recFilePath);
91
		ResourceSet rs = new ResourceSetImpl();
92
		Resource resource = rs.createResource(modelURI);
93
		resource.getContents().add(si);
94
		
95
		//TODO handle situation where file already exists.
96
		try {
97
			resource.save(RESOURCE_OPTIONS);
98
		}
99
		catch (IOException e) {
100
			e.printStackTrace();
101
		}
102
		
103
		return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(recModelPath));
104
74
105
		
75
		if(recordingFile != null){
106
	}
76
107
	public static EObject[] loadResource(IFile file) {
77
			isSuccessful = deleteFile(recordingFile);
108
		// Create a resource set before loading anything
78
109
		ResourceSet resourceSet = new ResourceSetImpl();
79
			if(isSuccessful){
110
		Resource resource =
80
111
			resourceSet.getResource(
81
				IPath iFilePath = recordingFile.getFullPath(); 
112
				URI.createPlatformResourceURI(file.getFullPath().toString(),true),
82
113
				true);
83
				if("rec".equals(iFilePath.getFileExtension())){ //$NON-NLS-1$					
114
		if (resource == null) {
84
					isSuccessful = deleteFile(ResourcesPlugin.getWorkspace().getRoot().getFile(iFilePath.removeFileExtension().addFileExtension("recmodel"))); //$NON-NLS-1$
115
			System.out.println("Failed to get the resource"); //$NON-NLS-1$
85
				}
116
			return null;
86
			}
117
		}
87
		}
118
		// Retrieve an array of root elements in this file. In this case, there is really only 
88
119
		// one TRCSourceInfo element.
89
		return isSuccessful;
120
		EObject[] elements =
121
			(EObject[]) resource.getContents().toArray(
122
				new EObject[resource.getContents().size()]);
123
		return elements;
124
	}
90
	}
91
125
	/**
92
	/**
126
	 * @param file
93
	 * <p>Deletes the {@link IFile} if it exists in the workspace or local file system.</p>
94
	 * 
95
	 * <p>If the {@link IFile} was successfully deleted, the {@link IFile}'s parent container is refreshed.</p> 
96
	 * 
97
	 * @param iFile The {@link IFile} to be deleted.
98
	 * @return <code>true</code> if the {@link IFile} was successfully deleted, otherwise <code>false</code>.
127
	 */
99
	 */
128
	public static IFile getTraceFile(IFile file) {
100
	public static boolean deleteFile(IFile iFile){
129
		EObject[] elements = RecorderFileUtil.loadResource(file);
101
130
		TRCSourceInfo tsi = (TRCSourceInfo) elements[0];
102
		boolean isSuccessful = false;
131
		// Get the location attribute
103
132
		String location = tsi.getLocation();
104
		if(iFile != null){
133
		System.out.println("Trace file: " + location); //$NON-NLS-1$
105
134
		// Find and open the trace file
106
			//Workspace file check: 
135
		IFile traceFile =
107
			if (iFile.exists()){
136
			(IFile) ResourcesPlugin.getWorkspace().getRoot().findMember(
108
137
				location);
109
				try {					
138
		return traceFile;
110
139
	}
111
					iFile.delete(true, new NullProgressMonitor());
140
	
112
					
141
	public static boolean fileExists(IFile wsFile)
113
					isSuccessful = true;
142
	{		
114
				} 
143
		if (wsFile.exists())
115
				catch (Exception e) {
144
			return true;
116
					//Ignore and return false;
145
		if (Platform.getOS().equals("win32"))
117
				}
146
		{  //although the IFile does not exist in the workspace (it is case-sensitive)
147
			//it may still be impossible to create the file in case-insensitive
148
			java.net.URI uri = wsFile.getRawLocationURI();
149
			if (uri == null)  //probably because project doesn't exist
150
				return false;
151
			java.io.File file = new java.io.File(uri);
152
			return file.exists();
153
			
154
		}
155
		return false;
156
	}
157
	
158
	public static boolean deleteFiles(IFile recFile, IFile tgFile)
159
	{	
160
		if (!(Platform.getOS().equals("win32")))
161
			return false;  //don't bother, since the case-insensitive delete is only required on Windows
162
		if (recFile != null)
163
		{
164
			java.io.File javaFile = new java.io.File(recFile.getRawLocationURI()); 
165
			javaFile.delete();
166
			if (recFile.toString().endsWith(".rec"))
167
			{
168
				java.io.File recmodel = new java.io.File(javaFile.toString()+ "model");
169
				recmodel.delete();
170
				//also remove recmodel paired file
171
			}
172
			try {
173
				recFile.getParent().refreshLocal(1, new NullProgressMonitor());
174
			}
118
			}
175
			catch (Exception e) {}
119
176
		}
120
			//File system file check: 
177
		if (tgFile != null)
121
			else{
178
		{
122
179
			java.io.File javaFile = new java.io.File(tgFile.getRawLocationURI()); 
123
				IPath iFilePath = iFile.getLocation();
180
			javaFile.delete();
124
181
			try {
125
				if (iFilePath != null){
182
				tgFile.getParent().refreshLocal(1, new NullProgressMonitor());
126
127
					File file = iFilePath.toFile();
128
129
					if(file.exists()){
130
						isSuccessful = file.delete();
131
					}
132
				}
183
			}
133
			}
184
			catch (Exception e) {}
185
134
135
			if(isSuccessful){
136
137
				//Attempt to refresh the file's container:
138
				try {
139
					iFile.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
140
				}
141
				catch (Exception e) {
142
					//Ignore since the file's container could not be refreshed.
143
				}
144
			}
186
		}
145
		}
187
		return true;
188
	}
189
146
147
		return isSuccessful;
148
	}
190
}
149
}
(-)src/org/eclipse/hyades/test/core/internal/changes/CreateFileChange.java (-10 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
2
 * Copyright (c) 2006, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-20 Link Here
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.io.InputStream;
15
import java.io.InputStream;
16
import java.io.UnsupportedEncodingException;
16
import java.io.UnsupportedEncodingException;
17
import java.net.URI;
18
17
19
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResource;
Lines 30-40 Link Here
30
import org.eclipse.osgi.util.NLS;
29
import org.eclipse.osgi.util.NLS;
31
30
32
/**
31
/**
33
 * Change that creates a text file and fills it in with an initial content.
32
 * <p>Change that creates a text file with initial content.</p>
34
 * @author jcanches
33
 * 
35
 * @author jbozier
34
 * 
36
 * @since 4.3
35
 * @author  Julien Canches
37
 * @version April 5, 2008
36
 * @author  Jerome Bozier
37
 * @author  Paul Slauenwhite
38
 * @version March 25, 2010
39
 * @since   August 29, 2006
38
 */
40
 */
39
public class CreateFileChange extends Change {
41
public class CreateFileChange extends Change {
40
42
Lines 111-123 Link Here
111
	}
113
	}
112
114
113
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
115
	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
116
		
114
		RefactoringStatus status = new RefactoringStatus();
117
		RefactoringStatus status = new RefactoringStatus();
115
		
118
		
116
		URI location = fFile.getLocationURI();
119
		if (fFile.getLocation() == null) {
117
		if (location == null) {
118
			status.addFatalError(NLS.bind(ChangesMessages.UNKNOWN_LOCATION, fFile.getFullPath().toString()));
120
			status.addFatalError(NLS.bind(ChangesMessages.UNKNOWN_LOCATION, fFile.getFullPath().toString()));
119
			return status;
120
		}
121
		}
122
		
121
		return status;
123
		return status;
122
	}
124
	}
123
125
(-)src/org/eclipse/hyades/test/core/testgen/util/TestGenFileUtil.java (-6 / +5 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-46 Link Here
34
import org.eclipse.osgi.util.NLS;
34
import org.eclipse.osgi.util.NLS;
35
35
36
/**
36
/**
37
 * File utility methods used by test generators.
37
 * <p>Utilities for test generator files.</p>
38
 * 
38
 * 
39
 * 
39
 * 
40
 * @author      Ashish Mathur
40
 * @author      Ashish Mathur
41
 * @author      Paul E. Slauenwhite
41
 * @author      Paul E. Slauenwhite
42
 * @author		Jerome Bozier
42
 * @author		Jerome Bozier
43
 * @version     November 17, 2009
43
 * @version     March 25, 2010
44
 * @since       June 8, 2005
44
 * @since       June 8, 2005
45
*/
45
*/
46
public class TestGenFileUtil {
46
public class TestGenFileUtil {
Lines 50-56 Link Here
50
	 * it will add ".rec"
50
	 * it will add ".rec"
51
	 * @param filepath
51
	 * @param filepath
52
	 * @return
52
	 * @return
53
	 * @deprecated
54
	 */
53
	 */
55
	public static IFile createTraceFile(String filepath) {
54
	public static IFile createTraceFile(String filepath) {
56
		
55
		
Lines 73-80 Link Here
73
				}
72
				}
74
			}
73
			}
75
		}
74
		}
76
		catch (RuntimeException e) {
75
		catch (Exception e) {
77
			e.printStackTrace();
76
			TestCorePlugin.getDefault().logError(e);
78
		}
77
		}
79
78
80
		return file;
79
		return file;
(-)src/org/eclipse/tptp/test/internal/recorder/framework/RecorderDataProcessor.java (-18 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-30 Link Here
14
import java.io.IOException;
14
import java.io.IOException;
15
15
16
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
18
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
20
import org.eclipse.hyades.execution.recorder.RecorderFactory;
19
import org.eclipse.hyades.execution.recorder.RecorderFactory;
21
import org.eclipse.hyades.internal.execution.recorder.utilities.RecorderFileUtil;
22
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
20
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
21
import org.eclipse.hyades.test.core.testgen.util.TestGenFileUtil;
23
import org.eclipse.tptp.test.provisional.recorder.framework.IRecorderMessageProvider;
22
import org.eclipse.tptp.test.provisional.recorder.framework.IRecorderMessageProvider;
24
23
25
/**
24
/**
26
 * @author jnevicos
25
 * <p>RecorderDataProcessor.java</p>
27
 *
26
 * 
27
 * 
28
 * @author  Jeffrey Nevicosi
29
 * @author  Paul Slauenwhite
30
 * @version March 25, 2010
31
 * @since   September 23, 2005
28
 */
32
 */
29
public class RecorderDataProcessor implements IRecorderDataProcessor {
33
public class RecorderDataProcessor implements IRecorderDataProcessor {
30
34
Lines 50-70 Link Here
50
		String fileName = RecorderFactory.getInstance().getRecorderWithID(recorderID).getRecordingPath();
54
		String fileName = RecorderFactory.getInstance().getRecorderWithID(recorderID).getRecordingPath();
51
		if (fileName != null && fileName.length() > 0)
55
		if (fileName != null && fileName.length() > 0)
52
		{
56
		{
53
			try
57
				if (provider == null){  
54
	
58
					
55
			{
59
					//creation of the trace file is a requirement of the provider's init() method
56
				if (provider == null)
57
				{  //creation of the trace file is a requirement of the provider's init() method
58
					//this is because one static method cannot be accountable for creation in any & all variations
60
					//this is because one static method cannot be accountable for creation in any & all variations
59
					traceFile = RecorderFileUtil.createTraceFile(fileName);
61
					traceFile = TestGenFileUtil.createTraceFile(fileName);
60
					if (!traceFile.exists())
62
					
61
						throw new IOException(TestCorePluginResourceBundle.RecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR); 
63
					if((traceFile == null) || (!traceFile.exists())){
64
						throw new IOException(TestCorePluginResourceBundle.RecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR + fileName); 
65
					}
62
				}
66
				}
63
			}
64
			catch (CoreException e)
65
			{
66
				throw new IOException(TestCorePluginResourceBundle.RecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR+e.getMessage()); 
67
			}
68
		}
67
		}
69
		if (provider != null)
68
		if (provider != null)
70
			provider.initialize();
69
			provider.initialize();
(-)src-recorder/org/eclipse/tptp/test/internal/recorder/ui/wizards/NewTestFromRecordingWizard.java (-5 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 38-50 Link Here
38
import org.eclipse.tptp.test.provisional.recorder.ui.wizards.RecLocationWizardPage;
38
import org.eclipse.tptp.test.provisional.recorder.ui.wizards.RecLocationWizardPage;
39
39
40
/**
40
/**
41
 * NewTestFromRecordingWizard.java.
41
 * <p>NewTestFromRecordingWizard.java.</p>
42
 * <p/>
43
 * 
42
 * 
44
 * 
43
 * 
45
 * @author  Paul E. Slauenwhite
44
 * @author  Paul E. Slauenwhite
46
 * @author  Jeffery Nevicosi
45
 * @author  Jeffery Nevicosi
47
 * @version July 4, 2008
46
 * @version March 25, 2010
48
 * @since   September 23, 2005
47
 * @since   September 23, 2005
49
 */
48
 */
50
public class NewTestFromRecordingWizard extends HyadesWizard implements IGenericRecorderWizard {
49
public class NewTestFromRecordingWizard extends HyadesWizard implements IGenericRecorderWizard {
Lines 124-130 Link Here
124
						UiPluginResourceBundle.DefaultRecWizardProvider_TESTSUITE_EXISTS);
123
						UiPluginResourceBundle.DefaultRecWizardProvider_TESTSUITE_EXISTS);
125
				if (!b)
124
				if (!b)
126
					return false;
125
					return false;
127
				RecorderFileUtil.deleteFiles(null, tgFile);
126
				RecorderFileUtil.deleteFile(tgFile);
128
				
127
				
129
			}
128
			}
130
			TestgenUIWrapper wrapper = new TestgenUIWrapper(getRecorderData(IRecorderPageProvider.WIZARD_KEY_TESTGEN_ID),
129
			TestgenUIWrapper wrapper = new TestgenUIWrapper(getRecorderData(IRecorderPageProvider.WIZARD_KEY_TESTGEN_ID),
(-)src-recorder/org/eclipse/tptp/test/provisional/recorder/ui/wizards/DefaultRecWizardProvider.java (-12 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-36 Link Here
23
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
24
25
/**
25
/**
26
 * A default implementation of IRecorderPageProvider.
26
 * <p>Default recording wizard provider that provides an additional page ({@link TestsuiteLocationWizardPage})
27
 * to enter the path/name of the test suite, which is used to derive the recording and recording model file 
28
 * paths/names.</p>
27
 * 
29
 * 
28
 * This provides 1 additonal page:  TestsuiteLocationWizardPage
30
 * 
29
 * This provides data for the testsuite path & the recording path (which is
31
 * @author  Jeffrey Nevicosi
30
 * derived from the user-input testsuite path)
32
 * @author  Paul Slauenwhite
31
 * @author jnevicos
33
 * @version March 25, 2010
32
 * @see IGenericRecorderPage
34
 * @since   February 1, 2006
33
 * @see NewTestFromRecordingWizard
35
 * @see     IRecorderPageProvider
36
 * @see     TestsuiteLocationWizardPage
37
 * @see     IGenericRecorderPage
34
 */
38
 */
35
public class DefaultRecWizardProvider implements IRecorderPageProvider {
39
public class DefaultRecWizardProvider implements IRecorderPageProvider {
36
40
Lines 89-96 Link Here
89
					UiPluginResourceBundle.DefaultRecWizardProvider_BOTH_EXIST);
93
					UiPluginResourceBundle.DefaultRecWizardProvider_BOTH_EXIST);
90
			if (!b)
94
			if (!b)
91
				return false;
95
				return false;
92
			//on win32, predelete the non-case-sensitive file			
96
93
			RecorderFileUtil.deleteFiles(recFile, tgFile);
97
			RecorderFileUtil.deleteRecordingFile(recFile);
98
			RecorderFileUtil.deleteFile(tgFile);
94
			
99
			
95
		}
100
		}
96
		else if (bRecExists)
101
		else if (bRecExists)
Lines 99-105 Link Here
99
					UiPluginResourceBundle.DefaultRecWizardProvider_REC_EXISTS);
104
					UiPluginResourceBundle.DefaultRecWizardProvider_REC_EXISTS);
100
			if (!b)
105
			if (!b)
101
				return false;
106
				return false;
102
			RecorderFileUtil.deleteFiles(recFile, null);
107
			RecorderFileUtil.deleteRecordingFile(recFile);
103
108
104
		}
109
		}
105
		else if (bTestExists)
110
		else if (bTestExists)
Lines 108-114 Link Here
108
					UiPluginResourceBundle.DefaultRecWizardProvider_TESTSUITE_EXISTS);
113
					UiPluginResourceBundle.DefaultRecWizardProvider_TESTSUITE_EXISTS);
109
			if (!b)
114
			if (!b)
110
				return false;
115
				return false;
111
			RecorderFileUtil.deleteFiles(null, tgFile);
116
			RecorderFileUtil.deleteFile(tgFile);
112
		}
117
		}
113
		
118
		
114
		String parms = wizard.getRecorderData(WIZARD_KEY_CONFIG_PARAMS);
119
		String parms = wizard.getRecorderData(WIZARD_KEY_CONFIG_PARAMS);
(-)src-testgen/org/eclipse/hyades/internal/execution/testgen/ui/wizards/RunTestGenWizard.java (-5 / +5 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 30-42 Link Here
30
import org.eclipse.ui.INewWizard;
30
import org.eclipse.ui.INewWizard;
31
31
32
/**
32
/**
33
 * <p>Wizard which prompts the user for the test generator to use with test generation and also prompts for the location of the generated
33
 * <p>Wizard which prompts the user for the test generator to use with test 
34
 * test suite.</p>
34
 * generation and also prompts for the location of the generated test suite.</p>
35
 * 
35
 * 
36
 * 
36
 * 
37
 * @author  Ernest Jessee
37
 * @author  Ernest Jessee
38
 * @author  Paul E. Slauenwhite
38
 * @author  Paul E. Slauenwhite
39
 * @version August 13, 2009
39
 * @version March 25, 2010
40
 * @since   February 1, 2005
40
 * @since   February 1, 2005
41
 */
41
 */
42
public class RunTestGenWizard extends HyadesNewWizard
42
public class RunTestGenWizard extends HyadesNewWizard
Lines 92-98 Link Here
92
					);
92
					);
93
			if (!b)
93
			if (!b)
94
				return b;
94
				return b;
95
			RecorderFileUtil.deleteFiles(null, file);
95
			RecorderFileUtil.deleteFile(file);
96
		}
96
		}
97
		
97
		
98
		TestgenUIWrapper wrapper = new TestgenUIWrapper(generatorID, selectedRecModelFile, testFileSelectionPage.getSelectedFilePath());
98
		TestgenUIWrapper wrapper = new TestgenUIWrapper(generatorID, selectedRecModelFile, testFileSelectionPage.getSelectedFilePath());
(-)src/org/eclipse/tptp/test/recorders/url/internal/local/URLRecorderDataProcessor.java (-17 / +14 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2010 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-24 Link Here
15
import java.io.IOException;
15
import java.io.IOException;
16
16
17
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.NullProgressMonitor;
18
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
19
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
21
import org.eclipse.hyades.internal.execution.recorder.utilities.RecorderFileUtil;
20
import org.eclipse.hyades.test.core.testgen.util.TestGenFileUtil;
22
import org.eclipse.tptp.test.provisional.recorder.framework.IRecorderMessageProvider;
21
import org.eclipse.tptp.test.provisional.recorder.framework.IRecorderMessageProvider;
23
import org.eclipse.tptp.test.provisional.recorder.messages.AbstractRecorderMessageProvider;
22
import org.eclipse.tptp.test.provisional.recorder.messages.AbstractRecorderMessageProvider;
24
import org.eclipse.tptp.test.recorders.url.internal.URLRecorderActivator;
23
import org.eclipse.tptp.test.recorders.url.internal.URLRecorderActivator;
Lines 34-40 Link Here
34
 * 
33
 * 
35
 * @author  Paul E. Slauenwhite
34
 * @author  Paul E. Slauenwhite
36
 * @author  Ernest Jessee
35
 * @author  Ernest Jessee
37
 * @version March 11, 2008
36
 * @version March 25, 2010
38
 * @since   March 11, 2008
37
 * @since   March 11, 2008
39
 */
38
 */
40
public class URLRecorderDataProcessor extends AbstractRecorderMessageProvider 
39
public class URLRecorderDataProcessor extends AbstractRecorderMessageProvider 
Lines 58-79 Link Here
58
	public void initialize() throws IOException
57
	public void initialize() throws IOException
59
	{
58
	{
60
		String fileName = URLRecorderActivator.getPreference(URLRecorderConstants.RECORDING_PATH);
59
		String fileName = URLRecorderActivator.getPreference(URLRecorderConstants.RECORDING_PATH);
61
		if (getRecorder() != null)
60
		
61
		if (getRecorder() != null){
62
			fileName = getRecorder().getRecordingPath();
62
			fileName = getRecorder().getRecordingPath();
63
		try
64
		{
65
			traceFile = RecorderFileUtil.createTraceFile(fileName);
66
			javaTraceFile = traceFile.getRawLocation().toFile();
67
			if (!javaTraceFile.exists())
68
			{	throw new IOException(URLRecorderResourceBundle.URLRecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR); 
69
			}
70
		}
63
		}
71
		catch (CoreException e)
72
		{
73
			throw new IOException(URLRecorderResourceBundle.URLRecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR+e.getMessage()); 
74
		}		
75
		
64
		
76
		RecorderFileUtil.createTraceModel(fileName, traceFile.getFullPath().toString());		
65
		traceFile = TestGenFileUtil.createTraceFile(fileName);
66
		
67
		if((traceFile == null) || (!traceFile.exists())){
68
			throw new IOException(URLRecorderResourceBundle.URLRecorderDataProcessor_UNABLE_TO_CREATE_TRACE_FILE_ERROR + fileName); 				
69
		}
70
71
		javaTraceFile = traceFile.getRawLocation().toFile();
72
73
		TestGenFileUtil.createTraceModel(fileName, traceFile.getFullPath().toString());		
77
	}
74
	}
78
75
79
	
76
	

Return to bug 307033