org.springframework.tests.sample.beans.Colour Java Examples

The following examples show how to use org.springframework.tests.sample.beans.Colour. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionTagTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected void extendRequest(MockHttpServletRequest request) {
	TestBean bean = new TestBean();
	bean.setName("foo");
	bean.setFavouriteColour(Colour.GREEN);
	bean.setStringArray(ARRAY);
	bean.setSpouse(new TestBean("Sally"));
	bean.setSomeNumber(new Float("12.34"));

	List friends = new ArrayList();
	friends.add(new TestBean("bar"));
	friends.add(new TestBean("penc"));
	bean.setFriends(friends);

	request.setAttribute("testBean", bean);
}
 
Example #2
Source File: OptionTagTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected void extendRequest(MockHttpServletRequest request) {
	TestBean bean = new TestBean();
	bean.setName("foo");
	bean.setFavouriteColour(Colour.GREEN);
	bean.setStringArray(ARRAY);
	bean.setSpouse(new TestBean("Sally"));
	bean.setSomeNumber(new Float("12.34"));

	List friends = new ArrayList();
	friends.add(new TestBean("bar"));
	friends.add(new TestBean("penc"));
	bean.setFriends(friends);

	request.setAttribute("testBean", bean);
}
 
Example #3
Source File: OptionTagTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected void extendRequest(MockHttpServletRequest request) {
	TestBean bean = new TestBean();
	bean.setName("foo");
	bean.setFavouriteColour(Colour.GREEN);
	bean.setStringArray(ARRAY);
	bean.setSpouse(new TestBean("Sally"));
	bean.setSomeNumber(new Float("12.34"));

	List friends = new ArrayList();
	friends.add(new TestBean("bar"));
	friends.add(new TestBean("penc"));
	bean.setFriends(friends);

	request.setAttribute("testBean", bean);
}
 
Example #4
Source File: CheckboxesTagTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	Set someObjects = new HashSet();
	someObjects.add(new ItemPet("PET1"));
	someObjects.add(new ItemPet("PET2"));

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(Boolean.TRUE);
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	this.bean.setSomeSet(someObjects);
	List list = new ArrayList();
	list.add("foo");
	list.add("bar");
	this.bean.setSomeList(list);
	return this.bean;
}
 
Example #5
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndNotAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class);

	assertTrue(context.getBeansOfType(Colour.class).isEmpty());
	assertThat(context.getBean(TestBean.class).getName(), equalTo(""));
}
 
Example #6
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredSingleConstructorSupported() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", AutowiredConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(AutowiredConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(AutowiredConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #7
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testObjectFactoryConstructorWithTypeVariable() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", ObjectFactoryConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(ObjectFactoryConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(ObjectFactoryConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #8
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationDependencies() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
			AutowiredConfigurationTests.class.getSimpleName() + ".xml", AutowiredConfigurationTests.class);

	assertThat(context.getBean("colour", Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean("testBean", TestBean.class).getName(), equalTo(Colour.RED.toString()));
}
 
Example #9
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
public TestBean testBean(Optional<Colour> colour, Optional<List<Colour>> colours) {
	if (!colour.isPresent() && !colours.isPresent()) {
		return new TestBean("");
	}
	else {
		return new TestBean(colour.get().toString() + "-" + colours.get().get(0).toString());
	}
}
 
Example #10
Source File: CheckboxTagTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	List someList = new ArrayList();
	someList.add("foo");
	someList.add("bar");

	Map someMap = new LinkedHashMap();
	someMap.put("key", Boolean.TRUE);

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(Boolean.TRUE);
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	this.bean.setSomeList(someList);
	this.bean.setSomeMap(someMap);
	return this.bean;
}
 
Example #11
Source File: RadioButtonsTagTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(Boolean.TRUE);
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	List list = new ArrayList();
	list.add("foo");
	list.add("bar");
	this.bean.setSomeList(list);
	return this.bean;
}
 
Example #12
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredAnnotatedConstructorSupported() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", MultipleConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(MultipleConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(MultipleConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #13
Source File: AutowiredConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutowiredConfigurationDependencies() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
			AutowiredConfigurationTests.class.getSimpleName() + ".xml", AutowiredConfigurationTests.class);

	assertThat(context.getBean("colour", Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean("testBean", TestBean.class).getName(), equalTo(Colour.RED.toString()));
}
 
Example #14
Source File: AutowiredConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependencies() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			AutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #15
Source File: AutowiredConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #16
Source File: AutowiredConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndNotAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class);

	assertTrue(context.getBeansOfType(Colour.class).isEmpty());
	assertThat(context.getBean(TestBean.class).getName(), equalTo(""));
}
 
Example #17
Source File: AutowiredConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Bean
public TestBean testBean(Optional<Colour> colour, Optional<List<Colour>> colours) {
	if (!colour.isPresent() && !colours.isPresent()) {
		return new TestBean("");
	}
	else {
		return new TestBean(colour.get().toString() + "-" + colours.get().get(0).toString());
	}
}
 
Example #18
Source File: CheckboxTagTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	List someList = new ArrayList();
	someList.add("foo");
	someList.add("bar");

	Map someMap = new LinkedHashMap();
	someMap.put("key", Boolean.TRUE);

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(new Boolean(true));
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	this.bean.setSomeList(someList);
	this.bean.setSomeMap(someMap);
	return this.bean;
}
 
Example #19
Source File: RadioButtonsTagTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(new Boolean(true));
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	List list = new ArrayList();
	list.add("foo");
	list.add("bar");
	this.bean.setSomeList(list);
	return this.bean;
}
 
Example #20
Source File: CheckboxesTagTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected TestBean createTestBean() {
	List colours = new ArrayList();
	colours.add(Colour.BLUE);
	colours.add(Colour.RED);
	colours.add(Colour.GREEN);

	List pets = new ArrayList();
	pets.add(new Pet("Rudiger"));
	pets.add(new Pet("Spot"));
	pets.add(new Pet("Fluffy"));
	pets.add(new Pet("Mufty"));

	Set someObjects = new HashSet();
	someObjects.add(new ItemPet("PET1"));
	someObjects.add(new ItemPet("PET2"));

	this.bean = new TestBean();
	this.bean.setDate(getDate());
	this.bean.setName("Rob Harrop");
	this.bean.setJedi(true);
	this.bean.setSomeBoolean(new Boolean(true));
	this.bean.setStringArray(new String[] {"bar", "foo"});
	this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
	this.bean.setOtherColours(colours);
	this.bean.setPets(pets);
	this.bean.setSomeSet(someObjects);
	List list = new ArrayList();
	list.add("foo");
	list.add("bar");
	this.bean.setSomeList(list);
	return this.bean;
}
 
Example #21
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependencies() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			AutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #22
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependencies() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			AutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #23
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #24
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndNotAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class);

	assertTrue(context.getBeansOfType(Colour.class).isEmpty());
	assertThat(context.getBean(TestBean.class).getName(), equalTo(""));
}
 
Example #25
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredSingleConstructorSupported() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", AutowiredConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(AutowiredConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(AutowiredConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #26
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testObjectFactoryConstructorWithTypeVariable() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", ObjectFactoryConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(ObjectFactoryConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(ObjectFactoryConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #27
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testAutowiredAnnotatedConstructorSupported() {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("annotation-config.xml", MultipleConstructorConfig.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.registerBeanDefinition("config1", new RootBeanDefinition(MultipleConstructorConfig.class));
	ctx.registerBeanDefinition("config2", new RootBeanDefinition(ColorConfig.class));
	ctx.refresh();
	assertSame(ctx.getBean(MultipleConstructorConfig.class).colour, ctx.getBean(Colour.class));
}
 
Example #28
Source File: AutowiredConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
public TestBean testBean(Optional<Colour> colour, Optional<List<Colour>> colours) {
	if (!colour.isPresent() && !colours.isPresent()) {
		return new TestBean("");
	}
	else {
		return new TestBean(colour.get().toString() + "-" + colours.get().get(0).toString());
	}
}
 
Example #29
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationMethodDependenciesWithOptionalAndAvailable() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
			OptionalAutowiredMethodConfig.class, ColorConfig.class);

	assertThat(context.getBean(Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean(TestBean.class).getName(), equalTo("RED-RED"));
}
 
Example #30
Source File: AutowiredConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testAutowiredConfigurationDependencies() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
			AutowiredConfigurationTests.class.getSimpleName() + ".xml", AutowiredConfigurationTests.class);

	assertThat(context.getBean("colour", Colour.class), equalTo(Colour.RED));
	assertThat(context.getBean("testBean", TestBean.class).getName(), equalTo(Colour.RED.toString()));
}