You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2011/08/18 04:25:21 UTC

svn commit: r1158995 [2/2] - in /maven/sandbox/trunk/mae: ./ mae-api/ mae-api/src/main/java/org/apache/maven/mae/conf/ mae-api/src/main/java/org/apache/maven/mae/internal/container/ mae-api/src/test/java/org/apache/maven/mae/ mae-booter/ mae-booter/src...

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/MAEApplicationTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/MAEApplicationTest.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/MAEApplicationTest.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/MAEApplicationTest.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.apache.maven.mae.MAEException;
+import org.apache.maven.mae.app.AbstractMAEApplication;
+import org.apache.maven.mae.boot.embed.MAEEmbedderBuilder;
+import org.apache.maven.mae.internal.container.fixture.ContainerOwner;
+import org.junit.Test;
+
+public class MAEApplicationTest
+{
+
+    @Test
+    // @Ignore
+    public void injectContainerIntoExternalInstance()
+        throws Exception
+    {
+        ContainerOwner owner = new ContainerOwner();
+        new TestApplication().withInstance( owner ).load();
+
+        assertThat( owner.container, notNullValue() );
+    }
+
+    @Test
+    // @Ignore
+    public void loadBare()
+        throws Exception
+    {
+        new TestApplication().load();
+    }
+
+    @Test
+    public void loadTwoApplications()
+        throws MAEException
+    {
+        ContainerOwner owner = new ContainerOwner();
+        new TestApplication().load();
+
+        assertThat( "Container holder should not have a container instance after unrelated application is loaded.",
+                    owner.container, nullValue() );
+
+        new TestApplication().withInstance( owner ).load();
+
+        assertThat( "Container holder should have a container instance after application with its registered instance is loaded.",
+                    owner.container, notNullValue() );
+    }
+
+    // @Test
+    // public void mappedRequirementContainsNoLiteralIds()
+    // throws Throwable
+    // {
+    // final ContainerConfiguration config = new DefaultContainerConfiguration().setClassPathScanning( "ON" );
+    //
+    // final MAEContainer container = new MAEContainer( config, new ComponentSelector(), new InstanceRegistry() );
+    //
+    // final MapOwner mapOwner = container.lookup( MapOwner.class );
+    // final Map<String, Child> members = mapOwner.members();
+    //
+    // System.out.println( members );
+    //
+    // assertNull( members.get( "simple" + ComponentKey.LITERAL_SUFFIX ) );
+    // }
+    //
+    // @Test
+    // public void singletonImpliedRequirementOnComponentWithImpliedHint()
+    // throws Throwable
+    // {
+    // final ContainerConfiguration config = new DefaultContainerConfiguration().setClassPathScanning( "ON" );
+    //
+    // final MAEContainer container = new MAEContainer( config, new ComponentSelector(), new InstanceRegistry() );
+    //
+    // final DefaultSingletonOwner owner = container.lookup( DefaultSingletonOwner.class );
+    //
+    // assertNotNull( owner.singleton() );
+    // }
+    //
+    // @Test
+    // public void singletonNonLiteralRequirement()
+    // throws Throwable
+    // {
+    // final ContainerConfiguration config = new DefaultContainerConfiguration().setClassPathScanning( "ON" );
+    //
+    // final MAEContainer container = new MAEContainer( config, new ComponentSelector(), new InstanceRegistry() );
+    //
+    // final SingletonOwner owner = container.lookup( SingletonOwner.class );
+    //
+    // assertNotNull( owner.singleton() );
+    // }
+    //
+    // @Test
+    // public void singletonLiteralRequirement()
+    // throws Throwable
+    // {
+    // final ContainerConfiguration config = new DefaultContainerConfiguration().setClassPathScanning( "ON" );
+    //
+    // final MAEContainer container = new MAEContainer( config, new ComponentSelector(), new InstanceRegistry() );
+    //
+    // final SingletonLiteralOwner owner = container.lookup( SingletonLiteralOwner.class );
+    //
+    // assertNotNull( owner.singletonLiteral() );
+    // }
+    //
+    // @Test
+    // public void initializableUsingRequirement()
+    // throws Throwable
+    // {
+    // final ContainerConfiguration config = new DefaultContainerConfiguration().setClassPathScanning( "ON" );
+    //
+    // final MAEContainer container = new MAEContainer( config, new ComponentSelector(), new InstanceRegistry() );
+    //
+    // container.lookup( InitializedUsingRequirement.class );
+    // }
+
+    private static final class TestApplication
+        extends AbstractMAEApplication
+    {
+        private final String name;
+
+        TestApplication()
+        {
+            name = new Exception().getStackTrace()[1].getMethodName();
+        }
+
+        public final TestApplication withInstance( final Object instance )
+        {
+            withComponentInstance( instance );
+            return this;
+        }
+
+        @Override
+        public String getId()
+        {
+            return name;
+        }
+
+        @Override
+        public String getName()
+        {
+            return name;
+        }
+
+        @Override
+        protected void configureBuilder( final MAEEmbedderBuilder builder )
+            throws MAEException
+        {
+            builder.withClassScanningEnabled( true );
+            super.configureBuilder( builder );
+        }
+
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/MAEApplicationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/Child.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/Child.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/Child.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/Child.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+
+@Component( role = Child.class, hint = "simple" )
+public class Child
+{
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/Child.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/ContainerOwner.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/ContainerOwner.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/ContainerOwner.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/ContainerOwner.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,14 @@
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component( role = ContainerOwner.class )
+public class ContainerOwner
+{
+
+    @Requirement
+    public PlexusContainer container;
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/ContainerOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultChild.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultChild.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultChild.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultChild.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+
+@Component( role = DefaultChild.class )
+public class DefaultChild
+{
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultChild.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultSingletonOwner.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultSingletonOwner.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultSingletonOwner.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultSingletonOwner.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component( role = DefaultSingletonOwner.class )
+public class DefaultSingletonOwner
+{
+
+    @Requirement
+    private DefaultChild singleton;
+
+    public DefaultChild singleton()
+    {
+        return singleton;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/DefaultSingletonOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/InitializedUsingRequirement.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/InitializedUsingRequirement.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/InitializedUsingRequirement.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/InitializedUsingRequirement.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+@Component( role = InitializedUsingRequirement.class )
+public class InitializedUsingRequirement
+    implements Initializable
+{
+
+    @Requirement
+    private DefaultChild child;
+
+    @Override
+    public void initialize()
+        throws InitializationException
+    {
+        System.out.println( child.toString() );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/InitializedUsingRequirement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/MapOwner.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/MapOwner.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/MapOwner.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/MapOwner.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+import java.util.Map;
+
+@Component( role = MapOwner.class )
+public class MapOwner
+{
+
+    @Requirement( role = Child.class )
+    private Map<String, Child> members;
+
+    public Map<String, Child> members()
+    {
+        return members;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/MapOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonLiteralOwner.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonLiteralOwner.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonLiteralOwner.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonLiteralOwner.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component( role = SingletonLiteralOwner.class )
+public class SingletonLiteralOwner
+{
+
+    @Requirement( role = Child.class, hint = "simple_" )
+    private Child singletonLiteral;
+
+    public Child singletonLiteral()
+    {
+        return singletonLiteral;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonLiteralOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonOwner.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonOwner.java?rev=1158995&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonOwner.java (added)
+++ maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonOwner.java Thu Aug 18 02:25:18 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.mae.internal.container.fixture;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+@Component( role = SingletonOwner.class )
+public class SingletonOwner
+{
+
+    @Requirement( role = Child.class, hint = "simple" )
+    private Child singleton;
+
+    public Child singleton()
+    {
+        return singleton;
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-booter/src/test/java/org/apache/maven/mae/internal/container/fixture/SingletonOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/sandbox/trunk/mae/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/pom.xml?rev=1158995&r1=1158994&r2=1158995&view=diff
==============================================================================
--- maven/sandbox/trunk/mae/pom.xml (original)
+++ maven/sandbox/trunk/mae/pom.xml Thu Aug 18 02:25:18 2011
@@ -69,7 +69,7 @@
     <maeVersion>${project.version}</maeVersion>
   	<mavenVersion>3.0.3</mavenVersion>
   	<plexusVersion>1.5.5</plexusVersion>
-  	<sisuVersion>2.1.1-selectable-1</sisuVersion>
+  	<sisuVersion>2.1.1</sisuVersion>
   </properties>
   
   <modules>