Author: adietish
Date: 2010-09-10 04:38:30 -0400 (Fri, 10 Sep 2010)
New Revision: 24851
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/GoogleAnalyticsEclipseMessages.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/messages.properties
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingEclipseEnvironment.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java
Removed:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseUserAgent.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFake.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingMessages.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/PreferencesUtils.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFakeSingleton.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/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/JBossToolsUsageIntegrationTest.java
Log:
[JBIDE-7034] extracted google analytics part to be independent from reporting
Modified: trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF 2010-09-10 00:10:15 UTC
(rev 24850)
+++ trunk/usage/plugins/org.jboss.tools.usage/META-INF/MANIFEST.MF 2010-09-10 08:38:30 UTC
(rev 24851)
@@ -6,7 +6,8 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.jboss.tools.usage,
org.jboss.tools.usage.googleanalytics,
- org.jboss.tools.usage.preferences; x-friends:="org.jboss.tools.usage.test",
+ org.jboss.tools.usage.googleanalytics.eclipse,
+ org.jboss.tools.usage.preferences;x-friends:="org.jboss.tools.usage.test",
org.jboss.tools.usage.reporting;x-friends:="org.jboss.tools.usage.test",
org.jboss.tools.usage.util
Require-Bundle: org.eclipse.osgi;bundle-version="3.5.0",
Copied:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java
(from rev 24848,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java)
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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.googleanalytics.eclipse;
+
+import java.util.Random;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.usage.googleanalytics.AbstractGoogleAnalyticsParameters;
+import org.jboss.tools.usage.googleanalytics.IGoogleAnalyticsParameters;
+import org.jboss.tools.usage.googleanalytics.IUserAgent;
+import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.preferences.IUsageReportPreferenceConstants;
+import org.jboss.tools.usage.util.PreferencesUtils;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractEclipseEnvironment extends
AbstractGoogleAnalyticsParameters implements IGoogleAnalyticsParameters {
+
+ private static final String SYSPROP_JAVA_VERSION = "java.version";
+
+ private String screenResolution;
+ private String screenColorDepth;
+ private Random random;
+ private IEclipsePreferences preferences;
+ private String firstVisit;
+ private String lastVisit;
+ private String currentVisit;
+ private long visitCount;
+ private IUserAgent eclipseUserAgent;
+
+ public AbstractEclipseEnvironment(String accountName, String hostName, String referral,
IEclipsePreferences preferences) {
+ super(accountName, hostName, referral);
+ this.random = new Random();
+ this.preferences = preferences;
+ eclipseUserAgent = createEclipseUserAgent();
+ initScreenSettings();
+ initVisits();
+ }
+
+ protected void initScreenSettings() {
+ final Display display = getDisplay();
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ screenColorDepth = display.getDepth() + SCREENCOLORDEPTH_POSTFIX;
+
+ Rectangle bounds = display.getBounds();
+ screenResolution = bounds.width + SCREERESOLUTION_DELIMITER + bounds.height;
+ }
+ });
+ }
+
+ private void initVisits() {
+ String currentTime = String.valueOf(System.currentTimeMillis());
+ this.currentVisit = currentTime;
+ this.firstVisit = preferences.get(IUsageReportPreferenceConstants.FIRST_VISIT, null);
+ if (firstVisit == null) {
+ this.firstVisit = currentTime;
+ preferences.put(IUsageReportPreferenceConstants.FIRST_VISIT, firstVisit);
+ }
+ lastVisit = preferences.get(IUsageReportPreferenceConstants.LAST_VISIT, currentTime);
+ visitCount = preferences.getLong(IUsageReportPreferenceConstants.VISIT_COUNT, 1);
+ }
+
+ protected IUserAgent createEclipseUserAgent() {
+ return new EclipseUserAgent();
+ }
+
+ public String getBrowserLanguage() {
+ return eclipseUserAgent.getBrowserLanguage();
+ }
+
+ public String getScreenResolution() {
+ return screenResolution;
+ }
+
+ public String getScreenColorDepth() {
+ return screenColorDepth;
+ }
+
+ protected Display getDisplay() {
+ if (PlatformUI.isWorkbenchRunning()) {
+ return PlatformUI.getWorkbench().getDisplay();
+ }
+
+ Display display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ return display;
+ }
+
+ public String getUserAgent() {
+ return eclipseUserAgent.toString();
+ }
+
+ public String getUserId() {
+ String userId = preferences.get(IUsageReportPreferenceConstants.ECLIPSE_INSTANCE_ID,
null);
+ if (userId == null) {
+ userId = createIdentifier();
+ preferences.put(IUsageReportPreferenceConstants.ECLIPSE_INSTANCE_ID, userId);
+ PreferencesUtils.checkedSavePreferences(preferences,
JBossToolsUsageActivator.getDefault(),
GoogleAnalyticsEclipseMessages.EclipseEnvironment_Error_SavePreferences);
+ }
+ return userId;
+ }
+
+ /**
+ * Creates an unique identifier.
+ *
+ * @return the identifier
+ */
+ private String createIdentifier() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(Math.abs(random.nextLong()));
+ builder.append(System.currentTimeMillis());
+ return builder.toString();
+ }
+
+ public abstract String getKeyword();
+
+ public String getCurrentVisit() {
+ return currentVisit;
+ }
+
+ public String getFirstVisit() {
+ return firstVisit;
+ }
+
+ public String getLastVisit() {
+ return lastVisit;
+ }
+
+ public long getVisitCount() {
+ return visitCount;
+ }
+
+ public void visit() {
+ lastVisit = currentVisit;
+ preferences.put(IUsageReportPreferenceConstants.LAST_VISIT, lastVisit);
+ currentVisit = String.valueOf(System.currentTimeMillis());
+ visitCount++;
+ preferences.putLong(IUsageReportPreferenceConstants.VISIT_COUNT, visitCount);
+ PreferencesUtils.checkedSavePreferences(preferences,
JBossToolsUsageActivator.getDefault(),
GoogleAnalyticsEclipseMessages.EclipseEnvironment_Error_SavePreferences);
+ }
+
+ public String getFlashVersion() {
+ return getJavaVersion();
+ }
+
+ private String getJavaVersion() {
+ return System.getProperty(SYSPROP_JAVA_VERSION);
+ }
+}
Copied:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
(from rev 24848,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseUserAgent.java)
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.googleanalytics.eclipse;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IProduct;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.usage.googleanalytics.IUserAgent;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class EclipseUserAgent implements IUserAgent {
+
+ public static final char JAVA_LOCALE_DELIMITER = '_';
+
+ private static final String ECLIPSE_RUNTIME_BULDEID =
"org.eclipse.core.runtime"; //$NON-NLS-1$
+
+ private static final String USERAGENT_WIN = "{0}/{1} (Windows; U; Windows NT 6.1;
{2})"; //$NON-NLS-1$
+ private static final String USERAGENT_MAC = "{0}/{1} (Macintosh; U; Intel Mac OS X
10.5; {2})"; //$NON-NLS-1$
+ private static final String USERAGENT_LINUX = "{0}/{1} (X11; U; Linux i686;
{2})"; //$NON-NLS-1$
+
+ public static final char VERSION_DELIMITER = '.';
+
+ private String browserLanguage;
+
+ private String createBrowserLanguage() {
+ String nl = getNL();
+ if (nl == null) {
+ return ""; //$NON-NLS-1$
+ }
+
+ int indexOf = nl.indexOf(JAVA_LOCALE_DELIMITER); //$NON-NLS-1$
+ if (indexOf <= 0) {
+ return nl;
+ }
+
+ StringBuilder builder = new StringBuilder();
+ builder.append(nl.substring(0, indexOf));
+ builder.append(BROWSER_LOCALE_DELIMITER);
+ builder.append(nl.substring(indexOf + 1));
+ return builder.toString();
+ }
+
+ protected String getNL() {
+ return Platform.getNL();
+ }
+
+ public String getBrowserLanguage() {
+ if (browserLanguage == null) {
+ browserLanguage = createBrowserLanguage();
+ }
+ return browserLanguage;
+ }
+
+ public String toString() {
+ String productId = getApplicationName();
+ String productVersion = getApplicationVersion();
+
+ /**
+ * Google API for android: this.userAgent = String.format(
+ * "GoogleAnalytics/%s (Linux; U; Android %s; %s-%s; %s; Build/%s)" ,
+ * new Object[] { "1.0" , Build.VERSION.RELEASE ,
+ * (localLocale.getLanguage() != null) ?
+ * localLocale.getLanguage().toLowerCase() : "en" ,
+ * (localLocale.getCountry() != null) ?
+ * localLocale.getCountry().toLowerCase() : "" , Build.MODEL, Build.ID
+ * });
+ */
+
+ return MessageFormat.format(
+ getUserAgentPattern(getOS())
+ , productId
+ , productVersion
+ , getBrowserLanguage()
+ );
+ }
+
+ protected String getOS() {
+ return Platform.getOS();
+ }
+
+ protected String getApplicationName() {
+ return getApplicationBundle().getSymbolicName();
+ }
+
+ protected String getApplicationVersion() {
+ String fullVersion = getApplicationBundle().getVersion().toString();
+ int productVersionStart = fullVersion.lastIndexOf(VERSION_DELIMITER);
+ if (productVersionStart > 0) {
+ return fullVersion.substring(0, productVersionStart);
+ } else {
+ return fullVersion;
+ }
+ }
+
+ /**
+ * Returns the bundle that launched the application that this class runs in.
+ *
+ * @return the defining bundle
+ */
+ private Bundle getApplicationBundle() {
+ IProduct product = Platform.getProduct();
+ if (product != null) {
+ return product.getDefiningBundle();
+ } else {
+ return Platform.getBundle(ECLIPSE_RUNTIME_BULDEID);
+ }
+ }
+
+ private String getUserAgentPattern(String os) {
+ String userAgentPattern = ""; //$NON-NLS-1$
+ /*
+ * TODO: implement architecture (i686, x86_64 etc.), Windows version, MacOS version
etc.
+ */
+ if (Platform.OS_LINUX.equals(os)) {
+ return USERAGENT_LINUX; //$NON-NLS-1$
+ } else if (Platform.OS_MACOSX.equals(os)) {
+ return USERAGENT_MAC; //$NON-NLS-1$
+ } else if (Platform.OS_WIN32.equals(os)) {
+ return USERAGENT_WIN; //$NON-NLS-1$
+ }
+ return userAgentPattern;
+ }
+}
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/EclipseUserAgent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/GoogleAnalyticsEclipseMessages.java
(from rev 24574,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsMessages.java)
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/GoogleAnalyticsEclipseMessages.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/GoogleAnalyticsEclipseMessages.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.googleanalytics.eclipse;
+
+import org.eclipse.osgi.util.NLS;
+
+public class GoogleAnalyticsEclipseMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.usage.googleanalytics.messages"; //$NON-NLS-1$
+
+ public static String EclipseEnvironment_Error_SavePreferences;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, GoogleAnalyticsEclipseMessages.class);
+ }
+
+ private GoogleAnalyticsEclipseMessages() {
+ }
+}
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/GoogleAnalyticsEclipseMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/messages.properties
(from rev 24574,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/messages.properties)
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/messages.properties
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/messages.properties 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1 @@
+EclipseEnvironment_Error_SavePreferences=Could not save preferences file
\"{0}\" .
\ No newline at end of file
Property changes on:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -1,193 +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.reporting;
-
-import java.util.Random;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.usage.googleanalytics.AbstractGoogleAnalyticsParameters;
-import org.jboss.tools.usage.googleanalytics.IGoogleAnalyticsParameters;
-import org.jboss.tools.usage.googleanalytics.IUserAgent;
-import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
-import org.jboss.tools.usage.preferences.IUsageReportPreferenceConstants;
-import org.jboss.tools.usage.util.BundleUtils;
-import org.jboss.tools.usage.util.BundleUtils.IBundleEntryFilter;
-import org.jboss.tools.usage.util.PreferencesUtils;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Andre Dietisheim
- */
-public class EclipseEnvironment extends AbstractGoogleAnalyticsParameters implements
IGoogleAnalyticsParameters {
-
- private static final String SYSPROP_JAVA_VERSION = "java.version";
- private static final String JBOSS_TOOLS_BUNDLES_PREFIX =
"org\\.jboss\\.tools.+"; //$NON-NLS-1$
- private static final char BUNDLE_GROUP_DELIMITER = '-';
-
- private String screenResolution;
- private String screenColorDepth;
- private Random random;
- private IEclipsePreferences preferences;
- private String firstVisit;
- private String lastVisit;
- private String currentVisit;
- private long visitCount;
- private IUserAgent eclipseUserAgent;
-
- public EclipseEnvironment(String accountName, String hostName, String referral,
IEclipsePreferences preferences) {
- super(accountName, hostName, referral);
- this.random = new Random();
- this.preferences = preferences;
- eclipseUserAgent = createEclipseUserAgent();
- initScreenSettings();
- initVisits();
- }
-
- protected void initScreenSettings() {
- final Display display = getDisplay();
- display.syncExec(new Runnable() {
-
- public void run() {
- screenColorDepth = display.getDepth() + SCREENCOLORDEPTH_POSTFIX;
-
- Rectangle bounds = display.getBounds();
- screenResolution = bounds.width + SCREERESOLUTION_DELIMITER + bounds.height;
- }
- });
- }
-
- private void initVisits() {
- String currentTime = String.valueOf(System.currentTimeMillis());
- this.currentVisit = currentTime;
- this.firstVisit = preferences.get(IUsageReportPreferenceConstants.FIRST_VISIT, null);
- if (firstVisit == null) {
- this.firstVisit = currentTime;
- preferences.put(IUsageReportPreferenceConstants.FIRST_VISIT, firstVisit);
- }
- lastVisit = preferences.get(IUsageReportPreferenceConstants.LAST_VISIT, currentTime);
- visitCount = preferences.getLong(IUsageReportPreferenceConstants.VISIT_COUNT, 1);
- }
-
- protected IUserAgent createEclipseUserAgent() {
- return new EclipseUserAgent();
- }
-
- public String getBrowserLanguage() {
- return eclipseUserAgent.getBrowserLanguage();
- }
-
- public String getScreenResolution() {
- return screenResolution;
- }
-
- public String getScreenColorDepth() {
- return screenColorDepth;
- }
-
- protected Display getDisplay() {
- if (PlatformUI.isWorkbenchRunning()) {
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- Display display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- return display;
- }
-
- public String getUserAgent() {
- return eclipseUserAgent.toString();
- }
-
- public String getUserId() {
- String userId = preferences.get(IUsageReportPreferenceConstants.ECLIPSE_INSTANCE_ID,
null);
- if (userId == null) {
- userId = createIdentifier();
- preferences.put(IUsageReportPreferenceConstants.ECLIPSE_INSTANCE_ID, userId);
- PreferencesUtils.checkedSavePreferences(preferences,
JBossToolsUsageActivator.getDefault(),
ReportingMessages.EclipseEnvironment_Error_SavePreferences);
- }
- return userId;
- }
-
- /**
- * Creates an unique identifier.
- *
- * @return the identifier
- */
- private String createIdentifier() {
- StringBuilder builder = new StringBuilder();
- builder.append(Math.abs(random.nextLong()));
- builder.append(System.currentTimeMillis());
- return builder.toString();
- }
-
- public String getKeyword() {
- JBossBundleGroups jbossBundleGroups = new JBossBundleGroups();
- IBundleEntryFilter jbossToolsFilter = new
BundleUtils.BundleSymbolicNameFilter(JBOSS_TOOLS_BUNDLES_PREFIX);
- IBundleEntryFilter compositeFilter = new BundleUtils.CompositeFilter(
- jbossToolsFilter
- , jbossBundleGroups);
- BundleUtils.getBundles(compositeFilter, getBundles());
-
- return bundleGroupsToKeywordString(jbossBundleGroups);
- }
-
- protected Bundle[] getBundles() {
- return
JBossToolsUsageActivator.getDefault().getBundle().getBundleContext().getBundles();
- }
-
- private String bundleGroupsToKeywordString(JBossBundleGroups jbossBundleGroups) {
- char delimiter = BUNDLE_GROUP_DELIMITER;
- StringBuilder builder = new StringBuilder();
- for (String bundleGroupId : jbossBundleGroups.getBundleGroupIds()) {
- builder.append(bundleGroupId)
- .append(delimiter);
- }
- return builder.toString();
- }
-
- public String getCurrentVisit() {
- return currentVisit;
- }
-
- public String getFirstVisit() {
- return firstVisit;
- }
-
- public String getLastVisit() {
- return lastVisit;
- }
-
- public long getVisitCount() {
- return visitCount;
- }
-
- public void visit() {
- lastVisit = currentVisit;
- preferences.put(IUsageReportPreferenceConstants.LAST_VISIT, lastVisit);
- currentVisit = String.valueOf(System.currentTimeMillis());
- visitCount++;
- preferences.putLong(IUsageReportPreferenceConstants.VISIT_COUNT, visitCount);
- PreferencesUtils.checkedSavePreferences(preferences,
JBossToolsUsageActivator.getDefault(),
ReportingMessages.EclipseEnvironment_Error_SavePreferences);
- }
-
- public String getFlashVersion() {
- return getJavaVersion();
- }
-
- private String getJavaVersion() {
- return System.getProperty(SYSPROP_JAVA_VERSION);
- }
-}
Deleted:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseUserAgent.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseUserAgent.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseUserAgent.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -1,135 +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.reporting;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.IProduct;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.usage.googleanalytics.IUserAgent;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Andre Dietisheim
- */
-public class EclipseUserAgent implements IUserAgent {
-
- public static final char JAVA_LOCALE_DELIMITER = '_';
-
- private static final String ECLIPSE_RUNTIME_BULDEID =
"org.eclipse.core.runtime"; //$NON-NLS-1$
-
- private static final String USERAGENT_WIN = "{0}/{1} (Windows; U; Windows NT 6.1;
{2})"; //$NON-NLS-1$
- private static final String USERAGENT_MAC = "{0}/{1} (Macintosh; U; Intel Mac OS X
10.5; {2})"; //$NON-NLS-1$
- private static final String USERAGENT_LINUX = "{0}/{1} (X11; U; Linux i686;
{2})"; //$NON-NLS-1$
-
- public static final char VERSION_DELIMITER = '.';
-
- private String browserLanguage;
-
- private String createBrowserLanguage() {
- String nl = getNL();
- if (nl == null) {
- return ""; //$NON-NLS-1$
- }
-
- int indexOf = nl.indexOf(JAVA_LOCALE_DELIMITER); //$NON-NLS-1$
- if (indexOf <= 0) {
- return nl;
- }
-
- StringBuilder builder = new StringBuilder();
- builder.append(nl.substring(0, indexOf));
- builder.append(BROWSER_LOCALE_DELIMITER);
- builder.append(nl.substring(indexOf + 1));
- return builder.toString();
- }
-
- protected String getNL() {
- return Platform.getNL();
- }
-
- public String getBrowserLanguage() {
- if (browserLanguage == null) {
- browserLanguage = createBrowserLanguage();
- }
- return browserLanguage;
- }
-
- public String toString() {
- String productId = getApplicationName();
- String productVersion = getApplicationVersion();
-
- /**
- * Google API for android: this.userAgent = String.format(
- * "GoogleAnalytics/%s (Linux; U; Android %s; %s-%s; %s; Build/%s)" ,
- * new Object[] { "1.0" , Build.VERSION.RELEASE ,
- * (localLocale.getLanguage() != null) ?
- * localLocale.getLanguage().toLowerCase() : "en" ,
- * (localLocale.getCountry() != null) ?
- * localLocale.getCountry().toLowerCase() : "" , Build.MODEL, Build.ID
- * });
- */
-
- return MessageFormat.format(
- getUserAgentPattern(getOS())
- , productId
- , productVersion
- , getBrowserLanguage()
- );
- }
-
- protected String getOS() {
- return Platform.getOS();
- }
-
- protected String getApplicationName() {
- return getApplicationBundle().getSymbolicName();
- }
-
- protected String getApplicationVersion() {
- String fullVersion = getApplicationBundle().getVersion().toString();
- int productVersionStart = fullVersion.lastIndexOf(VERSION_DELIMITER);
- if (productVersionStart > 0) {
- return fullVersion.substring(0, productVersionStart);
- } else {
- return fullVersion;
- }
- }
-
- /**
- * Returns the bundle that launched the application that this class runs in.
- *
- * @return the defining bundle
- */
- private Bundle getApplicationBundle() {
- IProduct product = Platform.getProduct();
- if (product != null) {
- return product.getDefiningBundle();
- } else {
- return Platform.getBundle(ECLIPSE_RUNTIME_BULDEID);
- }
- }
-
- private String getUserAgentPattern(String os) {
- String userAgentPattern = ""; //$NON-NLS-1$
- /*
- * TODO: implement architecture (i686, x86_64 etc.), Windows version, MacOS version
etc.
- */
- if (Platform.OS_LINUX.equals(os)) {
- return USERAGENT_LINUX; //$NON-NLS-1$
- } else if (Platform.OS_MACOSX.equals(os)) {
- return USERAGENT_MAC; //$NON-NLS-1$
- } else if (Platform.OS_WIN32.equals(os)) {
- return USERAGENT_WIN; //$NON-NLS-1$
- }
- return userAgentPattern;
- }
-}
Copied:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingEclipseEnvironment.java
(from rev 24848,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/EclipseEnvironment.java)
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingEclipseEnvironment.java
(rev 0)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingEclipseEnvironment.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.reporting;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.usage.googleanalytics.eclipse.AbstractEclipseEnvironment;
+import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
+import org.jboss.tools.usage.util.BundleUtils;
+import org.jboss.tools.usage.util.BundleUtils.IBundleEntryFilter;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class ReportingEclipseEnvironment extends AbstractEclipseEnvironment {
+
+ private static final String JBOSS_TOOLS_BUNDLES_PREFIX =
"org\\.jboss\\.tools.+"; //$NON-NLS-1$
+ private static final char BUNDLE_GROUP_DELIMITER = '-';
+
+ public ReportingEclipseEnvironment(String accountName, String hostName, String referral,
IEclipsePreferences preferences) {
+ super(accountName, hostName, referral, preferences);
+ }
+
+ @Override
+ public String getKeyword() {
+ JBossBundleGroups jbossBundleGroups = new JBossBundleGroups();
+ IBundleEntryFilter jbossToolsFilter = new
BundleUtils.BundleSymbolicNameFilter(JBOSS_TOOLS_BUNDLES_PREFIX);
+ IBundleEntryFilter compositeFilter = new BundleUtils.CompositeFilter(
+ jbossToolsFilter
+ , jbossBundleGroups);
+ BundleUtils.getBundles(compositeFilter, getBundles());
+
+ return bundleGroupsToKeywordString(jbossBundleGroups);
+ }
+
+ protected Bundle[] getBundles() {
+ return
JBossToolsUsageActivator.getDefault().getBundle().getBundleContext().getBundles();
+ }
+
+ private String bundleGroupsToKeywordString(JBossBundleGroups jbossBundleGroups) {
+ char delimiter = BUNDLE_GROUP_DELIMITER;
+ StringBuilder builder = new StringBuilder();
+ for (String bundleGroupId : jbossBundleGroups.getBundleGroupIds()) {
+ builder.append(bundleGroupId)
+ .append(delimiter);
+ }
+ return builder.toString();
+ }
+}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingMessages.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingMessages.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/ReportingMessages.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -14,7 +14,6 @@
public class ReportingMessages extends NLS {
private static final String BUNDLE_NAME =
"org.jboss.tools.usage.reporting.messages"; //$NON-NLS-1$
- public static String EclipseEnvironment_Error_SavePreferences;
public static String UsageReport_Reporting_Usage;
public static String UsageReport_Querying_Enablement;
@@ -26,6 +25,7 @@
public static String UsageReport_Error_SavePreferences;
public static String UsageReport_GoogleAnalyticsAccount;
public static String UsageReport_HostName;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ReportingMessages.class);
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/UsageReport.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -84,7 +84,7 @@
}
private ITracker getTracker() {
- IGoogleAnalyticsParameters eclipseEnvironment = new EclipseEnvironment(
+ IGoogleAnalyticsParameters eclipseEnvironment = new ReportingEclipseEnvironment(
GANALYTICS_ACCOUNTNAME
, HOST_NAME
, IGoogleAnalyticsParameters.VALUE_NO_REFERRAL
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/messages.properties 2010-09-10
08:38:30 UTC (rev 24851)
@@ -1,4 +1,3 @@
-EclipseEnvironment_Error_SavePreferences=Could not sage {0} to preferences.
UsageReport_Reporting_Usage=Reporting JBoss Tools usage
UsageReport_Querying_Enablement=Querying whether reporting is globally enabled
UsageReport_Asking_User=Asking User to allow reporting
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/PreferencesUtils.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/PreferencesUtils.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/PreferencesUtils.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -17,7 +17,6 @@
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.jboss.tools.usage.internal.JBossToolsUsageActivator;
-import org.jboss.tools.usage.reporting.ReportingMessages;
import org.osgi.service.prefs.BackingStoreException;
public class PreferencesUtils {
@@ -39,8 +38,8 @@
preferences.flush();
} catch (BackingStoreException e) {
IStatus status = StatusUtils.getErrorStatus(plugin.getBundle().getSymbolicName(),
- ReportingMessages.EclipseEnvironment_Error_SavePreferences,
- e, message);
+ message,
+ e, preferences.absolutePath());
plugin.getLog().log(status);
}
Deleted:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFake.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFake.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -1,70 +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.EclipseEnvironment;
-
-/**
- * @author Andre Dietisheim
- */
-public class EclipseEnvironmentFake extends EclipseEnvironment {
-
- public static final String GANALYTICS_ACCOUNTNAME = "UA-17645367-1";
- public static final String HOSTNAME = "jboss.org";
- public static final String REFERRAL = "0";
- public static final String JAVA_VERSION = "1.6.0_20";
-
- private String javaVersion;
-
- public EclipseEnvironmentFake() {
- this(GANALYTICS_ACCOUNTNAME, HOSTNAME, REFERRAL, JAVA_VERSION, new
EclipsePreferencesFake());
- }
-
- public EclipseEnvironmentFake(IEclipsePreferences preferences) {
- this(GANALYTICS_ACCOUNTNAME, HOSTNAME, REFERRAL, JAVA_VERSION, preferences);
- }
-
- public EclipseEnvironmentFake(String accountName, String hostName, String referral) {
- this(accountName, hostName, referral, JAVA_VERSION, new EclipsePreferencesFake());
- }
-
- public EclipseEnvironmentFake(String accountName, String hostName, String referral,
String javaVersion,
- IEclipsePreferences preferences) {
- super(accountName, hostName, referral, 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/EclipseEnvironmentFakeSingleton.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFakeSingleton.java 2010-09-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFakeSingleton.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -15,6 +15,6 @@
*/
public class EclipseEnvironmentFakeSingleton {
- public static EclipseEnvironmentFake INSTANCE = new EclipseEnvironmentFake();
+ public static ReportingEclipseEnvironmentFake INSTANCE = new
ReportingEclipseEnvironmentFake();
}
Modified:
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-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentFake.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -2,7 +2,7 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.usage.reporting.EclipseUserAgent;
+import org.jboss.tools.usage.googleanalytics.eclipse.EclipseUserAgent;
public class EclipseUserAgentFake extends EclipseUserAgent {
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-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseUserAgentTest.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -23,7 +23,7 @@
import java.util.regex.Pattern;
import org.eclipse.core.runtime.Platform;
-import org.jboss.tools.usage.reporting.EclipseEnvironment;
+import org.jboss.tools.usage.googleanalytics.eclipse.AbstractEclipseEnvironment;
import org.jboss.tools.usage.reporting.JBossBundleGroups;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -71,7 +71,7 @@
@Test
public void testKeyword() {
- EclipseEnvironment eclipseEnvironment = new EclipseEnvironmentFake() {
+ AbstractEclipseEnvironment eclipseEnvironment = new ReportingEclipseEnvironmentFake()
{
@Override
protected Bundle[] getBundles() {
return new Bundle[] {
@@ -235,7 +235,7 @@
@Test
public void testVisitsOnFirstVisit() {
EclipsePreferencesFake preferences = new EclipsePreferencesFake();
- EclipseEnvironment eclipseEnvironment = new EclipseEnvironmentFake(preferences);
+ AbstractEclipseEnvironment eclipseEnvironment = new
ReportingEclipseEnvironmentFake(preferences);
String firstVisit = eclipseEnvironment.getFirstVisit();
assertEquals(1, eclipseEnvironment.getVisitCount());
assertEquals(firstVisit, eclipseEnvironment.getLastVisit());
@@ -246,7 +246,7 @@
@Test
public void testVisitsOnSecondVisit() throws InterruptedException {
EclipsePreferencesFake preferences = new EclipsePreferencesFake();
- EclipseEnvironment eclipseEnvironment = new EclipseEnvironmentFake(preferences);
+ AbstractEclipseEnvironment eclipseEnvironment = new
ReportingEclipseEnvironmentFake(preferences);
String firstVisit = eclipseEnvironment.getFirstVisit();
Thread.sleep(10);
eclipseEnvironment.visit();
@@ -260,7 +260,7 @@
@Test
public void testVisitsOnThirdVisit() throws InterruptedException {
EclipsePreferencesFake preferences = new EclipsePreferencesFake();
- EclipseEnvironment eclipseEnvironment = new EclipseEnvironmentFake(preferences);
+ AbstractEclipseEnvironment eclipseEnvironment = new
ReportingEclipseEnvironmentFake(preferences);
String firstVisit = eclipseEnvironment.getFirstVisit();
Thread.sleep(10);
eclipseEnvironment.visit();
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-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/GoogleAnalyticsUrlStrategyTest.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -30,7 +30,7 @@
@Before
public void setUp() {
- this.urlStrategy = new GoogleAnalyticsUrlStrategy(new EclipseEnvironmentFake());
+ this.urlStrategy = new GoogleAnalyticsUrlStrategy(new
ReportingEclipseEnvironmentFake());
}
@Test
@@ -50,7 +50,7 @@
+ "&utmr=0"
+ "&utmp=%2Ftesting%2Fstrategy"
+ "&utmfl="
- + EclipseEnvironmentFake.JAVA_VERSION
+ + ReportingEclipseEnvironmentFake.JAVA_VERSION
+ "&utmac=UA-17645367-1"
+
"&utmcc=__utma%3D156030503.195542053.1281528584.1281528584.1281528584.1%3B%2B__utmz%3D156030500.1281528584.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B"
+ "&gaq=1";
@@ -76,7 +76,7 @@
@Test
public void visitCountIncreases() throws Exception {
- IGoogleAnalyticsParameters eclipseEnvironment = new EclipseEnvironmentFake();
+ IGoogleAnalyticsParameters eclipseEnvironment = new ReportingEclipseEnvironmentFake();
assertEquals(1, eclipseEnvironment.getVisitCount());
eclipseEnvironment.visit();
assertEquals(2, eclipseEnvironment.getVisitCount());
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-10
00:10:15 UTC (rev 24850)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -51,12 +51,12 @@
public void differentUserIdOnDifferentEclipseInstance() throws Exception {
String focusPointName = "testDifferentUserIdOnDifferentEclipseInstance"
+ System.currentTimeMillis();
- UrlRevealingTracker tracker = getTracker(new EclipseEnvironmentFake());
+ UrlRevealingTracker tracker = getTracker(new ReportingEclipseEnvironmentFake());
tracker.trackSynchronously(createFocusPoint(focusPointName));
String userId = getUserId(tracker.getTrackingUrl());
assertTrue(userId != null);
- tracker = getTracker(new EclipseEnvironmentFake());
+ tracker = getTracker(new ReportingEclipseEnvironmentFake());
FocusPoint focusPoint = createFocusPoint(focusPointName);
tracker.trackSynchronously(focusPoint);
String newUserId = getUserId(tracker.getTrackingUrl());
@@ -67,7 +67,7 @@
@Test
public void visitCountIncreases() throws Exception {
- IGoogleAnalyticsParameters eclipseEnvironment = new EclipseEnvironmentFake();
+ IGoogleAnalyticsParameters eclipseEnvironment = new ReportingEclipseEnvironmentFake();
assertEquals(1, eclipseEnvironment.getVisitCount());
UrlRevealingTracker tracker = getTracker(eclipseEnvironment);
tracker.trackSynchronously(createFocusPoint("testVisitCount"));
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java
(from rev 24848,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentFake.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/ReportingEclipseEnvironmentFake.java 2010-09-10
08:38:30 UTC (rev 24851)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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 REFERRAL = "0";
+ public static final String JAVA_VERSION = "1.6.0_20";
+
+ private String javaVersion;
+
+ public ReportingEclipseEnvironmentFake() {
+ this(GANALYTICS_ACCOUNTNAME, HOSTNAME, REFERRAL, JAVA_VERSION, new
EclipsePreferencesFake());
+ }
+
+ public ReportingEclipseEnvironmentFake(IEclipsePreferences preferences) {
+ this(GANALYTICS_ACCOUNTNAME, HOSTNAME, REFERRAL, JAVA_VERSION, preferences);
+ }
+
+ public ReportingEclipseEnvironmentFake(String accountName, String hostName, String
referral) {
+ this(accountName, hostName, referral, JAVA_VERSION, new EclipsePreferencesFake());
+ }
+
+ public ReportingEclipseEnvironmentFake(String accountName, String hostName, String
referral, String javaVersion,
+ IEclipsePreferences preferences) {
+ super(accountName, hostName, referral, 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/ReportingEclipseEnvironmentFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain