Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Paul Slauenwhite is currently offline Paul SlauenwhiteFriend
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 #101629 is a reply to message #101606] Mon, 25 June 2007 12:11 Go to previous messageGo to next message
Joe Toomey is currently offline Joe ToomeyFriend
Messages: 79
Registered: July 2009
Member
Hi Daniel,

Paul's instructions for how to edit an existing TPTP datapool are
correct. However, I notice that you said you are using Rational
Functional Tester datapools. RFT shares some parts of the TPTP datapool
implementation, but not all parts. While the read API and the editor
are shared, RFT does not use TPTP's persistence mechanism for datapools
(largely because they need to be able to access them from outside of
Java, so the EMF APIs are not an ideal access mechanism.) For this
reason, you won't be able to use TPTP write APIs to modify RFT datapools.

I suggest you contact IBM Rational support and see if they can provide
you with an API that you can use for editing/writing RFT datapools.

Hope this helps,
--Joe
Re: How to Write to a Datapool [message #101642 is a reply to message #101606] Mon, 25 June 2007 12:24 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Paul Slauenwhite is currently offline Paul SlauenwhiteFriend
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 Go to previous messageGo to next message
Paul Slauenwhite is currently offline Paul SlauenwhiteFriend
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 Go to previous message
Eclipse UserFriend
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.
>
>
Previous Topic:Problem getting started with the new TPTP version
Next Topic:test
Goto Forum:
  


Current Time: Fri Apr 19 22:09:31 GMT 2024

Powered by FUDForum. Page generated in 0.03081 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top