How to write unit test for the code using Oracle Object Types?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to write unit test for the code using Oracle Object Types?

Rakesh Gupta-4
I looked at org.dbunit.ext.oracle but I do not see any class which has the implementation for the Oracle Object Type support.?
 
An example of an Oracle Type is:
 
CREATE OR REPLACE TYPE Chapter_T AS OBJECT
( c_no NUMBER,
c_title VARCHAR2(20),
c_page_no NUMBER );

From what I know, the way the oracle types are handled in Java are by creating a POJO for the Oracle Type and registering it with connection using oracle.sql.STRUCT.

Are there any APIs in dbunit to hide the complexity of STRUCT and wrting the unit test for the procedures which has Oracle Types as input or output?

Thanks,
Rakesh

143 Newman Court
Pennington, NJ - 08534
Ph: 609-730-0651(H) 
      609-356-4333(Cell)
      609-734-5401(W)


--- On Sat, 5/30/09, [hidden email] <[hidden email]> wrote:

From: [hidden email] <[hidden email]>
Subject: dbunit-user Digest, Vol 37, Issue 18
To: [hidden email]
Date: Saturday, May 30, 2009, 8:04 AM

Send dbunit-user mailing list submissions to
    dbunit-user@...

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/dbunit-user
or, via email, send a message with subject or body 'help' to
    dbunit-user-request@...

You can reach the person managing the list at
    dbunit-user-owner@...

When replying, please edit your Subject line so it is more specific
than "Re: Contents of dbunit-user digest..."


Today's Topics:

   1. Re: subsection of dependent tables? (Matthias Gommeringer)


----------------------------------------------------------------------

Message: 1
Date: Fri, 29 May 2009 23:55:10 +0200
From: Matthias Gommeringer <Matthias.Gommeringer@...>
Subject: Re: [dbunit-user] subsection of dependent tables?
To: dbunit-user@...
Message-ID: <750091359@...>
Content-Type: text/plain; charset=iso-8859-15

Hi Karl,

I think you use the method correctly. You can see an example in the test class org.dbunit.database.search.ImportedKeysFilteredByPKsSingleTest (method "addInput" collects the IDs to be filtered). Note that if your List/Set of IDs are Strings that you should ensure that the case matches. You will get some more information if you set the log level to debug.

regards
matthias


> -----Urspr?ngliche Nachricht-----
> Von: "Karl J?hann P?lsson" <karlp@...>
> Gesendet: 29.05.09 13:36:49
> An: <dbunit-user@...>
> Betreff: [dbunit-user] subsection of dependent tables?


> I'm looking through the TablesDependencyHelper, trying to get all the
> dependencies otu of my database. However, I don't want all the
> content of all the dependents.
>
> I have a table of subscriptions, and the devices they use, and the
> cabinets they're in, but for my test dataset, I only want a handful
> of subscriptions. The getDependentTables* methods all simply take a
> table name for the root, but I want a set of ids from that table.
>
> There's methods called getDataset() that have parameters for "
> allowedIds" or a PK map, but they don't have any javadoc, and when I'
> ve tried using them, they seem to try and just get all the data in
> the table, regardless of the ids I've provided.
>
>  IDataSet depSet = TablesDependencyHelper.getDataset(connection, "
> Subscriptions", new HashSet(Arrays.asList(__Lots of ids here__)));
>
>  FlatXmlWriter depsWriter = new FlatXmlWriter(new FileOutputStream("
> test-deps.xml"));
>
> Is this method _meant_ work work like this? Or is there another,
> better way of getting only the necessary dependents, rather than
> entire tables?
>
> Cheers,
>
> Karl P
> ----------------------------------------------------------------------
> -------- Register Now for Creativity and Technology (CaT), June 3rd,
> NYC. CaT is a gathering of tech-side developers & brand creativity
> professionals. Meet the minds behind Google Creative Lab, Visual
> Complexity, Processing, & iPhoneDevCamp as they present alongside
> digital heavyweights like Barbarian Group, R/GA, & Big Spaceship.
> http://p.sf.net/sfu/creativitycat-com ________________________________
> _______________ dbunit-user mailing list dbunit-user@....
>
> net https://lists.sourceforge.net/lists/listinfo/dbunit-user


_______________________________________________________________________
Nur bis 31.05.: WEB.DE FreeDSL Komplettanschluss mit DSL 6.000 Flatrate
und Telefonanschluss f?r 17,95 Euro/mtl.! http://produkte.web.de/go/02/




------------------------------

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com

------------------------------

_______________________________________________
dbunit-user mailing list
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user


End of dbunit-user Digest, Vol 37, Issue 18
*******************************************


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: How to write unit test for the code using Oracle Object Types?

Matthias Gommeringer
Hi Rakesh,

that is true. Oracle Object Types are currently not supported in a simple way by dbunit. But feel free to submit a patch with this feature - improvements are always welcome.

Best regards,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "Rakesh Gupta" <[hidden email]>
> Gesendet: 01.06.09 14:55:20
> An: [hidden email]
> Betreff: [dbunit-user] How to write unit test for the code using Oracle Object Types?


> I looked at org.dbunit.ext.oracle but I do not see any class which
> has the implementation for the Oracle Object Type support.?
>
> An example of an Oracle Type is:
>
> CREATE OR REPLACE TYPE Chapter_T AS OBJECT
> ( c_no NUMBER,
> c_title VARCHAR2(20),
> c_page_no NUMBER );
>
> From what I know, the way the oracle types are handled in Java are by
> creating a POJO for the Oracle Type and registering it with
> connection using oracle.sql.STRUCT.
>
> Are there any APIs in dbunit to hide the complexity of STRUCT and
> wrting the unit test for the procedures which has Oracle Types as
> input or output?
>
> Thanks,
> Rakesh
>
> 143 Newman Court
> Pennington, NJ - 08534
> Ph: 609-730-0651(H)
>  609-356-4333(Cell)
>  609-734-5401(W)
>
> --- On  *Sat, 5/30/09, [hidden email] *<
> [hidden email]> wrote:
>
> From: [hidden email] <dbunit-user-request@
> lists.sourceforge.net>
> Subject: dbunit-user Digest, Vol 37, Issue 18
> To: [hidden email]
> Date: Saturday, May 30, 2009, 8:04 AM
>
> Send dbunit-user mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of dbunit-user digest..."
>
> Today's Topics:
>
>  1. Re: subsection of dependent tables? (Matthias Gommeringer)
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 29 May 2009 23:55:10 +0200
> From: Matthias Gommeringer <[hidden email]>
> Subject: Re: [dbunit-user] subsection of dependent tables?
> To: [hidden email]
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=iso-8859-15
>
> Hi Karl,
>
> I think you use the method correctly. You can see an example in the
> test class org.dbunit.database.search.ImportedKeysFilteredByPKsSingleTe
> st (method "addInput" collects the IDs to be filtered). Note that if
> your List/Set of IDs are Strings that you should ensure that the case
> matches. You will get some more information if you set the log level
> to debug.
>
> regards
> matthias
>
> > -----Urspr?ngliche Nachricht-----
> > Von: "Karl J?hann P?lsson" <[hidden email]>
> > Gesendet: 29.05.09 13:36:49
> > An: <[hidden email]>
> > Betreff: [dbunit-user] subsection of dependent tables?
>
> > I'm looking through the TablesDependencyHelper, trying to get all
> the
> > dependencies otu of my database. However, I don't want all the
> > content of all the dependents.
> >
> > I have a table of subscriptions, and the devices they use, and the
> > cabinets they're in, but for my test dataset, I only want a handful
> > of subscriptions. The getDependentTables* methods all simply take a
> > table name for the root, but I want a set of ids from that table.
> >
> > There's methods called getDataset() that have parameters for "
> > allowedIds" or a PK map, but they don't have any javadoc, and when
> I'
> > ve tried using them, they seem to try and just get all the data in
> > the table, regardless of the ids I've provided.
> >
> > IDataSet depSet = TablesDependencyHelper.getDataset(connection, "
> > Subscriptions", new HashSet(Arrays.asList(__Lots of ids here__)));
> >
> > FlatXmlWriter depsWriter = new FlatXmlWriter(new FileOutputStream("
> > test-deps.xml"));
> >
> > Is this method _meant_ work work like this? Or is there another,
> > better way of getting only the necessary dependents, rather than
> > entire tables?
> >
> > Cheers,
> >
> > Karl P
> > --------------------------------------------------------------------
> --
> > -------- Register Now for Creativity and Technology (CaT), June 3rd,
>
> > NYC. CaT is a gathering of tech-side developers & brand creativity
> > professionals. Meet the minds behind Google Creative Lab, Visual
> > Complexity, Processing, & iPhoneDevCamp as they present alongside
> > digital heavyweights like Barbarian Group, R/GA, & Big Spaceship.
> > http://p.sf.net/sfu/creativitycat-com ______________________________
> __
> > _______________ dbunit-user mailing list dbunit-user@lists.
> sourceforge.
> >
> > net https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
> ______________________________________________________________________
> _
> Nur bis 31.05.: WEB.DE FreeDSL Komplettanschluss mit DSL 6.000
> Flatrate
> und Telefonanschluss f?r 17,95 Euro/mtl.! http://produkte.web.de/go/
> 02/
>
> ------------------------------
>
> ----------------------------------------------------------------------
> --------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals
> . Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>
> iPhoneDevCamp as they present alongside digital heavyweights like
> Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
>
> ------------------------------
>
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
> End of dbunit-user Digest, Vol 37, Issue 18
> *******************************************
>
> ----------------------------------------------------------------------
> -------- Register Now for Creativity and Technology (CaT), June 3rd,
> NYC. CaT is a gathering of tech-side developers & brand creativity
> professionals. Meet the minds behind Google Creative Lab, Visual
> Complexity, Processing, & iPhoneDevCamp as they present alongside
> digital heavyweights like Barbarian Group, R/GA, & Big Spaceship.
> http://p.sf.net/sfu/creativitycat-com ________________________________
> _______________ dbunit-user mailing list [hidden email].
>
> net https://lists.sourceforge.net/lists/listinfo/dbunit-user


____________________________________________________________
Text: GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: How to write unit test for the code using Oracle Object Types?

Roberto Lo Giacco-4
In reply to this post by Rakesh Gupta-4
Rakesh Gupta wrote:

> I looked at org.dbunit.ext.oracle but I do not see any class which has
> the implementation for the Oracle Object Type support.?
>  
> An example of an Oracle Type is:
>  
> CREATE OR REPLACE TYPE Chapter_T AS OBJECT
> ( c_no NUMBER,
> c_title VARCHAR2(20),
> c_page_no NUMBER );akesh
>
> From what I know, the way the oracle types are handled in Java are by
> creating a POJO for the Oracle Type and registering it with connection
> using oracle.sql.STRUCT.
>
> Are there any APIs in dbunit to hide the complexity of STRUCT and
> wrting the unit test for the procedures which has Oracle Types as
> input or output?
>
I thought I already answered your question Rakesh: can't you just insert
datas into the tables with normal insert statements, operate on datas
using your pojos and check your operations comparing datasets?

--

  Roberto Lo Giacco

  Chief Technical Officer
  SmartLab s.r.l.
  via Spagna, snc - 87036 Rende (CS) - Italy

  Mobile: +39 392 8765657
  Email: [hidden email]
  Skype: longisland-75
  Web: http://www.smartlab.it 


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user