Author: adietish
Date: 2010-09-14 07:17:13 -0400 (Tue, 14 Sep 2010)
New Revision: 24910
Added:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/BundleGroupProviderFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipsePreferencesFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipseUserAgentFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/RepportingEclipseEnvironmentFakeSingleton.java
Removed:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipsePreferencesFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/RepportingEclipseEnvironmentFakeSingleton.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsCookie.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossComponentsTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java
Log:
[JBIDE-7035] tests corrected, succeed again
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsCookie.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsCookie.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsCookie.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.usage.googleanalytics;
-import org.eclipse.core.runtime.Assert;
public class GoogleAnalyticsCookie {
@@ -19,9 +18,6 @@
private char[] delimiters;
public GoogleAnalyticsCookie(String identifier, CharSequence value, char... delimiters)
{
- Assert.isTrue(identifier != null && identifier.length() > 0);
- Assert.isTrue(value != null && value.length() > 0);
-
this.identifier = identifier;
this.value = value;
this.delimiters = delimiters;
@@ -32,11 +28,13 @@
}
public void appendTo(StringBuilder builder) {
- builder.append(identifier)
- .append(IGoogleAnalyticsParameters.EQUALS_SIGN)
- .append(value);
- for (char delimiter : delimiters) {
- builder.append(delimiter);
+ if (identifier != null && identifier.length() > 0 && value != null
&& value.length() > 0) {
+ builder.append(identifier)
+ .append(IGoogleAnalyticsParameters.EQUALS_SIGN)
+ .append(value);
+ for (char delimiter : delimiters) {
+ builder.append(delimiter);
+ }
}
}
}
Deleted:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipsePreferencesFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipsePreferencesFake.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipsePreferencesFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-public class EclipsePreferencesFake implements IEclipsePreferences {
-
- private Map<String, String> preferences;
-
- public EclipsePreferencesFake() {
- this.preferences = new HashMap<String, String>();
- }
-
- public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException {
- throw new UnsupportedOperationException();
- }
-
- public void addNodeChangeListener(INodeChangeListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void addPreferenceChangeListener(IPreferenceChangeListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public Preferences node(String path) {
- throw new UnsupportedOperationException();
- }
-
- public void removeNode() throws BackingStoreException {
- throw new UnsupportedOperationException();
- }
-
- public void removeNodeChangeListener(INodeChangeListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public void removePreferenceChangeListener(IPreferenceChangeListener listener) {
- throw new UnsupportedOperationException();
- }
-
- public String absolutePath() {
- throw new UnsupportedOperationException();
- }
-
- public String[] childrenNames() throws BackingStoreException {
- throw new UnsupportedOperationException();
- }
-
- public void clear() throws BackingStoreException {
- this.preferences.clear();
- }
-
- public void flush() throws BackingStoreException {
- }
-
- public String get(String key, String defaultValue) {
- String value = preferences.get(key);
- if (value == null) {
- value = defaultValue;
- }
- return value;
- }
-
- public boolean getBoolean(String key, boolean defaultValue) {
- throw new UnsupportedOperationException();
- }
-
- public byte[] getByteArray(String key, byte[] defaultValue) {
- throw new UnsupportedOperationException();
- }
-
- public double getDouble(String key, double defaultValue) {
- throw new UnsupportedOperationException();
- }
-
- public float getFloat(String key, float defaultValue) {
- throw new UnsupportedOperationException();
- }
-
- public int getInt(String key, int defaultValue) {
- throw new UnsupportedOperationException();
- }
-
- public long getLong(String key, long defaultValue) {
- String value = preferences.get(key);
- if (value != null) {
- return Long.valueOf(value);
- } else {
- return defaultValue;
- }
- }
-
- public String[] keys() throws BackingStoreException {
- throw new UnsupportedOperationException();
- }
-
- public String name() {
- throw new UnsupportedOperationException();
- }
-
- public boolean nodeExists(String pathName) throws BackingStoreException {
- throw new UnsupportedOperationException();
- }
-
- public Preferences parent() {
- throw new UnsupportedOperationException();
- }
-
- public void put(String key, String value) {
- preferences.put(key, value);
- }
-
- public void putBoolean(String key, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- public void putByteArray(String key, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- public void putDouble(String key, double value) {
- throw new UnsupportedOperationException();
- }
-
- public void putFloat(String key, float value) {
- throw new UnsupportedOperationException();
- }
-
- public void putInt(String key, int value) {
- throw new UnsupportedOperationException();
- }
-
- public void putLong(String key, long value) {
- preferences.put(key, String.valueOf(value));
- }
-
- public void remove(String key) {
- throw new UnsupportedOperationException();
- }
-
- public void sync() throws BackingStoreException {
- // ignore
- }
-}
\ No newline at end of file
Deleted:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,85 +0,0 @@
-package org.jboss.tools.usage.test;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.usage.googleanalytics.eclipse.EclipseUserAgent;
-
-public class EclipseUserAgentFake extends EclipseUserAgent {
-
- private static final String APPLICATION_NAME = "com.jboss.jbds.product";
- private static final String APPLICATION_VERSION = "3.0.1";
-
- public static final String LOCALE_US = "en_US";
-
- static final String WIN2000_VERSION = "5.0";
- static final String WINXP_VERSION = "5.1";
- static final String VISTA_VERSION = "6.0";
- static final String WIN7_VERSION = "6.1";
- static final String MACLEOPARD_VERSION = "10.5";
- static final String MACSNOWLEOPARD_VERSION = "10.6";
-
- private String applicationName;
- private String applicationVersion;
- private String nl;
- private String os;
- private String osVersion;
-
- public EclipseUserAgentFake() {
- this(APPLICATION_NAME, APPLICATION_VERSION, LOCALE_US, Platform.OS_WIN32,
WIN7_VERSION);
- }
-
- public EclipseUserAgentFake(String nl) {
- this(APPLICATION_NAME, APPLICATION_VERSION, nl, Platform.OS_WIN32, WIN7_VERSION);
- }
-
- public EclipseUserAgentFake(String nl, String os, String osVersion) {
- this(APPLICATION_NAME, APPLICATION_VERSION, nl, os, osVersion);
- }
-
- /**
- * Instantiates a fake of the EclipseUserAgent class
- *
- * @param applicationName the name of the applicaiton
- * @param applicationVersion the version of the application
- * @param nl the platform locale as returned from
<code>Platform.getNL()</code>
- * @param os the os name as return from <code>Platform.getOS()</code>
- * @param osVersion the version of the os as returned from
<code>System.getProperty("os.name")</code>
- *
- * @see Platform#getNL()
- * @see Platform#getOS()
- * @see System#getProperty("os.version")
- */
- public EclipseUserAgentFake(String applicationName, String applicationVersion, String
nl, String os, String osVersion) {
- Assert.isTrue(nl != null && nl.indexOf(JAVA_LOCALE_DELIMITER) >= 0, "nl
parameter must for a java locale string <xx_XX>");
- this.applicationName = applicationName;
- this.applicationVersion = applicationVersion;
- this.nl = nl;
- this.os = os;
- this.osVersion = osVersion;
- }
-
- @Override
- protected String getNL() {
- return nl;
- }
-
- @Override
- protected String getApplicationName() {
- return applicationName;
- }
-
- @Override
- protected String getOS() {
- return os;
- }
-
- @Override
- protected String getOSVersion() {
- return osVersion;
- }
-
- @Override
- protected String getApplicationVersion() {
- return applicationVersion;
- }
-}
\ No newline at end of file
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentTest.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentTest.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -13,24 +13,15 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.Platform;
import org.jboss.tools.usage.googleanalytics.eclipse.AbstractEclipseEnvironment;
-import org.jboss.tools.usage.reporting.JBossComponents;
+import org.jboss.tools.usage.test.fakes.EclipsePreferencesFake;
+import org.jboss.tools.usage.test.fakes.EclipseUserAgentFake;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
/**
* @author Andre Dietisheim
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -19,6 +19,7 @@
import org.jboss.tools.usage.googleanalytics.GoogleAnalyticsUrlStrategy;
import org.jboss.tools.usage.googleanalytics.IGoogleAnalyticsParameters;
import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
import org.junit.Before;
import org.junit.Test;
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossComponentsTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossComponentsTest.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossComponentsTest.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,78 +1,34 @@
package org.jboss.tools.usage.test;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.util.Collection;
-import org.eclipse.core.runtime.IBundleGroup;
import org.eclipse.core.runtime.IBundleGroupProvider;
import org.jboss.tools.usage.reporting.JBossComponents;
+import org.jboss.tools.usage.test.fakes.BundleGroupProviderFake;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
-import org.osgi.framework.Bundle;
public class JBossComponentsTest {
@Test
public void reportedComponentsListIsComplete() {
- Collection<String> componentIds =
JBossComponents.getComponentIds(getBundleGroupProviders());
+ Collection<String> componentIds = JBossComponents.getComponentIds(
+ new IBundleGroupProvider[] {
+ new BundleGroupProviderFake("org.jboss.tools.gwt.feature")
+ , new BundleGroupProviderFake(
+ "rubbish",
+ "org.jboss.tools.seam.feature")
+ , new BundleGroupProviderFake("org.jboss.tools.smooks.feature")
+ , new BundleGroupProviderFake("org.jboss.tools.usage.feature.bandname")
+ });
assertThat(componentIds, JUnitMatchers.hasItems(
- JBossComponents.JBossToolsFeatureNames.GWT.name(),
- JBossComponents.JBossToolsFeatureNames.SEAM.name(),
- JBossComponents.JBossToolsFeatureNames.SMOOKS.name()));
+ JBossComponents.JBossToolsFeatureNames.GWT.getAbbreviation(),
+ JBossComponents.JBossToolsFeatureNames.SEAM.getAbbreviation(),
+ JBossComponents.JBossToolsFeatureNames.SMOOKS.getAbbreviation()));
+ assertFalse(componentIds.contains(JBossComponents.JBossToolsFeatureNames.USAGE.getAbbreviation()));
}
-
- protected IBundleGroupProvider[] getBundleGroupProviders() {
- return new IBundleGroupProvider[] { new IBundleGroupProvider() {
-
- public String getName() {
- return "bundleGroupProviderFake";
- }
-
- public IBundleGroup[] getBundleGroups() {
- return new IBundleGroup[] {
- new BundleGroupFake("org.jboss.tools.usage")
- };
- }
- }
- };
- }
-
-
- private class BundleGroupFake implements IBundleGroup {
- private String name;
-
- private BundleGroupFake(String name) {
- this.name = name;
- }
-
- public String getIdentifier() {
- throw new UnsupportedOperationException();
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- throw new UnsupportedOperationException();
- }
-
- public String getDescription() {
- throw new UnsupportedOperationException();
- }
-
- public String getProviderName() {
- throw new UnsupportedOperationException();
- }
-
- public Bundle[] getBundles() {
- throw new UnsupportedOperationException();
- }
-
- public String getProperty(String key) {
- throw new UnsupportedOperationException();
- }
- }
}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -24,6 +24,8 @@
import org.jboss.tools.usage.PluginLogger;
import org.jboss.tools.usage.googleanalytics.GoogleAnalyticsUrlStrategy;
import org.jboss.tools.usage.googleanalytics.IGoogleAnalyticsParameters;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
+import org.jboss.tools.usage.test.fakes.RepportingEclipseEnvironmentFakeSingleton;
import org.junit.Test;
/**
Deleted:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.test;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.jboss.tools.usage.googleanalytics.IUserAgent;
-import org.jboss.tools.usage.reporting.ReportingEclipseEnvironment;
-
-/**
- * @author Andre Dietisheim
- */
-public class ReportingEclipseEnvironmentFake extends ReportingEclipseEnvironment {
-
- public static final String GANALYTICS_ACCOUNTNAME = "UA-17645367-1";
- public static final String HOSTNAME = "jboss.org";
- public static final String JAVA_VERSION = "1.6.0_20";
-
- private String javaVersion;
-
- public ReportingEclipseEnvironmentFake() {
- this(GANALYTICS_ACCOUNTNAME, HOSTNAME, JAVA_VERSION, new EclipsePreferencesFake());
- }
-
- public ReportingEclipseEnvironmentFake(IEclipsePreferences preferences) {
- this(GANALYTICS_ACCOUNTNAME, HOSTNAME, JAVA_VERSION, preferences);
- }
-
- public ReportingEclipseEnvironmentFake(String accountName, String hostName) {
- this(accountName, hostName, JAVA_VERSION, new EclipsePreferencesFake());
- }
-
- public ReportingEclipseEnvironmentFake(String accountName, String hostName, String
javaVersion,
- IEclipsePreferences preferences) {
- super(accountName, hostName, preferences);
- this.javaVersion = javaVersion;
- }
-
- @Override
- protected void initScreenSettings() {
- // do not access swt/display
- }
-
- @Override
- protected IUserAgent createEclipseUserAgent() {
- return new EclipseUserAgentFake();
- }
-
- @Override
- public String getScreenResolution() {
- return 1920 + SCREERESOLUTION_DELIMITER + 1080;
- }
-
- @Override
- public String getScreenColorDepth() {
- return 24 + SCREENCOLORDEPTH_POSTFIX;
- }
-
- public String getFlashVersion() {
- return javaVersion;
- }
-}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentTest.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentTest.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.usage.test;
import static org.junit.Assert.assertTrue;
@@ -5,13 +15,16 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.core.runtime.IBundleGroup;
import org.eclipse.core.runtime.IBundleGroupProvider;
import org.jboss.tools.usage.googleanalytics.eclipse.AbstractEclipseEnvironment;
import org.jboss.tools.usage.reporting.JBossComponents;
+import org.jboss.tools.usage.test.fakes.BundleGroupProviderFake;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
import org.junit.Test;
-import org.osgi.framework.Bundle;
+/**
+ * @author Andre Dietisheim
+ */
public class ReportingEclipseEnvironmentTest {
@Test
@@ -56,59 +69,5 @@
assertTrue(keyword != null && keyword.length() == 0);
}
- private static class BundleGroupProviderFake implements IBundleGroupProvider {
- private String[] featureNames;
-
- public BundleGroupProviderFake(String... featureNames) {
- this.featureNames = featureNames;
- }
-
- public String getName() {
- throw new UnsupportedOperationException();
- }
-
- public IBundleGroup[] getBundleGroups() {
- IBundleGroup[] bundleGroups = new IBundleGroup[featureNames.length];
- for (int i = 0; i < featureNames.length; i++) {
- bundleGroups[i] = createBundleGroup(featureNames[i]);
- }
- return bundleGroups;
- }
-
- private IBundleGroup createBundleGroup(final String name) {
- return new IBundleGroup() {
-
- public String getVersion() {
- throw new UnsupportedOperationException();
- }
-
- public String getProviderName() {
- throw new UnsupportedOperationException();
- }
-
- public String getProperty(String key) {
- throw new UnsupportedOperationException();
- }
-
- public String getName() {
- return name;
- }
-
- public String getIdentifier() {
- throw new UnsupportedOperationException();
- }
-
- public String getDescription() {
- throw new UnsupportedOperationException();
-
- }
-
- public Bundle[] getBundles() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- }
}
Deleted:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/RepportingEclipseEnvironmentFakeSingleton.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/RepportingEclipseEnvironmentFakeSingleton.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/RepportingEclipseEnvironmentFakeSingleton.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.test;
-
-/**
- * @author Andre Dietisheim
- */
-public class RepportingEclipseEnvironmentFakeSingleton {
-
- public static ReportingEclipseEnvironmentFake INSTANCE = new
ReportingEclipseEnvironmentFake();
-
-}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java 2010-09-14
09:37:58 UTC (rev 24909)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -13,17 +13,20 @@
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+/**
+ * @author Andre Dietisheim
+ *
+ */
@RunWith(Suite.class)
-(a)Suite.SuiteClasses( {
+/**
+ */
+(a)Suite.SuiteClasses({
FocusPointTest.class,
GoogleAnalyticsUrlStrategyTest.class,
- JBossToolsUsageIntegrationTest.class,
EclipseUserAgentTest.class,
- GlobalUsageReportingSettingsTest.class})
-
-/**
- * @author Andre Dietisheim
- */
+ ReportingEclipseEnvironmentTest.class,
+ JBossComponentsTest.class,
+ GlobalUsageReportingSettingsTest.class,
+ JBossToolsUsageIntegrationTest.class })
public class UsageTestSuite {
-
-}
+}
\ No newline at end of file
Added:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/BundleGroupProviderFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/BundleGroupProviderFake.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/BundleGroupProviderFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.test.fakes;
+
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.osgi.framework.Bundle;
+
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+public class BundleGroupProviderFake implements IBundleGroupProvider {
+
+ private String[] featureNames;
+
+ public BundleGroupProviderFake(String... featureNames) {
+ this.featureNames = featureNames;
+ }
+
+ public String getName() {
+ throw new UnsupportedOperationException();
+ }
+
+ public IBundleGroup[] getBundleGroups() {
+ IBundleGroup[] bundleGroups = new IBundleGroup[featureNames.length];
+ for (int i = 0; i < featureNames.length; i++) {
+ bundleGroups[i] = createBundleGroup(featureNames[i]);
+ }
+ return bundleGroups;
+ }
+
+ private IBundleGroup createBundleGroup(final String name) {
+ return new IBundleGroup() {
+
+ public String getVersion() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getProviderName() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getProperty(String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIdentifier() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getDescription() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Bundle[] getBundles() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/BundleGroupProviderFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipsePreferencesFake.java
(from rev 24574,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipsePreferencesFake.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipsePreferencesFake.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipsePreferencesFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.test.fakes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+public class EclipsePreferencesFake implements IEclipsePreferences {
+
+ private Map<String, String> preferences;
+
+ public EclipsePreferencesFake() {
+ this.preferences = new HashMap<String, String>();
+ }
+
+ public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addNodeChangeListener(INodeChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addPreferenceChangeListener(IPreferenceChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Preferences node(String path) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeNode() throws BackingStoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeNodeChangeListener(INodeChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removePreferenceChangeListener(IPreferenceChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String absolutePath() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String[] childrenNames() throws BackingStoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void clear() throws BackingStoreException {
+ this.preferences.clear();
+ }
+
+ public void flush() throws BackingStoreException {
+ }
+
+ public String get(String key, String defaultValue) {
+ String value = preferences.get(key);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+
+ public boolean getBoolean(String key, boolean defaultValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] getByteArray(String key, byte[] defaultValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getDouble(String key, double defaultValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public float getFloat(String key, float defaultValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getInt(String key, int defaultValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getLong(String key, long defaultValue) {
+ String value = preferences.get(key);
+ if (value != null) {
+ return Long.valueOf(value);
+ } else {
+ return defaultValue;
+ }
+ }
+
+ public String[] keys() throws BackingStoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String name() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean nodeExists(String pathName) throws BackingStoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Preferences parent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void put(String key, String value) {
+ preferences.put(key, value);
+ }
+
+ public void putBoolean(String key, boolean value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putByteArray(String key, byte[] value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putDouble(String key, double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putFloat(String key, float value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putInt(String key, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void putLong(String key, long value) {
+ preferences.put(key, String.valueOf(value));
+ }
+
+ public void remove(String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sync() throws BackingStoreException {
+ // ignore
+ }
+}
\ No newline at end of file
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipsePreferencesFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipseUserAgentFake.java
(from rev 24874,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipseUserAgentFake.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipseUserAgentFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -0,0 +1,85 @@
+package org.jboss.tools.usage.test.fakes;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.usage.googleanalytics.eclipse.EclipseUserAgent;
+
+public class EclipseUserAgentFake extends EclipseUserAgent {
+
+ private static final String APPLICATION_NAME = "com.jboss.jbds.product";
+ private static final String APPLICATION_VERSION = "3.0.1";
+
+ public static final String LOCALE_US = "en_US";
+
+ public static final String WIN2000_VERSION = "5.0";
+ public static final String WINXP_VERSION = "5.1";
+ public static final String VISTA_VERSION = "6.0";
+ public static final String WIN7_VERSION = "6.1";
+ public static final String MACLEOPARD_VERSION = "10.5";
+ public static final String MACSNOWLEOPARD_VERSION = "10.6";
+
+ private String applicationName;
+ private String applicationVersion;
+ private String nl;
+ private String os;
+ private String osVersion;
+
+ public EclipseUserAgentFake() {
+ this(APPLICATION_NAME, APPLICATION_VERSION, LOCALE_US, Platform.OS_WIN32,
WIN7_VERSION);
+ }
+
+ public EclipseUserAgentFake(String nl) {
+ this(APPLICATION_NAME, APPLICATION_VERSION, nl, Platform.OS_WIN32, WIN7_VERSION);
+ }
+
+ public EclipseUserAgentFake(String nl, String os, String osVersion) {
+ this(APPLICATION_NAME, APPLICATION_VERSION, nl, os, osVersion);
+ }
+
+ /**
+ * Instantiates a fake of the EclipseUserAgent class
+ *
+ * @param applicationName the name of the applicaiton
+ * @param applicationVersion the version of the application
+ * @param nl the platform locale as returned from
<code>Platform.getNL()</code>
+ * @param os the os name as return from <code>Platform.getOS()</code>
+ * @param osVersion the version of the os as returned from
<code>System.getProperty("os.name")</code>
+ *
+ * @see Platform#getNL()
+ * @see Platform#getOS()
+ * @see System#getProperty("os.version")
+ */
+ public EclipseUserAgentFake(String applicationName, String applicationVersion, String
nl, String os, String osVersion) {
+ Assert.isTrue(nl != null && nl.indexOf(JAVA_LOCALE_DELIMITER) >= 0, "nl
parameter must for a java locale string <xx_XX>");
+ this.applicationName = applicationName;
+ this.applicationVersion = applicationVersion;
+ this.nl = nl;
+ this.os = os;
+ this.osVersion = osVersion;
+ }
+
+ @Override
+ protected String getNL() {
+ return nl;
+ }
+
+ @Override
+ protected String getApplicationName() {
+ return applicationName;
+ }
+
+ @Override
+ protected String getOS() {
+ return os;
+ }
+
+ @Override
+ protected String getOSVersion() {
+ return osVersion;
+ }
+
+ @Override
+ protected String getApplicationVersion() {
+ return applicationVersion;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/EclipseUserAgentFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
(from rev 24874,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.test.fakes;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.usage.googleanalytics.IUserAgent;
+import org.jboss.tools.usage.reporting.ReportingEclipseEnvironment;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class ReportingEclipseEnvironmentFake extends ReportingEclipseEnvironment {
+
+ public static final String GANALYTICS_ACCOUNTNAME = "UA-17645367-1";
+ public static final String HOSTNAME = "jboss.org";
+ public static final String JAVA_VERSION = "1.6.0_20";
+
+ private String javaVersion;
+
+ public ReportingEclipseEnvironmentFake() {
+ this(GANALYTICS_ACCOUNTNAME, HOSTNAME, JAVA_VERSION, new EclipsePreferencesFake());
+ }
+
+ public ReportingEclipseEnvironmentFake(IEclipsePreferences preferences) {
+ this(GANALYTICS_ACCOUNTNAME, HOSTNAME, JAVA_VERSION, preferences);
+ }
+
+ public ReportingEclipseEnvironmentFake(String accountName, String hostName) {
+ this(accountName, hostName, JAVA_VERSION, new EclipsePreferencesFake());
+ }
+
+ public ReportingEclipseEnvironmentFake(String accountName, String hostName, String
javaVersion,
+ IEclipsePreferences preferences) {
+ super(accountName, hostName, preferences);
+ this.javaVersion = javaVersion;
+ }
+
+ @Override
+ protected void initScreenSettings() {
+ // do not access swt/display
+ }
+
+ @Override
+ protected IUserAgent createEclipseUserAgent() {
+ return new EclipseUserAgentFake();
+ }
+
+ @Override
+ public String getScreenResolution() {
+ return 1920 + SCREERESOLUTION_DELIMITER + 1080;
+ }
+
+ @Override
+ public String getScreenColorDepth() {
+ return 24 + SCREENCOLORDEPTH_POSTFIX;
+ }
+
+ public String getFlashVersion() {
+ return javaVersion;
+ }
+}
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/RepportingEclipseEnvironmentFakeSingleton.java
(from rev 24874,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/RepportingEclipseEnvironmentFakeSingleton.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/RepportingEclipseEnvironmentFakeSingleton.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/RepportingEclipseEnvironmentFakeSingleton.java 2010-09-14
11:17:13 UTC (rev 24910)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.test.fakes;
+
+
+/**
+ * @author Andre Dietisheim
+ */
+public class RepportingEclipseEnvironmentFakeSingleton {
+
+ public static ReportingEclipseEnvironmentFake INSTANCE = new
ReportingEclipseEnvironmentFake();
+
+}
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/RepportingEclipseEnvironmentFakeSingleton.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain