Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:00:01+00:00 2026-05-27T22:00:01+00:00

i use seam framework to develop a web site. I want to share one

  • 0

i use seam framework to develop a web site. I want to share one problem when developing time. I have a one seam test method as succeding ;

    @Test
    public void saveTwoCategoryToRoot() throws Exception {
    new FacesRequest() {

        Category enduringRoot = new Category(
                ItemTreeVocabulary.ROOTNODE_NAME);

        protected void beforeRequest() {
            // clear database..
            clearDb();

            enduringRoot.addChild(new Category(
                    ItemTreeVocabulary.COMPUTER));

            enduringRoot.addChild(new Category(
                    ItemTreeVocabulary.WHITE_GOODS));
        };

        protected void invokeApplication() throws Exception {

            // set the root to database..
            ((EntityManager) getValue("#{entityManager}")).persist(enduringRoot);

            // feth the root from database..
            @SuppressWarnings("rawtypes")
            List resultList = ((EntityManager) getValue("#{entityManager}")).createQuery(
                    "Select i From Item i").getResultList();

            Category root = (Category) resultList.get(0);

            // list shuld not to be empty..
            Assert.assertFalse(resultList.isEmpty());

            // checks the nodes in the first depth..
            **Assert.assertEquals(2, root.getChildren().size());**                   

            // assert rootNode name..
            Assert.assertEquals(((Category) resultList.get(0)).getName(),
                    ItemTreeVocabulary.ROOTNODE_NAME);
            // assert first node in first depth..
            Assert.assertEquals(((Category) resultList.get(0))
                    .getChildren().get(0).getName(),
                    ItemTreeVocabulary.COMPUTER);
            // assert second node in first depth..
            Assert.assertEquals(root
                    .getChildren().get(0).getName(),
                    ItemTreeVocabulary.WHITE_GOODS);
        };

    }.run();

}

Category class is;

@Entity
public class Category extends Item implements Serializable {

private static final long serialVersionUID = -1154500438874768209L;

private List<Item> children;

public Category() {
}

public Category(String name) {
    this();
    setName(name);
}

@OneToMany(targetEntity=Item.class, mappedBy = "parent",cascade = CascadeType.ALL)
public List<Item> getChildren() {
    return children;
}

public void addChild(Item child) {
    if (children == null) {
        children = new ArrayList<Item>();
    }

    if (!children.contains(child)) {
        child.setParent(this);
        children.add(child);
    }
}

public void setChildren(List<Item> children) {
    this.children = children;
}

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Category other = (Category) obj;
    if (children == null) {
        if (other.children != null)
            return false;
    } else if (!children.equals(other.children))
        return false;
    return true;
}

}

Class of Item is ;

@Inheritance(strategy = InheritanceType.JOINED)
@Entity
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
public class Item implements Serializable {

private static final long serialVersionUID = 8332532835833777840L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
    return id;
}

/**
 * Hold the item's parent.
 */
private Category parent;

/**
 * Hold the item's name.
 */
private String name;

private Long id;

@Transient
public List<Item> getChildren() {
    return null;
}

@ManyToOne(targetEntity=Category.class)
public Category getParent() {
    return parent;
}

public void setParent(Category parent) {
    this.parent = parent;
}


public void setId(Long id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}
 }

Following this method, when i was run to test, below exception is occured about bold line ;

 FAILED: saveOneCategoryToRoot
java.lang.AssertionError: expected:<2> but was:<1>
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.failNotEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:126)
at org.junit.Assert.assertEquals(Assert.java:470)
at org.junit.Assert.assertEquals(Assert.java:454)
at com.galaksiya.kobar.test.itemtree.CategoryTest$2.invokeApplication(CategoryTest.java:105)
at org.jboss.seam.mock.AbstractSeamTest$Request.invokeApplicationPhase(AbstractSeamTest.java:656)
at org.jboss.seam.mock.AbstractSeamTest$Request.emulateJsfLifecycle(AbstractSeamTest.java:605)
at org.jboss.seam.mock.AbstractSeamTest$Request.access$100(AbstractSeamTest.java:177)
at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:505)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:499)
at org.jboss.seam.mock.AbstractSeamTest$FacesRequest.run(AbstractSeamTest.java:872)
at com.galaksiya.kobar.test.itemtree.CategoryTest.saveOneCategoryToRoot(CategoryTest.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:676)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:845)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1169)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.runWorkers(TestRunner.java:1182)
at org.testng.TestRunner.privateRun(TestRunner.java:761)
at org.testng.TestRunner.run(TestRunner.java:612)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:241)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1169)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1094)
at org.testng.TestNG.run(TestNG.java:1006)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:107)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170)

I dont understand why instance of ‘whiteGoods’ is not save database.

Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:00:02+00:00Added an answer on May 27, 2026 at 10:00 pm

    The problem is caused by the fact that when you add an Item to a category’s children, you only do it if the item is not already contained in the children. And the equels method of Category considers two categories equal if they have the same children, even if they don’t have the same name. So your both categories are equal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use RichFaces <rich:fileUpload> component (with Seam as the overall framework) to
I am working on a web app using JSF w/Seam. I want to be
I use the Seam framework. If I do Session sess = (Session)em.getDelegate(); Connection conn
I would like to use @Restrict in seam application. One of my scenario contains
I have a seam app and would like to use the MultiPowUploader ( http://www.element-it.com/multiple-file-upload/flash-uploader.aspx
I have a Seam 2.2 based Java EE 5 web application with a bunch
We are porting a seam app(2 apps) to one play app to test out
How can Seam be configured to use different security-constraints for different web-resource-collections? In web.xml
I want to use my message bundle (messages_fr.properties) in a Java class with seam.
I'm developing a web interface with seam/richfaces. Alot of the components has something akin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.