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.config.proxy;
17  
18  import java.io.IOException;
19  
20  import org.junit.BeforeClass;
21  import org.junit.experimental.theories.DataPoint;
22  
23  import test.de.smartics.properties.spi.config.proxy.examples.MoreProperties;
24  import test.de.smartics.properties.spi.config.proxy.examples.TestProperties;
25  import de.smartics.properties.api.config.domain.key.ApplicationId;
26  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
27  import de.smartics.properties.api.config.domain.key.EnvironmentId;
28  import de.smartics.properties.api.core.security.Base64PropertyValueSecurity;
29  import de.smartics.properties.impl.config.domain.key.envapp.EnvAppConfigurationKey;
30  import de.smartics.properties.impl.config.properties.PropertiesConfigurationProperties;
31  import de.smartics.properties.spi.config.proxy.PropertyConfigurationObjectBuilder;
32  import de.smartics.testdoc.annotations.Uut;
33  import de.smartics.util.test.theories.SerializationTheory;
34  
35  /**
36   * Tests {@link MoreProperties}.
37   */
38  @Uut(type = MoreProperties.class)
39  public class PropertiesSerializableTest extends SerializationTheory
40  { // NOPMD
41  
42    // ********************************* Fields *********************************
43  
44    // --- constants ------------------------------------------------------------
45  
46    // --- members --------------------------------------------------------------
47  
48    // ****************************** Inner Classes *****************************
49  
50    // ********************************* Methods ********************************
51  
52    private static PropertyConfigurationObjectBuilder builder;
53  
54    private static PropertiesConfigurationProperties configurationProperties;
55  
56    @BeforeClass
57    public static void setUpClass()
58    {
59      final EnvironmentId environmentId = new EnvironmentId("test");
60      final ApplicationId applicationId =
61          new ApplicationId("groupId", "artefactId", "version");
62      final ConfigurationKey<?> key =
63          new EnvAppConfigurationKey(environmentId, applicationId);
64      configurationProperties =
65          new PropertiesConfigurationProperties(key,
66              new Base64PropertyValueSecurity());
67  
68      configurationProperties.addClassPathProperties(TestProperties.class);
69  
70      builder = new PropertyConfigurationObjectBuilder();
71  
72    }
73  
74    // --- helper ---------------------------------------------------------------
75  
76    // --- tests ----------------------------------------------------------------
77  
78    @DataPoint
79    public MoreProperties allProxyImplementationsOfAPropertyInterfaceAreSerializable()
80      throws IOException, ClassNotFoundException
81    {
82      final MoreProperties properties =
83          builder.build(MoreProperties.class, configurationProperties);
84      return properties;
85    }
86  
87  }