Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The AlfrescoPerson does not work in Maven SDK 1.1.1 #168

Closed
mindthegab opened this issue Jul 20, 2014 · 9 comments
Closed

The AlfrescoPerson does not work in Maven SDK 1.1.1 #168

mindthegab opened this issue Jul 20, 2014 · 9 comments

Comments

@mindthegab
Copy link
Contributor

From m.swe...@aca-it.be on December 02, 2013 10:30:31

What steps will reproduce the problem? 1. Create a fresh project with the Maven SDK 1.1.1
2. Create a test using the AlfrescoPerson rule to create a temporary user
3. The test will fail, because it cannot find the bean "testUserComponent". What is the expected output? What do you see instead? The rule should still work (just like in Maven SDK version 1.0.2), but it complains about the bean that cannot be found. What version of the product are you using? On what operating system? Maven SDK 1.1.1. on OSX with Maven 3.1.1 and Alfresco 4.2.e. Please provide any additional information below. The bean is defined in the file "community-integration-test-context.xml". I added it to my resources and referenced it in the @ContextConfiguration annotation to work around this problem. However this should work out of the box.

I also noticed that it is difficult to make it work out of the box, because it is hard getting to the application context before the JUnit rule is initialised. To fix it:

  • My test implements ApplicationContextAware
  • I have a custom ApplicationContextInit class which has a setter for the ApplicationContext and a simple getter. I instantiate it as a private variable on my test class.
  • I pass the ApplicationContext within my test in the setApplicationContext method provided by the ApplicationContextAware interface
  • I am then able to pass the ApplicationContextInit instance to the AlfrescoPerson rule.

This is also necessary to be able to use the TemporaryNodes rule. I feel that it shouldn't be so hard trying to make the default test utility classes to work.

Original issue: http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=168

@mindthegab
Copy link
Contributor Author

From m.swe...@aca-it.be on December 10, 2013 05:06:51

An issue has been created: http://issues.alfresco.com/jira/browse/ALF-20644

@mindthegab
Copy link
Contributor Author

From colum...@gmail.com on July 18, 2014 13:19:40

Sam, you are assigned to the related http://issues.alfresco.com/jira/browse/ALF-20644 so assigning this to you if you don't mind.

Can you have a look at this?

Status: Accepted
Owner: samuel.l...@alfresco.com
Labels: Milestone-Release-sdk-2.0.0

@mindthegab mindthegab modified the milestone: Release-sdk-2.0.0 Jul 20, 2014
@mindthegab mindthegab assigned marcomancuso and unassigned slanglois Jul 30, 2014
@mindthegab
Copy link
Contributor Author

@marcomancuso can you just do a double check whether with 2.0.0-SNAPSHOT (and the new 5.0.a) artifacts this still reproduces? If not, please close the issue.

@mindthegab mindthegab modified the milestones: 2.0.0-beta-1, 2.0.0 Aug 22, 2014
@marcomancuso
Copy link

I cannot replicate the issue with Maven 1.1.1, Alfresco 4.2.e (same as issue), AMP archetype
Created a simple Java test:

@RunWith(RemoteTestRunner.class)
@Remote(runnerClass=SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:alfresco/application-context.xml")
public class AlfrescoPersonTest{

public static ApplicationContextInit APP_CONTEXT_INIT = new ApplicationContextInit();
public static AlfrescoPerson TEST_USER1 = new AlfrescoPerson(APP_CONTEXT_INIT, "UserOne");
public static AlfrescoPerson TEST_USER2 = new AlfrescoPerson(APP_CONTEXT_INIT, "UserTwo");

@ClassRule 
public static RuleChain ruleChain = RuleChain.outerRule(APP_CONTEXT_INIT).around(TEST_USER1).around(TEST_USER2);

@Test
public void test1() {
    assertNotNull(TEST_USER1.getPersonNode());
    assertNotNull(TEST_USER2.getPersonNode());
}

}

In order to use Alfresco Person I had to add in the pom.xml the test dependency:

    <dependency>
        <groupId>${alfresco.groupId}</groupId>
        <artifactId>alfresco-repository</artifactId>
        <version>${alfresco.version}</version>
        <classifier>tests</classifier>
        <scope>test</scope>
    </dependency>

org.alfresco.util.test.junitrules.AlfrescoPerson is in fact defined inside alfresco-repository-4.2.e-tests.jar

It doesn't throw any error:
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 78.199 sec - in org.alfresco.demoamp.test.AlfrescoPersonTest

Am I missing something?

@marcomancuso
Copy link

Tested with Maven SDK 2.0.0-beta-2, Alfresco Version 5.0.a as well
I still had to add in the pom.xml

    <dependency>
        <groupId>${alfresco.groupId}</groupId>
        <artifactId>alfresco-repository</artifactId>
        <version>${alfresco.version}</version>
        <classifier>tests</classifier>
        <scope>test</scope>
    </dependency>

Results: no errors

mindthegab added a commit that referenced this issue Dec 23, 2014
…ed to work in amp and aio in eclipse and cmd line
@mindthegab mindthegab modified the milestones: 2.0.0, 2.1.0 Dec 23, 2014
@ohej
Copy link
Contributor

ohej commented Jun 8, 2015

Hi Marco

Does this issue still happen with 2.0.0 / 2.1.0? It seems the dependency is added, but the issue was never closed. Could you verify and close the issue if it's fixed?

/Ole

@jgoldhammer
Copy link
Contributor

In SDK 3, this dependency does not exists anymore.
So in SDK3 we have no generated unit-tests running.
@gravitonian and @ohej : what is the current state of testing with SDK 3?

@jgoldhammer jgoldhammer assigned ohej and gravitonian and unassigned marcomancuso Nov 24, 2016
@ohej
Copy link
Contributor

ohej commented Mar 24, 2017

Given the age of this issue I will close it. Feel free to reopen if this is still a valid issue with SDK3

@tmttn
Copy link

tmttn commented Jun 27, 2017

This is still a valid issue in SDK 3 (alfresco-platform version 5.0.3).
Defining the following dependency solves the issue:

<dependency>
    <groupId>${alfresco.groupId}</groupId>
    <artifactId>alfresco-repository</artifactId>
    <version>${alfresco.platform.version}</version>
    <classifier>tests</classifier>
    <scope>test</scope>
</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants