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.model.impl.repository;
 
 
Tests the marshaling/unmarshaling of the net.officefloor.model.officefloor.OfficeFloorModel via the net.officefloor.model.repository.ModelRepository.

Author(s):
Daniel Sagenschneider
 
 
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see junit.framework.TestCase#setUp()
 	 */
 	protected void setUp() throws Exception {
 
 		// Specify location of the configuration
 				this.getClass(), "TestOfficeFloor.officefloor.xml"), null);
 	}

 
 	public void testRetrieveOfficeFloor() throws Exception {
 
 		// Load the Office Floor
 		ModelRepository repository = new ModelRepositoryImpl();
 		OfficeFloorModel officeFloor = new OfficeFloorModel();
 		officeFloor = repository.retrieve(officeFloorthis.);
 
 		// ----------------------------------------
 		// Validate the office floor managed object sources
 		// ----------------------------------------
 		assertList(new String[] { "getOfficeFloorManagedObjectSourceName",
 				"getManagedObjectSourceClassName""getObjectType",
 				"getTimeout""getX""getY" }, officeFloor
						"MANAGED_OBJECT_SOURCE",
						"net.example.ExampleManagedObjectSource",
						"net.orm.Session""10"nullnullnullnullnull,
						nullnullnull, 100, 101));
		OfficeFloorManagedObjectSourceModel moSource = officeFloor
		assertList(new String[] { "getName""getValue" }, moSource
				.getProperties(), new PropertyModel("MO_ONE""VALUE_ONE"),
				new PropertyModel("MO_TWO""VALUE_TWO"));
		// Managing office
						"OFFICE"), moSource.getManagingOffice(),
				"getManagingOfficeName");
		// Input managed object and dependencies
						"INPUT_MANAGED_OBJECT"), moSource
				"getOfficeFloorInputManagedObjectName");
				"getOfficeFloorManagedObjectSourceInputDependencyName",
				"getDependencyType" }, moSource
						"INPUT_DEPENDENCY""java.sql.Connection"));
						"MANAGED_OBJECT_TWO"), inputDependency
				"getOfficeFloorManagedObjectName");
		// Flows
		assertList(new String[] { "getOfficeFloorManagedObjectSourceFlowName",
				"getArgumentType" }, moSource
						Integer.class.getName()));
						"OFFICE""SECTION""INPUT"), flow
						.getDeployedOfficeInput(), "getDeployedOfficeName",
				"getSectionName""getSectionInputName");
		// Teams
				new String[] { "getOfficeFloorManagedObjectSourceTeamName" },
						"TEAM"), mosTeam.getOfficeFloorTeam(),
				"getOfficeFloorTeamName");
		// ----------------------------------------
		// Validate the office floor input managed objects
		// ----------------------------------------
		assertList(new String[] { "getOfficeFloorInputManagedObjectName",
				"getObjectType""getX""getY" }, officeFloor
				new OfficeFloorInputManagedObjectModel("INPUT_MANAGED_OBJECT",
						"net.orm.Session"nullnullnullnull, 200, 201));
		OfficeFloorInputManagedObjectModel inputMo = officeFloor
						"MANAGED_OBJECT_SOURCE"), inputMo
				"getOfficeFloorManagedObjectSourceName");
		// ----------------------------------------
		// Validate the office floor managed objects
		// ----------------------------------------
		assertList(new String[] { "getOfficeFloorManagedObjectName",
				"getManagedObjectScope""getX""getY" }, officeFloor
				new OfficeFloorManagedObjectModel("MANAGED_OBJECT_ONE",
						"THREAD"nullnullnullnullnull, 300, 301),
				new OfficeFloorManagedObjectModel("MANAGED_OBJECT_TWO",
						"PROCESS"nullnullnullnullnull, 310, 311));
		// Link to managed object source
						"MANAGED_OBJECT_SOURCE"), mo
				"getOfficeFloorManagedObjectSourceName");
		// Dependencies
		assertList(new String[] { "getOfficeFloorManagedObjectDependencyName",
				"getDependencyType" }, mo
						"net.orm.Session"));
						"MANAGED_OBJECT_TWO"), dependencyOne
				"getOfficeFloorManagedObjectName");
						"INPUT_MANAGED_OBJECT"), dependencyTwo
				"getOfficeFloorInputManagedObjectName");
		// ----------------------------------------
		// Validate the office floor teams
		// ----------------------------------------
		assertList(new String[] { "getOfficeFloorTeamName",
				"getTeamSourceClassName""getX""getY" }, officeFloor
				"net.example.ExampleTeamSource"nullnullnull, 400, 401));
		OfficeFloorTeamModel team = officeFloor.getOfficeFloorTeams().get(0);
		assertList(new String[] { "getName""getValue" },
				new PropertyModel("TEAM_ONE""VALUE_ONE"), new PropertyModel(
						"TEAM_TWO""VALUE_TWO"));
		// ----------------------------------------
		// Validate the deployed offices
		// ----------------------------------------
				new String[] { "getDeployedOfficeName",
						"getOfficeSourceClassName""getOfficeLocation",
						"getX""getY" }, officeFloor.getDeployedOffices(),
				new DeployedOfficeModel("OFFICE",
						"net.example.ExampleOfficeSource""OFFICE_LOCATION",
						nullnullnullnullnull, 400, 401));
		DeployedOfficeModel office = officeFloor.getDeployedOffices().get(0);
		assertList(new String[] { "getName""getValue" }, office
				.getProperties(), new PropertyModel("OFFICE_ONE""VALUE_ONE"),
				new PropertyModel("OFFICE_TWO""VALUE_TWO"));
		// Deployed office objects
		assertList(new String[] { "getDeployedOfficeObjectName",
				"getObjectType" }, office.getDeployedOfficeObjects(),
				new DeployedOfficeObjectModel("OBJECT_A""net.orm.Session"),
				new DeployedOfficeObjectModel("OBJECT_B""net.orm.Session"));
		DeployedOfficeObjectModel officeObjectA = office
						"MANAGED_OBJECT"), officeObjectA
				"getOfficeFloorManagedObjectName");
		DeployedOfficeObjectModel officeObjectB = office
						"INPUT_MANAGED_OBJECT"), officeObjectB
				"getOfficeFloorInputManagedObjectName");
		// Deployed office inputs
		assertList(new String[] { "getSectionName""getSectionInputName",
				"getParameterType" }, office.getDeployedOfficeInputs(),
				new DeployedOfficeInputModel("SECTION""INPUT"Integer.class
						.getName()));
		// Deployed office team
		assertList(new String[] { "getDeployedOfficeTeamName" }, office
				"OFFICE_TEAM"));
				.get(0);
				"getOfficeFloorTeamName");
	}

Ensure able to round trip storing and retrieving the net.officefloor.model.officefloor.OfficeFloorModel.
		// Load the Office Floor
		ModelRepository repository = new ModelRepositoryImpl();
		OfficeFloorModel officeFloor = new OfficeFloorModel();
		officeFloor = repository.retrieve(officeFloorthis.);
		// Store the Office Floor
		repository.store(officeFloorcontents);
		// Reload the Office Floor
		OfficeFloorModel reloadedOfficeFloor = new OfficeFloorModel();
		reloadedOfficeFloor = repository
				.retrieve(reloadedOfficeFloorcontents);
		// Validate round trip
		assertGraph(officeFloorreloadedOfficeFloor,
	}
New to GrepCode? Check out our FAQ X