incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1059064 - in /sling/trunk/installer/core/src/test/java/org/apache/sling/installer: api/ api/InstallableResourceTest.java core/impl/InternalResourceTest.java core/impl/mocks/ core/impl/mocks/MockFileDataStore.java
Date Fri, 14 Jan 2011 16:40:16 GMT
Author: cziegeler
Date: Fri Jan 14 16:40:16 2011
New Revision: 1059064

URL: http://svn.apache.org/viewvc?rev=1059064&view=rev
Log:
Start adding simple junit tests.

Added:
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
  (with props)
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
  (with props)
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/
    sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
  (with props)

Added: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java?rev=1059064&view=auto
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
(added)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
Fri Jan 14 16:40:16 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.sling.installer.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.util.Hashtable;
+
+import org.junit.Test;
+
+/**
+ * Test for the installable resource.
+ */
+public class InstallableResourceTest {
+
+    @Test public void testConstructor() {
+        // no id
+        try {
+            new InstallableResource(null, null, new Hashtable<String, Object>(), null,
null, null);
+            fail("IAE expected : no id");
+        } catch (IllegalArgumentException iae) {
+            // expected
+        }
+        // no input stream, no dict
+        try {
+            new InstallableResource("1", null, null, null, null, null);
+            fail("IAE expected : no is no dict");
+        } catch (IllegalArgumentException iae) {
+            // expected
+        }
+        new InstallableResource("1", new ByteArrayInputStream("a".getBytes()), null, null,
null, null);
+        new InstallableResource("1", null, new Hashtable<String, Object>(), null, null,
null);
+        new InstallableResource("1",  new ByteArrayInputStream("a".getBytes()), new Hashtable<String,
Object>(), null, null, null);
+    }
+
+    @Test public void testPriority() {
+        final InstallableResource defaultPrio =
+            new InstallableResource("1", null, new Hashtable<String, Object>(), null,
null, null);
+        assertEquals(InstallableResource.DEFAULT_PRIORITY, defaultPrio.getPriority());
+        final InstallableResource ownPrio =
+            new InstallableResource("1", null, new Hashtable<String, Object>(), null,
null, 47);
+        assertEquals(47, ownPrio.getPriority());
+    }
+}

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/api/InstallableResourceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java?rev=1059064&view=auto
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
(added)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
Fri Jan 14 16:40:16 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.sling.installer.core.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+import org.apache.sling.installer.api.InstallableResource;
+import org.apache.sling.installer.core.impl.mocks.MockFileDataStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+/**
+ * Test for the installable resource.
+ */
+public class InternalResourceTest {
+
+    private static final String SCHEME = "test";
+
+    @Before public void setDataStore() {
+        MockFileDataStore.set();
+    }
+
+    @After public void unsetDataStore() {
+        MockFileDataStore.unset();
+    }
+
+    private InstallableResource getInstallableResource() {
+        return new InstallableResource("1",
+                null, new Hashtable<String, Object>(), null, null, null);
+    }
+
+    @Test public void testConstructor() throws IOException {
+        final InternalResource ir = InternalResource.create(SCHEME,
+                getInstallableResource());
+        assertTrue(ir.getURL().startsWith(SCHEME + ':'));
+        assertNotNull(ir.getDictionary());
+        assertNotNull(ir.getPrivateCopyOfDictionary());
+        assertNull(ir.getInputStream());
+        assertNull(ir.getPrivateCopyOfFile());
+        assertEquals(InstallableResource.TYPE_PROPERTIES, ir.getType());
+    }
+}

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/InternalResourceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java?rev=1059064&view=auto
==============================================================================
--- sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
(added)
+++ sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
Fri Jan 14 16:40:16 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.sling.installer.core.impl.mocks;
+
+import org.apache.sling.installer.core.impl.FileDataStore;
+import org.apache.sling.installer.core.impl.MockBundleContext;
+
+public class MockFileDataStore {
+
+    public static void set() {
+        new FileDataStore(new MockBundleContext());
+    }
+
+    public static void unset() {
+        FileDataStore.SHARED = null;
+    }
+}

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/mocks/MockFileDataStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message