Package samples.system

Examples of samples.system.SystemClassUser


        expect(InetAddress.getLocalHost()).andReturn(mock);

        replayAll();

        final SystemClassUser systemClassUser = new SystemClassUser();
        assertSame(mock, systemClassUser.getLocalHost());

        verifyAll();
    }
View Full Code Here


  public void assertThatMockingOfNonFinalSystemClassesWorks() throws Exception {
    mockStatic(URLEncoder.class);

    when(URLEncoder.encode("string", "enc")).thenReturn("something");

    assertEquals("something", new SystemClassUser().performEncode());

  }
View Full Code Here

    Process processMock = mock(Process.class);

    when(Runtime.getRuntime()).thenReturn(runtimeMock);
    when(runtimeMock.exec("command")).thenReturn(processMock);

    assertSame(processMock, new SystemClassUser().executeCommand());
  }
View Full Code Here

  public void assertThatMockingOfFinalSystemClassesWorks() throws Exception {
    mockStatic(System.class);

    when(System.getProperty("property")).thenReturn("my property");

    assertEquals("my property", new SystemClassUser().getSystemProperty());
  }
View Full Code Here

  public void assertThatPartialMockingOfFinalSystemClassesWorks() throws Exception {
    spy(System.class);

    when(System.nanoTime()).thenReturn(2L);

    new SystemClassUser().doMoreComplicatedStuff();

    assertEquals("2", System.getProperty("nanoTime"));
  }
View Full Code Here

    List<?> list = new LinkedList<Object>();
    mockStatic(Collections.class);

    Collections.shuffle(list);

    new SystemClassUser().shuffleCollection(list);

    verifyStatic(times(2));
    Collections.shuffle(list);
  }
View Full Code Here

  public void assertThatPartialMockingOfFinalSystemClassesWorksForNonVoidMethods() throws Exception {
    spy(System.class);

    when(System.getProperty("property")).thenReturn("my property");

    final SystemClassUser systemClassUser = new SystemClassUser();
    systemClassUser.copyProperty("to", "property");
  }
View Full Code Here

    final String args = "args";
    final String returnValue = "returnValue";

    when(String.format(string, args)).thenReturn(returnValue);

    final SystemClassUser systemClassUser = new SystemClassUser();
    assertEquals(systemClassUser.format(string, args), returnValue);
  }
View Full Code Here

    mockStatic(Thread.class);
    doNothing().when(Thread.class);
    Thread.sleep(anyLong());

    long startTime = System.currentTimeMillis();
    final SystemClassUser systemClassUser = new SystemClassUser();
    systemClassUser.threadSleep();
    long endTime = System.currentTimeMillis();
    assertTrue(endTime - startTime < 5000);
  }
View Full Code Here

        final UUID mock = mock(UUID.class);
        mockStatic(UUID.class);
        given(UUID.randomUUID()).willReturn(mock);

    // when
    String actual = new SystemClassUser().generatePerishableToken();

    // then
    assertEquals("00000000000000000000000000000000", actual);
    }
View Full Code Here

TOP

Related Classes of samples.system.SystemClassUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.