Lucas, My lack of any proficiency in aspects (whatsoever) means I can’t piece together how your example gets wired into the execution chain in order to try it out.
Currently, there’s this in the test class that I’m using:
@RunWith(FrameworkRunner.class)
@CreateDS(name = "classDS", partitions =
{ @CreatePartition(name = "example", suffix = "dc=example,dc=com") })
@CreateLdapServer(
transports =
{
@CreateTransport(protocol = "LDAP", port = 10389)
})
@ApplyLdifFiles(
{ "fortress-schema.ldif", "init-ldap.ldif"/*, "test-data.ldif"*/})
public class FortressJUnitApachedsTest extends AbstractLdapTestUnit
***
How does your aspect get hooked in? Sorry for the rudimentary question. Is
there a more complete example you can point me to?
Thanks,
Shawn
> On Dec 12, 2018, at 11:27 AM, Lucas Theisen <[email protected]> wrote:
>
> Not sure this helps much, but my team works around this for our integration
> test by using aop. Specifically:
>
> <aspectj>
> <aspects>
> <aspect name=" com.pastdev.apacheds.server.GetUniqueResourceReplacer" />
> </aspects>
> </aspectj>
>
>
> And this implementation
>
> /**
> * An aspect workaround for <a
> * href="https://issues.apache.org/jira/browse/DIRSERVER-1606"
> * >DIRSERVER-1606</a>
> *
> * @author LTHEISEN
> */
> @Aspect
> public class GetUniqueResourceReplacer {
> private static final Logger log = LoggerFactory.getLogger(
> GetUniqueResourceReplacer.class );
>
> @Pointcut( "execution(*
> org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor.getUniqueResource(String,String))
> &&" +
> "args(resourceName,resourceDescription)" )
> private void getUniqueResourceReplacer( String resourceName, String
> resourceDescription ) {
> }
>
> @Around(
> "com.pastdev.apacheds.server.GetUniqueResourceReplacer.getUniqueResourceReplacer(resourceName,resourceDescription)"
> )
> public URL getFirstMatchingResource( String resourceName, String
> resourceDescription ) throws IOException {
> Enumeration<URL> resources =
> DefaultSchemaLdifExtractor.class.getClassLoader().getResources( resourceName
> );
> if ( !resources.hasMoreElements() ) {
> throw new UniqueResourceException( resourceName,
> resourceDescription );
> }
> URL result = resources.nextElement();
> if ( resources.hasMoreElements() ) {
> log.debug( "found more than one copy of " + resourceName + "
> using first one" );
> }
> return result;
> }
> }
>
> As stated in the comment, this issue relates to
> https://issues.apache.org/jira/browse/DIRSERVER-1606
>
> Maybe that will work for you too.
>
> On Wed, Dec 12, 2018 at 8:58 AM Shawn McKinney <[email protected]> wrote:
>
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <[email protected]> wrote:
> >
> > if you include ApacheDS, it will implicitely include LDAP API, so including
> > ldap-api-all will be a duplicate, AFAIR.
>
> Here, fortress core apacheDS depends are: <scope>test</scope>, and of course
> we have compile-time dependency on the api.
>
> >
> > On Dec 12, 2018, at 5:08 AM, Emmanuel Lécharny <[email protected]> wrote:
> >
> > I'll have a closer look later today. What command are you executing that I
> > can run to get the same result ?
>
> Simply executed the test class inside IDE, but it could command-line:
>
> $ mvn -Dtest=FortressJUnitApachedsTest test
>
> Thanks,
> —Shawn
>
signature.asc
Description: Message signed with OpenPGP
