Skip to content

Instantly share code, notes, and snippets.

View mehmetcemyucel's full-sized avatar

Mehmet Cem Yücel mehmetcemyucel

View GitHub Profile
@SpringBootApplication
public class McySbJasyptApplication {
public static void main(String[] args) {
SpringApplication.run(McySbJasyptApplication.class, args);
}
@Bean(name = "mcyEncryptor")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
@mehmetcemyucel
mehmetcemyucel / SimpleController.java
Created February 4, 2019 19:40
mcy-sb-external-config
package com.mcy;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Slf4j
Geleneksel uygulama On iki faktör uygulaması
Dağıtımlar arasındaki zaman Haftalar Saatler
Kod yazarları ve kod dağıtımcıları Farklı insanlar Aynı insanlar
Geliştirme ve ürün ortamı Farklı Olabildiğince benzer
@mehmetcemyucel
mehmetcemyucel / RestService.java
Last active April 4, 2021 09:21
mcy-sb-rest-test
@RestController
public class RestService {
@Autowired
SecondService service;
@PostMapping("/post-service")
public Response restService(@RequestBody Request request) {
return new Response(request.getRequestValue1() + service.getValue(), request.getRequestValue2());
}
@mehmetcemyucel
mehmetcemyucel / SecondService.java
Last active April 4, 2021 09:21
mcy-sb-rest-test
@Component
public class SecondService {
public String getValue() {
return "service";
}
}
//ORT: 2.186 MS
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { McySbRestTestApplication.class })
@WebAppConfiguration
public class RestServiceWebContextTest {
@Autowired
private WebApplicationContext wac;
private MockMvc mvc;
// ORT: 556 MS
public class RestServiceStandaloneTest {
@InjectMocks
private RestService restService;
@Mock
private SecondService service;
private MockMvc mvc;
@Before
public class WithoutExpectedExceptionTest {
@Test(expected = NullPointerException.class)
public void test() {
String value = null;
value.split("");
}
@Test(expected = ArithmeticException.class)
public void test2() {
@mehmetcemyucel
mehmetcemyucel / ExpectedExceptionTest.java
Last active April 4, 2021 09:03
springboot-junit-rule
public class ExpectedExceptionTest {
@Rule
public ExpectedException exp = ExpectedException.none();
@Test
public void test() {
exp.expect(NullPointerException.class);
String value = null;
value.split("");
@mehmetcemyucel
mehmetcemyucel / TestNameTest.java
Last active April 4, 2021 09:03
springboot-junit-rule
public class TestNameTest {
@Rule
public final TestName name = new TestName();
@Test
public void testA() {
assertEquals("testA", name.getMethodName());
}
@Test