org.testng.annotations.BeforeTest Java Examples

The following examples show how to use org.testng.annotations.BeforeTest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ESBJAVA4931PreserveContentTypeHeaderCharSetTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@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");
}
 
Example #2
Source File: CacheTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: AzureServiceBusTest.java    From oneops with Apache License 2.0 6 votes vote down vote up
@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);


}
 
Example #4
Source File: AppTestIOS.java    From samples with MIT License 6 votes vote down vote up
@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);
}
 
Example #5
Source File: AddModsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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");
}
 
Example #6
Source File: QuarkusTestNgCallbacks.java    From quarkus with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example #7
Source File: AddExportsTestWarningError.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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");
}
 
Example #8
Source File: WebTestIOS.java    From samples with MIT License 6 votes vote down vote up
@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);
}
 
Example #9
Source File: ListModuleDeps.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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"
    ));
}
 
Example #10
Source File: SearchTest.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 6 votes vote down vote up
@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/");
}
 
Example #11
Source File: DryRunTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #12
Source File: FastDeserializerDefaultsTest.java    From avro-util with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@BeforeTest(groups = {"deserializationTest"})
public void prepare() throws Exception {
  Path tempPath = Files.createTempDirectory("generated");
  tempDir = tempPath.toFile();

  classLoader = URLClassLoader.newInstance(new URL[]{tempDir.toURI().toURL()},
      FastDeserializerDefaultsTest.class.getClassLoader());
}
 
Example #13
Source File: FastSpecificSerializerGeneratorTest.java    From avro-util with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@BeforeTest(groups = {"serializationTest"})
public void prepare() throws Exception {
  Path tempPath = Files.createTempDirectory("generated");
  tempDir = tempPath.toFile();

  classLoader = URLClassLoader.newInstance(new URL[]{tempDir.toURI().toURL()},
      FastSpecificSerializerGeneratorTest.class.getClassLoader());
}
 
Example #14
Source File: ArrayPropertyValueTest.java    From egeria with Apache License 2.0 5 votes vote down vote up
@BeforeTest
private void setObject() {
    ArrayPropertyValue arrayPropertyValue = new ArrayPropertyValue();
    arrayPropertyValue.setArrayCount(100);
    arrayPropertyValue.setTypeGUID(typeGUID);
    arrayPropertyValue.setTypeGUID(typeName);

    InstancePropertyValue propertyValueMock = new InstancePropertyValueMock();
    propertyValueMock.setTypeGUID(typeGUID);
    propertyValueMock.setTypeName(typeName);
    propertyValueMock.setInstancePropertyCategory(category);
    arrayPropertyValue.setArrayValue(0, propertyValueMock);

    InstancePropertyValue propertyValueMock1 = new InstancePropertyValueMock();
    propertyValueMock1.setTypeGUID(typeGUID);
    propertyValueMock1.setTypeName(typeName);
    propertyValueMock1.setInstancePropertyCategory(category);
    arrayPropertyValue.setArrayValue(17, propertyValueMock1);

    InstancePropertyValue propertyValueMock2 = new InstancePropertyValueMock();
    propertyValueMock2.setTypeGUID(typeGUID);
    propertyValueMock2.setTypeName(typeName);
    propertyValueMock2.setInstancePropertyCategory(category);
    arrayPropertyValue.setArrayValue(88, propertyValueMock2);

    this.arrayPropertyValue = arrayPropertyValue;
}
 
Example #15
Source File: JaasModularDefaultHandlerTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pre-compile and generate the artifacts required to run this test before
 * running each test cases.
 */
@BeforeTest
public void buildArtifacts() {

    boolean done = true;
    try {
        done = CompilerUtils.compile(S_SRC, S_BUILD_DIR);
        // Generate modular/regular handler jars.
        generateJar(true, MODULE_TYPE.EXPLICIT, MS_JAR, S_BUILD_DIR, false);
        generateJar(true, MODULE_TYPE.UNNAMED, S_JAR, S_BUILD_DIR, false);
        // Compile client source codes.
        done &= CompilerUtils.compile(C_SRC, C_BLD_DIR);
        done &= CompilerUtils.compile(CL_SRC, C_BLD_DIR);
        // Generate modular client jar with explicit dependency
        generateJar(false, MODULE_TYPE.EXPLICIT, MC_JAR, C_BLD_DIR, true);
        // Generate modular client jar without any dependency
        generateJar(false, MODULE_TYPE.EXPLICIT, MCN_JAR, C_BLD_DIR, false);
        // Generate regular client jar
        generateJar(false, MODULE_TYPE.UNNAMED, C_JAR, C_BLD_DIR, false);
        System.out.format("%nArtifacts generated successfully? %s", done);
        if (!done) {
            throw new RuntimeException("Artifact generation failed");
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #16
Source File: CustomInvokeWithJsonPProviderTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void setupClient() throws Exception {
    SmallRyeConfig config = ConfigUtils.configBuilder(true).build();
    QuarkusConfigFactory.setConfig(config);
    ConfigProviderResolver cpr = ConfigProviderResolver.instance();
    try {
        Config old = cpr.getConfig();
        if (old != config) {
            cpr.releaseConfig(old);
        }
    } catch (IllegalStateException ignored) {
    }
    super.setupClient();
}
 
Example #17
Source File: SuggestProviders.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeTest
public void compileAll() throws Throwable {
    if (!hasJmods()) return;

    for (String mn : modules) {
        Path msrc = SRC_DIR.resolve(mn);
        assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
            "--module-source-path", SRC_DIR.toString()));
    }
}
 
Example #18
Source File: JavaClassPathTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeTest
public void setup() throws Exception {
    boolean compiled = CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE),
                                             MODS_DIR.resolve(TEST_MODULE));
    assertTrue(compiled, "module " + TEST_MODULE + " did not compile");

    // add the class and a resource to the current working directory
    Path file = Paths.get("jdk/test/Main.class");
    Files.createDirectories(file.getParent());
    Files.copy(MODS_DIR.resolve(TEST_MODULE).resolve(file), file);

    Path res = Paths.get("jdk/test/res.properties");
    Files.createFile(res);

    ToolProvider jartool = ToolProvider.findFirst("jar").orElseThrow(
        () -> new RuntimeException("jar tool not found")
    );

    Path jarfile = LIB_DIR.resolve("m.jar");
    Files.createDirectories(LIB_DIR);
    assertTrue(jartool.run(System.out, System.err, "cfe",
                           jarfile.toString(), TEST_MAIN,
                           file.toString()) == 0);

    Path manifest = LIB_DIR.resolve("manifest");
    try (BufferedWriter writer = Files.newBufferedWriter(manifest)) {
        writer.write("CLASS-PATH: lib/m.jar");
    }
    jarfile = LIB_DIR.resolve("m1.jar");
    assertTrue(jartool.run(System.out, System.err, "cfme",
                           jarfile.toString(), manifest.toString(), TEST_MAIN,
                           file.toString()) == 0);
}
 
Example #19
Source File: JaxbMarshallTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #20
Source File: ModuleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compiles all modules used by the test
 */
@BeforeTest
public void compileAll() throws Exception {
    CompilerUtils.cleanDir(MODS_DIR);
    CompilerUtils.cleanDir(UNNAMED_DIR);

    assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
                                           "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
    // m4 is not referenced
    Arrays.asList("mI", "mII", "mIII", "mIV")
          .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));

    assertTrue(CompilerUtils.compile(SRC_DIR.resolve("mIII"), UNNAMED_DIR, "-p", MODS_DIR.toString()));
    Files.delete(UNNAMED_DIR.resolve("module-info.class"));
}
 
Example #21
Source File: JmodNegativeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeTest
public void buildExplodedModules() throws IOException {
    if (Files.exists(EXPLODED_DIR))
        FileUtils.deleteFileTreeWithRetry(EXPLODED_DIR);

    for (String name : new String[] { "foo"/*, "bar", "baz"*/ } ) {
        Path dir = EXPLODED_DIR.resolve(name);
        assertTrue(compileModule(name, dir.resolve("classes")));
    }

    if (Files.exists(MODS_DIR))
        FileUtils.deleteFileTreeWithRetry(MODS_DIR);
    Files.createDirectories(MODS_DIR);
}
 
Example #22
Source File: IOSTest.java    From coteafs-appium with Apache License 2.0 5 votes vote down vote up
/**
 * @author wasiqb
 * @since Oct 28, 2018
 */
@Parameters( { "server", "device" })
@BeforeTest(alwaysRun = true)
public void setupTest(final String server, final String device) {
    this.server = new AppiumServer(server);
    this.server.start();

    this.device = new IOSDevice(this.server, device);
}
 
Example #23
Source File: JanusGraphProviderTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void setUp() throws Exception {
    GraphSandboxUtil.create();

    //First get Instance
    graph         = new AtlasJanusGraph();
    configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), AtlasJanusGraphDatabase.GRAPH_PREFIX);
}
 
Example #24
Source File: TestPermission.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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()));
    }
}
 
Example #25
Source File: PatchTestWarningError.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeTest
public void setup() throws Exception {

    // javac -d mods/test src/test/**
    boolean compiled= CompilerUtils.compile(SRC_DIR.resolve("test"),
                                            MODS_DIR.resolve("test"));
    assertTrue(compiled, "classes did not compile");

    // javac --patch-module $MODULE=patches1/$MODULE -d patches1/$MODULE patches1/$MODULE/**
    Path src = SRC1_DIR.resolve("java.base");
    Path output = PATCHES1_DIR.resolve(src.getFileName());
    Files.createDirectories(output);
    String mn = src.getFileName().toString();
    compiled  = CompilerUtils.compile(src, output,
                                      "--patch-module", mn + "=" + src.toString());
    assertTrue(compiled, "classes did not compile");

    // javac --patch-module $MODULE=patches2/$MODULE -d patches2/$MODULE patches2/$MODULE/**
    src = SRC2_DIR.resolve("java.base");
    output = PATCHES2_DIR.resolve(src.getFileName());
    Files.createDirectories(output);
    mn = src.getFileName().toString();
    compiled  = CompilerUtils.compile(src, output,
                                      "--patch-module", mn + "=" + src.toString());
    assertTrue(compiled, "classes did not compile");

}
 
Example #26
Source File: AddReadsTestWarningError.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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");
}
 
Example #27
Source File: AtlasEntityStoreV2Test.java    From atlas with Apache License 2.0 5 votes vote down vote up
@BeforeTest
public void init() throws Exception {
    entityStore = new AtlasEntityStoreV2(graph, deleteDelegate, typeRegistry, mockChangeNotifier, graphMapper);
    RequestContext.clear();
    RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);

    LOG.debug("RequestContext: activeCount={}, earliestActiveRequestTime={}", RequestContext.getActiveRequestsCount(), RequestContext.earliestActiveRequestTime());
}
 
Example #28
Source File: NoPersistenceCachingTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeTest
public void setupTest() {
   stderr = new ByteArrayOutputStream();
   prevStderr = System.err;
   System.setErr(new PrintStream(stderr));
   NashornScriptEngineFactory nashornFactory = null;
   final ScriptEngineManager sm = new ScriptEngineManager();
   for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
      if (fac instanceof NashornScriptEngineFactory) {
         nashornFactory = (NashornScriptEngineFactory) fac;
         break;
      }
   }
   if (nashornFactory == null) {
      fail("Cannot find nashorn factory!");
   }
   // fine is enough for cache hits, finest produces way too much information
   // TODO this should be ported to use the RuntimeEvents instead of screen scraping
   // logs, as obviously this is very brittle
   final String[] options = new String[]{"--log=compiler:fine"};
   engine = nashornFactory.getScriptEngine(options);
   context1 = engine.getContext();
   context2 = new SimpleScriptContext();
   context2.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
   context3 = new SimpleScriptContext();
   context3.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
}
 
Example #29
Source File: JaxbMarshallTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #30
Source File: AccessTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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));
    }
}