Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2015-01-15 17:49:09 -0500
committerAngel Avila2015-01-15 17:49:09 -0500
commit02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d (patch)
tree9dacb266c8813658add6ca4276e52940a71da80a /plugins/org.eclipse.osee.framework.core.server.test
parent0b3a6efb33f4caee629df6cd255fb549bf538e8f (diff)
downloadorg.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.tar.gz
org.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.tar.xz
org.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.zip
feature[ats_ATS152956]: Remove osee.build.designation from app server
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.server.test')
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/BuildTypeIdentifierTest.java121
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/CoreServerInternalTestSuite.java5
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/session/SessionFactoryTest.java21
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeDataProvider.java36
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeIdentifier.java40
-rw-r--r--plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockLog.java105
6 files changed, 18 insertions, 310 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/BuildTypeIdentifierTest.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/BuildTypeIdentifierTest.java
deleted file mode 100644
index 08ad83598c..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/BuildTypeIdentifierTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.test.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.osee.framework.core.server.internal.BuildInfo;
-import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier;
-import org.eclipse.osee.framework.core.server.test.mocks.MockBuildTypeDataProvider;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Test Case for {@link BuildTypeIdentifier}
- *
- * @author Roberto E. Escobar
- */
-@RunWith(Parameterized.class)
-public class BuildTypeIdentifierTest {
- private static final String NULL_XML = null;
- private static final String INVALID_XML = "Invalid<><>";
- private static final Collection<BuildInfo> EMPTY_INFOS = Collections.emptyList();
- private static final String XML_DATA1 =
- "<builds><build type=\"BUILD1\"><matches>version1</matches></build></builds>";
- private static final Collection<BuildInfo> BUILD_DATA1 = Collections.singleton(new BuildInfo("BUILD1", "version1"));
-
- private static final String XML_DATA2 =
- "<builds><build type=\"BUILD1\"><matches>version1.*</matches></build></builds>";
- private static final Collection<BuildInfo> BUILD_DATA2 =
- Collections.singleton(new BuildInfo("BUILD1", "version1.*"));
-
- private static final String XML_DATA3 =
- "<builds><build type=\"BUILD1\"><matches>ver[a|B].*?456</matches></build></builds>";
- private static final Collection<BuildInfo> BUILD_DATA3 = Collections.singleton(new BuildInfo("BUILD1",
- "ver[a|B].*?456"));
-
- private static final String XML_DATA4 =
- "<builds><build type=\"BUILD1\"><matches>0.9.1.*</matches></build><build type=\"BUILD2\"><matches>0.9.2.*</matches><matches>0.9.3.*</matches></build></builds>";
- private static final Collection<BuildInfo> BUILD_DATA4 = Arrays.asList(new BuildInfo("BUILD1", "0.9.1.*"),
- new BuildInfo("BUILD2", "0.9.2.*", "0.9.3.*"));
-
- private static final String XML_DATA5 =
- "<builds><build type=\"Release Candidate\"><matches>0.9.2.*</matches></build><build type=\"Release\"><matches>0.9.*</matches></build><build type=\"Hacking\"><matches>.*</matches></build></builds>";
- private static final Collection<BuildInfo> BUILD_DATA5 = Arrays.asList(
- new BuildInfo("Release Candidate", "0.9.2.*"), new BuildInfo("Release", "0.9.*"), new BuildInfo("Hacking", ".*"));
-
- private final BuildTypeIdentifier buildIdentifier;
- private final String clientVersion;
- private final String expectedMatch;
- private final String description;
- private final boolean isError;
- private final String xmlData;
- private final Collection<BuildInfo> expectedInfos;
-
- public BuildTypeIdentifierTest(String description, String clientVersion, String expectedMatch, String xmlData, boolean isError, Collection<BuildInfo> expectedInfos) {
- this.isError = isError;
- this.xmlData = xmlData;
- this.buildIdentifier = new BuildTypeIdentifier(new MockBuildTypeDataProvider(xmlData, isError));
- this.description = description;
- this.clientVersion = clientVersion;
- this.expectedMatch = expectedMatch;
- this.expectedInfos = expectedInfos;
- }
-
- @Test
- public void testBuildType() {
- Collection<BuildInfo> actualInfos = null;
- try {
- actualInfos = buildIdentifier.getBuildTypeEntries();
- if (isExceptionExpected()) {
- Assert.fail("This line should not executed during an xml data access exception");
- }
- } catch (OseeCoreException ex1) {
- Assert.assertTrue("Threw exception when not expected. \n" + Lib.exceptionToString(ex1), isExceptionExpected());
- }
- Assert.assertFalse(Compare.isDifferent(expectedInfos, actualInfos));
- }
-
- @Test
- public void testBuildDesignation() {
- String actualMatch = buildIdentifier.getBuildDesignation(clientVersion);
- Assert.assertEquals(description, expectedMatch, actualMatch);
- }
-
- private boolean isExceptionExpected() {
- return isError || INVALID_XML.equals(xmlData);
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- List<Object[]> data = new ArrayList<Object[]>();
-
- data.add(new Object[] {"null version && null xml data", null, "N/A", NULL_XML, false, EMPTY_INFOS});
- data.add(new Object[] {"valid versions && xml DataAccessException", "version1", "N/A", NULL_XML, true, null});
- data.add(new Object[] {"valid version && invalid xml data", "version1", "N/A", INVALID_XML, false, null});
- data.add(new Object[] {"exact match", "version1", "BUILD1", XML_DATA1, false, BUILD_DATA1});
- data.add(new Object[] {"regex match", "version12 !@#$da", "BUILD1", XML_DATA2, false, BUILD_DATA2});
- data.add(new Object[] {"complex regex match1", "verB!@#$_456", "BUILD1", XML_DATA3, false, BUILD_DATA3});
- data.add(new Object[] {"complex regex match2", "0.9.3.123132131", "BUILD2", XML_DATA4, false, BUILD_DATA4});
- data.add(new Object[] {"complex regex match3", "Development", "Hacking", XML_DATA5, false, BUILD_DATA5});
- return data;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/CoreServerInternalTestSuite.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/CoreServerInternalTestSuite.java
index 298df377e1..533fe64cbf 100644
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/CoreServerInternalTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/CoreServerInternalTestSuite.java
@@ -15,10 +15,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({ //
-BuildTypeIdentifierTest.class, //
- SessionTestSuite.class, //
-})
+@Suite.SuiteClasses({SessionTestSuite.class})
/**
* @author Roberto E. Escobar
*/
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/session/SessionFactoryTest.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/session/SessionFactoryTest.java
index 0e9db8f9c0..f51718809b 100644
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/session/SessionFactoryTest.java
+++ b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/internal/session/SessionFactoryTest.java
@@ -10,18 +10,21 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.server.test.internal.session;
+import static org.mockito.MockitoAnnotations.initMocks;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import org.eclipse.osee.framework.core.server.internal.session.Session;
import org.eclipse.osee.framework.core.server.internal.session.SessionFactory;
-import org.eclipse.osee.framework.core.server.test.mocks.MockBuildTypeIdentifier;
-import org.eclipse.osee.framework.core.server.test.mocks.MockLog;
+import org.eclipse.osee.jdbc.JdbcService;
+import org.eclipse.osee.logger.Log;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
+import org.mockito.Mock;
/**
* Test Case for {@link Session}
@@ -31,6 +34,11 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class SessionFactoryTest {
+ @Mock
+ private Log logger;
+ @Mock
+ private JdbcService jdbcService;
+
private final String guid;
private final String userId;
private final Date creationDate;
@@ -38,8 +46,7 @@ public class SessionFactoryTest {
private final String clientMachineName;
private final String clientAddress;
private final int clientPort;
- private final MockBuildTypeIdentifier typeIdentifier = new MockBuildTypeIdentifier();
- private final SessionFactory factory = new SessionFactory(new MockLog(), null, typeIdentifier);
+ private final SessionFactory factory;
public SessionFactoryTest(String guid, String userId, Date creationDate, String clientVersion, String clientMachineName, String clientAddress, int clientPort) {
super();
@@ -50,6 +57,12 @@ public class SessionFactoryTest {
this.clientMachineName = clientMachineName;
this.clientAddress = clientAddress;
this.clientPort = clientPort;
+ this.factory = new SessionFactory(logger, jdbcService);
+ }
+
+ @Before
+ public void setup() {
+ initMocks(this);
}
@Test
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeDataProvider.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeDataProvider.java
deleted file mode 100644
index 4f819546d7..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeDataProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.test.mocks;
-
-import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier.BuildTypeDataProvider;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockBuildTypeDataProvider implements BuildTypeDataProvider {
-
- private final String data;
- private final boolean isErrorOnGet;
-
- public MockBuildTypeDataProvider(String data, boolean isErrorOnGet) {
- this.data = data;
- this.isErrorOnGet = isErrorOnGet;
- }
-
- @Override
- public String getData() {
- if (isErrorOnGet) {
- throw new OseeCoreException("Error case set");
- }
- return data;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeIdentifier.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeIdentifier.java
deleted file mode 100644
index 00b7ada080..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockBuildTypeIdentifier.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.test.mocks;
-
-import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockBuildTypeIdentifier extends BuildTypeIdentifier {
-
- private String clientVersion;
- private String designation;
-
- public MockBuildTypeIdentifier() {
- super(null);
- }
-
- @Override
- public String getBuildDesignation(String clientVersion) {
- this.clientVersion = clientVersion;
- return designation;
- }
-
- public String getClientVersion() {
- return clientVersion;
- }
-
- public void setDesignation(String designation) {
- this.designation = designation;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockLog.java b/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockLog.java
deleted file mode 100644
index 7521956dc8..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server.test/src/org/eclipse/osee/framework/core/server/test/mocks/MockLog.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.test.mocks;
-
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class MockLog implements Log {
-
- @Override
- public boolean isTraceEnabled() {
- return true;
- }
-
- @Override
- public void trace(String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public void trace(Throwable th, String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return true;
- }
-
- @Override
- public void debug(String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public void debug(Throwable th, String format, Object... args) {
- commonOut(th, format, args);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return true;
- }
-
- @Override
- public void info(String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public void info(Throwable th, String format, Object... args) {
- commonOut(th, format, args);
- }
-
- @Override
- public boolean isWarnEnabled() {
- return true;
- }
-
- @Override
- public void warn(String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public void warn(Throwable th, String format, Object... args) {
- commonOut(th, format, args);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return true;
- }
-
- @Override
- public void error(String format, Object... args) {
- commonOut(format, args);
- }
-
- @Override
- public void error(Throwable th, String format, Object... args) {
- commonOut(th, format, args);
- }
-
- private void commonOut(String format, Object... args) {
- System.out.printf(format, args);
- System.out.println();
- }
-
- private void commonOut(Throwable th, String format, Object... args) {
- commonOut(format, args);
- th.printStackTrace();
- }
-
-}

Back to the top