You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2011/04/01 18:42:42 UTC
svn commit: r1087796 [16/37] - in /incubator/rave/donations/mitre-osec: ./
conf/ db/ db/data/ db/sequences/ db/tables/ lib/ lib/apache-commons/
lib/apache-taglibs/ lib/build/ lib/build/cobertura/ lib/eclipselink/
lib/freemarker/ lib/google-collections/...
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerRegistryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerRegistryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerRegistryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerRegistryTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.ContainerRegistry;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class ContainerRegistryTest
+{
+
+ // test data
+ private Long VALID_ID = 1L;
+ private ContainerRegistry cr;
+
+ @Before
+ public void setup() {
+ cr = new ContainerRegistry(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(cr.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ ContainerRegistry cr2 = new ContainerRegistry();
+ assertFalse(cr.equals(cr2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ ContainerRegistry cr2 = new ContainerRegistry(new Long(2));
+ assertFalse(cr.equals(cr2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ ContainerRegistry cr2 = new ContainerRegistry(VALID_ID);
+ assertTrue(cr.equals(cr2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(cr.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerRegistryTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.Container;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class ContainerTest
+{
+ // test data
+ private Long VALID_ID = 1L;
+ private Container c;
+
+ @Before
+ public void setup() {
+ c = new Container(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(c.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ Container c2 = new Container();
+ assertFalse(c.equals(c2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ Container c2 = new Container(new Long(2));
+ assertFalse(c.equals(c2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ Container c2 = new Container(VALID_ID);
+ assertTrue(c.equals(c2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(c.equals(o));
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/ContainerTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetRatingTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetRatingTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetRatingTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetRatingTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.mitre.portal.model;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Sean Cooper
+ */
+public class GadgetRatingTest {
+
+ private final Long VALID_ID = new Long(1);
+ private final Long INVALID_ID = new Long(-1);
+ private final Gadget VALID_GADGET = new Gadget(VALID_ID);
+ private final Gadget INVALID_GADGET = new Gadget();
+ private final Long VALID_RATING = new Long(5);
+ private final Long INVALID_RATING = new Long(-1);
+ private final String VALID_USER_ID = "28063";
+ private final String INVALID_USER_ID = "secooper";
+
+ @Test
+ public void simpleCreation() {
+ GadgetRating instance = new GadgetRating();
+ GadgetRating secondInstance = new GadgetRating();
+ assertEquals(instance, secondInstance);
+ }
+
+ @Test
+ public void idCreation() {
+ GadgetRating instance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ GadgetRating secondInstance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ assertEquals(instance, secondInstance);
+ assertNotSame(instance, new GadgetRating());
+ }
+
+ @Test
+ public void invalidId() {
+ GadgetRating instance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ GadgetRating secondInstance = new GadgetRating(INVALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetRatingId(VALID_ID);
+ assertEquals(instance, secondInstance);
+ secondInstance.setGadgetRatingId(null);
+ assertNotSame(instance, secondInstance);
+ instance.setGadgetRatingId(null);
+ assertEquals(instance, secondInstance);
+ secondInstance.setGadgetRatingId(VALID_ID);
+ assertNotSame(instance, secondInstance);
+ }
+
+ @Test
+ public void invalidGadget() {
+ GadgetRating instance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ GadgetRating secondInstance = new GadgetRating(VALID_ID, INVALID_GADGET, VALID_RATING, VALID_USER_ID);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadget(VALID_GADGET);
+ assertEquals(instance, secondInstance);
+ secondInstance.setGadget(null);
+ assertNotSame(instance, secondInstance);
+ instance.setGadget(null);
+ assertEquals(instance, secondInstance);
+ secondInstance.setGadget(VALID_GADGET);
+ assertNotSame(instance, secondInstance);
+ }
+
+ @Test
+ public void invalidRating() {
+ GadgetRating instance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ GadgetRating secondInstance = new GadgetRating(VALID_ID, VALID_GADGET, INVALID_RATING, VALID_USER_ID);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setRating(VALID_RATING);
+ assertEquals(instance, secondInstance);
+ secondInstance.setRating(null);
+ assertNotSame(instance, secondInstance);
+ instance.setRating(null);
+ assertEquals(instance, secondInstance);
+ secondInstance.setRating(VALID_RATING);
+ assertNotSame(instance, secondInstance);
+ }
+
+ @Test
+ public void invalidUserId() {
+ GadgetRating instance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, VALID_USER_ID);
+ GadgetRating secondInstance = new GadgetRating(VALID_ID, VALID_GADGET, VALID_RATING, INVALID_USER_ID);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setUserId(VALID_USER_ID);
+ assertEquals(instance, secondInstance);
+ secondInstance.setUserId(null);
+ assertNotSame(instance, secondInstance);
+ instance.setUserId(null);
+ assertEquals(instance, secondInstance);
+ secondInstance.setUserId(VALID_USER_ID);
+ assertNotSame(instance, secondInstance);
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetRatingTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.mitre.portal.model;
+
+
+import org.mitre.portal.model.Gadget;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class GadgetTest {
+
+ // test data
+ private Long VALID_ID = 1L;
+ private Gadget g;
+
+ @Before
+ public void setup() {
+ g = new Gadget(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(g.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ Gadget g2 = new Gadget();
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ Gadget g2 = new Gadget(new Long(2));
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ Gadget g2 = new Gadget(VALID_ID);
+ assertTrue(g.equals(g2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(g.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetUserPrefTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetUserPrefTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetUserPrefTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetUserPrefTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.GadgetUserPref;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class GadgetUserPrefTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private GadgetUserPref g;
+
+ @Before
+ public void setup() {
+ g = new GadgetUserPref(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(g.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ GadgetUserPref g2 = new GadgetUserPref();
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ GadgetUserPref g2 = new GadgetUserPref(new Long(2));
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ GadgetUserPref g2 = new GadgetUserPref(VALID_ID);
+ assertTrue(g.equals(g2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(g.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/GadgetUserPrefTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageLayoutTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageLayoutTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageLayoutTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageLayoutTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.PageLayout;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PageLayoutTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private PageLayout p;
+
+ @Before
+ public void setup() {
+ p = new PageLayout(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(p.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PageLayout p2 = new PageLayout();
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PageLayout p2 = new PageLayout(new Long(2));
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PageLayout p2 = new PageLayout(VALID_ID);
+ assertTrue(p.equals(p2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(p.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageLayoutTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateGadgetTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateGadgetTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateGadgetTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateGadgetTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.PageTemplateGadget;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PageTemplateGadgetTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private PageTemplateGadget p;
+
+ @Before
+ public void setup() {
+ p = new PageTemplateGadget(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(p.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PageTemplateGadget p2 = new PageTemplateGadget();
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PageTemplateGadget p2 = new PageTemplateGadget(new Long(2));
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PageTemplateGadget p2 = new PageTemplateGadget(VALID_ID);
+ assertTrue(p.equals(p2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(p.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateGadgetTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateOwnerTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateOwnerTypeTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateOwnerTypeTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateOwnerTypeTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.PageTemplateOwnerType;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PageTemplateOwnerTypeTest {
+ // test data
+ private String VALID_CODE = "CODE1";
+ private PageTemplateOwnerType p;
+
+ @Before
+ public void setup() {
+ p = new PageTemplateOwnerType(VALID_CODE);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(p.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PageTemplateOwnerType p2 = new PageTemplateOwnerType();
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PageTemplateOwnerType p2 = new PageTemplateOwnerType("CODE2");
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PageTemplateOwnerType p2 = new PageTemplateOwnerType(VALID_CODE);
+ assertTrue(p.equals(p2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(p.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateOwnerTypeTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.PageTemplate;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PageTemplateTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private PageTemplate p;
+
+ @Before
+ public void setup() {
+ p = new PageTemplate(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(p.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PageTemplate p2 = new PageTemplate();
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PageTemplate p2 = new PageTemplate(new Long(2));
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PageTemplate p2 = new PageTemplate(VALID_ID);
+ assertTrue(p.equals(p2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(p.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTemplateTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.Page;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PageTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private Page p;
+
+ @Before
+ public void setup() {
+ p = new Page(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(p.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ Page p2 = new Page();
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ Page p2 = new Page(new Long(2));
+ assertFalse(p.equals(p2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ Page p2 = new Page(VALID_ID);
+ assertTrue(p.equals(p2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(p.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PageTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.mitre.portal.model;
+
+
+
+import org.mitre.portal.model.PersonGadget;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PersonGadgetTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private PersonGadget g;
+
+ @Before
+ public void setup() {
+ g = new PersonGadget(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(g.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PersonGadget g2 = new PersonGadget();
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PersonGadget g2 = new PersonGadget(new Long(2));
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PersonGadget g2 = new PersonGadget(VALID_ID);
+ assertTrue(g.equals(g2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(g.equals(o));
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetUserPrefTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetUserPrefTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetUserPrefTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetUserPrefTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.mitre.portal.model;
+
+
+
+import org.mitre.portal.model.PersonGadgetUserPref;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PersonGadgetUserPrefTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private PersonGadgetUserPref g;
+
+ @Before
+ public void setup() {
+ g = new PersonGadgetUserPref(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(g.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ PersonGadgetUserPref g2 = new PersonGadgetUserPref();
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ PersonGadgetUserPref g2 = new PersonGadgetUserPref(new Long(2));
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ PersonGadgetUserPref g2 = new PersonGadgetUserPref(VALID_ID);
+ assertTrue(g.equals(g2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(g.equals(o));
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonGadgetUserPrefTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,86 @@
+/*
+ * 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.mitre.portal.model;
+
+
+import org.mitre.portal.model.Person;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.GrantedAuthorityImpl;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PersonTest {
+
+ // test data
+ private List<GrantedAuthority> validAuthorityList;
+ private List<GrantedAuthority> invalidAuthorityList;
+ private List<GrantedAuthority> existingAuthoritiesList;
+ private Person p;
+
+ @Before
+ public void setup() {
+ p = new Person();
+ existingAuthoritiesList = new ArrayList<GrantedAuthority>();
+ existingAuthoritiesList.add(new GrantedAuthorityImpl("ROLE1"));
+ existingAuthoritiesList.add(new GrantedAuthorityImpl("ROLE2"));
+ p.setAuthorities(existingAuthoritiesList);
+
+ validAuthorityList = new ArrayList<GrantedAuthority>();
+ validAuthorityList.add(new GrantedAuthorityImpl("ROLE1"));
+ validAuthorityList.add(new GrantedAuthorityImpl("ROLE2"));
+ validAuthorityList.add(new GrantedAuthorityImpl("ROLE3"));
+
+ invalidAuthorityList = new ArrayList<GrantedAuthority>();
+ invalidAuthorityList.add(new GrantedAuthorityImpl("ROLE4"));
+ }
+
+ @Test
+ public void hasAnyAuthority_validList_true() {
+ assertTrue(p.hasAnyAuthority(validAuthorityList));
+ }
+
+ @Test
+ public void hasAnyAuthority_invalidList_false() {
+ assertFalse(p.hasAnyAuthority(invalidAuthorityList));
+ }
+
+ @Test
+ public void hasAnyAuthority_emptyList_false() {
+ assertFalse(p.hasAnyAuthority(new ArrayList<GrantedAuthority>()));
+ }
+
+ @Test
+ public void hasAnyAuthority_nullList_false() {
+ assertFalse(p.hasAnyAuthority(null));
+ }
+
+ @Test
+ public void hasAnyAuthority_nullPersonList_validList_false() {
+ p.setAuthorities(null);
+ assertFalse(p.hasAnyAuthority(validAuthorityList));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/PersonTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionGadgetTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionGadgetTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionGadgetTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionGadgetTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,70 @@
+/*
+ * 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.mitre.portal.model;
+
+
+import org.mitre.portal.model.RegionGadget;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class RegionGadgetTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private RegionGadget g;
+
+ @Before
+ public void setup() {
+ g = new RegionGadget(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(g.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ RegionGadget g2 = new RegionGadget();
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ RegionGadget g2 = new RegionGadget(new Long(2));
+ assertFalse(g.equals(g2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ RegionGadget g2 = new RegionGadget(VALID_ID);
+ assertTrue(g.equals(g2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(g.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionGadgetTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.mitre.portal.model;
+
+
+import org.mitre.portal.model.Region;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class RegionTest {
+ // test data
+ private Long VALID_ID = 1L;
+ private Region r;
+
+ @Before
+ public void setup() {
+ r = new Region(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(r.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ Region r2 = new Region();
+ assertFalse(r.equals(r2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ Region r2 = new Region(new Long(2));
+ assertFalse(r.equals(r2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ Region r2 = new Region(VALID_ID);
+ assertTrue(r.equals(r2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(r.equals(o));
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/RegionTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/TokenInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/TokenInfoTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/TokenInfoTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/TokenInfoTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.mitre.portal.model;
+
+import org.mitre.portal.model.TokenInfo;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class TokenInfoTest
+{
+ // test data
+ private Long VALID_ID = 1L;
+ private TokenInfo ti;
+
+ @Before
+ public void setup() {
+ ti = new TokenInfo();
+ ti.setTokenInfoId(VALID_ID);
+ }
+
+ @Test
+ public void equals_nullObject_false() {
+ assertFalse(ti.equals(null));
+ }
+
+ @Test
+ public void equals_emptyObject_false() {
+ TokenInfo ti2 = new TokenInfo();
+ assertFalse(ti.equals(ti2));
+ }
+
+ @Test
+ public void equals_validObjectDifferentId_false() {
+ TokenInfo ti2 = new TokenInfo();
+ ti2.setTokenInfoId(new Long(2));
+ assertFalse(ti.equals(ti2));
+ }
+
+ @Test
+ public void equals_validObjectSameId_true() {
+ TokenInfo ti2 = new TokenInfo();
+ ti2.setTokenInfoId(VALID_ID);
+ assertTrue(ti.equals(ti2));
+ }
+
+ @Test
+ public void equals_differentObjectClass_false() {
+ Object o = new Object();
+ assertFalse(ti.equals(o));
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/TokenInfoTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/BooleanConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/BooleanConverterTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/BooleanConverterTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/BooleanConverterTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,94 @@
+
+/*
+ * 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.mitre.portal.model.util;
+
+import org.mitre.portal.model.util.BooleanConverter;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class BooleanConverterTest {
+
+ // test data
+ private final String VALID_TRUE_VALUE = "Y";
+ private final String VALID_FALSE_VALUE = "N";
+ private BooleanConverter bc = new BooleanConverter();
+
+ @Test
+ public void convertObjectValueToDataValue_validTrueBoolean_yString() {
+ Boolean bool = new Boolean(true);
+ String result = (String) bc.convertObjectValueToDataValue(bool, null);
+ assertEquals(VALID_TRUE_VALUE, result);
+ }
+
+ @Test
+ public void convertObjectValueToDataValue_nullBoolean_nString() {
+ Boolean bool = null;
+ String result = (String) bc.convertObjectValueToDataValue(bool, null);
+ assertEquals(VALID_FALSE_VALUE, result);
+ }
+
+ @Test
+ public void convertObjectValueToDataValue_validFalseBoolean_nString() {
+ Boolean bool = new Boolean(false);
+ String result = (String) bc.convertObjectValueToDataValue(bool, null);
+ assertEquals(VALID_FALSE_VALUE, result);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void convertObjectValueToDataValue_invalidObject_exception() {
+ Object o = new Object();
+ String result = (String) bc.convertObjectValueToDataValue(o, null);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_validYString_true() {
+ Boolean result = (Boolean) bc.convertDataValueToObjectValue(VALID_TRUE_VALUE, null);
+ assertTrue(result);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_null_false() {
+ Boolean result = (Boolean) bc.convertDataValueToObjectValue(null, null);
+ assertFalse(result);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_validNString_false() {
+ Boolean result = (Boolean) bc.convertDataValueToObjectValue(VALID_FALSE_VALUE, null);
+ assertFalse(result);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void convertDataValueToObjectValue_invalidObject_exception() {
+ Object o = new Object();
+ Boolean result = (Boolean) bc.convertDataValueToObjectValue(o, null);
+ }
+
+ @Test
+ public void isMutable_true() {
+ assertTrue(bc.isMutable());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/BooleanConverterTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/FeaturedComparatorTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/FeaturedComparatorTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/FeaturedComparatorTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/FeaturedComparatorTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,99 @@
+/*
+ * 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.mitre.portal.model.util;
+
+import org.mitre.portal.model.Gadget;
+import org.mitre.portal.model.ContainerRegistry;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class FeaturedComparatorTest {
+ private FeaturedComparator fc;
+
+ private ContainerRegistry cr1;
+ private ContainerRegistry cr2;
+ private Gadget g1;
+ private Gadget g2;
+
+ @Before
+ public void setup() {
+ fc = new FeaturedComparator();
+
+ cr1 = new ContainerRegistry();
+ g1 = new Gadget();
+ cr1.setGadget(g1);
+
+ cr2 = new ContainerRegistry();
+ g2 = new Gadget();
+ cr2.setGadget(g2);
+ }
+
+ @Test
+ public void compare_featured1False_featured2False() {
+ g1.setFeatured(false);
+ g2.setFeatured(false);
+
+ int value = fc.compare(cr1, cr2);
+ assertEquals(0, value);
+ }
+
+ @Test
+ public void compare_featured1True_featured2True() {
+ g1.setFeatured(true);
+ g2.setFeatured(true);
+
+ int value = fc.compare(cr1, cr2);
+ assertEquals(0, value);
+ }
+
+ @Test
+ public void compare_featured1True_featured2False() {
+ g1.setFeatured(true);
+ g2.setFeatured(false);
+
+ int value = fc.compare(cr1, cr2);
+ assertEquals(-1, value);
+ }
+
+ @Test
+ public void compare_featured1False_featured2True() {
+ g1.setFeatured(false);
+ g2.setFeatured(true);
+
+ int value = fc.compare(cr1, cr2);
+ assertEquals(1, value);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void compare_invalidFeatured1_classCastException() {
+ int value = fc.compare(new String(), cr2);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void compare_invalidFeatured2_classCastException() {
+ int value = fc.compare(cr1, new String());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/FeaturedComparatorTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/GadgetStatisticsTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/GadgetStatisticsTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/GadgetStatisticsTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/GadgetStatisticsTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.mitre.portal.model.util;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Sean Cooper
+ */
+public class GadgetStatisticsTest {
+
+ public static Long VALID_GADGET_ID = 1L;
+ public static Long VALID_SECOND_GADGET_ID = 2L;
+ public static int VALID_USER_COUNT = 1;
+ public static int VALID_USER_LIKE = 2;
+ public static int VALID_USER_DISLIKE = 3;
+ public static int VALID_USER_RATING = 4;
+
+ private GadgetStatistics generateValidGadgetStatistics() {
+
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setGadgetId(VALID_GADGET_ID);
+ instance.setUserCount(VALID_USER_COUNT);
+ instance.setUserDislike(VALID_USER_DISLIKE);
+ instance.setUserLike(VALID_USER_LIKE);
+ instance.setUserRating(VALID_USER_RATING);
+
+ return instance;
+ }
+
+ /**
+ * Test of setGadgetId method, of class GadgetStatistics.
+ */
+ @Test
+ public void testGadgetId() {
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setGadgetId(VALID_GADGET_ID);
+ assertEquals(VALID_GADGET_ID, instance.getGadgetId());
+ }
+
+ /**
+ * Test of setUserCount method, of class GadgetStatistics.
+ */
+ @Test
+ public void testUserCount() {
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setUserCount(VALID_USER_COUNT);
+ assertEquals(VALID_USER_COUNT, instance.getUserCount());
+ }
+
+ /**
+ * Test of setUserLike method, of class GadgetStatistics.
+ */
+ @Test
+ public void testUserLike() {
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setUserLike(VALID_USER_LIKE);
+ assertEquals(VALID_USER_LIKE, instance.getUserLike());
+ }
+
+
+ /**
+ * Test of setUserDislike method, of class GadgetStatistics.
+ */
+ @Test
+ public void testUserDislike() {
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setUserDislike(VALID_USER_DISLIKE);
+ assertEquals(VALID_USER_DISLIKE, instance.getUserDislike());
+ }
+
+ /**
+ * Test of setUserRating method, of class GadgetStatistics.
+ */
+ @Test
+ public void testUserRating() {
+ GadgetStatistics instance = new GadgetStatistics();
+ instance.setUserRating(VALID_USER_RATING);
+ assertEquals(VALID_USER_RATING, instance.getUserRating());
+ }
+
+ /**
+ * Test of toString method, of class GadgetStatistics.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+ GadgetStatistics instance = generateValidGadgetStatistics();
+ assertTrue(instance.toString() instanceof String);
+ }
+
+ /**
+ * Test of equals method, of class GadgetStatistics.
+ */
+ @Test
+ public void testEquals() {
+ GadgetStatistics instance = generateValidGadgetStatistics();
+ assertFalse(instance.equals(null));
+ assertFalse(instance.equals(VALID_GADGET_ID));
+
+ GadgetStatistics secondInstance = generateValidGadgetStatistics();
+ assertEquals(instance, secondInstance);
+ secondInstance.setGadgetId(null);
+ assertNotSame(secondInstance, instance);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetId(VALID_GADGET_ID);
+ assertEquals(instance, secondInstance);
+
+ secondInstance.setUserCount(0);
+ assertNotSame(instance, secondInstance);
+ assertNotSame(secondInstance, instance);
+ secondInstance.setGadgetId(null);
+ assertNotSame(secondInstance, instance);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetId(VALID_GADGET_ID);
+ secondInstance.setUserCount(VALID_USER_COUNT);
+
+ secondInstance.setUserDislike(0);
+ assertNotSame(instance, secondInstance);
+ assertNotSame(secondInstance, instance);
+ secondInstance.setGadgetId(null);
+ assertNotSame(secondInstance, instance);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetId(VALID_GADGET_ID);
+ secondInstance.setUserDislike(VALID_USER_DISLIKE);
+
+ secondInstance.setUserLike(0);
+ assertNotSame(instance, secondInstance);
+ assertNotSame(secondInstance, instance);
+ secondInstance.setGadgetId(null);
+ assertNotSame(secondInstance, instance);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetId(VALID_GADGET_ID);
+ secondInstance.setUserLike(VALID_USER_LIKE);
+
+ secondInstance.setUserRating(0);
+ assertNotSame(instance, secondInstance);
+ assertNotSame(secondInstance, instance);
+ secondInstance.setGadgetId(null);
+ assertNotSame(secondInstance, instance);
+ assertNotSame(instance, secondInstance);
+ secondInstance.setGadgetId(VALID_GADGET_ID);
+ secondInstance.setUserRating(VALID_USER_RATING);
+
+ }
+
+ /**
+ * Test of hashCode method, of class GadgetStatistics.
+ */
+ @Test
+ public void testHashCode() {
+ GadgetStatistics instance = generateValidGadgetStatistics();
+ GadgetStatistics secondInstance = generateValidGadgetStatistics();
+ secondInstance.setGadgetId(VALID_SECOND_GADGET_ID);
+ assertNotSame(instance.hashCode(), secondInstance.hashCode());
+
+ instance.setGadgetId(null);
+ assertTrue(instance.hashCode() > -1);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/GadgetStatisticsTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/JaxbWrappersTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/JaxbWrappersTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/JaxbWrappersTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/JaxbWrappersTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.mitre.portal.model.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.mitre.portal.model.util.JaxbWrappers.GenericMapWrapper;
+import org.mitre.portal.model.util.JaxbWrappers.StringStringMapWrapper;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Sean Cooper
+ */
+public class JaxbWrappersTest {
+
+ @Test
+ public void testStringString() {
+
+ //verify constructor doesn't blow up
+ new JaxbWrappers();
+
+ Map<String, String> data = new HashMap<String, String>();
+ data.put("Test", "Case");
+ data.put("Always", "Valid");
+ data.put("Got", "To");
+ data.put("Love", "Code");
+ data.put("Coverage", "!");
+
+ StringStringMapWrapper wrapper = new StringStringMapWrapper(data);
+ assertEquals(wrapper.getData(), data);
+
+ wrapper = new StringStringMapWrapper();
+ wrapper.setData(data);
+ assertEquals(wrapper.getData(), data);
+ }
+
+ @Test
+ public void testGenericMap() {
+ Map<String, String> data = new HashMap<String, String>();
+ data.put("Test", "Case");
+ data.put("Always", "Valid");
+ data.put("Got", "To");
+ data.put("Love", "Code");
+ data.put("Coverage", "!");
+
+ GenericMapWrapper wrapper = new GenericMapWrapper(data);
+ assertEquals(wrapper.getData(), data);
+
+ wrapper = new GenericMapWrapper();
+ wrapper.setData(data);
+ assertEquals(wrapper.getData(), data);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/JaxbWrappersTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/ListUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/ListUtilTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/ListUtilTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/ListUtilTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,139 @@
+/*
+ * 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.mitre.portal.model.util;
+
+import java.util.HashMap;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class ListUtilTest {
+ private List<String> list;
+
+ @Before
+ public void setup() {
+ list = new ArrayList<String>();
+ }
+
+ @Test
+ public void constructorTest() {
+ new ListUtil();
+ }
+
+ @Test
+ public void getSingleOrNullResultObject_nullList_null() {
+ assertNull(ListUtil.getSingleOrNullResultObject(null));
+ }
+
+ @Test
+ public void getSingleOrNullResultObject_emptyList_null() {
+ assertNull(ListUtil.getSingleOrNullResultObject(list));
+ }
+
+ @Test
+ public void getSingleOrNullResultObject_singleItemList_item() {
+ String expected = "hello";
+ list.add(expected);
+ assertEquals(expected, ListUtil.getSingleOrNullResultObject(list));
+ }
+
+ @Test(expected = IncorrectResultSizeDataAccessException.class)
+ public void getSingleOrNullResultObject_multipleItemList_exception() {
+ list.add("asdf");
+ list.add("2222d");
+ ListUtil.getSingleOrNullResultObject(list);
+ }
+
+ @Test(expected = IncorrectResultSizeDataAccessException.class)
+ public void getSingleResultObject_nullList_null() {
+ ListUtil.getSingleResultObject(null);
+ }
+
+ @Test(expected = IncorrectResultSizeDataAccessException.class)
+ public void getSingleResultObject_multipleItemList_exception() {
+ list.add("asdf");
+ list.add("2222d");
+ ListUtil.getSingleResultObject(list);
+ }
+
+ @Test
+ public void getSingleResultObject_singleItemList_item() {
+ String expected = "hello";
+ list.add(expected);
+ assertEquals(expected, ListUtil.getSingleResultObject(list));
+ }
+
+ @Test
+ public void getCacheKey_validString_validString() {
+ final String key = "mykey";
+ final String expected = "MYKEY";
+ assertEquals(expected, ListUtil.getCacheKey(key));
+ }
+
+ @Test
+ public void getCacheKey_null_null() {
+ assertNull(ListUtil.getCacheKey(null));
+ }
+
+ @Test
+ public void addEntryToObjectsMap_validKey_validObject_validEmptyObjectMap() {
+ final String key = "MYKEY";
+ String testObject = "my super cool string";
+ String testObject2 = "my super cool string2";
+ Map<String, List<String>> keyToObjectsMap = new HashMap<String, List<String>>();
+
+ ListUtil.addEntryToObjectsMap(key, testObject, keyToObjectsMap);
+ assertFalse(keyToObjectsMap.isEmpty());
+ assertTrue(keyToObjectsMap.containsKey(key));
+ List<String> objList = keyToObjectsMap.get(key);
+ assertFalse(objList.isEmpty());
+ assertEquals(testObject, objList.get(0));
+
+ // now add a second object to the already created internal object list
+ ListUtil.addEntryToObjectsMap(key, testObject2, keyToObjectsMap);
+ assertFalse(keyToObjectsMap.isEmpty());
+ assertTrue(keyToObjectsMap.containsKey(key));
+ objList = keyToObjectsMap.get(key);
+ assertFalse(objList.isEmpty());
+ assertEquals(2, objList.size());
+ }
+
+ @Test
+ public void addEntryToObjectsMap_nullKey_validObject_validEmptyObjectMap() {
+ final String key = null;
+ String testObject = "my super cool string";
+ Map<String, List<String>> keyToObjectsMap = new HashMap<String, List<String>>();
+
+ ListUtil.addEntryToObjectsMap(key, testObject, keyToObjectsMap);
+ assertTrue(keyToObjectsMap.isEmpty());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/ListUtilTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/StringStringMapToXmlConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/StringStringMapToXmlConverterTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/StringStringMapToXmlConverterTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/StringStringMapToXmlConverterTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.mitre.portal.model.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.eclipse.persistence.sessions.Session;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class StringStringMapToXmlConverterTest {
+
+ private Map<String,String> objectValue;
+ private String dataValue;
+ private Session session = null;
+ private StringStringMapToXmlConverter c = new StringStringMapToXmlConverter();
+
+ private final String VALID_KEY = "mykey";
+ private final String VALID_VALUE = "myvalue";
+
+ @Test
+ public void convertObjectValueToDataValue_validObjectValue_validSession_validString() {
+ objectValue = new HashMap<String,String>();
+ objectValue.put(VALID_KEY, VALID_VALUE);
+
+ String returnValue = (String) c.convertObjectValueToDataValue(objectValue, session);
+ assertNotNull(returnValue);
+ }
+
+ @Test
+ public void convertObjectValueToDataValue_nullObjectValue_validSession_nullString() {
+ objectValue = null;
+
+ String returnValue = (String) c.convertObjectValueToDataValue(objectValue, session);
+ assertNull(returnValue);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_validDatabaseValue_validSession_validMap() {
+ dataValue = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><map><data><entry><key>" + VALID_KEY + "</key><value>" + VALID_VALUE + "</value></entry></data></map>";
+
+ Map<String,String> map = (Map<String, String>) c.convertDataValueToObjectValue(dataValue, session);
+ assertNotNull(map);
+ assertTrue(map.containsKey(VALID_KEY));
+ assertEquals(VALID_VALUE, map.get(VALID_KEY));
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_nullDatabaseValue_validSession_emptyMap() {
+ dataValue = null;
+
+ Map<String,String> returnValue = (Map<String, String>) c.convertDataValueToObjectValue(dataValue, session);
+ assertTrue(returnValue.isEmpty());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/StringStringMapToXmlConverterTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/URLConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/URLConverterTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/URLConverterTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/URLConverterTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,101 @@
+
+/*
+ * 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.mitre.portal.model.util;
+
+import org.mitre.portal.model.util.URLConverter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class URLConverterTest {
+
+ // test data
+ private URLConverter converter = new URLConverter();
+ private final String VALID_URL = "http://content.example.com";
+ private final String INVALID_URL = "THISISNOTVALIDURL";
+ private URL validURL = null;
+
+ @Before
+ public void setup() throws MalformedURLException {
+ validURL = new URL(VALID_URL);
+ }
+
+ @Test
+ public void convertObjectValueToDataValue_validURL_validString() {
+ String result = (String) converter.convertObjectValueToDataValue(validURL, null);
+ assertEquals(VALID_URL, result);
+ }
+
+ @Test
+ public void convertObjectValueToDataValue_nullURL_nullString() {
+ String result = (String) converter.convertObjectValueToDataValue(null, null);
+ assertNull(result);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void convertObjectValueToDataValue_invalidObject_exception() {
+ Object o = new Object();
+ String result = (String) converter.convertObjectValueToDataValue(o, null);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_validUrlString_validURL() {
+ URL result = (URL) converter.convertDataValueToObjectValue(VALID_URL, null);
+ assertNotNull(result);
+ assertEquals(VALID_URL, result.toString());
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_nullUrlString_nullURL() {
+ URL result = (URL) converter.convertDataValueToObjectValue(null, null);
+ assertNull(result);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_emptyUrlString_nullURL() {
+ URL result = (URL) converter.convertDataValueToObjectValue("", null);
+ assertNull(result);
+ }
+
+ @Test
+ public void convertDataValueToObjectValue_invalidURLString_nullURL() {
+ URL result = (URL) converter.convertDataValueToObjectValue(INVALID_URL, null);
+ assertNull(result);
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void convertDataValueToObjectValue_invalidObject_exception() {
+ Object o = new Object();
+ URL result = (URL) converter.convertDataValueToObjectValue(o, null);
+ }
+
+ @Test
+ public void isMutable_true() {
+ assertTrue(converter.isMutable());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/model/util/URLConverterTest.java
------------------------------------------------------------------------------
svn:executable = *