/** * {@literal main} method that read JSON from STDIN. * <p>Passivation exceptions are written to STDERR if any.</p> * @param args Unused * @throws AssemblyException if the assembly failed * @throws ActivationException if the activation failed */ public static void main( String[] args ) throws ActivationException, AssemblyException { fromJson( System.in ).withPassivationShutdownHook().newApplication(); } }
/** * {@literal main} method that read JSON from STDIN. * <p>Passivation exceptions are written to STDERR if any.</p> * @param args Unused * @throws AssemblyException if the assembly failed * @throws ActivationException if the activation failed */ public static void main( String[] args ) throws ActivationException, AssemblyException { fromJson( System.in ).withPassivationShutdownHook().newApplication(); } }
@Test public void givenJsonInputStreamWhenBuildingApplicationExpectSuccess() throws IOException, ActivationException, AssemblyException { InputStream input = new ByteArrayInputStream( APPLICATION.getBytes( "UTF-8" ) ); ApplicationBuilder builder = ApplicationBuilder.fromJson( input ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
@Test public void givenJsonWhenBuildingApplicationExpectSuccess() throws ActivationException, AssemblyException { ApplicationBuilder builder = ApplicationBuilder.fromJson( APPLICATION ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
@Test public void givenBuilderUseWhenBuildingApplicationExpectSuccess() throws AssemblyException, ActivationException { ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." ); builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" ); builder.withLayer( "layer2" ); builder.withLayer( "layer3" ) .withModule( "test module" ) .withAssemblers( findClasses( getClass() ).filter( matches( ".*ServiceAssembler" ) ) .collect( toList() ) ); Application application = builder.newApplication(); Module module = application.findModule( "layer3", "test module" ); TestService service = module.findService( TestService.class ).get(); assertThat( service.sayHello(), equalTo( "Hello Polygene!" ) ); }
appBuilder.registerActivationEventListener( new TestActivationEventListener() ); Application app = appBuilder.newApplication();