alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Apache CXF example source code file (InitParamResourceResolverTest.java)

This example Apache CXF source code file (InitParamResourceResolverTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Apache CXF tags/keywords

boolean_value, byte_value, double_value, float_value, int_value, short_value, string, string, string_value, string_value, t, t, test, test, util

The Apache CXF InitParamResourceResolverTest.java source code

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.cxf.jaxws.handler;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


public class InitParamResourceResolverTest extends Assert {

    public static final String STRING_PARAM = "stringParam";
    public static final String STRING_VALUE = "a string";
    public static final String INT_PARAM = "intParam";
    public static final String INT_VALUE = "42";
    public static final String FLOAT_PARAM = "floatParam";
    public static final String FLOAT_VALUE = Float.toString(Float.MAX_VALUE);
    public static final String CHAR_PARAM = "charParam";
    public static final String CHAR_VALUE = "a";
    public static final String BYTE_PARAM = "byteParam";
    public static final String BYTE_VALUE = Byte.toString(Byte.MAX_VALUE);
    public static final String SHORT_PARAM = "shortParam";
    public static final String SHORT_VALUE = "12";
    public static final String LONG_PARAM = "longParam";
    public static final String LONG_VALUE = Long.toString(Long.MAX_VALUE);
    public static final String DOUBLE_PARAM = "doubleParam";
    public static final String DOUBLE_VALUE = Double.toString(Double.MAX_VALUE);
    public static final String BOOLEAN_PARAM = "booleanParam"; 
    public static final String BOOLEAN_VALUE = "true";
        
    private Map<String, String> params = new HashMap();
    
    private InitParamResourceResolver resolver; 
    
    @Before
    public void setUp() {
        params.put(STRING_PARAM, STRING_VALUE);
        params.put(INT_PARAM, INT_VALUE);
        params.put(FLOAT_PARAM, FLOAT_VALUE);
        params.put(CHAR_PARAM, CHAR_VALUE);
        params.put(BYTE_PARAM, BYTE_VALUE);
        params.put(SHORT_PARAM, SHORT_VALUE);
        params.put(LONG_PARAM, LONG_VALUE);
        params.put(DOUBLE_PARAM, DOUBLE_VALUE);
        params.put(BOOLEAN_PARAM, BOOLEAN_VALUE);
        resolver = new InitParamResourceResolver(params);
    }
    
    /*
     char, byte, short, int, long, float, double, boolean
     */
    
    @Test
    public void testResolveChar() {
        doResolveTypeTest(CHAR_PARAM, Character.class, CHAR_VALUE.charAt(0));
    }
    
    @Test
    public void testResolveByte() {
        doResolveTypeTest(BYTE_PARAM, Byte.class, Byte.valueOf(BYTE_VALUE));
    }
    
    @Test
    public void testResolveShort() {
        doResolveTypeTest(SHORT_PARAM, Short.class, Short.valueOf(SHORT_VALUE));
    }
    
    @Test
    public void testResolveLong() {
        doResolveTypeTest(LONG_PARAM, Long.class, Long.valueOf(LONG_VALUE));
    }
    
    @Test
    public void testResolveFloat() {
        doResolveTypeTest(FLOAT_PARAM, Float.class, Float.valueOf(FLOAT_VALUE));
    }
    
    @Test
    public void testResolveDouble() {
        doResolveTypeTest(DOUBLE_PARAM, Double.class, Double.valueOf(DOUBLE_VALUE));
    }
    
    @Test
    public void tesResolveBoolean() {
        doResolveTypeTest(BOOLEAN_PARAM, Boolean.class, Boolean.valueOf(BOOLEAN_VALUE));
    }
    
    @Test
    public void testResolveInt() {        
        doResolveTypeTest(INT_PARAM, Integer.class, Integer.valueOf(INT_VALUE));
    }

    @Test
    public void testResolveString() {        
        String ret = resolver.resolve(STRING_PARAM, String.class);        
        assertEquals("incorrect string value returned", STRING_VALUE, ret);
    }

    private <T> void doResolveTypeTest(String param, Class type, T expectedValue) {
        T ret = resolver.resolve(param, type);        
        assertEquals("incorrect string value returned", expectedValue, ret);      
    }
    
}

Other Apache CXF examples (source code examples)

Here is a short list of links related to this Apache CXF InitParamResourceResolverTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.