View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
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 test.de.smartics.properties.spi.core.util;
17  
18  import java.lang.reflect.Method;
19  
20  import org.junit.experimental.categories.Category;
21  import org.junit.experimental.theories.DataPoint;
22  
23  import de.smartics.properties.spi.core.util.SerializableMethod;
24  import de.smartics.testdoc.annotations.Uut;
25  import de.smartics.testdoc.categories.type.ObjectBasics;
26  import de.smartics.util.test.theories.SerializationTheory;
27  
28  /**
29   * Tests serialization of {@link SerializableMethod}.
30   */
31  @Category(ObjectBasics.class)
32  @Uut(type = SerializableMethod.class)
33  public class SerializableMethodSerializableTest extends SerializationTheory
34  {
35    private static final Method NO_ARG_METHOD;
36  
37    private static final Method ONE_ARG_METHOD;
38  
39    private static final Method MANY_ARGS_METHOD;
40  
41    static
42    {
43      try
44      {
45        NO_ARG_METHOD = String.class.getMethod("toString", new Class<?>[0]);
46        ONE_ARG_METHOD =
47            String.class.getMethod("concat", new Class<?>[] { String.class });
48        MANY_ARGS_METHOD =
49            String.class.getMethod("replaceAll", new Class<?>[] { String.class,
50                                                                 String.class });
51      }
52      catch (final Exception e)
53      {
54        throw new IllegalStateException("Cannot find method for test.", e);
55      }
56    }
57  
58    @DataPoint
59    public static final SerializableMethod NULL = new SerializableMethod(null);
60  
61    @DataPoint
62    public static final SerializableMethod NO_ARGS = new SerializableMethod(
63        NO_ARG_METHOD);
64  
65    @DataPoint
66    public static final SerializableMethod ONE_ARG = new SerializableMethod(
67        ONE_ARG_METHOD);
68  
69    @DataPoint
70    public static final SerializableMethod MANY_ARGS = new SerializableMethod(
71        MANY_ARGS_METHOD);
72  }