You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Vladimir Nišević <vn...@gmail.com> on 2014/11/24 11:52:57 UTC

Using property files to setup IsisSystemForTest

Hi guys, based on example from ToDo, we have wrote an our own
AppSystemInitializier, where we building our own IsisSystemForTest but with
the difference that we want to reuse current property files, and not
explicitly declare same we have in the properties again (e.g. domain
services).

So the question is how to build a IsisSystemForTest where we just point to
webapp\WEBINF\ directory.

Here what we tried using the idea (
http://isis.apache.org/reference/externalized-configuration.html) but yet
not succeeded.


package integration;

import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
import
org.apache.isis.core.commons.config.IsisConfigurationBuilderResourceStreams;
import org.apache.isis.core.commons.resource.ResourceStreamSourceComposite;
import org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem;
import org.apache.isis.core.integtestsupport.IsisSystemForTest;

/**
 * Holds an instance of an {@link IsisSystemForTest} as a {@link
ThreadLocal} on
 * the current thread, initialized with ToDo app's domain services.
 */
public class AddressSearchEngineSystemInitializer {

    public static IsisSystemForTest initIsft() {
        IsisSystemForTest isft = IsisSystemForTest.getElseNull();
        if (isft == null) {
            isft = new
AddressSearchEngineSystemBuilder().build().setUpSystem();
            IsisSystemForTest.set(isft);
        }
        return isft;
    }

    private static class AddressSearchEngineSystemBuilder extends
IsisSystemForTest.Builder {

        public AddressSearchEngineSystemBuilder() {
            with(loadFromFileSystem());

        }

        private static IsisConfiguration loadFromFileSystem() {
            final String configLocation =
"D:\\aseDev\\WorkspaceAse.eclipse.luna\\ase\\webapp\\src\\main\\webapp\\WEB-INF\\";
            final ResourceStreamSourceComposite compositeSource = new
ResourceStreamSourceComposite(ResourceStreamSourceFileSystem.create(configLocation));
            final IsisConfigurationBuilder isisConfigurationBuilder = new
IsisConfigurationBuilderResourceStreams(compositeSource);
            return isisConfigurationBuilder.getConfiguration();
        }
    }
}



Thanks,Vladimir

Re: Using property files to setup IsisSystemForTest

Posted by Jeroen van der Wal <je...@stromboli.it>.
No worries, always happy to help.

Cheers,

Jeroen

On Thu, Dec 4, 2014 at 2:55 PM, Vladimir Nišević <vn...@gmail.com> wrote:

> Hi Jeroen, was actually a bad idea.
>
> Thanks,Vladimir
>
> 2014-11-24 15:15 GMT+01:00 Jeroen van der Wal <je...@stromboli.it>:
>
> > Hi Vladimir,
> >
> > The isis.properties you want to point to lives in a different project and
> > might have a different purpose so you should rather not create and
> > inter-project dependency like that. Also your example uses a resource
> > location which is specific to your machine which is a pain if you want to
> > have another developer work on the same code base.
> >
> > In general there are only a few properties you need to set in ISFT since
> > most domain services are automatically discovered by the @DomainService
> > annotation. We've had no requirement to use isis.properties in our
> > integtest projects so far, perhaps you can share the reason why the
> current
> > situation doesn't work for you?
> >
> > Cheers,
> >
> > Jeroen
> >
> >
> >
> >
> >
> >
> > On Mon, Nov 24, 2014 at 11:52 AM, Vladimir Nišević <vn...@gmail.com>
> > wrote:
> >
> > > Hi guys, based on example from ToDo, we have wrote an our own
> > > AppSystemInitializier, where we building our own IsisSystemForTest but
> > with
> > > the difference that we want to reuse current property files, and not
> > > explicitly declare same we have in the properties again (e.g. domain
> > > services).
> > >
> > > So the question is how to build a IsisSystemForTest where we just point
> > to
> > > webapp\WEBINF\ directory.
> > >
> > > Here what we tried using the idea (
> > > http://isis.apache.org/reference/externalized-configuration.html) but
> > yet
> > > not succeeded.
> > >
> > >
> > > package integration;
> > >
> > > import org.apache.isis.core.commons.config.IsisConfiguration;
> > > import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
> > > import
> > >
> > >
> >
> org.apache.isis.core.commons.config.IsisConfigurationBuilderResourceStreams;
> > > import
> > org.apache.isis.core.commons.resource.ResourceStreamSourceComposite;
> > > import
> > > org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem;
> > > import org.apache.isis.core.integtestsupport.IsisSystemForTest;
> > >
> > > /**
> > >  * Holds an instance of an {@link IsisSystemForTest} as a {@link
> > > ThreadLocal} on
> > >  * the current thread, initialized with ToDo app's domain services.
> > >  */
> > > public class AddressSearchEngineSystemInitializer {
> > >
> > >     public static IsisSystemForTest initIsft() {
> > >         IsisSystemForTest isft = IsisSystemForTest.getElseNull();
> > >         if (isft == null) {
> > >             isft = new
> > > AddressSearchEngineSystemBuilder().build().setUpSystem();
> > >             IsisSystemForTest.set(isft);
> > >         }
> > >         return isft;
> > >     }
> > >
> > >     private static class AddressSearchEngineSystemBuilder extends
> > > IsisSystemForTest.Builder {
> > >
> > >         public AddressSearchEngineSystemBuilder() {
> > >             with(loadFromFileSystem());
> > >
> > >         }
> > >
> > >         private static IsisConfiguration loadFromFileSystem() {
> > >             final String configLocation =
> > >
> > >
> >
> "D:\\aseDev\\WorkspaceAse.eclipse.luna\\ase\\webapp\\src\\main\\webapp\\WEB-INF\\";
> > >             final ResourceStreamSourceComposite compositeSource = new
> > >
> > >
> >
> ResourceStreamSourceComposite(ResourceStreamSourceFileSystem.create(configLocation));
> > >             final IsisConfigurationBuilder isisConfigurationBuilder =
> new
> > > IsisConfigurationBuilderResourceStreams(compositeSource);
> > >             return isisConfigurationBuilder.getConfiguration();
> > >         }
> > >     }
> > > }
> > >
> > >
> > >
> > > Thanks,Vladimir
> > >
> >
>

Re: Using property files to setup IsisSystemForTest

Posted by Vladimir Nišević <vn...@gmail.com>.
Hi Jeroen, was actually a bad idea.

Thanks,Vladimir

2014-11-24 15:15 GMT+01:00 Jeroen van der Wal <je...@stromboli.it>:

> Hi Vladimir,
>
> The isis.properties you want to point to lives in a different project and
> might have a different purpose so you should rather not create and
> inter-project dependency like that. Also your example uses a resource
> location which is specific to your machine which is a pain if you want to
> have another developer work on the same code base.
>
> In general there are only a few properties you need to set in ISFT since
> most domain services are automatically discovered by the @DomainService
> annotation. We've had no requirement to use isis.properties in our
> integtest projects so far, perhaps you can share the reason why the current
> situation doesn't work for you?
>
> Cheers,
>
> Jeroen
>
>
>
>
>
>
> On Mon, Nov 24, 2014 at 11:52 AM, Vladimir Nišević <vn...@gmail.com>
> wrote:
>
> > Hi guys, based on example from ToDo, we have wrote an our own
> > AppSystemInitializier, where we building our own IsisSystemForTest but
> with
> > the difference that we want to reuse current property files, and not
> > explicitly declare same we have in the properties again (e.g. domain
> > services).
> >
> > So the question is how to build a IsisSystemForTest where we just point
> to
> > webapp\WEBINF\ directory.
> >
> > Here what we tried using the idea (
> > http://isis.apache.org/reference/externalized-configuration.html) but
> yet
> > not succeeded.
> >
> >
> > package integration;
> >
> > import org.apache.isis.core.commons.config.IsisConfiguration;
> > import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
> > import
> >
> >
> org.apache.isis.core.commons.config.IsisConfigurationBuilderResourceStreams;
> > import
> org.apache.isis.core.commons.resource.ResourceStreamSourceComposite;
> > import
> > org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem;
> > import org.apache.isis.core.integtestsupport.IsisSystemForTest;
> >
> > /**
> >  * Holds an instance of an {@link IsisSystemForTest} as a {@link
> > ThreadLocal} on
> >  * the current thread, initialized with ToDo app's domain services.
> >  */
> > public class AddressSearchEngineSystemInitializer {
> >
> >     public static IsisSystemForTest initIsft() {
> >         IsisSystemForTest isft = IsisSystemForTest.getElseNull();
> >         if (isft == null) {
> >             isft = new
> > AddressSearchEngineSystemBuilder().build().setUpSystem();
> >             IsisSystemForTest.set(isft);
> >         }
> >         return isft;
> >     }
> >
> >     private static class AddressSearchEngineSystemBuilder extends
> > IsisSystemForTest.Builder {
> >
> >         public AddressSearchEngineSystemBuilder() {
> >             with(loadFromFileSystem());
> >
> >         }
> >
> >         private static IsisConfiguration loadFromFileSystem() {
> >             final String configLocation =
> >
> >
> "D:\\aseDev\\WorkspaceAse.eclipse.luna\\ase\\webapp\\src\\main\\webapp\\WEB-INF\\";
> >             final ResourceStreamSourceComposite compositeSource = new
> >
> >
> ResourceStreamSourceComposite(ResourceStreamSourceFileSystem.create(configLocation));
> >             final IsisConfigurationBuilder isisConfigurationBuilder = new
> > IsisConfigurationBuilderResourceStreams(compositeSource);
> >             return isisConfigurationBuilder.getConfiguration();
> >         }
> >     }
> > }
> >
> >
> >
> > Thanks,Vladimir
> >
>

Re: Using property files to setup IsisSystemForTest

Posted by Jeroen van der Wal <je...@stromboli.it>.
Hi Vladimir,

The isis.properties you want to point to lives in a different project and
might have a different purpose so you should rather not create and
inter-project dependency like that. Also your example uses a resource
location which is specific to your machine which is a pain if you want to
have another developer work on the same code base.

In general there are only a few properties you need to set in ISFT since
most domain services are automatically discovered by the @DomainService
annotation. We've had no requirement to use isis.properties in our
integtest projects so far, perhaps you can share the reason why the current
situation doesn't work for you?

Cheers,

Jeroen






On Mon, Nov 24, 2014 at 11:52 AM, Vladimir Nišević <vn...@gmail.com>
wrote:

> Hi guys, based on example from ToDo, we have wrote an our own
> AppSystemInitializier, where we building our own IsisSystemForTest but with
> the difference that we want to reuse current property files, and not
> explicitly declare same we have in the properties again (e.g. domain
> services).
>
> So the question is how to build a IsisSystemForTest where we just point to
> webapp\WEBINF\ directory.
>
> Here what we tried using the idea (
> http://isis.apache.org/reference/externalized-configuration.html) but yet
> not succeeded.
>
>
> package integration;
>
> import org.apache.isis.core.commons.config.IsisConfiguration;
> import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
> import
>
> org.apache.isis.core.commons.config.IsisConfigurationBuilderResourceStreams;
> import org.apache.isis.core.commons.resource.ResourceStreamSourceComposite;
> import
> org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem;
> import org.apache.isis.core.integtestsupport.IsisSystemForTest;
>
> /**
>  * Holds an instance of an {@link IsisSystemForTest} as a {@link
> ThreadLocal} on
>  * the current thread, initialized with ToDo app's domain services.
>  */
> public class AddressSearchEngineSystemInitializer {
>
>     public static IsisSystemForTest initIsft() {
>         IsisSystemForTest isft = IsisSystemForTest.getElseNull();
>         if (isft == null) {
>             isft = new
> AddressSearchEngineSystemBuilder().build().setUpSystem();
>             IsisSystemForTest.set(isft);
>         }
>         return isft;
>     }
>
>     private static class AddressSearchEngineSystemBuilder extends
> IsisSystemForTest.Builder {
>
>         public AddressSearchEngineSystemBuilder() {
>             with(loadFromFileSystem());
>
>         }
>
>         private static IsisConfiguration loadFromFileSystem() {
>             final String configLocation =
>
> "D:\\aseDev\\WorkspaceAse.eclipse.luna\\ase\\webapp\\src\\main\\webapp\\WEB-INF\\";
>             final ResourceStreamSourceComposite compositeSource = new
>
> ResourceStreamSourceComposite(ResourceStreamSourceFileSystem.create(configLocation));
>             final IsisConfigurationBuilder isisConfigurationBuilder = new
> IsisConfigurationBuilderResourceStreams(compositeSource);
>             return isisConfigurationBuilder.getConfiguration();
>         }
>     }
> }
>
>
>
> Thanks,Vladimir
>