Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * OfficeFloor - http://www.officefloor.net
   * Copyright (C) 2005-2011 Daniel Sagenschneider
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package net.officefloor.compile.impl.officefloor;
 
 
 
 public class LoadOfficeFloorSourceContextTest extends
Ensure issue if fail to instantiate the net.officefloor.compile.spi.officefloor.source.OfficeFloorSource.
 
 	public void testFailInstantiate() {
 
 		final RuntimeException failure = new RuntimeException(
 				"instantiate failure");
 
 		// Record failure to instantiate
 		this.record_officefloor_issue("Failed to instantiate "
 				+ " by default constructor"failure);
 
 		// Attempt to instantiate
 		this.loadOfficeFloor(falsenull);
 	}

Ensure obtain the correct net.officefloor.frame.api.manage.OfficeFloor location.
 
 	public void testOfficeFloorLocation() {
 		this.loadOfficeFloor(truenew OfficeFloorMaker() {
 			public void make(OfficeFloorMakerContext context) {
 				assertEquals("Incorrect office location",
 			}
 		});
 	}

Ensures issue if fails to obtain the net.officefloor.model.repository.ConfigurationItem.
 
 	public void testFailGetConfigurationItem() throws Exception {
 
 		final String location = "LOCATION";
 		final IOException failure = new IOException(
 				"Configuration Item failure");
 
 		// Record failing to obtain the configuration item
 				failure);
 				"Failure obtaining configuration 'LOCATION'"failure);
 
 		// Attempt to obtain the configuration item
 		this.loadOfficeFloor(falsenew OfficeFloorMaker() {
 			public void make(OfficeFloorMakerContext context) {
				context.getContext().getConfiguration(location);
			}
		});
	}

	public void testGetConfigurationItem() throws Exception {
		final String location = "LOCATION";
		final ConfigurationItem item = this.createMock(ConfigurationItem.class);
		// Record obtaining the configuration item
				.getConfigurationItem(location), item);
		// Obtain the configuration item
		this.loadOfficeFloor(truenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				assertEquals("Incorrect configuation item"itemcontext
			}
		});
	}

	public void testMissingProperty() {
		// Record missing property
		this
				.record_officefloor_issue("Missing property 'missing' for OfficeFloorSource "
		// Attempt to load office floor
		this.loadOfficeFloor(falsenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				context.getContext().getProperty("missing");
			}
		});
	}

Ensure able to get properties.
	public void testGetProperties() {
		// Attempt to load office floor
		this.loadOfficeFloor(truenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext makerContext) {
				OfficeFloorSourceContext context = makerContext.getContext();
				assertEquals("Ensure get defaulted property""DEFAULT",
						context.getProperty("missing""DEFAULT"));
				assertEquals("Ensure get property ONE""1"context
						.getProperty("ONE"));
				assertEquals("Ensure get property TWO""2"context
						.getProperty("TWO"));
				String[] names = context.getPropertyNames();
				assertEquals("Incorrect number of property names", 3,
						names.length);
				assertEquals("Incorrect property name 0""ONE"names[0]);
				assertEquals("Incorrect property name 1""TWO"names[1]);
				assertEquals("Incorrect identifier",
						names[2]);
				Properties properties = context.getProperties();
				assertEquals("Incorrect number of properties", 3, properties
						.size());
				assertEquals("Incorrect property ONE""1"properties
						.get("ONE"));
				assertEquals("Incorrect property TWO""2"properties
						.get("TWO"));
						"Incorrect identifier",
						properties
			}
		}, "ONE""1""TWO""2");
	}

Ensure able to get the java.lang.ClassLoader.
	public void testGetClassLoader() {
		// Attempt to load office floor
		this.loadOfficeFloor(truenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				assertEquals("Incorrect class loader",
			}
		});
	}

	public void testFailSourceOfficeFloor() {
				"Fail source office floor");
		// Record failure to source the office floor
				"Failed to source OfficeFloor from OfficeFloorSource (source="
", location=" +  + ")"failure);
		// Attempt to load office floor
		this.loadOfficeFloor(falsenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				throw failure;
			}
		});
	}

	public void testLoadManagedObjectType() {
		this.loadOfficeFloor(truenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				OfficeFloorSourceContext ofsContext = context.getContext();
				// Load the managed object type
				PropertyList properties = ofsContext.createPropertyList();
				properties.addProperty(
				ManagedObjectType<?> managedObjectType = ofsContext
								.getName(), properties);
				// Ensure correct managed object type
				MockLoadManagedObject
						.assertManagedObjectType(managedObjectType);
			}
		});
	}

Ensure issue if fails to load the net.officefloor.compile.managedobject.ManagedObjectType.
		// Ensure issue in not loading managed object type
				."loadManagedObjectType",
				"Missing property 'class.name'");
		this
				.record_officefloor_issue("Failure loading ManagedObjectType from source "
		// Fail to load the managed object type
		this.loadOfficeFloor(falsenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				OfficeFloorSourceContext ofsContext = context.getContext();
				// Do not specify class causing failure to load type
				PropertyList properties = ofsContext.createPropertyList();
						.getName(), properties);
				// Should not reach this point
				fail("Should not successfully load managed object type");
			}
		});
	}

	public void testLoadOfficeType() {
		this.loadOfficeFloor(truenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				OfficeFloorSourceContext ofsContext = context.getContext();
				// Load the office type
				PropertyList properties = ofsContext.createPropertyList();
						.setValue("provided");
				OfficeType officeType = ofsContext.loadOfficeType(
						MockLoadOfficeSource.class.getName(), "mock",
						properties);
				// Ensure correct office type
				MockLoadOfficeSource.assertOfficeType(officeType);
			}
		});
	}

Ensure issue if fails to load the net.officefloor.compile.office.OfficeType.
	public void testFailLoadingOfficeType() {
		// Ensure issue in not loading office type
		this..addIssue(."mock"nullnull,
				"Missing property 'required.property' for OfficeSource "
		this.record_officefloor_issue("Failure loading OfficeType from source "
		// Fail to load the office type
		this.loadOfficeFloor(falsenew OfficeFloorMaker() {
			public void make(OfficeFloorMakerContext context) {
				OfficeFloorSourceContext ofsContext = context.getContext();
				// Do not specify class causing failure to load type
				PropertyList properties = ofsContext.createPropertyList();
						"mock"properties);
				// Should not reach this point
				fail("Should not successfully load office type");
			}
		});
	}
New to GrepCode? Check out our FAQ X