BAEL-633 proper formatting and test naming
This commit is contained in:
parent
5b1135cae6
commit
12193e96fa
|
@ -1,8 +1,8 @@
|
||||||
package com.baeldung.cglib.mixin;
|
package com.baeldung.cglib.mixin;
|
||||||
|
|
||||||
public class Class1 implements Interface1 {
|
public class Class1 implements Interface1 {
|
||||||
@Override
|
@Override
|
||||||
public String first() {
|
public String first() {
|
||||||
return "first behaviour";
|
return "first behaviour";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package com.baeldung.cglib.mixin;
|
package com.baeldung.cglib.mixin;
|
||||||
|
|
||||||
public class Class2 implements Interface2 {
|
public class Class2 implements Interface2 {
|
||||||
@Override
|
@Override
|
||||||
public String second() {
|
public String second() {
|
||||||
return "second behaviour";
|
return "second behaviour";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
package com.baeldung.cglib.mixin;
|
package com.baeldung.cglib.mixin;
|
||||||
|
|
||||||
public interface Interface1 {
|
public interface Interface1 {
|
||||||
String first();
|
String first();
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
package com.baeldung.cglib.mixin;
|
package com.baeldung.cglib.mixin;
|
||||||
|
|
||||||
public interface Interface2 {
|
public interface Interface2 {
|
||||||
String second();
|
String second();
|
||||||
}
|
}
|
|
@ -11,18 +11,22 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
public class BeanGeneratorTest {
|
public class BeanGeneratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBeanGenerator() throws Exception {
|
public void givenBeanCreator_whenAddPropery_classShouldHaveFieldValue() throws Exception {
|
||||||
//given
|
//given
|
||||||
BeanGenerator beanGenerator = new BeanGenerator();
|
BeanGenerator beanGenerator = new BeanGenerator();
|
||||||
|
|
||||||
//when
|
//when
|
||||||
beanGenerator.addProperty("name", String.class);
|
beanGenerator.addProperty("name", String.class);
|
||||||
Object myBean = beanGenerator.create();
|
Object myBean = beanGenerator.create();
|
||||||
Method setter = myBean.getClass().getMethod("setName", String.class);
|
Method setter = myBean
|
||||||
|
.getClass()
|
||||||
|
.getMethod("setName", String.class);
|
||||||
setter.invoke(myBean, "some string value set by a cglib");
|
setter.invoke(myBean, "some string value set by a cglib");
|
||||||
|
|
||||||
//then
|
//then
|
||||||
Method getter = myBean.getClass().getMethod("getName");
|
Method getter = myBean
|
||||||
|
.getClass()
|
||||||
|
.getMethod("getName");
|
||||||
assertEquals("some string value set by a cglib", getter.invoke(myBean));
|
assertEquals("some string value set by a cglib", getter.invoke(myBean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import static junit.framework.TestCase.assertEquals;
|
||||||
public class MixinTest {
|
public class MixinTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMixinBehaviour() throws Exception {
|
public void givenTwoClasses_whenMixtThemIntoOne_mixinShouldHaveMethodsFromBothClasses() throws Exception {
|
||||||
//when
|
//when
|
||||||
Mixin mixin = Mixin.create(
|
Mixin mixin = Mixin.create(
|
||||||
new Class[]{Interface1.class, Interface2.class, MixinInterface.class},
|
new Class[]{Interface1.class, Interface2.class, MixinInterface.class},
|
||||||
|
|
|
@ -9,7 +9,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class PersonServiceProxyTest {
|
public class PersonServiceProxyTest {
|
||||||
@Test
|
@Test
|
||||||
public void testService() {
|
public void givenPersonService_whenSayHello_shouldReturnResult() {
|
||||||
//given
|
//given
|
||||||
PersonService personService = new PersonService();
|
PersonService personService = new PersonService();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class PersonServiceProxyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFixedValue() throws Exception {
|
public void givenEnhancerProxy_whenExtendPersonService_shouldInterceptMethod() throws Exception {
|
||||||
//given
|
//given
|
||||||
Enhancer enhancer = new Enhancer();
|
Enhancer enhancer = new Enhancer();
|
||||||
enhancer.setSuperclass(PersonService.class);
|
enhancer.setSuperclass(PersonService.class);
|
||||||
|
@ -36,7 +36,7 @@ public class PersonServiceProxyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodInterceptor() throws Exception {
|
public void givenEnhancer_whenExecuteMethodOnProxy_shouldInterceptOnlyStringReturnTypeMethod() throws Exception {
|
||||||
//given
|
//given
|
||||||
Enhancer enhancer = new Enhancer();
|
Enhancer enhancer = new Enhancer();
|
||||||
enhancer.setSuperclass(PersonService.class);
|
enhancer.setSuperclass(PersonService.class);
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -28,6 +28,7 @@
|
||||||
<module>autovalue</module>
|
<module>autovalue</module>
|
||||||
|
|
||||||
<module>cdi</module>
|
<module>cdi</module>
|
||||||
|
<module>cglib</module>
|
||||||
<!-- <module>core-java-9</module> -->
|
<!-- <module>core-java-9</module> -->
|
||||||
<module>core-java</module>
|
<module>core-java</module>
|
||||||
<module>couchbase-sdk</module>
|
<module>couchbase-sdk</module>
|
||||||
|
@ -192,7 +193,6 @@
|
||||||
<module>xstream</module>
|
<module>xstream</module>
|
||||||
|
|
||||||
<module>struts2</module>
|
<module>struts2</module>
|
||||||
<module>cglib</module>
|
|
||||||
<module>apache-velocity</module>
|
<module>apache-velocity</module>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue