Home » Archived » Test and Performance Tools Platform (TPTP) » How to Write to a Datapool
How to Write to a Datapool [message #101514] |
Sun, 24 June 2007 19:39 |
Eclipse User |
|
|
|
Originally posted by: chirillo.us.ibm.com
Warning: TPTP newbie here.
I'm writing client code in tool that implements TPTP (Rational
Functional Tester). I'm trying to write code that writes to a datapool
that has already been created within the tool. Functional Tester has a
convenient API for reading datapools, but not for writing to them.
From what I can tell by poking around the TPTP API, if I want to add a
row to a datapool, I need to get soemthing that implements
org.eclipse.hyades.edit.datapool.IDatapool.
org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolIm pl
implements this interface, but that's I'm stalled.
Am I pursuing this problem correctly? Do I want to use a
DPLDatapoolImpl to write to a datapool. If so, how can I get one? There
don't seem to be an factory methods in the DPLDatapoolImpl class.
|
|
|
Re: How to Write to a Datapool [message #101606 is a reply to message #101514] |
Mon, 25 June 2007 11:14 |
Paul Slauenwhite Messages: 975 Registered: July 2009 |
Senior Member |
|
|
Hi Daniel,
TPTP datapools are implemented as EMF models, similar to other test
artifacts (for example, test suite, execution results, etc.). For more
information, see the class diagram for the datapool model:
http://www.eclipse.org/tptp/platform/documents/resources/mod els/cat3950c20c0018/cat3e68bb5f0068/cat3f81f641019d/dgm40206 8580223.png
Since you are trying to write to a datapool that has already been
created and assuming you do not have a handle to the
org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
de-serialized the *.datapool file using the following code to get a handle
to the org.eclipse.hyades.models.common.datapool.DPLDatapool object:
//Resolve the datapool file:
File datapoolFile = new File(<datapool file path>);
//Initialize the test models:
org.eclipse.hyades.models.common.facades.behavioral.impl.Fac adeResourceFactoryImpl.initializeRequisiteModels();
//Create the resource set:
org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new
ResourceSetImpl();
//Resolve the datapool resource:
org.eclipse.emf.ecore.resource.Resource datapoolResource =
resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),true);
//Resolve the datapool:
org.eclipse.hyades.models.common.datapool.DPLDatapool datapool =
(DPLDatapool) datapoolResource.getContents().get(0);
Once you have a handle to the
org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can modify
the datapool and then serialized it back to a *.datapool file using the
following code:
//Save the datapool resource:
org.eclipse.hyades.test.core.util.save(datapoolResource);
Paul
"Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
news:f5mhc0$4oo$1@build.eclipse.org...
> Warning: TPTP newbie here.
>
> I'm writing client code in tool that implements TPTP (Rational Functional
> Tester). I'm trying to write code that writes to a datapool that has
> already been created within the tool. Functional Tester has a convenient
> API for reading datapools, but not for writing to them.
>
> From what I can tell by poking around the TPTP API, if I want to add a row
> to a datapool, I need to get soemthing that implements
> org.eclipse.hyades.edit.datapool.IDatapool.
> org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolIm pl implements
> this interface, but that's I'm stalled.
>
> Am I pursuing this problem correctly? Do I want to use a DPLDatapoolImpl
> to write to a datapool. If so, how can I get one? There don't seem to be
> an factory methods in the DPLDatapoolImpl class.
>
>
>
|
|
| |
Re: How to Write to a Datapool [message #101642 is a reply to message #101606] |
Mon, 25 June 2007 12:24 |
Eclipse User |
|
|
|
Originally posted by: chirillo.us.ibm.com
Hi Paul,
Many thanks for your very detailed response. Three follow-ups:
1. The code blows up at
resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),
true);
The exception message is: Exception in thread "main"
java.lang.RuntimeException: Cannot create a resource for 'file:<complete
path to Datapool file>'; a registered resource factory is needed
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:387)
I noticed someone else complaining of the exact same issue in this
newsgroup in the thread with Subject "Datapool and". Do you think this
is a defect in TPTP?
2. Regrading:
org.eclipse.hyades.test.core.util.save(datapoolResource);
I don't have a org.eclipse.hyades.test.core package anywhere in my
classpath.
Will SaveManager.saveResource(datapoolResource) achieve the same result?
3. I found a way to get an org.eclipse.hyades.edit.datapool.IDatapool
that I've been able to use to write to the datapool. It *seems* to
work. Can you see/think of anyhting "bad" about this technique?
com.rational.test.ft.datapool.DatapoolFactory dpFactory =
com.rational.test.ft.datapool.DatapoolFactory.get();
org.eclipse.hyades.edit.datapool.IDatapool datapool =
dpFactory.loadForEdit(new File(<path to datapool file>), true);
int equivalenceClassIndex = datapool.getDefaultEquivalenceClassIndex();
// This is a big leap: a cast from an
//org.eclipse.hyades.execution.runtime.datapool.IDatapool to an
//org.eclipse.hyades.edit.datapool.IDatapool
org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass
equivalenceClass =
(org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass) datapool
..getEquivalenceClass(equivalenceClassIndex);
// Now that I've got an
// org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass I can
// insert records using IDatapoolEquivalenceClass
// and IDatapoolCell
// To save changes:
dpFactory.save(datapool);
dpFactory.unload(datapool);
Paul Slauenwhite wrote:
> Hi Daniel,
> TPTP datapools are implemented as EMF models, similar to other test
> artifacts (for example, test suite, execution results, etc.). For more
> information, see the class diagram for the datapool model:
>
> http://www.eclipse.org/tptp/platform/documents/resources/mod els/cat3950c20c0018/cat3e68bb5f0068/cat3f81f641019d/dgm40206 8580223.png
>
> Since you are trying to write to a datapool that has already been
> created and assuming you do not have a handle to the
> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
> de-serialized the *.datapool file using the following code to get a handle
> to the org.eclipse.hyades.models.common.datapool.DPLDatapool object:
>
> //Resolve the datapool file:
>
> File datapoolFile = new File(<datapool file path>);
>
>
> //Initialize the test models:
>
> org.eclipse.hyades.models.common.facades.behavioral.impl.Fac adeResourceFactoryImpl.initializeRequisiteModels();
>
>
>
>
> //Create the resource set:
>
> org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new
> ResourceSetImpl();
>
>
>
>
> //Resolve the datapool resource:
>
> org.eclipse.emf.ecore.resource.Resource datapoolResource =
>
> resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),true);
>
>
>
>
> //Resolve the datapool:
>
> org.eclipse.hyades.models.common.datapool.DPLDatapool datapool =
>
> (DPLDatapool) datapoolResource.getContents().get(0);
>
> Once you have a handle to the
> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can modify
> the datapool and then serialized it back to a *.datapool file using the
> following code:
>
> //Save the datapool resource:
>
> org.eclipse.hyades.test.core.util.save(datapoolResource);
>
> Paul
> "Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
> news:f5mhc0$4oo$1@build.eclipse.org...
>> Warning: TPTP newbie here.
>>
>> I'm writing client code in tool that implements TPTP (Rational Functional
>> Tester). I'm trying to write code that writes to a datapool that has
>> already been created within the tool. Functional Tester has a convenient
>> API for reading datapools, but not for writing to them.
>>
>> From what I can tell by poking around the TPTP API, if I want to add a row
>> to a datapool, I need to get soemthing that implements
>> org.eclipse.hyades.edit.datapool.IDatapool.
>> org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolIm pl implements
>> this interface, but that's I'm stalled.
>>
>> Am I pursuing this problem correctly? Do I want to use a DPLDatapoolImpl
>> to write to a datapool. If so, how can I get one? There don't seem to be
>> an factory methods in the DPLDatapoolImpl class.
>>
>>
>>
>
>
|
|
|
Re: How to Write to a Datapool [message #101719 is a reply to message #101642] |
Tue, 26 June 2007 11:11 |
Paul Slauenwhite Messages: 975 Registered: July 2009 |
Senior Member |
|
|
Hi Daniel,
1) You need to replace '<complete path to Datapool file>' in the code
snippet with the actual path to the serialized datapool file.
2) I missed the class (EMFUtil) in the code snippet. You can also use the
following code instead:
public static final Map RESOURCE_OPTIONS = new HashMap();
RESOURCE_OPTIONS.put(XMLResource.OPTION_DECLARE_XML, Boolean.TRUE);
RESOURCE_OPTIONS.put(XMLResource.OPTION_SKIP_ESCAPE, Boolean.FALSE);
RESOURCE_OPTIONS.put(XMLResource.OPTION_SKIP_ESCAPE_URI, Boolean.FALSE);
RESOURCE_OPTIONS.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATU RE,
Boolean.TRUE);
datapoolResource.save(RESOURCE_OPTIONS);
This is the same code as
org.eclipse.hyades.models.common.util.SaveManager.saveResour ces().
Paul
"Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
news:f5oc8s$3kn$1@build.eclipse.org...
> Hi Paul,
>
> Many thanks for your very detailed response. Three follow-ups:
>
>
> 1. The code blows up at
>
> resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),
> true);
>
> The exception message is: Exception in thread "main"
> java.lang.RuntimeException: Cannot create a resource for 'file:<complete
> path to Datapool file>'; a registered resource factory is needed
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:387)
>
>
> I noticed someone else complaining of the exact same issue in this
> newsgroup in the thread with Subject "Datapool and". Do you think this
> is a defect in TPTP?
>
>
> 2. Regrading:
>
> org.eclipse.hyades.test.core.util.save(datapoolResource);
>
>
> I don't have a org.eclipse.hyades.test.core package anywhere in my
> classpath.
>
> Will SaveManager.saveResource(datapoolResource) achieve the same result?
>
>
> 3. I found a way to get an org.eclipse.hyades.edit.datapool.IDatapool
> that I've been able to use to write to the datapool. It *seems* to
> work. Can you see/think of anyhting "bad" about this technique?
>
> com.rational.test.ft.datapool.DatapoolFactory dpFactory =
> com.rational.test.ft.datapool.DatapoolFactory.get();
>
> org.eclipse.hyades.edit.datapool.IDatapool datapool =
> dpFactory.loadForEdit(new File(<path to datapool file>), true);
>
> int equivalenceClassIndex = datapool.getDefaultEquivalenceClassIndex();
>
>
> // This is a big leap: a cast from an
> //org.eclipse.hyades.execution.runtime.datapool.IDatapool to an
> //org.eclipse.hyades.edit.datapool.IDatapool
>
> org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass
> equivalenceClass =
> (org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass) datapool
> .getEquivalenceClass(equivalenceClassIndex);
>
> // Now that I've got an
> // org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass I can
> // insert records using IDatapoolEquivalenceClass
> // and IDatapoolCell
>
>
>
> // To save changes:
> dpFactory.save(datapool);
> dpFactory.unload(datapool);
>
>
>
>
>
>
>
>
>
>
>
>
>
> Paul Slauenwhite wrote:
>> Hi Daniel,
>> TPTP datapools are implemented as EMF models, similar to other test
>> artifacts (for example, test suite, execution results, etc.). For more
>> information, see the class diagram for the datapool model:
>>
>> http://www.eclipse.org/tptp/platform/documents/resources/mod els/cat3950c20c0018/cat3e68bb5f0068/cat3f81f641019d/dgm40206 8580223.png
>>
>> Since you are trying to write to a datapool that has already been
>> created and assuming you do not have a handle to the
>> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
>> de-serialized the *.datapool file using the following code to get a
>> handle to the org.eclipse.hyades.models.common.datapool.DPLDatapool
>> object:
>>
>> //Resolve the datapool file:
>>
>> File datapoolFile = new File(<datapool file path>);
>>
>>
>> //Initialize the test models:
>>
>> org.eclipse.hyades.models.common.facades.behavioral.impl.Fac adeResourceFactoryImpl.initializeRequisiteModels();
>>
>>
>>
>>
>> //Create the resource set:
>>
>> org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new
>> ResourceSetImpl();
>>
>>
>>
>>
>> //Resolve the datapool resource:
>>
>> org.eclipse.emf.ecore.resource.Resource datapoolResource =
>>
>> resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),true);
>>
>>
>>
>>
>> //Resolve the datapool:
>>
>> org.eclipse.hyades.models.common.datapool.DPLDatapool datapool =
>>
>> (DPLDatapool) datapoolResource.getContents().get(0);
>>
>> Once you have a handle to the
>> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
>> modify the datapool and then serialized it back to a *.datapool file
>> using the following code:
>>
>> //Save the datapool resource:
>>
>> org.eclipse.hyades.test.core.util.save(datapoolResource);
>>
>> Paul
>> "Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
>> news:f5mhc0$4oo$1@build.eclipse.org...
>>> Warning: TPTP newbie here.
>>>
>>> I'm writing client code in tool that implements TPTP (Rational
>>> Functional Tester). I'm trying to write code that writes to a datapool
>>> that has already been created within the tool. Functional Tester has a
>>> convenient API for reading datapools, but not for writing to them.
>>>
>>> From what I can tell by poking around the TPTP API, if I want to add a
>>> row to a datapool, I need to get soemthing that implements
>>> org.eclipse.hyades.edit.datapool.IDatapool.
>>> org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolIm pl
>>> implements this interface, but that's I'm stalled.
>>>
>>> Am I pursuing this problem correctly? Do I want to use a
>>> DPLDatapoolImpl to write to a datapool. If so, how can I get one? There
>>> don't seem to be an factory methods in the DPLDatapoolImpl class.
>>>
>>>
>>>
>>
>>
>
|
|
|
Re: How to Write to a Datapool [message #101841 is a reply to message #101642] |
Wed, 27 June 2007 10:17 |
Paul Slauenwhite Messages: 975 Registered: July 2009 |
Senior Member |
|
|
Hi Daniel,
Regarding questions #3, Joe has proposed that you request the
appropriate write APIs for RFT datapools from IBM Rational support.
Paul
"Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
news:f5oc8s$3kn$1@build.eclipse.org...
> Hi Paul,
>
> Many thanks for your very detailed response. Three follow-ups:
>
>
> 1. The code blows up at
>
> resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),
> true);
>
> The exception message is: Exception in thread "main"
> java.lang.RuntimeException: Cannot create a resource for 'file:<complete
> path to Datapool file>'; a registered resource factory is needed
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:387)
>
>
> I noticed someone else complaining of the exact same issue in this
> newsgroup in the thread with Subject "Datapool and". Do you think this
> is a defect in TPTP?
>
>
> 2. Regrading:
>
> org.eclipse.hyades.test.core.util.save(datapoolResource);
>
>
> I don't have a org.eclipse.hyades.test.core package anywhere in my
> classpath.
>
> Will SaveManager.saveResource(datapoolResource) achieve the same result?
>
>
> 3. I found a way to get an org.eclipse.hyades.edit.datapool.IDatapool
> that I've been able to use to write to the datapool. It *seems* to
> work. Can you see/think of anyhting "bad" about this technique?
>
> com.rational.test.ft.datapool.DatapoolFactory dpFactory =
> com.rational.test.ft.datapool.DatapoolFactory.get();
>
> org.eclipse.hyades.edit.datapool.IDatapool datapool =
> dpFactory.loadForEdit(new File(<path to datapool file>), true);
>
> int equivalenceClassIndex = datapool.getDefaultEquivalenceClassIndex();
>
>
> // This is a big leap: a cast from an
> //org.eclipse.hyades.execution.runtime.datapool.IDatapool to an
> //org.eclipse.hyades.edit.datapool.IDatapool
>
> org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass
> equivalenceClass =
> (org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass) datapool
> .getEquivalenceClass(equivalenceClassIndex);
>
> // Now that I've got an
> // org.eclipse.hyades.edit.datapool.IDatapoolEquivalenceClass I can
> // insert records using IDatapoolEquivalenceClass
> // and IDatapoolCell
>
>
>
> // To save changes:
> dpFactory.save(datapool);
> dpFactory.unload(datapool);
>
>
>
>
>
>
>
>
>
>
>
>
>
> Paul Slauenwhite wrote:
>> Hi Daniel,
>> TPTP datapools are implemented as EMF models, similar to other test
>> artifacts (for example, test suite, execution results, etc.). For more
>> information, see the class diagram for the datapool model:
>>
>> http://www.eclipse.org/tptp/platform/documents/resources/mod els/cat3950c20c0018/cat3e68bb5f0068/cat3f81f641019d/dgm40206 8580223.png
>>
>> Since you are trying to write to a datapool that has already been
>> created and assuming you do not have a handle to the
>> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
>> de-serialized the *.datapool file using the following code to get a
>> handle to the org.eclipse.hyades.models.common.datapool.DPLDatapool
>> object:
>>
>> //Resolve the datapool file:
>>
>> File datapoolFile = new File(<datapool file path>);
>>
>>
>> //Initialize the test models:
>>
>> org.eclipse.hyades.models.common.facades.behavioral.impl.Fac adeResourceFactoryImpl.initializeRequisiteModels();
>>
>>
>>
>>
>> //Create the resource set:
>>
>> org.eclipse.emf.ecore.resource.ResourceSet resourceSet = new
>> ResourceSetImpl();
>>
>>
>>
>>
>> //Resolve the datapool resource:
>>
>> org.eclipse.emf.ecore.resource.Resource datapoolResource =
>>
>> resourceSet.getResource(URI.createFileURI(datapoolFile.getAb solutePath()),true);
>>
>>
>>
>>
>> //Resolve the datapool:
>>
>> org.eclipse.hyades.models.common.datapool.DPLDatapool datapool =
>>
>> (DPLDatapool) datapoolResource.getContents().get(0);
>>
>> Once you have a handle to the
>> org.eclipse.hyades.models.common.datapool.DPLDatapool object, you can
>> modify the datapool and then serialized it back to a *.datapool file
>> using the following code:
>>
>> //Save the datapool resource:
>>
>> org.eclipse.hyades.test.core.util.save(datapoolResource);
>>
>> Paul
>> "Daniel Chirillo" <chirillo@us.ibm.com> wrote in message
>> news:f5mhc0$4oo$1@build.eclipse.org...
>>> Warning: TPTP newbie here.
>>>
>>> I'm writing client code in tool that implements TPTP (Rational
>>> Functional Tester). I'm trying to write code that writes to a datapool
>>> that has already been created within the tool. Functional Tester has a
>>> convenient API for reading datapools, but not for writing to them.
>>>
>>> From what I can tell by poking around the TPTP API, if I want to add a
>>> row to a datapool, I need to get soemthing that implements
>>> org.eclipse.hyades.edit.datapool.IDatapool.
>>> org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolIm pl
>>> implements this interface, but that's I'm stalled.
>>>
>>> Am I pursuing this problem correctly? Do I want to use a
>>> DPLDatapoolImpl to write to a datapool. If so, how can I get one? There
>>> don't seem to be an factory methods in the DPLDatapoolImpl class.
>>>
>>>
>>>
>>
>>
>
|
|
|
Re: How to Write to a Datapool [message #101861 is a reply to message #101841] |
Wed, 27 June 2007 11:58 |
Eclipse User |
|
|
|
Originally posted by: chirillo.us.ibm.com
Hi Paul,
Thanks. I confirmed with the RFT development team that what I wrote is
the current API. I've submitted a RFE for either an RFT wrapper API
that makes writing to datatools easier or documentation of what I had to
figure out on my own.
Cheers,
dan
Paul Slauenwhite wrote:
> Hi Daniel,
> Regarding questions #3, Joe has proposed that you request the
> appropriate write APIs for RFT datapools from IBM Rational support.
>
>
|
|
|
Goto Forum:
Current Time: Fri Apr 19 22:09:31 GMT 2024
Powered by FUDForum. Page generated in 0.03081 seconds
|