use of org.testng.annotations.BeforeClass in project OpenAM by OpenRock.
the class SetApplicationTest method setup.
@BeforeClass
@Override
public void setup() throws Exception {
super.setup();
Application appl = ApplicationManager.newApplication("/", APPL_NAME, ApplicationTypeManager.getAppplicationType(adminSubject, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
Map<String, Boolean> actions = new HashMap<String, Boolean>();
actions.put("GET", true);
appl.setActions(actions);
appl.setEntitlementCombiner(DenyOverride.class);
ApplicationManager.saveApplication(adminSubject, "/", appl);
}
use of org.testng.annotations.BeforeClass in project OpenAM by OpenRock.
the class MultipleResourceRestTest method setup.
@BeforeClass
public void setup() throws Exception {
PrivilegeManager pm = PrivilegeManager.getInstance(REALM, adminSubject);
{
Privilege privilege = Privilege.getNewInstance();
privilege.setName(PRIVILEGE_NAME + "1");
Map<String, Boolean> actions = new HashMap<String, Boolean>();
actions.put("GET", true);
Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
privilege.setEntitlement(entitlement);
EntitlementSubject sbj = new AuthenticatedUsers();
privilege.setSubject(sbj);
pm.add(privilege);
}
{
Privilege privilege = Privilege.getNewInstance();
privilege.setName(PRIVILEGE_NAME + "2");
Map<String, Boolean> actions = new HashMap<String, Boolean>();
actions.put("GET", false);
Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/index.html", actions);
privilege.setEntitlement(entitlement);
EntitlementSubject sbj = new AuthenticatedUsers();
privilege.setSubject(sbj);
pm.add(privilege);
}
String tokenId = adminToken.getTokenID().toString();
hashedTokenId = Hash.hash(tokenId);
tokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + tokenId;
String cookieValue = tokenId;
if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
cookieValue = URLEncoder.encode(tokenId, "UTF-8");
}
cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
user = IdRepoUtils.createUser(REALM, "MultipleResourceRestTestUser");
decisionsClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/decisions");
entitlementsClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/entitlements");
}
use of org.testng.annotations.BeforeClass in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method loadEthalonAnnotations.
@BeforeClass
private void loadEthalonAnnotations() throws IOException {
myPluginRoot = new File(PluginPathManager.getPluginHomePath(HgVcs.VCS_NAME));
myAnnotateDataDir = new File(myPluginRoot, "testData/annotate");
myOutputsDir = new File(myAnnotateDataDir, "outputs");
final File etalonFile = new File(myAnnotateDataDir, "etalon");
XStream xStream = new XStream();
FileReader reader = new FileReader(etalonFile);
try {
myAnnotations = (List<HgAnnotationLine>) xStream.fromXML(reader);
} finally {
reader.close();
}
}
use of org.testng.annotations.BeforeClass in project async-http-client by AsyncHttpClient.
the class MultipleHeaderTest method setUpGlobal.
@BeforeClass
public void setUpGlobal() throws Exception {
serverSocket = ServerSocketFactory.getDefault().createServerSocket(0);
port1 = serverSocket.getLocalPort();
executorService = Executors.newFixedThreadPool(1);
voidFuture = executorService.submit(new Callable<Void>() {
public Void call() throws Exception {
Socket socket;
while ((socket = serverSocket.accept()) != null) {
InputStream inputStream = socket.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String req = reader.readLine().split(" ")[1];
int i = inputStream.available();
long l = inputStream.skip(i);
assertEquals(l, i);
socket.shutdownInput();
if (req.endsWith("MultiEnt")) {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(socket.getOutputStream());
outputStreamWriter.append("HTTP/1.0 200 OK\n" + "Connection: close\n" + "Content-Type: text/plain; charset=iso-8859-1\n" + "Content-Length: 2\n" + "Content-Length: 1\n" + "\n0\n");
outputStreamWriter.flush();
socket.shutdownOutput();
} else if (req.endsWith("MultiOther")) {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(socket.getOutputStream());
outputStreamWriter.append("HTTP/1.0 200 OK\n" + "Connection: close\n" + "Content-Type: text/plain; charset=iso-8859-1\n" + "Content-Length: 1\n" + "X-Forwarded-For: abc\n" + "X-Forwarded-For: def\n" + "\n0\n");
outputStreamWriter.flush();
socket.shutdownOutput();
}
}
return null;
}
});
}
use of org.testng.annotations.BeforeClass in project async-http-client by AsyncHttpClient.
the class AbstractBasicHttpsTest method setUpGlobal.
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
server = new Server();
ServerConnector connector = addHttpConnector(server);
server.setHandler(configureHandler());
server.start();
port1 = connector.getLocalPort();
logger.info("Local HTTP server started successfully");
}
Aggregations