|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package com.alipay.lookout.jvm; |
| 18 | + |
| 19 | +import com.alipay.lookout.api.Id; |
| 20 | +import com.alipay.lookout.api.Registry; |
| 21 | +import com.alipay.lookout.core.DefaultRegistry; |
| 22 | +import com.alipay.lookout.core.InfoWrapper; |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +import static org.junit.Assert.assertEquals; |
| 26 | + |
| 27 | +/** |
| 28 | + * JvmSystemPropertiesInfoMetricImporter Tester. |
| 29 | + * |
| 30 | + * @author <guanchao.ygc> |
| 31 | + * @version 1.0 |
| 32 | + * @since <pre>07/03/2018</pre> |
| 33 | + */ |
| 34 | +public class JvmSystemPropertiesInfoMetricImporterTest { |
| 35 | + |
| 36 | + /** |
| 37 | + * Method: register(Registry registry) |
| 38 | + */ |
| 39 | + @Test |
| 40 | + public void testRegister() throws Exception { |
| 41 | + Registry registry = new DefaultRegistry(); |
| 42 | + JvmSystemPropertiesInfoMetricImporter jvmSystemPropertiesInfoMetricImporter = new JvmSystemPropertiesInfoMetricImporter(); |
| 43 | + jvmSystemPropertiesInfoMetricImporter.register(registry); |
| 44 | + Id idSys = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_PROP_NAME); |
| 45 | + InfoWrapper infoWrapper = registry.get(idSys); |
| 46 | + assertEquals(System.getProperties(), infoWrapper.value()); |
| 47 | + Id envId = registry.createId(LookoutIdNameConstants.JVM_SYSTEM_ENV_NAME); |
| 48 | + InfoWrapper envWrapper = registry.get(envId); |
| 49 | + assertEquals(System.getenv(), envWrapper.value()); |
| 50 | + } |
| 51 | +} |
0 commit comments