incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahrw...@apache.org
Subject svn commit: r1054062 - in /incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org: ./ apache/ apache/aries/ apache/aries/application/ apache/aries/application/runtime/ apache/aries/application/runtime/framework/ ap...
Date Fri, 31 Dec 2010 08:35:53 GMT
Author: mahrwald
Date: Fri Dec 31 08:35:52 2010
New Revision: 1054062

URL: http://svn.apache.org/viewvc?rev=1054062&view=rev
Log:
ARIES-528: Commit test that was missed in first commit

Added:
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/
    incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerTest.java

Added: incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerTest.java?rev=1054062&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerTest.java
(added)
+++ incubator/aries/trunk/application/application-runtime-framework-management/src/test/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerTest.java
Fri Dec 31 08:35:52 2010
@@ -0,0 +1,86 @@
+package org.apache.aries.application.runtime.framework.management;
+import java.util.Arrays;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.spi.framework.BundleFramework;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkFactory;
+import org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion;
+import org.apache.aries.application.runtime.framework.management.BundleFrameworkManagerImpl;
+import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+import static junit.framework.Assert.*;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public class BundleFrameworkManagerTest {
+  private BundleFrameworkManagerImpl sut;
+  private Skeleton frameworkFactory;
+  
+  @Before
+  public void setup() {
+    sut = new BundleFrameworkManagerImpl();
+
+    BundleFrameworkConfigurationFactory bfcf = Skeleton.newMock(BundleFrameworkConfigurationFactory.class);
+    sut.setBundleFrameworkConfigurationFactory(bfcf);
+    
+    BundleFrameworkFactory bff = Skeleton.newMock(BundleFrameworkFactory.class);
+    sut.setBundleFrameworkFactory(bff); 
+    frameworkFactory = Skeleton.getSkeleton(bff);
+    
+    sut.init();
+  }
+  
+  @Test
+  public void testFailedInstall() throws Exception {
+    /*
+     * Mock up a failing framework install
+     */
+    BundleFramework fwk = Skeleton.newMock(new Object() {
+      public Bundle install(BundleSuggestion suggestion, AriesApplication app) throws BundleException
{
+        throw new BundleException("Expected failure");
+      }
+    }, BundleFramework.class);
+
+    frameworkFactory.setReturnValue(
+        new MethodCall(BundleFrameworkFactory.class, "createBundleFramework", 
+            BundleContext.class, BundleFrameworkConfiguration.class), 
+        fwk);    
+    
+    try {
+      sut.installIsolatedBundles(Arrays.asList(Skeleton.newMock(BundleSuggestion.class)),

+          Skeleton.newMock(AriesApplication.class));
+      
+      fail("Expected a BundleException");
+      
+    } catch (BundleException be) {
+      // when a failure occurred we need to have cleaned up the new framework, otherwise
it is
+      // left as floating debris
+      Skeleton.getSkeleton(fwk).assertCalled(new MethodCall(BundleFramework.class, "close"));
+    }
+  }
+}



Mime
View raw message