ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r939835 - in /incubator/ace/trunk/ace-identification-property: pom.xml src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java
Date Fri, 30 Apr 2010 21:50:24 GMT
Author: marrs
Date: Fri Apr 30 21:50:24 2010
New Revision: 939835

URL: http://svn.apache.org/viewvc?rev=939835&view=rev
Log:
Added unit tests, and a dependency to the pom to make them work. Fixed a standard header.

Added:
    incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java
Modified:
    incubator/ace/trunk/ace-identification-property/pom.xml
    incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java

Modified: incubator/ace/trunk/ace-identification-property/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-identification-property/pom.xml?rev=939835&r1=939834&r2=939835&view=diff
==============================================================================
--- incubator/ace/trunk/ace-identification-property/pom.xml (original)
+++ incubator/ace/trunk/ace-identification-property/pom.xml Fri Apr 30 21:50:24 2010
@@ -25,7 +25,7 @@
         <groupId>org.apache.ace</groupId>
         <artifactId>ace-pom</artifactId>
         <version>0.8.0-SNAPSHOT</version>
-        <relativePath>../pom/</relativePath>                
+        <relativePath>../pom/</relativePath>
     </parent>
 
     <groupId>org.apache.ace</groupId>
@@ -49,7 +49,6 @@
         </plugins>
     </build>
 
-
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
@@ -68,7 +67,10 @@
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.dependencymanager</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${groupId}</groupId>
+            <artifactId>ace-util</artifactId>
+            <version>${version}</version>
+        </dependency>
     </dependencies>
-    
-
 </project>
\ No newline at end of file

Modified: incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java?rev=939835&r1=939834&r2=939835&view=diff
==============================================================================
--- incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java
(original)
+++ incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/PropertyBasedIdentificationTest.java
Fri Apr 30 21:50:24 2010
@@ -1,19 +1,20 @@
 /*
- * Copyright 2009 Toni Menzel.
+ * 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
  *
- * Licensed 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
  *
- * 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.
+ * 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.
  */
 package org.apache.ace.identification.property;
 
@@ -32,24 +33,15 @@ import org.junit.Test;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.log.LogService;
 
-/**
- * @author Toni Menzel
- * @since Dec 7, 2009
- */
-public class PropertyBasedIdentificationTest
-{
-
+public class PropertyBasedIdentificationTest {
     @Test
-    public void getIdWithoutUpdate()
-    {
+    public void getIdWithoutUpdate() {
         PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification();
         assertThat( basedIdentification.getID(), is( nullValue() ) );
     }
 
     @Test
-    public void getIdWithUpdate()
-        throws ConfigurationException
-    {
+    public void getIdWithUpdate() throws ConfigurationException {
         PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification();
         Dictionary dict = new Hashtable();
         dict.put( IdentificationConstants.IDENTIFICATION_GATEWAYID_KEY, "myGatewayId" );
@@ -58,9 +50,7 @@ public class PropertyBasedIdentification
     }
 
     @Test
-    public void getIdOverwrite()
-        throws ConfigurationException
-    {
+    public void getIdOverwrite() throws ConfigurationException {
         PropertyBasedIdentification basedIdentification = new PropertyBasedIdentification();
         injectServices( basedIdentification );
 
@@ -75,27 +65,21 @@ public class PropertyBasedIdentification
         assertThat( basedIdentification.getID(), is( equalTo( "newId" ) ) );
     }
 
-    private void injectServices( Object o )
-    {
-        for( Field field : o.getClass().getDeclaredFields() )
-        {
-            if( field.getType() == LogService.class )
-            {
-                field.setAccessible( true );
-                try
-                {
-                    field.set( o, getLogService() );
-                } catch( IllegalAccessException e )
-                {
+    private void injectServices(Object o) {
+        for (Field field : o.getClass().getDeclaredFields()) {
+            if (field.getType() == LogService.class) {
+                field.setAccessible(true);
+                try {
+                    field.set(o, getLogService());
+                }
+                catch (IllegalAccessException e) {
                     e.printStackTrace();
                 }
             }
         }
     }
 
-    private LogService getLogService()
-    {
-        return mock( LogService.class );
-
+    private LogService getLogService() {
+        return mock(LogService.class);
     }
 }

Added: incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java?rev=939835&view=auto
==============================================================================
--- incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java
(added)
+++ incubator/ace/trunk/ace-identification-property/src/test/java/org/apache/ace/identification/property/SimpleIdentificationTest.java
Fri Apr 30 21:50:24 2010
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.ace.identification.property;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+
+import java.util.Properties;
+
+import org.apache.ace.identification.property.constants.IdentificationConstants;
+import org.apache.ace.test.utils.TestUtils;
+import org.osgi.service.log.LogService;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+public class SimpleIdentificationTest {
+    private PropertyBasedIdentification m_identification;
+
+    private static final String TEST_ID = "testGatewayID";
+
+    @BeforeTest(alwaysRun = true)
+    protected void setUp() throws Exception {
+        m_identification = new PropertyBasedIdentification();
+        TestUtils.configureObject(m_identification, LogService.class);
+    }
+
+    /**
+     * Test simple identification
+     *
+     * @throws Exception
+     */
+    @SuppressWarnings("serial")
+    @Test(groups = { UNIT })
+    public void testSimpleIdentification() throws Exception {
+        m_identification.updated(
+            new Properties() {
+                {put(IdentificationConstants.IDENTIFICATION_GATEWAYID_KEY, TEST_ID);}
+            });
+        assert TEST_ID.equals(m_identification.getID()) : "gateway ID does not match configured
gateway ID";
+    }
+}



Mime
View raw message