org.testng.annotations.BeforeSuite#org.testng.annotations.BeforeTest源码实例Demo

下面列出了org.testng.annotations.BeforeSuite#org.testng.annotations.BeforeTest 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: oneops   文件: AzureServiceBusTest.java
@BeforeTest
public void before() throws Exception {

    Environment environment= mock(Environment.class);
    when(environment.getProperty("AzureSvcBusConnString", "")).thenReturn("amqpwss://localhost:444");
    when(environment.getProperty("AzureSvcBusSasKeyName", "")).thenReturn("TESTsasKeyName");
    when(environment.getProperty("AzureSvcBusSasKey", "")).thenReturn("TESTsasKey");
    when(environment.getProperty("AzureSvcBusMonitoringQueue", "")).thenReturn("TESTQUEUE_NAME");
    azureServiceBus.setEnvironment(environment);

	azureServiceBus.setAzureServiceBusEventsListner(azureServiceBusEventsListner);
	ReflectionTestUtils.setField(azureServiceBus, "isAzureServiceBusIntegrationEnabled", true, boolean.class);
	

	org.apache.qpid.jms.JmsConnection azureServiceBusConnection = mock(org.apache.qpid.jms.JmsConnection.class, Mockito.RETURNS_DEEP_STUBS);
	org.apache.qpid.jms.JmsSession azureServiceBusReceiveSession= mock(org.apache.qpid.jms.JmsSession.class, Mockito.RETURNS_DEEP_STUBS);
	org.apache.qpid.jms.JmsMessageConsumer azureServiceBusReceiver=mock(org.apache.qpid.jms.JmsMessageConsumer.class, Mockito.RETURNS_DEEP_STUBS);
	
	azureServiceBus.setAzureServiceBusConnection(azureServiceBusConnection);
	azureServiceBus.setAzureServiceBusReceiveSession(azureServiceBusReceiveSession);
	azureServiceBus.setAzureServiceBusReceiver(azureServiceBusReceiver);


}
 
源代码2 项目: openjdk-jdk9   文件: CacheTest.java
@BeforeTest
public void compileTestModules() throws Exception {

    for (String mn : new String[] {MAIN_BUNDLES_MODULE, TEST_MODULE}) {
        boolean compiled =
            CompilerUtils.compile(SRC_DIR.resolve(mn),
                                  MODS_DIR.resolve(mn),
                        "--module-path", MODS_DIR.toString());
        assertTrue(compiled, "module " + mn + " did not compile");
    }

    Path res = Paths.get("jdk", "test", "resources", "MyResources.properties");
    Path dest = MODS_DIR.resolve(MAIN_BUNDLES_MODULE).resolve(res);
    Files.createDirectories(dest.getParent());
    Files.copy(SRC_DIR.resolve(MAIN_BUNDLES_MODULE).resolve(res), dest);
}
 
@BeforeTest(alwaysRun = true)
public void init() throws Exception {
    super.init();

    wireMonitorServer = new WireMonitorServer(6780);
    wireMonitorServer.start();
    File sourceFile = new File(
            getESBResourceLocation() + File.separator + "passthru" + File.separator + "transport" + File.separator
                    + "ESBJAVA4931" + File.separator + "sample_proxy_3.wsdl");
    File targetFile = new File(
            System.getProperty(ServerConstants.CARBON_HOME) + File.separator + "samples" + File.separator
                    + "service-bus" + File.separator + "resources" + File.separator + "proxy" + File.separator
                    + "sample_proxy_3.wsdl");
    FileUtils.copyFile(sourceFile, targetFile);
    verifyProxyServiceExistence("PreserveContentTypeHeaderCharSetTestProxy");
}
 
源代码4 项目: openjdk-jdk9   文件: AddExportsTestWarningError.java
@BeforeTest
public void setup() throws Exception {
    ModuleInfoMaker builder = new ModuleInfoMaker(SRC_DIR);
    builder.writeJavaFiles("m1",
        "module m1 { }",
        "package p1; public class C1 { " +
            "    public static void main(String... args) {}" +
            "}");

    builder.writeJavaFiles("m2",
        "module m2 { requires m1; exports p2; }",
        "package p2; public class C2 {  private p1.C1 c1; }");

    builder.writeJavaFiles("m3",
        "module m3 { requires m2; }",
        "package p3; class C3 { " +
            "    p1.C1 c; " +
            "    public static void main(String... args) { new p2.C2(); }" +
            "}");

    builder.compile("m1", MODS_DIR);
    builder.compile("m2", MODS_DIR, "--add-exports", "m1/p1=m2");
    builder.compile("m3", MODS_DIR, "--add-exports", "m1/p1=m3");
}
 
源代码5 项目: openjdk-jdk9   文件: DryRunTest.java
@BeforeTest
public void compileTestModule() throws Exception {

    // javac -d mods/$TESTMODULE src/$TESTMODULE/**
    assertTrue(CompilerUtils.compile(SRC_DIR.resolve(M_MODULE),
                                     MODS_DIR,
                                     "--module-source-path", SRC_DIR.toString()));

    assertTrue(CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
                                     MODS_DIR,
                                     "--module-source-path", SRC_DIR.toString()));

    Files.createDirectories(LIBS_DIR);

    // create JAR files with no module-info.class
    assertTrue(jar(M_MODULE, "p/Lib.class") == 0);
    assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0);
}
 
@BeforeTest
public void setUp() throws Exception {


    String USERNAME = "benehmke";
    String AUTOMATE_KEY = "RzA1hJpssWs1i4NcxRxR";
    String URL = "https://" + USERNAME + ":"
            + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";

    // Set the desired capabilities for iPhone X
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "iPhone");
    caps.setCapability("device", "iPhone X");
    caps.setCapability("realMobile", "true");
    caps.setCapability("os_version", "11.0");

    driver = new RemoteWebDriver(new URL(URL), caps);

    driver.get("http://demo-store.seleniumacademy.com/");
}
 
源代码7 项目: openjdk-jdk9   文件: ListModuleDeps.java
/**
 * Compiles classes used by the test
 */
@BeforeTest
public void compileAll() throws Exception {
    // compile library
    assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "lib"), LIB_DIR));

    // simple program depends only on java.base
    assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "hi"), CLASSES_DIR));

    // compile classes in unnamed module
    assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "z"),
        CLASSES_DIR,
        "-cp", LIB_DIR.toString(),
        "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
        "--add-exports=java.base/sun.security.util=ALL-UNNAMED",
        "--add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED"
    ));
}
 
源代码8 项目: samples   文件: WebTestIOS.java
@BeforeTest
@Override
public void Setup() throws Exception {
    super.Setup();

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("sessionName", "IOS Web Test");
    capabilities.setCapability("sessionDescription", "Kobiton sample session");
    capabilities.setCapability("deviceOrientation", "portrait");
    capabilities.setCapability("captureScreenshots", true);
    capabilities.setCapability("browserName", "safari");
    capabilities.setCapability("deviceName", "iPhone 6");
    capabilities.setCapability("platformName", "iOS");

    driver = new RemoteWebDriver(getAutomationUrl(), capabilities);
}
 
源代码9 项目: quarkus   文件: QuarkusTestNgCallbacks.java
static void invokeTestNgBeforeMethods(Object testInstance)
        throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException {
    if (testInstance != null) {
        List<Method> beforeMethods = new ArrayList<>();
        collectCallbacks(testInstance.getClass(), beforeMethods, (Class<? extends Annotation>) testInstance.getClass()
                .getClassLoader().loadClass(BeforeMethod.class.getName()));
        collectCallbacks(testInstance.getClass(), beforeMethods, (Class<? extends Annotation>) testInstance.getClass()
                .getClassLoader().loadClass(BeforeTest.class.getName()));
        for (Method m : beforeMethods) {
            // we don't know the values for parameterized methods that TestNG allows, we just skip those
            if (m.getParameterCount() == 0) {
                m.setAccessible(true);
                m.invoke(testInstance);
            }
        }
    }
}
 
源代码10 项目: openjdk-jdk9   文件: AddModsTest.java
@BeforeTest
public void compile() throws Exception {
    // javac -d mods1/test src/test/**
    boolean compiled = CompilerUtils.compile(
        SRC_DIR.resolve(TEST_MODULE),
        MODS1_DIR.resolve(TEST_MODULE)
    );
    assertTrue(compiled, "test did not compile");

    // javac -d mods1/logger src/logger/**
    compiled= CompilerUtils.compile(
        SRC_DIR.resolve(LOGGER_MODULE),
        MODS2_DIR.resolve(LOGGER_MODULE)
    );
    assertTrue(compiled, "test did not compile");
}
 
源代码11 项目: samples   文件: AppTestIOS.java
@BeforeTest
@Override
public void Setup() throws Exception {
    super.Setup();

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("sessionName", "iOS App Test");
    capabilities.setCapability("sessionDescription", "Kobiton sample session");
    capabilities.setCapability("deviceOrientation", "portrait");
    capabilities.setCapability("captureScreenshots", true);
    capabilities.setCapability("app", "https://s3-ap-southeast-1.amazonaws.com/kobiton-devvn/apps-test/demo/iFixit.ipa");
    capabilities.setCapability("deviceName", "iPhone 6s");
    capabilities.setCapability("platformName", "iOS");

    driver = new IOSDriver<>(getAutomationUrl(), capabilities);
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
 
源代码12 项目: openjdk-jdk9   文件: AccessTest.java
/**
 * Compiles all modules used by the test
 */
@BeforeTest
public void compileAll() throws Exception {
    for (String mn : modules) {
        Path src = SRC_DIR.resolve(mn);
        Path mods = MODS_DIR.resolve(mn);
        assertTrue(CompilerUtils.compile(src, mods));
    }
}
 
源代码13 项目: heat   文件: SingleMode.java
/**
 * Method that takes tests parameters and sets some environment properties.
 * @param inputJsonParamPath path of the json input file with input data for tests
 * @param enabledEnvironments environments enabled for the specific suite
 * @param context testNG context
 */
@BeforeTest
@Override
@Parameters({INPUT_JSON_PATH, ENABLED_ENVIRONMENTS})
public void beforeTestCase(String inputJsonParamPath,
                           String enabledEnvironments,
                           ITestContext context) {
    super.beforeTestCase(inputJsonParamPath, enabledEnvironments, context);
    this.webappName = TestSuiteHandler.getInstance().getWebappName();
    this.webappPath = TestSuiteHandler.getInstance().getEnvironmentHandler().getEnvironmentUrl(webappName);
}
 
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@BeforeTest(alwaysRun = true)
public void deployServices() throws IOException, LoginAuthenticationExceptionException, ExceptionException {

    axis2Server1 = new SampleAxis2Server("test_axis2_server_9009.xml");
    axis2Server1.start();
    axis2Server1.deployService(serviceNames[0]);
    axis2Server1.deployService(serviceNames[1]);
    axis2Server1.deployService(serviceNames[2]);

}
 
@BeforeTest(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    loadESBConfigurationFromClasspath("/artifacts/ESB/jaxrs/jsonHTTPGetProxy.xml");
    tomcatServerManager = new TomcatServerManager(MusicConfig.class.getName(), "jaxrs", 8080);
    tomcatServerManager.startServer();
}
 
@BeforeTest(alwaysRun = true)
public void setEnvironment() throws Exception {

    super.init();
    serviceUrl = context.getContextUrls().getServiceUrl() + "/jsonproducer/";
    jsonClient = new JSONClient();
}
 
源代码17 项目: micro-integrator   文件: NhttpBaseTestCase.java
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@BeforeTest(alwaysRun = true)
public void startJMSBrokerAndConfigureESB() throws Exception {
    super.init();
    serverConfigurationManager = new ServerConfigurationManager(
            new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
    serverConfigurationManager
            .applyMIConfiguration(Paths.get(getESBResourceLocation(), "nhttp", "transport", "axis2.xml").toFile());
    serverConfigurationManager.applyMIConfigurationWithRestart(new File(
            getESBResourceLocation() + File.separator + "nhttp" + File.separator + "transport" + File.separator
                    + "json" + File.separator + "deployment.toml"));

}
 
源代码18 项目: openjdk-jdk9   文件: BasicTest.java
@BeforeTest
public void compileTestModule() throws Exception {

    // javac -d mods/$TESTMODULE src/$TESTMODULE/**
    boolean compiled
        = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
                                MODS_DIR.resolve(TEST_MODULE));

    assertTrue(compiled, "test module did not compile");
}
 
源代码19 项目: openjdk-jdk9   文件: SplitPackage.java
@BeforeTest
private void setup() throws Exception {
    Files.createDirectory(BAR_DIR);

    Path pkgDir = Paths.get("p");
    // compile classes in package p
    assertTrue(CompilerUtils.compile(SRC_DIR.resolve(pkgDir), BAR_DIR));

    // move p.Foo to a different directory
    Path foo = pkgDir.resolve("Foo.class");
    Files.createDirectories(FOO_DIR.resolve(pkgDir));
    Files.move(BAR_DIR.resolve(foo), FOO_DIR.resolve(foo),
               StandardCopyOption.REPLACE_EXISTING);
}
 
@BeforeTest(alwaysRun = true)
public void addNonAdminUser() throws Exception {
    AutomationContext esbContext = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);
    String sessionCookie = new LoginLogoutClient(esbContext).login();
    ResourceAdminServiceClient resourceAdmin = new ResourceAdminServiceClient(
            esbContext.getContextUrls().getBackEndUrl(), sessionCookie);
    UserManagementClient userManagementClient = new UserManagementClient(
            esbContext.getContextUrls().getBackEndUrl(), sessionCookie);

    //done this change due to a bug in UM - please refer to carbon dev mail
    // "G-Reg integration test failures due to user mgt issue."
    String[] permissions = { "/permission/admin/configure/", "/permission/admin/login", "/permission/admin/manage/",
            "/permission/admin/monitor", "/permission/protected" };

    if (!userManagementClient.roleNameExists(ROLE_NAME)) {
        userManagementClient.addRole(ROLE_NAME, null, permissions);
        resourceAdmin.addResourcePermission("/", ROLE_NAME, "3", "1");
        resourceAdmin.addResourcePermission("/", ROLE_NAME, "2", "1");
        resourceAdmin.addResourcePermission("/", ROLE_NAME, "4", "1");
        resourceAdmin.addResourcePermission("/", ROLE_NAME, "5", "1");
    }

    userManagementClient.addUser("nonadminuser", "password", new String[] { ROLE_NAME }, null);
    //check user creation
    nonAdminUser = new User();
    nonAdminUser.setUserName("nonadminuser");
    nonAdminUser.setPassword("password");

}
 
源代码21 项目: morpheus-core   文件: ArrayIOTests.java
@BeforeTest
public void deleteFiles() {
    if (directory.exists() && directory.isDirectory()) {
        final File[] files = directory.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile() && file.getName().endsWith(".ser")) {
                    if (file.delete()) {
                        System.out.println("Deleted file " + file.getAbsolutePath());
                    }
                }
            }
        }
    }
}
 
源代码22 项目: strongbox   文件: AWSConfigTest.java
@BeforeTest
public void setup() {
    AWSCLIConfigFile.Section section = new AWSCLIConfigFile.Section(profile.name);
    section.addProperty(mfa_serial);
    section.addProperty(source_profile);
    section.addProperty(role_arn);
    section.addProperty(aws_access_key_id);
    section.addProperty(aws_secret_access_key);

    Map<String, AWSCLIConfigFile.Section> sectionMap = new HashMap<>();
    sectionMap.put(profile.name, section);

    config = new AWSConfig(new AWSCLIConfigFile.Config(sectionMap));
}
 
源代码23 项目: openjdk-jdk9   文件: OverlappingPackagesTest.java
/**
 * Compiles all modules used by the test
 */
@BeforeTest
public void compileAll() throws Exception {
    for (String mn : modules) {
        Path src = SRC_DIR.resolve(mn);
        Path mods = MODS_DIR.resolve(mn);
        assertTrue(CompilerUtils.compile(src, mods));
    }
    Path srcMisc = SRC_DIR.resolve("misc");
    Path modsMisc = MODS_DIR.resolve("misc");
    assertTrue(CompilerUtils.compile(srcMisc, modsMisc));
}
 
源代码24 项目: openjdk-jdk9   文件: CompiledVersionTest.java
@BeforeTest
public void compileAll() throws Throwable {
    if (!hasJmods()) return;

    for (int i=0; i < modules.length; i++) {
        String mn = modules[i];
        String version = versions[i];
        Path msrc = SRC_DIR.resolve(mn);
        if (version.equals("0")) {
            assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
                "--add-exports", "java.base/jdk.internal.module=m1",
                "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1",
                "--module-source-path", SRC_DIR.toString()));
        } else {
            assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
                "--add-exports", "java.base/jdk.internal.module=m1",
                "--add-exports", "java.base/jdk.internal.org.objectweb.asm=m1",
                "--module-source-path", SRC_DIR.toString(),
                "--module-version", version));
        }
    }

    if (Files.exists(IMAGE)) {
        FileUtils.deleteFileTreeUnchecked(IMAGE);
    }

    createImage(IMAGE, modules);
}
 
源代码25 项目: openjdk-jdk9   文件: RequestBodyTest.java
@BeforeTest
public void setup() throws Exception {
    LightWeightHttpServer.initServer();
    httpURI = LightWeightHttpServer.httproot + "echo/foo";
    httpsURI = LightWeightHttpServer.httpsroot + "echo/foo";

    SSLContext ctx = LightWeightHttpServer.ctx;
    client = HttpClient.newBuilder()
                       .sslContext(ctx)
                       .version(HttpClient.Version.HTTP_1_1)
                       .followRedirects(HttpClient.Redirect.ALWAYS)
                       .executor(exec)
                       .build();
}
 
源代码26 项目: openjdk-jdk9   文件: PrivateLookupInTests.java
@BeforeTest
public void init() throws Exception {
    publicType = Class.forName("p.internal.PublicType");
    assertTrue(this.getClass().getModule() == publicType.getModule());
    assertNotEquals(this.getClass().getPackageName(), publicType.getPackageName());
    assertTrue(Modifier.isPublic(publicType.getModifiers()));

    nonPublicType = Class.forName("p.internal.NonPublicType");
    assertTrue(this.getClass().getModule() == nonPublicType.getModule());
    assertNotEquals(this.getClass().getPackageName(), nonPublicType.getPackageName());
    assertFalse(Modifier.isPublic(nonPublicType.getModifiers()));
}
 
源代码27 项目: TencentKona-8   文件: JaxbMarshallTest.java
@BeforeTest
public void setUp() throws IOException {
    // Create test directory inside scratch
    testWorkDir = Paths.get(System.getProperty("user.dir", "."));
    // Save its URL
    testWorkDirUrl = testWorkDir.toUri().toURL();
    // Get test source directory path
    testSrcDir = Paths.get(System.getProperty("test.src", "."));
    // Get path of xjc result folder
    xjcResultDir = testWorkDir.resolve(TEST_PACKAGE);
    // Copy schema document file to scratch directory
    Files.copy(testSrcDir.resolve(XSD_FILENAME), testWorkDir.resolve(XSD_FILENAME), REPLACE_EXISTING);
}
 
源代码28 项目: openjdk-jdk9   文件: AddReadsTestWarningError.java
@BeforeTest
public void setup() throws Exception {
    ModuleInfoMaker builder = new ModuleInfoMaker(SRC_DIR);
    builder.writeJavaFiles("m1",
        "module m1 { requires m4; }",
        "package p1; public class C1 { " +
        "    public static void main(String... args) {" +
        "        p2.C2 c2 = new p2.C2();" +
        "        p3.C3 c3 = new p3.C3();" +
        "    }" +
        "}"
    );

    builder.writeJavaFiles("m2",
        "module m2 { exports p2; }",
        "package p2; public class C2 { }"
    );

    builder.writeJavaFiles("m3",
        "module m3 { exports p3; }",
        "package p3; public class C3 { }"
    );

    builder.writeJavaFiles("m4",
        "module m4 { requires m2; requires m3; }",
        "package p4; public class C4 { " +
        "    public static void main(String... args) {}" +
        "}"
    );

    builder.compile("m2", MODS_DIR);
    builder.compile("m3", MODS_DIR);
    builder.compile("m4", MODS_DIR);
    builder.compile("m1", MODS_DIR, "--add-reads", "m1=m2,m3");
}
 
源代码29 项目: openjdk-jdk9   文件: TestPermission.java
/**
 * Compiles all modules used by the test
 */
@BeforeTest
public void compileAll() throws Exception {
    for (String mn : modules) {
        Path msrc = SRC_DIR.resolve(mn);
        assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
    }
}
 
源代码30 项目: atlas   文件: JanusGraphProviderTest.java
@BeforeTest
public void setUp() throws Exception {
    GraphSandboxUtil.create();

    //First get Instance
    graph         = new AtlasJanusGraph();
    configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), AtlasJanusGraphDatabase.GRAPH_PREFIX);
}