Java 类org.testng.annotations.BeforeMethod 实例源码

项目:shibboleth-idp-oidc-extension    文件:EncodeMessageTest.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@BeforeMethod
public void setUp() throws ComponentInitializationException {
    message = new MockMessage();
    message.getProperties().put("foo", "3");
    message.getProperties().put("bar", "1");
    message.getProperties().put("baz", "2");

    // Encoded mock message, keys sorted alphabetically, per
    // MockMessage#toString
    expectedMessage = "bar=1&baz=2&foo=3";

    messageContext = new MessageContext<>();
    messageContext.setMessage(message);

    profileCtx = new ProfileRequestContext();
    profileCtx.setOutboundMessageContext(messageContext);

    encoder = new MockMessageEncoder();
    // Note: we don't init the encoder, b/c that is done by the action after
    // setting the message context
}
项目:NaukriSite    文件:Setup.java   
@BeforeMethod
public void siteUp () {

    final String exe = "chromedriver.exe";
    final String path = getClass ().getClassLoader ()
        .getResource (exe)
        .getPath ();
    final String webSite = "http://www.naukri.com";
    final String binaryPath = "C:\\Users\\DELL\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe";

    System.setProperty("webdriver.chrome.driver", path);
    ChromeOptions chromeOpt= new ChromeOptions();
    chromeOpt.setBinary(binaryPath);

    driver = new ChromeDriver (chromeOpt);
    driver.get(webSite);
    driver.manage ().timeouts ().implicitlyWait (10, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    windowHandling ();
}
项目:shibboleth-idp-oidc-extension    文件:StorageServiceClientInformationManagerTest.java   
@BeforeMethod
public void setupTests() throws Exception {
    storageService = new MemoryStorageService();
    storageService.setId("mockId");
    storageService.initialize();

    manager = new StorageServiceClientInformationManager();
    manager.setStorageService(storageService);
    manager.setId("mockId");
    manager.initialize();

    resolver = new StorageServiceClientInformationResolver();
    resolver.setStorageService(storageService);
    resolver.setId("mockId");
    resolver.initialize();

    clientIdValue = "mockClientId";
}
项目:marathonv5    文件:RComboBox2Test.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(RComboBox2Test.class.getName());
            frame.setName("dialog-1");
            Employee[] items = { new Employee("Phillip"), new Employee("Larry"), new Employee("Lisa"), new Employee("James"),
                    new Employee("Larry") };
            MyComboBoxModel model = new MyComboBoxModel(items);
            JComboBox comboBox = new JComboBox(model);
            comboBox.setName("Employee");
            frame.getContentPane().add(comboBox);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:pyplyn    文件:SensitiveByteArraySerializerTest.java   
@BeforeMethod
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    // ARRANGE
    serializer = new SensitiveByteArraySerializer();
    deserializer = new SensitiveByteArrayDeserializer();
}
项目:teamcity-powershell    文件:ScriptGeneratorTest.java   
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
@BeforeMethod
public void setUp() throws Exception {
  super.setUp();
  m = new Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};
  myTempDir = createTempDir();
  myCheckoutDir = createTempDir();
  myGenerator = new ScriptGenerator();
}
项目:marathonv5    文件:JSpinnerJavaElementTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            JSpinner listSpinner = createListSpinner();
            Calendar calendar = Calendar.getInstance();
            JSpinner numberSpinner = createNumberSpinner(calendar);
            JSpinner dateSpinner = createDateSpinner(calendar);

            frame.setLayout(new FlowLayout());
            frame.getContentPane().add(listSpinner);
            frame.getContentPane().add(numberSpinner);
            frame.getContentPane().add(dateSpinner);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaAgent();
}
项目:cryptotrader    文件:EstimatorImplTest.java   
@BeforeMethod
public void setUp() throws Exception {

    services = new TreeMap<>();
    services.put("id0", mock(Estimator.class));
    services.put("id1", mock(Estimator.class));
    services.put("id2", mock(Estimator.class));
    services.put("id3", mock(Estimator.class));
    services.put("id4", mock(Estimator.class));
    services.put("id5", mock(Estimator.class));
    services.put("id6", mock(Estimator.class));
    services.put("id7", mock(Estimator.class));
    services.forEach((k, v) -> when(v.get()).thenReturn(k));

    module = new TestModule();
    when(module.getMock(ServiceFactory.class).loadMap(Estimator.class)).thenReturn(services);

    context = module.getMock(Context.class);
    request = module.createRequestBuilder().build();

    target = new EstimatorImpl(module.createInjector());

}
项目:gold    文件:ReferencedByTest.java   
@BeforeMethod
private void loadSchemas() {
    SchemaWriteAccess access = buildSchemaWriteAccessCacheTestNamespace();

    Map<String, Object> variableMap = buildVariableMap(REFERENCEDBY_TEST_NAMESPACE);

    GraphQLResult resultVideoSchemaCreation = schemaService.executeQuery(videoSchema, variableMap, access);
    assertTrue(resultVideoSchemaCreation.isSuccessful());

    GraphQLResult resultAudioSchemaCreation = schemaService.executeQuery(audioSchema, variableMap, access);
    assertTrue(resultAudioSchemaCreation.isSuccessful());

    GraphQLResult resultDescriptionBlockSchemaCreation = schemaService.executeQuery(descriptionBlockSchema,
            variableMap, access);
    assertTrue(resultDescriptionBlockSchemaCreation.isSuccessful());

    GraphQLResult resultMediaSchemaCreation = schemaService.executeQuery(mediaSchema, variableMap, access);
    assertTrue(resultMediaSchemaCreation.isSuccessful());

    GraphQLResult resultPlaylistSchemaCreation = schemaService.executeQuery(playlistSchema, variableMap, access);
    assertTrue(resultPlaylistSchemaCreation.isSuccessful());

    GraphQLResult resultAudioListSchemaCreation = schemaService.executeQuery(audioListSchema, variableMap, access);
    assertTrue(resultAudioListSchemaCreation.isSuccessful());
}
项目:marathonv5    文件:JSpinner4Test.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JSpinner2Test.class.getSimpleName());
            frame.setName("frame-" + JSpinner2Test.class.getSimpleName());
            frame.getContentPane().add(new SpinnerDemo4(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });

    driver = new JavaDriver();
    spinner = driver.findElement(By.cssSelector("spinner"));

    spinnerButttonUp = spinner.findElement(By.cssSelector("basic-arrow-button:nth(1)"));
    spinnerButtonDown = spinner.findElement(By.cssSelector("basic-arrow-button:nth(2)"));

}
项目:gold    文件:BaseExternalReferenceTest.java   
@BeforeMethod
public void loadExternalData() {
    loadSchema();

    final String IMAGE_ID = "1234";
    final String VIDEO_ID = "5678";

    Map<String, Object> imageMap = new HashMap<>();
    imageMap.put("id", IMAGE_ID);
    imageMap.put("title", "Hitchhikers Guide");
    externalReferenceRepository.loadExternalInstance("Image", IMAGE_ID, imageMap);

    Map<String, Object> videoMap = new HashMap<>();
    videoMap.put("id", VIDEO_ID);
    videoMap.put("title", "Casablanca");
    videoMap.put("caption", "The greatest movie ever.");

    externalReferenceRepository.loadExternalInstance("Video", VIDEO_ID, videoMap);
}
项目:openjdk-jdk10    文件:EntityTest.java   
@BeforeMethod
public void setUp() {
    try {
        factory = XMLInputFactory.newInstance();
    } catch (Exception ex) {
        Assert.fail("Could not create XMLInputFactory");
    }
}
项目:marathonv5    文件:JSplitPaneTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JSplitPaneTest.class.getSimpleName());
            frame.setName("frame-" + JSplitPaneTest.class.getSimpleName());
            frame.getContentPane().add(new SplitPaneDemo().getSplitPane(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
}
项目:jtk    文件:ArrayMathDoubleTest.java   
@BeforeMethod
public void setUp() {
  a1 = rampdouble(0d,1d,n1);
  a2 = rampdouble(0d,1d,10d,n1,n2);
  a3 = rampdouble(0d,1d,10d,100d,n1,n2,n3);
  b1 = zerodouble(n1);
  b2 = zerodouble(n1,n2);
  b3 = zerodouble(n1,n2,n3);
}
项目:datarouter    文件:CascadeIterableTests.java   
@BeforeMethod
public void beforeMethod(){
    twoLists = new ArrayList<>();
    twoLists.add(new ArrayList<>(Arrays.asList(1, 2, 3)));
    twoLists.add(new ArrayList<>(Arrays.asList(400, 500)));
    counter = new AtomicInteger(0);
}
项目:java-ilp-plugin    文件:MockQueuedLedgerPluginTest.java   
@BeforeMethod
public void setup() {
  MockitoAnnotations.initMocks(this);

  // Enable debug mode...
  ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME))
      .setLevel(Level.DEBUG);

  this.ledgerInfo = ImmutableLedgerInfo.builder()
      .currencyScale(8)
      .currencyUnit(Monetary.getCurrency("USD"))
      .ledgerPrefix(LEDGER_PREFIX)
      .build();
  final SimulatedLedger simulatedLedger = new SimulatedLedger(ledgerInfo);

  // Initialize the ledger plugin under test...
  this.eventBus = new EventBus();
  this.mockLedgerPlugin = new QueuedMockLedgerPlugin(getLedgerPluginConfig(), simulatedLedger,
      eventBus);

  // Wire-up an async event handler...
  final EventBusLedgerPluginEventHandler asyncLedgerPluginEventHandler
      = new EventBusLedgerPluginEventHandler(ledgerPluginEventHandlerMock);
  eventBus.register(asyncLedgerPluginEventHandler);
  mockLedgerPlugin.addLedgerPluginEventHandler(asyncLedgerPluginEventHandler);
  mockLedgerPlugin.connect();

  // Reset the event handler so we don't count the "connect" event, in general
  reset(ledgerPluginEventHandlerMock);
}
项目:pyplyn    文件:MetadataTest.java   
@BeforeMethod
public void setUp() throws Exception {
    // ARRANGE
    Transmutation.Metadata metadata = ImmutableTransmutation.Metadata.builder()
            .tags(singletonMap("data", "point"))
            .build();
    data = ImmutableTransmutation.of(ZonedDateTime.now(ZoneOffset.UTC),
            "test",
            1.0d,
            100.0d,
            metadata);
}
项目:cryptotrader    文件:AgentImplTest.java   
@BeforeMethod
public void setUp() throws Exception {

    module = new TestModule();
    context = null;
    propertyManager = module.getMock(PropertyManager.class);
    service = module.getMock(Agent.class);

    Map<String, Agent> services = singletonMap("s", service);
    when(module.getMock(ServiceFactory.class).loadMap(Agent.class)).thenReturn(services);

    target = new AgentImpl(module.createInjector());

}
项目:shibboleth-idp-oidc-extension    文件:OIDCAuthenticationRequestDecoderTest.java   
@BeforeMethod
protected void setUp() throws Exception {
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("GET");
    decoder = new OIDCAuthenticationRequestDecoder();
    decoder.setHttpServletRequest(httpRequest);
    decoder.initialize();
}
项目:teamcity-kubernetes-plugin    文件:KubeCloudClientTest.java   
@BeforeMethod
public void setUp() throws Exception {
    super.setUp();
    m = new Mockery();
    myApi = m.mock(KubeApiConnector.class);
    myPodTemplateProviders = m.mock(BuildAgentPodTemplateProviders.class);
    myCache = new KubeDataCacheImpl();
}
项目:gdl2    文件:AssignmentStatementTest.java   
@BeforeMethod
public void setUp() {
    interpreter = new Interpreter();
    inputMap = new HashMap<>();
    resultMap = new HashMap<>();
    dataValue = null;
}
项目:strongbox    文件:FileUserConfigTest.java   
@BeforeMethod
public void setUp() throws Exception {
    if (configFile.exists()) {
        configFile.delete();
    }
    fileUserConfig = new FileUserConfig(configFile);
    fileUserConfig.addLocalFilePath(GROUP1_US, new File("uswest1-test-group.sm"));
    fileUserConfig.addLocalFilePath(GROUP1_EU, new File("euwest1-test-group.sm"));
    fileUserConfig.addLocalFilePath(GROUP2_EU, new File("euwest1-test-group2.sm"));
}
项目:Java_Good    文件:GroupModificationTests.java   
@BeforeMethod

    public void ensurePreconditions() {
        if (app.db().groups().size() == 0) {
            app.goTo().groupPage();
            app.group().create(new GroupData().withName("test3"));
        }
        // if (app.group().all().size()== 0){
        //}
    }
项目:oneops    文件:DeployerTest.java   
@BeforeMethod
private void resetDeploymentData() throws Exception {
  Connection conn = ds.getConnection();
  try (PreparedStatement stmt = conn.prepareStatement("UPDATE dj_deployment_rfc SET state_id = 10 where deployment_id = ?")) {
    stmt.setLong(1, DPMT_ID);
    stmt.executeUpdate();
  }
  try (PreparedStatement stmt = conn.prepareStatement("UPDATE dj_deployment SET state_id = 100, "
      + "auto_pause_exec_orders = null, current_step = null, flags = 0 where deployment_id = ?")) {
    stmt.setLong(1, DPMT_ID);
    stmt.executeUpdate();
  }
  reset(mockExecutor);
}
项目:openjdk-jdk10    文件:Bug7157608Test.java   
@BeforeMethod
public void setUp() throws IOException {
    File file1 = new File(getClass().getResource("Bug7157608.xml").getFile());
    xml1 = file1.getPath().replace("\\", "\\\\");
    File file2 = new File(getClass().getResource("Bug7157608_1.xml").getFile());
    xml2 = file2.getPath();
}
项目:marathonv5    文件:JavaAgentTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            JMenuBar menuBar = new JMenuBar();
            menu = new JMenu("File");
            menu.setMnemonic(KeyEvent.VK_F);
            menuBar.add(menu);
            exitItem = new JMenuItem("Exit");
            menu.add(exitItem);
            frame.setJMenuBar(menuBar);
            Box box = new Box(BoxLayout.Y_AXIS);
            textField = new JTextField("");

            box.add(textField);
            button = new JButton("Click Me!!");
            box.add(button);
            new Timer().schedule(new TimerTask() {
                @Override public void run() {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override public void run() {
                            JButton button1 = new JButton("Click Me Delayed!!");
                            button1.setName("click-me-delayed");
                            frame.getContentPane().add(button1);
                        }
                    });
                }
            }, 1000);
            button.setName("click-me");
            frame.setContentPane(box);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaAgent();
}
项目:strongbox    文件:IAMPolicyManagerTest.java   
@BeforeMethod
public void setUp() {
    mockCredentials = mock(AWSCredentialsProvider.class);
    mockClient = mock(AmazonIdentityManagementClient.class);
    ClientConfiguration mockConfig = mock(ClientConfiguration.class);
    IAMPolicyManager policyManager = new IAMPolicyManager(mockClient, mockCredentials, mockConfig);

    // The mockito spy acts like original object but mocks out the getAccount() method. As the getAccount() calls
    // directly rather than via a client that we can pass in we need to mock this out using a spy.
    partiallyMockedPolicyManager = spy(policyManager);
    doReturn(ACCOUNT).when(partiallyMockedPolicyManager).getAccount();

    // Set up KMSEncryptor for testing the policy creation methods. This gets a bit complicated but we need to
    // mock all the AWS dependencies from the KMSManager before using it to create the KMSEncryptor. The getAliasArn
    // needs to be mocked out with a spy to stop the call to getAccount.
    mockKMSClient = mock(AWSKMSClient.class);
    KMSManager kmsManager = new KMSManager(mockKMSClient, mockCredentials, mockConfig, group);
    KMSManager partiallyMockedKMSManager = spy(kmsManager);
    doReturn(KMS_ALIAS_ARN).when(partiallyMockedKMSManager).getAliasArn();
    kmsEncryptor = new KMSEncryptor(partiallyMockedKMSManager, mockCredentials, mockConfig, group, mock(AwsCrypto.class), EncryptionStrength.AES_256);

    // Set up store for testing the policy creation methods. Mock out the getArn method with a spy to stop the
    // call to getAccount().
    mockDynamoDBClient = mock(AmazonDynamoDBClient.class);
    DynamoDB store = new DynamoDB(mockDynamoDBClient, mockCredentials, mockConfig, group, new ReentrantReadWriteLock());
    partiallyMockedStore = spy(store);
    doReturn(DYNAMODB_ARN).when(partiallyMockedStore).getArn();
}
项目:arez    文件:AbstractArezExtrasTest.java   
@BeforeMethod
protected void beforeTest()
  throws Exception
{
  BrainCheckTestUtil.resetConfig( false );
  ArezTestUtil.resetConfig( false );
}
项目:WebAutomation_AllureParallel    文件:WebDriverFactory.java   
@Parameters({ "browser" , "url" })
@BeforeMethod
public void beforeMethod(String browser, String url) throws Exception
{       
    InitMethod.Browser=browser;
    InitMethod.WebsiteURL=url;
    System.out.println("Browser: "+browser);
    System.out.println("WebsiteURL: "+url);
    new WebDriverFactory();
    WebDriver driver = WebDriverFactory.createDriver(browser,url);
    setWebDriver(driver);
}
项目:marathonv5    文件:JTabbedPaneJavaElementTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JTableJavaElementTest.class.getSimpleName());
            frame.setName("frame-" + JTableJavaElementTest.class.getSimpleName());
            frame.getContentPane().add(new TabbedPaneDemo(), BorderLayout.CENTER);
            frame.setSize(640, 480);
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaAgent();
}
项目:marathonv5    文件:RMenuItemTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            MenuSelectionManager.defaultManager().clearSelectedPath();
            frame = new JFrame(RMenuItemTest.class.getSimpleName());
            frame.setName("frame-" + RMenuItemTest.class.getSimpleName());
            MenuDemo demo = new MenuDemo();
            frame.setJMenuBar(demo.createMenuBar());
            frame.setContentPane(demo.createContentPane());
            frame.pack();
            frame.setVisible(true);
        }
    });
    menus = ComponentUtils.findComponents(JMenu.class, frame);
}
项目:TestNG-Foundation    文件:SkipFromBefore.java   
@BeforeMethod
public void beforeMethod(Method method) {
    if ("testMethod".equals(method.getName())) {
        fromBefore = VALUE;
        beforeResult = Reporter.getCurrentTestResult();
        beforeResult.setAttribute(ATTRIBUTE, fromBefore);
        throw new SkipException("Skip from [before]");
    }
}
项目:marathonv5    文件:JTextAreaTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new TextAreaDemo();
            frame.setName("frame-" + JTextAreaTest.class.getSimpleName());
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
}
项目:marathonv5    文件:RAbstractButtonTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    siw(new Runnable() {
        @Override public void run() {
            frame = new JFrame(RAbstractButtonTest.class.getSimpleName());
            frame.setName("frame-" + RAbstractButtonTest.class.getSimpleName());
            frame.getContentPane().add(new DynamicTreeDemo(), BorderLayout.CENTER);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:keti    文件:ResourceAttributeResolverTest.java   
@BeforeMethod
public void beforeMethod() {
    MockitoAnnotations.initMocks(this);

    this.testResource = new BaseResource("/test/resource");
    when(this.defaultResourceAttributeReader.getAttributes(eq(this.testResource.getResourceIdentifier())))
            .thenReturn(Collections.emptySet());
}
项目:marathonv5    文件:JCheckBoxTest.java   
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JCheckBoxTest.class.getSimpleName());
            frame.setName("frame-" + JCheckBoxTest.class.getSimpleName());
            frame.getContentPane().add(new CheckBoxDemo(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
}
项目:deployment-recorder-extension    文件:PomReadIT.java   
@BeforeMethod
public void beforeMethod() {
    consoleOutputStdErr = new StringBuilder();
    consoleOutputStdOut = new StringBuilder();

    originalStdErr = System.err;
    originalStdOut = System.out;

    PrintStream interceptorStdOut = new InterceptorStdOut(originalStdOut);
    PrintStream interceptorStdErr = new InterceptorStdErr(originalStdErr);

    System.setOut(interceptorStdOut);
    System.setErr(interceptorStdErr);
}