/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: RestTest.java,v 1.3 2009/11/24 23:08:35 veiming Exp $
*
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* Portions copyright 2014 ForgeRock AS.
*/
/**
* To Test REST interface
* @author Ravi Hingarajiya <ravi.hingarajiya@sun.com>
*/
public class RestTest {
try {
actions);
if (Boolean.parseBoolean(
}
"/ws/1/entitlement/decision");
"/ws/1/entitlement/decisions");
"/ws/1/entitlement/entitlement");
"/ws/1/entitlement/entitlements");
} catch (Exception e) {
throw e;
}
}
}
@Test
throw new Exception("RESTTest.getDecisionTest() failed");
}
}
@Test
.accept("application/json")
throw new Exception(
"RESTTest.getDecisionsTest() failed, status code not 200");
}
throw new Exception(
"RESTTest.getDecisionsTest() failed, body element is null");
}
throw new Exception(
"RESTTest.getDecisionsTest() failed, results array is null");
}
throw new Exception(
"RESTTest.getDecisionsTest() failed, results array is empty");
}
if (!result) {
throw new Exception("RESTTest.getDecisionsTest() failed");
}
}
@Test
.accept("application/json")
throw new Exception(
"RESTTest.getEntitlementTest() failed, status code not 200");
}
throw new Exception(
"RESTTest.getEntitlementTest() failed, body element is null");
}
if (!result) {
throw new Exception("RESTTest.getEntitlementTest() failed");
}
}
@Test
.accept("application/json")
throw new Exception(
"RESTTest.getEntitlementsTest: failed, status code not 200");
}
throw new Exception(
"RESTTest.getEntitlementsTest: failed, body element is null");
}
throw new Exception(
"RESTTest.getEntitlementsTest: failed, results element is null");
}
throw new Exception(
"RESTTest.getEntitlementsTest: failed, results array is empty");
}
// dude, there are two entitlements returned.
// the first one is the root resource which is http://www.resttest.com
// and the action value is empty.
// we need to get the second one, which is http://www.resttest.com:80/*
throw new Exception(
"RESTTest.getEntitlementsTest: failed, action value is false");
}
} else {
throw new Exception(
"RESTTest.getEntitlementsTest: failed, action value is null");
}
}
@Test
throw new Exception("RESTTest.negativeTest (/decision) failed");
}
.accept("application/json")
throw new Exception("RESTTest.negativeTest() failed, status code not 200");
}
throw new Exception("RESTTest.negativeTest() failed, body element is null");
}
boolean result = false;
}
if (result) {
throw new Exception("RESTTest.getnegativeTest() failed");
}
NumericAttributeCondition.class.getName());
throw new Exception("RESTTest.negativeTest: no advice");
}
throw new Exception("RESTTest.negativeTest: incorrect advice");
}
}
@Test
try {
.accept("application/json")
throw new Exception(
"RESTTest.missingResourceTest: no exception thrown.");
} catch (UniformInterfaceException e) {
if (errorCode != 400) {
throw new Exception(
"RESTTest.missingResourceTest: incorrect error code");
}
throw new Exception(
"RESTTest.missingResourceTest() failed, status code not 420");
}
throw new Exception(
"RESTTest.missingResourceTest() failed, body not empty");
}
}
}
@Test
try {
.accept("application/json")
throw new Exception(
"RESTTest.missingResourceTest: no exception thrown.");
} catch (UniformInterfaceException e) {
if (errorCode != 400) {
throw new Exception(
"RESTTest.missingResourceTest: incorrect error code");
}
throw new Exception(
"RESTTest.missingResourcesTest() failed, status code not 424");
}
throw new Exception(
"RESTTest.missingResourcesTest() failed, body not empty");
}
}
}
@Test
try {
throw new Exception(
"RESTTest.missingActionTest: no exception thrown.");
} catch (UniformInterfaceException e) {
if (errorCode != 400) {
throw new Exception(
"RESTTest.missingActionTest: incorrect error code");
}
}
}
}