abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r660657 - in /incubator/abdera/java/trunk/extensions: features/src/test/ features/src/test/java/ features/src/test/java/org/ features/src/test/java/org/apache/ features/src/test/java/org/apache/abdera/ features/src/test/java/org/apache/abde...
Date Tue, 27 May 2008 19:41:52 GMT
Author: jmsnell
Date: Tue May 27 12:41:48 2008
New Revision: 660657

URL: http://svn.apache.org/viewvc?rev=660657&view=rev
Log:
It would be helpful if I moved the tests for the features extension also

Added:
    incubator/abdera/java/trunk/extensions/features/src/test/
    incubator/abdera/java/trunk/extensions/features/src/test/java/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java
    incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/TestSuite.java
Removed:
    incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/features/
Modified:
    incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java

Added: incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java?rev=660657&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java
(added)
+++ incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java
Tue May 27 12:41:48 2008
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.ext.features;
+
+import junit.framework.Assert;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.features.AcceptSelector;
+import org.apache.abdera.ext.features.Feature;
+import org.apache.abdera.ext.features.FeatureSelector;
+import org.apache.abdera.ext.features.Features;
+import org.apache.abdera.ext.features.FeaturesHelper;
+import org.apache.abdera.ext.features.Selector;
+import org.apache.abdera.ext.features.XPathSelector;
+import org.apache.abdera.ext.features.FeaturesHelper.Status;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.junit.Test;
+
+public class FeatureTest extends Assert {
+
+  @Test
+  public void testFeaturesDocument() throws Exception {
+    Abdera abdera = Abdera.getInstance();
+    Features features = FeaturesHelper.newFeatures(abdera);
+    assertNotNull(features);
+    assertNotNull(features.getDocument());
+    Document<Features> doc = features.getDocument();
+    assertTrue(doc.getRoot() instanceof Features);
+  }
+  
+  @Test
+  public void testFeatures() throws Exception {
+    Abdera abdera = Abdera.getInstance();
+    Collection coll = abdera.getFactory().newCollection();
+    Features features = FeaturesHelper.addFeaturesElement(coll);
+    features.addFeature(
+      "http://example.com/features/foo", 
+      null, "foo & here");
+    features.addFeature(
+      "http://example.com/features/bar", 
+      null, null);
+    
+    assertEquals(Status.SPECIFIED,FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/foo"));
+    assertEquals(Status.SPECIFIED, FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/bar"));
+    assertEquals(Status.UNSPECIFIED, FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/baz"));
+    assertEquals(Status.UNSPECIFIED,FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/pez"));
+
+  }
+
+  @Test
+  public void testSelectors() throws Exception {
+    
+    Abdera abdera = Abdera.getInstance();
+    Service service = abdera.newService();
+    Workspace workspace = service.addWorkspace("a");
+    Collection collection1 = workspace.addCollection("a1","a1");
+    collection1.setAcceptsEntry();
+    Features features = FeaturesHelper.addFeaturesElement(collection1);
+    features.addFeature(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
+    Collection collection2 = workspace.addCollection("a2","a2");
+    collection2.setAccept("image/*");
+    
+    Selector s1 = new FeatureSelector(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
+    
+    Collection[] collections = FeaturesHelper.select(service, s1);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection1);
+    
+    Selector s2 = new AcceptSelector("image/png");
+    
+    collections = FeaturesHelper.select(service,s2);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection2);
+    
+    Selector s3 = new XPathSelector(
+      "f:features/f:feature[@ref='" + FeaturesHelper.FEATURE_SUPPORTS_DRAFTS + "']");
+    
+    collections = FeaturesHelper.select(service,s3);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection1);
+  }
+  
+
+  @Test
+  public void testType() throws Exception {
+    Abdera abdera = Abdera.getInstance();
+     Feature feature = abdera.getFactory().newElement(FeaturesHelper.FEATURE);
+     feature.addType("image/jpg","image/gif","image/png","image/*");
+     String[] types = feature.getTypes();
+     assertEquals(1,types.length);
+     assertEquals("image/*", types[0]);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/TestSuite.java?rev=660657&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/TestSuite.java
(added)
+++ incubator/abdera/java/trunk/extensions/features/src/test/java/org/apache/abdera/test/ext/features/TestSuite.java
Tue May 27 12:41:48 2008
@@ -0,0 +1,31 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.ext.features;
+
+import org.junit.internal.runners.TextListener;
+import org.junit.runner.JUnitCore;
+
+public class TestSuite {
+  public static void main(String[] args)
+  {
+    JUnitCore runner = new JUnitCore();
+    runner.addListener(new TextListener(System.out));
+    runner.run(
+      FeatureTest.class);
+  }
+}

Modified: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java?rev=660657&r1=660656&r2=660657&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java
(original)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java
Tue May 27 12:41:48 2008
@@ -18,7 +18,6 @@
 package org.apache.abdera.test.ext.main;
 
 import org.apache.abdera.test.ext.bidi.BidiTest;
-import org.apache.abdera.test.ext.features.FeatureTest;
 import org.apache.abdera.test.ext.history.FeedPagingTest;
 import org.apache.abdera.test.ext.license.LicenseTest;
 import org.apache.abdera.test.ext.thread.ThreadTest;
@@ -32,7 +31,6 @@
     runner.addListener(new TextListener(System.out));
     runner.run(
       BidiTest.class,
-      FeatureTest.class,
       FeedPagingTest.class,
       LicenseTest.class,
       ThreadTest.class);



Mime
View raw message