View Javadoc
1   /*
2    * Copyright 2011 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.fatwire.gst.foundation.controller.support;
17  
18  import junit.framework.TestCase;
19  
20  /**
21   * @deprecated helper class; no replacement
22   */
23  public class TemplateMethodFactoryTest extends TestCase {
24  
25      static public class Bar {
26         
27          @Override
28          public String toString() {
29              return "Bar";
30          }
31  
32      }
33  
34      class Foo {
35          public String createString() {
36              return "foo";
37          }
38      }
39  
40      public void testCreateByMethod() {
41          try {
42              String foo = TemplateMethodFactory.createByMethod(new Foo(), String.class);
43              assertEquals("foo", foo);
44          } catch (Exception e) {
45              fail(e.getMessage());
46          }
47  
48      }
49  
50      public void testCreateByConstructor() {
51          Bar foo;
52          try {
53              foo = TemplateMethodFactory.createByConstructor(Bar.class);
54              assertEquals("Bar", foo.toString());
55          } catch (Exception e) {
56              e.printStackTrace();
57              fail(e.getMessage());
58          }
59          
60      }
61  
62  }