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 8837575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:45:41+00:00 2026-06-14T09:45:41+00:00

In our integration test for a Spring Roo managed entity, we’re running into a

  • 0

In our integration test for a Spring Roo managed entity, we’re running into a problem in using AspectJ mix-in style interfaces which introduce not only methods with default implementations, but which also add an attribute annotated with JSR 303 validation rules. The problem is that the Spring Roo DataOnDemand logic does not see these fields and thus does not account for them in the getNewTransientObject() method.

For example, the following (simplistic) interface adds a “key” field to every entity that implements the “Keyed” interface:

import javax.persistence.Column;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

public interface Keyed {

    public String getKey();

    public void setKey(String key);

    /**
     * AspectJ MixIn for any class which implements the interface. Provides a
     * default implementation using AspectJ. This is the style shown in
     * Manning's AspectJ in Action (2nd edition) for providing a default
     * implementation interface.
     * 
     * @author tgh
     */
    static aspect Impl {

        @NotNull
        @Column(name = "key", unique = true)
        @Size(min = 8, max = 12)
        private String Keyed.key;

        public void Keyed.setKey(String key) {
            this.key = key;
        }

        public String Keyed.getKey() {
            return this.key;
        }
    }
}

That’s actually a solved problem for us. What we’ve done is to push-in the getNewTransientObject() method from the Spring Roo created AspectJ ITD (.aj) file and then made sure that the attribute gets set with an acceptable value. In our DataOnDemand.java file for the test class, we have the following fragment.

public KeyedExampleA getNewTransientKeyedExampleA(int index) {
    KeyedExampleA obj = new KeyedExampleA();
    setDescription(obj, index);
    setListPrice(obj, index);
    setName(obj, index);

    // Deal with mix-in variables that Roo doesn't know about
    obj.setKey("KEY_" + index);

    return obj;
}

What makes me uncomfortable about the above is that we’re not creating a setKey(obj, index) method in the DataOnDemand.java file and using the same style as what Spring Roo generated for the getNewTransientKeyedObject(int) method.

Is it worth bothering to create the setKey(obj,index) method for such a trivial case, or should we just go with what we have of doing obj.setKey(value) inside the getNewTransientObject() method?

From looking at the Spring Roo created .aj files, I can’t see that it makes much difference because there’s nothing that calls setField(obj,index) other then the getNewTransientObject() method. And since Spring Roo isn’t figuring out that we have mix-in introduced attributes, it probably won’t ever care in the future either.

  • 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-06-14T09:45:43+00:00Added an answer on June 14, 2026 at 9:45 am

    I would write the setKey() method just for consistency.
    But you are not causing any problems by not doing this.

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

Sidebar

Related Questions

we use the nunit.exe application to run our (integration)test Now i experience the problem
We have been using TeamBuild and test for our continuous integration build for about
i'm having a problem running an integration test through Gallio. The test works fine
We are using NUnit to run our integration tests. One of tests should always
In our web-application we manage our continuous integration using TeamCity. So far we have
We are using continuous integration as part of our build automation. For every check
I'm using Camel 2.9.x for integration purposes in our current project. One of the
I'm using Maven 3.0.3. For our project integration testing, we require a virtual frame
We're developing in Java for the most, but we want to integration test (using
We are building a comprehensive integration test framework in C# for our application which

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.