1   package org.apache.fulcrum.yaafi;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  
23  import org.apache.fulcrum.yaafi.testcontainer.BaseUnitTest;
24  
25  /**
26   * Test suite for the project
27   *
28   * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
29   */
30  
31  public class TestComponentTest extends BaseUnitTest
32  {
33      /**
34       * Constructor
35       * @param name the name of the test case
36       */
37      public TestComponentTest( String name )
38      {
39          super(name);
40      }
41  
42      public void testTestComponent() throws Exception
43      {
44          TestComponent testComponent = (TestComponent) this.lookup(
45              TestComponent.ROLE
46              );
47  
48          testComponent.test();
49          testComponent.doSomething(100, new Object[10]);
50  
51          assertEquals( testComponent.getBar(), "BAR" );
52          assertEquals( testComponent.getFoo(), "FOO" );
53  
54          assertNotNull( testComponent.getUrnAvalonClassLoader() );
55          assertNotNull( testComponent.getUrnAvaloneHome() );
56          assertNotNull( testComponent.getUrnAvaloneTemp() );
57          assertNotNull( testComponent.getUrnAvalonName() );
58          assertNotNull( testComponent.getUrnAvalonPartition() );
59  
60          Object [] temp = new Object[10];
61          System.out.println(temp.toString());
62  
63          try
64          {
65              testComponent.createException("enforce exception", this);
66          }
67          catch( Exception e )
68          {
69              // nothing to do
70          }
71      }
72  
73      /**
74       * Verify bug fix for not calling dispose method of components
75       * @throws Exception
76       */
77      public void testTestComponentDecomissioned() throws Exception
78      {
79          // lookup the test component
80          TestComponent testComponent = (TestComponent) this.lookup(
81              TestComponent.ROLE
82              );
83  
84          assertFalse( testComponent.isDecomissioned() );
85  
86          // decommision the test component
87          this.decommision( TestComponent.ROLE );
88          assertTrue( testComponent.isDecomissioned() );
89  
90          // resurrect the test component - resurrecting a decommisioned service
91          // might need some reviewing but I'm quite happy with the semantics
92          testComponent = (TestComponent) this.lookup(
93              TestComponent.ROLE
94              );
95  
96          assertFalse( testComponent.isDecomissioned() );
97      }
98  }