001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 003 * agreements. See the NOTICE file distributed with this work for additional information regarding 004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 005 * "License"); you may not use this file except in compliance with the License. You may obtain a 006 * copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software distributed under the License 011 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing permissions and limitations under 013 * the License. 014 */ 015package org.apache.maven.execution.scope.internal; 016 017import junit.framework.TestCase; 018 019import com.google.inject.Key; 020 021public class MojoExecutionScopeTest 022 extends TestCase 023{ 024 public void testNestedEnter() 025 throws Exception 026 { 027 MojoExecutionScope scope = new MojoExecutionScope(); 028 029 scope.enter(); 030 031 Object o1 = new Object(); 032 scope.seed( Object.class, o1 ); 033 assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); 034 035 scope.enter(); 036 Object o2 = new Object(); 037 scope.seed( Object.class, o2 ); 038 assertSame( o2, scope.scope( Key.get( Object.class ), null ).get() ); 039 040 scope.exit(); 041 assertSame( o1, scope.scope( Key.get( Object.class ), null ).get() ); 042 043 scope.exit(); 044 045 try 046 { 047 scope.exit(); 048 } 049 catch ( IllegalStateException expected ) 050 { 051 } 052 } 053}