Search in sources :

Example 41 with BeforeClass

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);
}
Also used : HashMap(java.util.HashMap) Application(com.sun.identity.entitlement.Application) BeforeClass(org.testng.annotations.BeforeClass) DenyOverride(com.sun.identity.entitlement.DenyOverride)

Example 42 with BeforeClass

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");
}
Also used : EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) Cookie(javax.ws.rs.core.Cookie) AuthenticatedUsers(org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers) PrivilegeManager(com.sun.identity.entitlement.PrivilegeManager) Privilege(com.sun.identity.entitlement.Privilege) JSONEntitlement(com.sun.identity.entitlement.JSONEntitlement) Entitlement(com.sun.identity.entitlement.Entitlement) HashMap(java.util.HashMap) Map(java.util.Map) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) BeforeClass(org.testng.annotations.BeforeClass)

Example 43 with BeforeClass

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();
    }
}
Also used : HgAnnotationLine(org.zmlx.hg4idea.provider.annotate.HgAnnotationLine) XStream(com.thoughtworks.xstream.XStream) FileReader(java.io.FileReader) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Example 44 with BeforeClass

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;
        }
    });
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) OutputStreamWriter(java.io.OutputStreamWriter) Callable(java.util.concurrent.Callable) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket) BeforeClass(org.testng.annotations.BeforeClass)

Example 45 with BeforeClass

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");
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

BeforeClass (org.testng.annotations.BeforeClass)1186 Series (com.axibase.tsd.api.model.series.Series)178 File (java.io.File)157 ArrayList (java.util.ArrayList)78 HashMap (java.util.HashMap)43 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)37 Injector (com.google.inject.Injector)36 Properties (java.util.Properties)35 Path (org.apache.hadoop.fs.Path)33 ClusterSetup (org.apache.helix.tools.ClusterSetup)33 Configuration (org.apache.hadoop.conf.Configuration)31 BigDecimal (java.math.BigDecimal)29 URL (java.net.URL)28 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)27 Date (java.util.Date)26 Server (org.eclipse.jetty.server.Server)25 ServerConnector (org.eclipse.jetty.server.ServerConnector)25 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)23 IOException (java.io.IOException)23 Path (java.nio.file.Path)23