View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.rest.model;
21  
22  import java.io.IOException;
23  import java.io.StringReader;
24  import java.io.StringWriter;
25  
26  import javax.xml.bind.JAXBContext;
27  import javax.xml.bind.JAXBException;
28  
29  import org.apache.hadoop.hbase.SmallTests;
30  import org.apache.hadoop.hbase.util.Base64;
31  
32  import junit.framework.TestCase;
33  import org.junit.experimental.categories.Category;
34  
35  @Category(SmallTests.class)
36  public class TestVersionModel extends TestModelBase<VersionModel> {
37    private static final String REST_VERSION = "0.0.1";
38    private static final String OS_VERSION = 
39      "Linux 2.6.18-128.1.6.el5.centos.plusxen amd64";
40    private static final String JVM_VERSION =
41      "Sun Microsystems Inc. 1.6.0_13-11.3-b02";
42    private static final String JETTY_VERSION = "6.1.14";
43    private static final String JERSEY_VERSION = "1.1.0-ea";
44    
45    public TestVersionModel() throws Exception {
46      super(VersionModel.class);
47      AS_XML =
48        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Version JVM=\"Sun " +
49            "Microsystems Inc. 1.6.0_13-11.3-b02\" Jersey=\"1.1.0-ea\" " +
50            "OS=\"Linux 2.6.18-128.1.6.el5.centos.plusxen amd64\" REST=\"0.0.1\" Server=\"6.1.14\"/>";
51  
52      AS_PB =
53        "CgUwLjAuMRInU3VuIE1pY3Jvc3lzdGVtcyBJbmMuIDEuNi4wXzEzLTExLjMtYjAyGi1MaW51eCAy" +
54        "LjYuMTgtMTI4LjEuNi5lbDUuY2VudG9zLnBsdXN4ZW4gYW1kNjQiBjYuMS4xNCoIMS4xLjAtZWE=";
55  
56      AS_JSON =
57        "{\"JVM\":\"Sun Microsystems Inc. 1.6.0_13-11.3-b02\",\"Jersey\":\"1.1.0-ea\"," +
58            "\"OS\":\"Linux 2.6.18-128.1.6.el5.centos.plusxen amd64\",\"" +
59            "REST\":\"0.0.1\",\"Server\":\"6.1.14\"}";
60    }
61  
62    protected VersionModel buildTestModel() {
63      VersionModel model = new VersionModel();
64      model.setRESTVersion(REST_VERSION);
65      model.setOSVersion(OS_VERSION);
66      model.setJVMVersion(JVM_VERSION);
67      model.setServerVersion(JETTY_VERSION);
68      model.setJerseyVersion(JERSEY_VERSION);
69      return model;
70    }
71  
72    protected void checkModel(VersionModel model) {
73      assertEquals(model.getRESTVersion(), REST_VERSION);
74      assertEquals(model.getOSVersion(), OS_VERSION);
75      assertEquals(model.getJVMVersion(), JVM_VERSION);
76      assertEquals(model.getServerVersion(), JETTY_VERSION);
77      assertEquals(model.getJerseyVersion(), JERSEY_VERSION);
78    }
79  }
80