You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <Cr...@Sun.COM> on 2010/03/23 00:48:26 UTC
What does getParent return?
Hi,
I'm (finally) writing some test code for the metadata feature and have
run into a problem.
Here's the code:
/** test getMetadata with abstract class name*/
public void testAbstractClassName() {
pm = getPM();
String className = "org.apache.jdo.tck.pc.company.Employee";
TypeMetadata metadata = pmf.getMetadata(className);
assertNotNull(ASSERTION_FAILED
+ "metadata must not be null for abstract class" +
className, metadata);
dump(metadata);
Metadata parent = metadata.getParent();
assertNotNull(ASSERTION_FAILED
+ "parent metadata must not be null for abstract
class" + className, parent);
String name = metadata.getName();
String packageName = ((PackageMetadata)
metadata.getParent()).getName();
assertEquals(ASSERTION_FAILED
+ "metadata name and class name must match",
className, packageName + "." + name);
}
The parent metadata is the issue. For a TypeMetadata the parent should
be a PackageMetadata. But it looks like getParent() returns null for a
ClassMetadata.
Before I file a JIRA I thought I'd double check...
Craig
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!
Re: What does getParent return?
Posted by Craig L Russell <Cr...@Sun.COM>.
Thanks, I'll take a look.
Craig
On Mar 25, 2010, at 9:52 AM, Andy Jefferson wrote:
>>> The parent metadata is the issue. For a TypeMetadata the parent
>>> should be a PackageMetadata. But it looks like getParent() returns
>>> null for a ClassMetadata.
>
> FYI. DN SVN trunk and SVN branches/2.0 (aka 2.1.0-m1-SNAPSHOT and
> 2.0.3-
> SNAPSHOT in nightly builds) return a valid parent.
>
> --
> Andy
> DataNucleus (http://www.datanucleus.org)
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!
Re: What does getParent return?
Posted by Andy Jefferson <an...@datanucleus.org>.
> > The parent metadata is the issue. For a TypeMetadata the parent
> > should be a PackageMetadata. But it looks like getParent() returns
> > null for a ClassMetadata.
FYI. DN SVN trunk and SVN branches/2.0 (aka 2.1.0-m1-SNAPSHOT and 2.0.3-
SNAPSHOT in nightly builds) return a valid parent.
--
Andy
DataNucleus (http://www.datanucleus.org)
Re: What does getParent return?
Posted by Craig L Russell <Cr...@Sun.COM>.
And I also assume that every xml element has a parent that is the
element which contains it.
So PackageMetadata has a parent JDOMetadata.
And each element in metadata that is contained in another has a
parent. Except JDOMetadata that has no parent.
Craig
On Mar 22, 2010, at 4:48 PM, Craig L Russell wrote:
> Hi,
>
> I'm (finally) writing some test code for the metadata feature and
> have run into a problem.
>
> Here's the code:
>
> /** test getMetadata with abstract class name*/
> public void testAbstractClassName() {
> pm = getPM();
> String className = "org.apache.jdo.tck.pc.company.Employee";
> TypeMetadata metadata = pmf.getMetadata(className);
> assertNotNull(ASSERTION_FAILED
> + "metadata must not be null for abstract class" +
> className, metadata);
> dump(metadata);
> Metadata parent = metadata.getParent();
> assertNotNull(ASSERTION_FAILED
> + "parent metadata must not be null for abstract
> class" + className, parent);
> String name = metadata.getName();
> String packageName = ((PackageMetadata)
> metadata.getParent()).getName();
> assertEquals(ASSERTION_FAILED
> + "metadata name and class name must match",
> className, packageName + "." + name);
> }
>
> The parent metadata is the issue. For a TypeMetadata the parent
> should be a PackageMetadata. But it looks like getParent() returns
> null for a ClassMetadata.
>
> Before I file a JIRA I thought I'd double check...
>
> Craig
>
> Craig L Russell
> Architect, Oracle
> http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@oracle.com
> P.S. A good JDO? O, Gasp!
>
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!