This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Calculator { | |
public int add(final int x, final int y) { | |
if (x < 0 || y < 0) { | |
throw new IllegalArgumentException("arguments must be positive"); | |
} | |
return x + y; | |
} | |
public int substract(final int x, final int y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CalculatorTest { | |
private Calculator classUnderTest; | |
@Before | |
public void setUp() throws Exception { | |
this.classUnderTest = new Calculator(); | |
} | |
@After |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmployeeServiceSingleton { | |
private static final EmployeeServiceSingleton instance = new EmployeeServiceSingleton(); | |
private final EmployeeDao employeeDao; | |
private EmployeeServiceSingleton() { | |
employeeDao = ServiceLocator.getEmployeeDao(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmployeeService { | |
private final EmployeeDao employeeDao; | |
public EmployeeService(final EmployeeDao employeeDao) { | |
this.employeeDao = employeeDao; | |
} | |
public String findManagerName(final Long employeeId) { | |
if (null == employeeId) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(MockitoJUnitRunner.class) | |
public class EmployeeServiceTest { | |
@Mock | |
private EmployeeDao daoMock; | |
@Test | |
public void testFindManagerName() throws Exception { | |
final Long employeeId = 666L; | |
final String expectedManagerName = "Eran Harel"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* המחלקה העברית הראשונה | |
* @author Eran Harel | |
*/ | |
public final class מחלקה_סגורה { | |
int שלם = 1; | |
// בנאי | |
public מחלקה_סגורה() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | |
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> | |
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/> | |
<property name="properties"> | |
<map> | |
<entry key="imaginaryFeature.implementation.bean" value="oldImaginaryFeature"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} catch (final Throwable e) { | |
_logger.error("Failed to init blah", e); | |
try { | |
throw e; | |
} catch (final Throwable e1) { | |
_logger.error("Failed to throw throwable excpetion", e1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} catch (final Throwable e) { | |
throw new MyException("Failed to blah", (Exception) e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
... | |
try { | |
... | |
} catch (final Throwable t) { | |
logger.error("...", t); | |
throw new RuntimeException(msg, t); | |
} | |
} catch (final Throwable t) { | |
logger.error("..", t); |
OlderNewer