Example usage for java.lang Number Number

List of usage examples for java.lang Number Number

Introduction

In this page you can find the example usage for java.lang Number Number.

Prototype

public Number() 

Source Link

Document

Constructor for subclasses to call.

Usage

From source file:org.apache.coheigea.cxf.kerberos.jaxrs.JAXRSAuthenticationTest.java

@org.junit.Test
public void testKerberos() throws Exception {

    URL busFile = JAXRSAuthenticationTest.class.getResource("cxf-client.xml");

    String address = "https://localhost:" + PORT + "/doubleit/services";
    WebClient client = WebClient.create(address, busFile.toString());
    client = client.type("application/xml");

    Map<String, Object> requestContext = WebClient.getConfig(client).getRequestContext();
    requestContext.put("auth.spnego.useKerberosOid", "true");

    SpnegoAuthSupplier authSupplier = new SpnegoAuthSupplier();
    authSupplier.setServicePrincipalName("bob@service.ws.apache.org");
    authSupplier.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE);
    WebClient.getConfig(client).getHttpConduit().setAuthSupplier(authSupplier);

    Number numberToDouble = new Number();
    numberToDouble.setDescription("This is the number to double");
    numberToDouble.setNumber(25);/*from   ww w .  j  a va2  s .  c o  m*/

    Response response = client.post(numberToDouble);
    Assert.assertEquals(response.getStatus(), 200);
    Assert.assertEquals(response.readEntity(Number.class).getNumber(), 50);
}

From source file:org.richfaces.tests.metamer.ftest.AbstractWebDriverTest.java

public static <T extends Number & Comparable<T>> Number countMedian(List<T> values) {
    assertTrue(values.size() > 0);/*from   ww w  .  jav a  2  s  .  c o m*/
    if (values.size() == 1) {
        return values.get(0);
    }

    final List<T> copy = Lists.newArrayList(values);
    Collections.sort(copy);

    int middleIndex = (copy.size() - 1) / 2;

    double result = copy.get(middleIndex).doubleValue();
    if (copy.size() % 2 == 0) {
        result = (result + copy.get(middleIndex + 1).doubleValue()) / 2.0;
    }
    final Double median = Double.valueOf(result);
    return new Number() {
        private static final long serialVersionUID = 1L;

        @Override
        public int intValue() {
            return median.intValue();
        }

        @Override
        public long longValue() {
            return median.longValue();
        }

        @Override
        public float floatValue() {
            return median.floatValue();

        }

        @Override
        public double doubleValue() {
            return median.doubleValue();

        }

        @Override
        public String toString() {
            return median.doubleValue() + " from values(sorted) " + copy.toString() + '.';
        }
    };
}