Java Code Examples for org.junit.Test#None

The following examples show how to use org.junit.Test#None . 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: TestGithubIssues.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
@Test( expected = Test.None.class /* no exception expected */ )
public void TestIssue82() throws InterruptedException
{
    // The exception that might be thrown by the date picker control
    // will be thrown in an AWT-EventQueue thread. To be able to detect
    // these exceptions we register an UncaughtExceptionHandler that
    // writes all occurring exceptions into exInfo.
    // As a result we always have access to the latest thrown exception
    // from any running thread
    final ExceptionInfo exInfo = new ExceptionInfo();
    try {
        RegisterUncaughtExceptionHandlerToAllThreads(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException( Thread t, Throwable e ) {
                exInfo.set(t.getName(), e);
            }
        });
        JFrame testWin = new JFrame();
        testWin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        testWin.add(date_picker);
        testWin.pack();
        testWin.setVisible(true);
        Thread.sleep(10);
        assertFalse("DatePicker must not have an open popup.", date_picker.isPopupOpen());
        Thread.sleep(10);
        date_picker.openPopup();
        Thread.sleep(10);
        assertTrue("DatePicker must have an open popup.", date_picker.isPopupOpen());
        testWin.dispatchEvent(new WindowEvent(testWin, WindowEvent.WINDOW_CLOSING));
        Thread.sleep(50);
        assertFalse("Exception in antother Thread triggered:\n"
                +"ThreadName: "+exInfo.getThreadName()+"\n"
                +"Exception: "+exInfo.getExceptionMessage()
                +"\nStacktrace:\n"+exInfo.getStackTrace()
                , exInfo.wasSet());
        } finally {
            RegisterUncaughtExceptionHandlerToAllThreads(null);
    }
}
 
Example 2
Source File: UserServiceTest.java    From sunbird-lms-service with MIT License 5 votes vote down vote up
@Test(expected = Test.None.class)
public void testCheckKeyUniquenessWhenKeyBlank() {
  try {
    when(cassandraOperation.getRecordsByIndexedProperty(
            userDb.getKeySpace(), userDb.getTableName(), "", ""))
        .thenReturn(new Response());
    userService.checkKeyUniqueness("", "", false);
  } catch (Exception e) {
    Assert.assertTrue(false);
  }
}
 
Example 3
Source File: ParameterTest.java    From openCypher with Apache License 2.0 5 votes vote down vote up
private static Class<? extends Throwable> getExpectedException( Test annotation )
{
    if ( annotation == null || annotation.expected() == Test.None.class )
    {
        return null;
    }
    else
    {
        return annotation.expected();
    }
}
 
Example 4
Source File: TestGithubIssues.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
@Test( expected = Test.None.class /* no exception expected */ )
public void TestIssue60()
{
    DateTimeFormatter era_date = DateTimeFormatter.ofPattern("ddMMyyyy");
    date_picker.getSettings().setFormatForDatesCommonEra(era_date);
    date_picker.setText("30 04 2019");
    AssertDateTextValidity(false);
    date_picker.setText("30042019");
    AssertDateTextValidity(true);
    date_picker.setText("31042019");
    AssertDateTextValidity(false);
    date_picker.setText(" 30042019 ");
    AssertDateTextValidity(true);
}
 
Example 5
Source File: SparkJava.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testSparkSQLUserDefinedTypedAggregation() throws Exception {
  final String inputFileName = "inputs/test_input_employees.json";
  final String inputFilePath = ExampleTestArgs.getFileBasePath() + inputFileName;

  JobLauncher.main(builder
    .addJobId(JavaUserDefinedTypedAggregation.class.getSimpleName() + "_test")
    .addUserMain(JavaUserDefinedTypedAggregation.class.getCanonicalName())
    .addUserArgs(inputFilePath)
    .addOptimizationPolicy(DefaultPolicy.class.getCanonicalName())
    .build());
}
 
Example 6
Source File: SparkJava.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testSparkPi() throws Exception {
  final String numParallelism = "3";

  JobLauncher.main(builder
    .addJobId(JavaSparkPi.class.getSimpleName() + "_test")
    .addUserMain(JavaSparkPi.class.getCanonicalName())
    .addUserArgs(numParallelism)
    .addOptimizationPolicy(DefaultPolicy.class.getCanonicalName())
    .build());
}
 
Example 7
Source File: WordCountITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testSpeculativeExecution() throws Exception {
  JobLauncher.main(builder
    .addResourceJson(executorResourceFileName)
    .addJobId(WordCountITCase.class.getSimpleName() + "_speculative")
    .addMaxTaskAttempt(Integer.MAX_VALUE)
    .addOptimizationPolicy(AggressiveSpeculativeCloningPolicyParallelismFive.class.getCanonicalName())
    .build());
}
 
Example 8
Source File: TestGithubIssues.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
@Test( expected = Test.None.class /* no exception expected */ )
public void TestIssue74()
{
    DateTimeFormatter era_date = DateTimeFormatter.ofPattern("dd/MM/yyyy");
    date_picker.getSettings().setFormatForDatesCommonEra(era_date);
    date_picker.setText("12/31/2019");
    AssertDateTextValidity(false);
    date_picker.setText("31/12/2019");
    AssertDateTextValidity(true);
    date_picker.setText("31/04/2019");
    AssertDateTextValidity(false);
    date_picker.setText("30/04/2019");
    AssertDateTextValidity(true);
}
 
Example 9
Source File: WordCountITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testTransientResource() throws Exception {
  JobLauncher.main(builder
    .addResourceJson(executorResourceFileName)
    .addJobId(WordCountITCase.class.getSimpleName() + "_transient")
    .addOptimizationPolicy(TransientResourcePolicyParallelismFive.class.getCanonicalName())
    .build());
}
 
Example 10
Source File: WordCountITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testConditionalLargeShuffle() throws Exception {
  JobLauncher.main(builder
    .addResourceJson(executorResourceFileName)
    .addJobId(WordCountITCase.class.getSimpleName() + "_conditionalLargeShuffle")
    .addOptimizationPolicy(ConditionalLargeShufflePolicy.class.getCanonicalName())
    .build());
}
 
Example 11
Source File: TestGithubIssues.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
@Test( expected = Test.None.class /* no exception expected */ )
public void TestIssue76()
{
    DatePickerSettings dateSettingsPgmDate = new DatePickerSettings();
    dateSettingsPgmDate.setAllowEmptyDates(true);
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy").withLocale(Locale.ENGLISH);
    dateSettingsPgmDate.setFormatForDatesCommonEra(dateFormatter);
    date_picker.setSettings(dateSettingsPgmDate);
    date_picker.getComponentDateTextField().setEditable(false);
    date_picker.getComponentDateTextField().setToolTipText("The earliest date for booking to display.");
    date_picker.getComponentToggleCalendarButton().setToolTipText("The earliest date for booking to display.");
    date_picker.getComponentToggleCalendarButton().setText("+");
    date_picker.getComponentToggleCalendarButton().setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
    date_picker.getComponentDateTextField().setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    date_picker.getComponentDateTextField().setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 12));
    date_picker.getComponentDateTextField().setDisabledTextColor(Color.BLACK);
    date_picker.setBounds(115, 50, 160, 20);
    date_picker.setDateToToday();
    date_picker.setText("sun, 11 Aug 2019");
    AssertDateTextValidity(false);
    date_picker.setText("Sun, 11 Aug 2019");
    AssertDateTextValidity(true);
    date_picker.setText("Mon, 11 Aug 2019");
    AssertDateTextValidity(false);
    date_picker.setText("Tue, 30 Apr 2019");
    AssertDateTextValidity(true);
    date_picker.setText("Wed, 31 Apr 2019");
    AssertDateTextValidity(false);
}
 
Example 12
Source File: WordCountITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testLargeShuffle() throws Exception {
  JobLauncher.main(builder
    .addResourceJson(executorResourceFileName)
    .addJobId(WordCountITCase.class.getSimpleName() + "_largeShuffle")
    .addOptimizationPolicy(LargeShufflePolicyParallelismFive.class.getCanonicalName())
    .build());
}
 
Example 13
Source File: LogLevelTestRule.java    From mapper with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement statement, final Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      Test test = description.getAnnotation(Test.class);
      boolean exceptionExpected = test != null && test.expected() != Test.None.class;

      Level level = getLevel(description.getAnnotation(LogLevel.class));
      if (level == null && exceptionExpected) {
        level = Level.OFF;
      }

      Level prevLevel;
      if (level != null) {
        prevLevel = resetLogsLevel(level);
      } else {
        prevLevel = null;
      }

      try {
        statement.evaluate();
      } finally {
        if (prevLevel != null) {
          resetLogsLevel(prevLevel);
        }
      }
    }
  };
}
 
Example 14
Source File: BroadcastITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void testTransientResource() throws Exception {
  JobLauncher.main(builder
    .addJobId(BroadcastITCase.class.getSimpleName() + "_transient")
    .addOptimizationPolicy(TransientResourcePolicyParallelismFive.class.getCanonicalName())
    .build());
}
 
Example 15
Source File: BroadcastITCase.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
@Test(timeout = ExampleTestArgs.TIMEOUT, expected = Test.None.class)
public void test() throws Exception {
  JobLauncher.main(builder
    .addJobId(BroadcastITCase.class.getSimpleName())
    .addOptimizationPolicy(DefaultPolicyParallelismFive.class.getCanonicalName())
    .build());
}
 
Example 16
Source File: PowerShellTest.java    From jPowerShell with Apache License 2.0 5 votes vote down vote up
/**
 * Test github example.
 */
@Test(expected = Test.None.class /* no exception expected */)
public void testFunctionalExample() {
    System.out.println("testFunctionalExample");
    if (OSDetector.isWindows()) {
        PowerShell.openSession()
                .executeCommandAndChain("Get-Process", (res -> System.out.println("List Processes:" + res.getCommandOutput())))
                .executeCommandAndChain("Get-WmiObject Win32_BIOS", (res -> System.out.println("BIOS information:" + res.getCommandOutput())))
                .close();
    }
}
 
Example 17
Source File: RetryRule.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(Statement statement, Description description) {
	RetryOnFailure retryOnFailure = description.getAnnotation(RetryOnFailure.class);
	RetryOnException retryOnException = description.getAnnotation(RetryOnException.class);

	// sanity check that we don't use expected exceptions with the RetryOnX annotations
	if (retryOnFailure != null || retryOnException != null) {
		Test test = description.getAnnotation(Test.class);
		if (test.expected() != Test.None.class) {
			throw new IllegalArgumentException("You cannot combine the RetryOnFailure " +
					"annotation with the Test(expected) annotation.");
		}
	}

	// sanity check that we don't use both annotations
	if (retryOnFailure != null && retryOnException != null) {
		throw new IllegalArgumentException(
				"You cannot combine the RetryOnFailure and RetryOnException annotations.");
	}

	if (retryOnFailure != null) {
		return new RetryOnFailureStatement(retryOnFailure.times(), statement);
	}
	else if (retryOnException != null) {
		return new RetryOnExceptionStatement(retryOnException.times(), retryOnException.exception(), statement);
	}
	else {
		return statement;
	}
}
 
Example 18
Source File: SpringJUnit4ClassRunner.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Get the {@code exception} that the supplied {@linkplain FrameworkMethod
 * test method} is expected to throw.
 * <p>Supports JUnit's {@link Test#expected() @Test(expected=...)} annotation.
 * <p>Can be overridden by subclasses.
 * @return the expected exception, or {@code null} if none was specified
 */
@Nullable
protected Class<? extends Throwable> getExpectedException(FrameworkMethod frameworkMethod) {
	Test test = frameworkMethod.getAnnotation(Test.class);
	return (test != null && test.expected() != Test.None.class ? test.expected() : null);
}
 
Example 19
Source File: SpringJUnit4ClassRunner.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Get the {@code exception} that the supplied {@linkplain FrameworkMethod
 * test method} is expected to throw.
 * <p>Supports JUnit's {@link Test#expected() @Test(expected=...)} annotation.
 * <p>Can be overridden by subclasses.
 * @return the expected exception, or {@code null} if none was specified
 */
@Nullable
protected Class<? extends Throwable> getExpectedException(FrameworkMethod frameworkMethod) {
	Test test = frameworkMethod.getAnnotation(Test.class);
	return (test != null && test.expected() != Test.None.class ? test.expected() : null);
}
 
Example 20
Source File: SpringJUnit4ClassRunner.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Get the {@code exception} that the supplied {@linkplain FrameworkMethod
 * test method} is expected to throw.
 * <p>Supports JUnit's {@link Test#expected() @Test(expected=...)} annotation.
 * <p>Can be overridden by subclasses.
 * @return the expected exception, or {@code null} if none was specified
 */
protected Class<? extends Throwable> getExpectedException(FrameworkMethod frameworkMethod) {
	Test test = frameworkMethod.getAnnotation(Test.class);
	return (test != null && test.expected() != Test.None.class ? test.expected() : null);
}