git clone [email protected]:project-name.git
git checkout -b $feature_name
git commit -am "My feature is ready"
| public class TestUtils { | |
| // an AutoCloseable bean is needed to guarantee the found port is freed before we can use it | |
| private static class SocketHolder implements Closeable { | |
| private final ServerSocket socket; | |
| public SocketHolder(ServerSocket socket) { | |
| this.socket = socket; | |
| } |
| @RunWith(SpringRunner.class) | |
| @EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class }) | |
| @SpringBootTest( | |
| classes = { TestFooRequest.FooController.class }, | |
| webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT | |
| ) | |
| @AutoConfigureMockMvc(secure = false) | |
| public class TestFooRequest { |
| @Configuration | |
| static class ConversionServiceConfiguration implements BeanFactoryPostProcessor { | |
| @Override | |
| public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | |
| beanFactory.setConversionService(ApplicationConversionService.getSharedInstance()); | |
| } | |
| } |
| @ConfigurationProperties("") | |
| public class CustomProperties { | |
| private Map<String, Object> mongodb = new HashMap<>(); | |
| public Map<String, Object> getMongodb() { | |
| return ImmutableMap.copyOf(mongodb); | |
| } | |
| public void setMongodb(Map<String, Object> mongodb) { |
| @RunWith(SpringRunner.class) | |
| @TestPropertySource("classpath:server-test.properties") | |
| public class SpelUnitTest { | |
| public static final Logger logger = LoggerFactory.getLogger(Sample.class); | |
| @Value("${testclock.start}") | |
| private String startTime; | |
| @Autowired |
| import org.junit.Test; | |
| import static org.hamcrest.Matchers.is; | |
| import static org.junit.Assert.assertThat; | |
| public class TestFormatStringIndexer { | |
| @Test | |
| public void index_simpleSpecifiers_ok() { | |
| final String result = FormatStringIndexer.index("there are %d apples in the %s basket that cost %f", 1); |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| //helper class that adds format index specifiers to plain specifiers in format strings | |
| public class FormatStringIndexer { | |
| private static Pattern pattern = Pattern.compile("%[-#+\\s0,(]?\\d*(\\.\\d)?[bBhHsScCdDoxXeEfgGaAtT%n]"); | |
| public static String index(final String formatString, int start) { |
| import org.jetbrains.annotations.NotNull; | |
| import org.junit.Test; | |
| import org.junit.runner.RunWith; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.test.context.ContextConfiguration; | |
| import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
git clone [email protected]:project-name.git
git checkout -b $feature_name
git commit -am "My feature is ready"
| # delete local tag 'mytag' | |
| git tag -d mytag | |
| # delete remote tag 'mytag' (e.g. GitHub version too) | |
| git push origin :refs/tags/mytag | |
| # alternative approach | |
| git push --delete origin mytag | |
| git tag -d mytag |