ontopia / ontopia

The open source tools for building, maintaining and deploying Topic Maps-based applications.
https://ontopia.net
Apache License 2.0
54 stars 12 forks source link

Error in TopicNameIF.remove? #295

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Environment:  ontopia-engine:5.2.0-SNAPSHOT-2010-08-25, oracle 11g

After deploying the abovementioned jar we have a unit-test in our test suite 
fail. 

--------------------------------------------------------------------------
Test set: no.kommune.bergen.portal.domain.emne.SeksjonTest
--------------------------------------------------------------------------
Tests run: 22, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.294 sec <<< 
FAILURE!
testSetNavn(no.kommune.bergen.portal.domain.emne.SeksjonTest)  Time elapsed: 
0.005 sec  <<< FAILURE!
junit.framework.AssertionFailedError: expected:<1> but was:<2>

SeksjonTest.java: 

public void testSetNavn() {
        Seksjon testobj = new Seksjon( tm );
        testobj.setNavn( "first" );
        testobj.setNavn( "second" );

        Collection names = testobj.getTopic().getTopicNames();
        assertEquals( 1, names.size() );
        assertEquals( "second", ((TopicNameIF)names.iterator().next()).getValue() );
    }

Seksjon.java: 

public void setNavn( String navn ) {
        setTypedName( navn, null );
}

private void setTypedName( String navn, TopicIF nameType ) {
    TopicNameIF[] names = (TopicNameIF[]) topic.getTopicNames().toArray( new TopicNameIF[0] );
    for (TopicNameIF name : names) {
        if (nameType == null && name.getType() == null || nameType != null && nameType.equals( name.getType() )) {
            name.remove();
        }
    }
    if (navn == null) return;
    builder.makeTopicName( topic, nameType, navn );
}

//----------------------

I see four possibilities: 
 - name.remove() is not doing what it is supposed to be doing
 - name.getType() is returning something when it in earlier versions did not. 
 - TopicMapBuilderIF is doing something funky
 - something else

Original issue reported on code.google.com by ljant...@gmail.com on 26 Aug 2010 at 8:24

GoogleCodeExporter commented 9 years ago
TopicNameIF.getType() no longer returns null, but instead returns the default 
TMDM name type. See issue 162.

Original comment by indiapaleale@gmail.com on 26 Aug 2010 at 8:33

GoogleCodeExporter commented 9 years ago
Doesn't this mean there is no issue here? We can close, right?

Original comment by lar...@gmail.com on 20 Sep 2010 at 7:48

GoogleCodeExporter commented 9 years ago
Yup.  Close away! :) 

Original comment by ljant...@gmail.com on 20 Sep 2010 at 8:44

GoogleCodeExporter commented 9 years ago
Wonderful. :-)

Original comment by lar...@gmail.com on 20 Sep 2010 at 8:56