Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    TypeError
Message:      Couldn't cast array of type
struct<content_hash: string, timestamp: string, source: string, line_count: int64, max_line_length: int64, avg_line_length: double, alnum_prop: double, repo_name: string, id: string, size: string, binary: bool, copies: string, ref: string, path: string, mode: string, license: string, language: list<item: struct<name: string, bytes: string>>, symlink_target: string>
to
{'content_hash': Value(dtype='string', id=None), 'timestamp': Value(dtype='string', id=None), 'source': Value(dtype='string', id=None), 'line_count': Value(dtype='int64', id=None), 'max_line_length': Value(dtype='int64', id=None), 'avg_line_length': Value(dtype='float64', id=None), 'alnum_prop': Value(dtype='float64', id=None), 'repo_name': Value(dtype='string', id=None), 'id': Value(dtype='string', id=None), 'size': Value(dtype='string', id=None), 'binary': Value(dtype='bool', id=None), 'copies': Value(dtype='string', id=None), 'ref': Value(dtype='string', id=None), 'path': Value(dtype='string', id=None), 'mode': Value(dtype='string', id=None), 'license': Value(dtype='string', id=None), 'language': [{'name': Value(dtype='string', id=None), 'bytes': Value(dtype='string', id=None)}]}
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in cast_table_to_schema
                  arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()]
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2261, in <listcomp>
                  arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()]
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in wrapper
                  return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 1802, in <listcomp>
                  return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2122, in cast_array_to_feature
                  raise TypeError(f"Couldn't cast array of type\n{_short_str(array.type)}\nto\n{_short_str(feature)}")
              TypeError: Couldn't cast array of type
              struct<content_hash: string, timestamp: string, source: string, line_count: int64, max_line_length: int64, avg_line_length: double, alnum_prop: double, repo_name: string, id: string, size: string, binary: bool, copies: string, ref: string, path: string, mode: string, license: string, language: list<item: struct<name: string, bytes: string>>, symlink_target: string>
              to
              {'content_hash': Value(dtype='string', id=None), 'timestamp': Value(dtype='string', id=None), 'source': Value(dtype='string', id=None), 'line_count': Value(dtype='int64', id=None), 'max_line_length': Value(dtype='int64', id=None), 'avg_line_length': Value(dtype='float64', id=None), 'alnum_prop': Value(dtype='float64', id=None), 'repo_name': Value(dtype='string', id=None), 'id': Value(dtype='string', id=None), 'size': Value(dtype='string', id=None), 'binary': Value(dtype='bool', id=None), 'copies': Value(dtype='string', id=None), 'ref': Value(dtype='string', id=None), 'path': Value(dtype='string', id=None), 'mode': Value(dtype='string', id=None), 'license': Value(dtype='string', id=None), 'language': [{'name': Value(dtype='string', id=None), 'bytes': Value(dtype='string', id=None)}]}
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1529, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1154, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2038, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

text
string
meta
dict
package org.usfirst.frc.team910.robot.Auton; import edu.wpi.first.wpilibj.Timer; public class AutonDriveTime extends AutonStep { private static final double POWER_FILT = 0.15; private double power; private double time; private double angle; private boolean prime; private double endTime; private double prevPower; public AutonDriveTime(double power, double time, double angle, boolean prime){ this.power = power; this.time = time; this.angle = angle; this.prime = prime; prevPower = 0; } public void setup(boolean blueAlliance) { endTime = Timer.getFPGATimestamp() + time; } public void run() { prevPower += POWER_FILT * (power - prevPower); drive.originAngle.set(angle); drive.driveStraightNavX(false, prevPower, 0); if(prime){ shoot.shooterPrime(true, false, 36, false, false); } else { shoot.shooterPrime(false, false, 36, false, false); } } public boolean isDone() { return Timer.getFPGATimestamp() > endTime; } }
{ "content_hash": "d1e3be21b1f4cb4bbad522cc1f9cf97f", "timestamp": "", "source": "github", "line_count": 44, "max_line_length": 79, "avg_line_length": 22.363636363636363, "alnum_prop": 0.709349593495935, "repo_name": "FoleyFreeze/2017FRC", "id": "6cdfe7200630ed01d0c7d87a10de40a1841f3523", "size": "984", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/org/usfirst/frc/team910/robot/Auton/AutonDriveTime.java", "mode": "33188", "license": "mit", "language": [ { "name": "Java", "bytes": "173919" } ] }
<?php namespace Lucid\Modular; class ModulesServiceProvider extends \Illuminate\Support\ServiceProvider { public function boot() { $this->publishes([ __DIR__.'/modules.php' => config_path('modules.php'), __DIR__.'/migrations' => database_path('/migrations') ]); $modules = config(env('MODULES_CONFIG_FILE', 'modules').'._modules',[]); $path = config(env('MODULES_CONFIG_FILE', 'modules').'.path'); $commands = []; $serviceProviders = []; if(empty($modules)) error_log('Any module was found in config: '.env('MODULES_CONFIG_FILE', 'modules').'._modules'.' ¿Are you sure your configuration is ok?'); foreach ($modules as $module) { $dir_exp = explode('/',$path); $namespace = app()->getNamespace().$dir_exp[count($dir_exp) - 2].'\\'.$module; if(is_dir($path.$module.'/views')) { $this->loadViewsFrom($path.$module.'/views', $module); } if(file_exists($path.$module.'/config.php')) { $this->mergeConfigFrom($path.$module.'/config.php', $module); } if(is_dir($path.$module.'/lang')) { $this->loadTranslationsFrom($path.$module.'/lang', $module); } if(file_exists($path.$module.'/ServiceProvider.php')) { $serviceProviders[$namespace] = $path.$module.'/ServiceProvider.php'; } $commands = array_merge($commands,config("{$module}._commands",[])); } //Route for module assets \Route::get('modules/{moduleName}/{path}',function($moduleName,$path){ return ModulesManager::getAsset($moduleName,$path); })->where('path', '(.*)'); $this->commands($commands); foreach($serviceProviders as $namespace => $serviceProvider){ $ServiceProviderClass = "$namespace\\ServiceProvider"; if(method_exists($ServiceProviderClass,'boot')) $ServiceProviderClass::boot(); } } public function register(){ $this->app->singleton('lucid-modular', function ($app) { return new ModulesManager(); }); $this->commands([ 'Lucid\Modular\commands\migrate', 'Lucid\Modular\commands\test', 'Lucid\Modular\commands\newModule', ]); } }
{ "content_hash": "6138bcf2caf4c73a8c78c820bbdfe94e", "timestamp": "", "source": "github", "line_count": 70, "max_line_length": 151, "avg_line_length": 34.871428571428574, "alnum_prop": 0.5374846374436706, "repo_name": "rudignet/Laravel-Modular", "id": "9983044b526495145c0c9d72cba5402325a2c655", "size": "2442", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/ModulesServiceProvider.php", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "443" }, { "name": "HTML", "bytes": "842" }, { "name": "PHP", "bytes": "19413" } ] }
%% endEdit(object) % Disables editmode % % INPUT % object : |EnsightLib| object % % OUTPUT % none % % USAGE % object.endEdit % %% function endEdit(this) valueArray = [1, 0, 5]; EnsightLib_interface('obj', 'endEdit', valueArray, this.getObjectHandle()); this.editMode = 0; end
{ "content_hash": "6808f0b780be854b7f1bc5cdb1fb0e4a", "timestamp": "", "source": "github", "line_count": 20, "max_line_length": 79, "avg_line_length": 14.8, "alnum_prop": 0.6418918918918919, "repo_name": "ITWM-TVFS/Ensight4Matlab", "id": "08a135e5ab036f4082195cb20b2131f0ce4d921d", "size": "296", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "EnsightMatlab/@EnsightLib/endEdit.m", "mode": "33188", "license": "mit", "language": [ { "name": "C++", "bytes": "399986" }, { "name": "GLSL", "bytes": "1584138" }, { "name": "Matlab", "bytes": "74986" }, { "name": "QMake", "bytes": "5268" }, { "name": "TeX", "bytes": "767" } ] }
ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name null ### Remarks null
{ "content_hash": "98dc3d0f74c7cb369fea0ebe843cb7a1", "timestamp": "", "source": "github", "line_count": 13, "max_line_length": 31, "avg_line_length": 9.692307692307692, "alnum_prop": 0.7063492063492064, "repo_name": "mdoering/backbone", "id": "c6c12fb60c8fa8fb39819f9f45e19254a7282794", "size": "178", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "life/Plantae/Magnoliophyta/Magnoliopsida/Ranunculales/Papaveraceae/Borckhausenia/Borckhausenia capnoides/README.md", "mode": "33188", "license": "apache-2.0", "language": [] }
layout: post microblog: true audio: photo: date: 2012-09-24 14:51:07 -0600 guid: http://craigmcclellan.micro.blog/2012/09/24/t250336585801940992.html --- WadsI the only one who somehow missed that Marcus Mumford was a really good drummer (and not just kick drum)? #iTunesFestival
{ "content_hash": "e488439dd1a022cefb5719354b5bd1f4", "timestamp": "", "source": "github", "line_count": 8, "max_line_length": 125, "avg_line_length": 35.25, "alnum_prop": 0.7730496453900709, "repo_name": "craigwmcclellan/craigwmcclellan.github.io", "id": "5a097bddae70168c00fa76425de1c3628c14b133", "size": "286", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "_posts/2012-09-24-t250336585801940992.md", "mode": "33188", "license": "mit", "language": [ { "name": "CSS", "bytes": "27257" }, { "name": "HTML", "bytes": "34777166" }, { "name": "Ruby", "bytes": "13054" } ] }
/* $NetBSD: lutil.h,v 1.1.1.4 2014/05/28 09:58:40 tron Exp $ */ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 1998-2014 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ #ifndef _LUTIL_H #define _LUTIL_H 1 #include <ldap_cdefs.h> #include <lber_types.h> /* * Include file for LDAP utility routine */ LDAP_BEGIN_DECL /* n octets encode into ceiling(n/3) * 4 bytes */ /* Avoid floating point math through extra padding */ #define LUTIL_BASE64_ENCODE_LEN(n) (((n)+2)/3 * 4) #define LUTIL_BASE64_DECODE_LEN(n) ((n)/4*3) /* ISC Base64 Routines */ /* base64.c */ LDAP_LUTIL_F( int ) lutil_b64_ntop LDAP_P(( unsigned char const *, size_t, char *, size_t)); LDAP_LUTIL_F( int ) lutil_b64_pton LDAP_P(( char const *, unsigned char *, size_t)); /* detach.c */ LDAP_LUTIL_F( int ) lutil_detach LDAP_P(( int debug, int do_close)); /* entropy.c */ LDAP_LUTIL_F( int ) lutil_entropy LDAP_P(( unsigned char *buf, ber_len_t nbytes )); /* passfile.c */ struct berval; /* avoid pulling in lber.h */ LDAP_LUTIL_F( int ) lutil_get_filed_password LDAP_P(( const char *filename, struct berval * )); /* passwd.c */ struct lutil_pw_scheme; #define LUTIL_PASSWD_OK (0) #define LUTIL_PASSWD_ERR (-1) typedef int (LUTIL_PASSWD_CHK_FUNC)( const struct berval *scheme, const struct berval *passwd, const struct berval *cred, const char **text ); typedef int (LUTIL_PASSWD_HASH_FUNC) ( const struct berval *scheme, const struct berval *passwd, struct berval *hash, const char **text ); LDAP_LUTIL_F( int ) lutil_passwd_add LDAP_P(( struct berval *scheme, LUTIL_PASSWD_CHK_FUNC *chk_fn, LUTIL_PASSWD_HASH_FUNC *hash_fn )); LDAP_LUTIL_F( void ) lutil_passwd_init LDAP_P(( void )); LDAP_LUTIL_F( void ) lutil_passwd_destroy LDAP_P(( void )); LDAP_LUTIL_F( int ) lutil_authpasswd LDAP_P(( const struct berval *passwd, /* stored password */ const struct berval *cred, /* user supplied value */ const char **methods )); LDAP_LUTIL_F( int ) lutil_authpasswd_hash LDAP_P(( const struct berval *cred, struct berval **passwd, /* password to store */ struct berval **salt, /* salt to store */ const char *method )); #ifdef SLAPD_CRYPT typedef int (lutil_cryptfunc) LDAP_P(( const char *key, const char *salt, char **hash )); LDAP_LUTIL_V (lutil_cryptfunc *) lutil_cryptptr; #endif LDAP_LUTIL_F( int ) lutil_passwd LDAP_P(( const struct berval *passwd, /* stored password */ const struct berval *cred, /* user supplied value */ const char **methods, const char **text )); /* error message */ LDAP_LUTIL_F( int ) lutil_passwd_generate LDAP_P(( struct berval *pw, ber_len_t )); LDAP_LUTIL_F( int ) lutil_passwd_hash LDAP_P(( const struct berval *passwd, const char *method, struct berval *hash, const char **text )); LDAP_LUTIL_F( int ) lutil_passwd_scheme LDAP_P(( const char *scheme )); LDAP_LUTIL_F( int ) lutil_salt_format LDAP_P(( const char *format )); LDAP_LUTIL_F( int ) lutil_passwd_string64 LDAP_P(( const struct berval *sc, const struct berval *hash, struct berval *b64, const struct berval *salt )); /* utils.c */ LDAP_LUTIL_F( char* ) lutil_progname LDAP_P(( const char* name, int argc, char *argv[] )); typedef struct lutil_tm { int tm_sec; /* seconds 0-60 (1 leap second) */ int tm_min; /* minutes 0-59 */ int tm_hour; /* hours 0-23 */ int tm_mday; /* day 1-31 */ int tm_mon; /* month 0-11 */ int tm_year; /* year - 1900 */ int tm_usec; /* microseconds */ int tm_usub; /* submicro */ } lutil_tm; typedef struct lutil_timet { unsigned int tt_sec; /* seconds since 1900 */ int tt_gsec; /* seconds since 1900, high 7 bits */ unsigned int tt_usec; /* microseconds */ } lutil_timet; /* Parse a timestamp string into a structure */ LDAP_LUTIL_F( int ) lutil_parsetime LDAP_P(( char *atm, struct lutil_tm * )); /* Convert structured time to time in seconds since 1900 */ LDAP_LUTIL_F( int ) lutil_tm2time LDAP_P(( struct lutil_tm *, struct lutil_timet * )); #ifdef _WIN32 LDAP_LUTIL_F( void ) lutil_slashpath LDAP_P(( char* path )); #define LUTIL_SLASHPATH(p) lutil_slashpath(p) #else #define LUTIL_SLASHPATH(p) #endif LDAP_LUTIL_F( char* ) lutil_strcopy LDAP_P(( char *dst, const char *src )); LDAP_LUTIL_F( char* ) lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n )); LDAP_LUTIL_F( char* ) lutil_memcopy LDAP_P(( char *dst, const char *src, size_t n )); #define lutil_strbvcopy(a, bv) lutil_memcopy((a),(bv)->bv_val,(bv)->bv_len) struct tm; /* use this macro to statically allocate buffer for lutil_gentime */ #define LDAP_LUTIL_GENTIME_BUFSIZE 22 #define lutil_gentime(s,m,t) lutil_localtime((s),(m),(t),0) LDAP_LUTIL_F( size_t ) lutil_localtime LDAP_P(( char *s, size_t smax, const struct tm *tm, long delta )); #ifndef HAVE_MKSTEMP LDAP_LUTIL_F( int ) mkstemp LDAP_P (( char * template )); #endif /* sockpair.c */ LDAP_LUTIL_F( int ) lutil_pair( ber_socket_t sd[2] ); /* uuid.c */ /* use this macro to allocate buffer for lutil_uuidstr */ #define LDAP_LUTIL_UUIDSTR_BUFSIZE 40 LDAP_LUTIL_F( size_t ) lutil_uuidstr( char *buf, size_t len ); LDAP_LUTIL_F( int ) lutil_uuidstr_from_normalized( char *uuid, size_t uuidlen, char *buf, size_t buflen ); /* * Sometimes not all declarations in a header file are needed. * An indicator to this is whether or not the symbol's type has * been defined. Thus, we don't need to include a symbol if * its type has not been defined through another header file. */ #ifdef HAVE_NT_SERVICE_MANAGER LDAP_LUTIL_V (int) is_NT_Service; #ifdef _LDAP_PVT_THREAD_H LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event; #endif /* _LDAP_PVT_THREAD_H */ /* macros are different between Windows and Mingw */ #if defined(_WINSVC_H) || defined(_WINSVC_) LDAP_LUTIL_V (SERVICE_STATUS) lutil_ServiceStatus; LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hlutil_ServiceStatus; #endif /* _WINSVC_H */ LDAP_LUTIL_F (void) lutil_CommenceStartupProcessing( char *serverName, void (*stopper)(int)) ; LDAP_LUTIL_F (void) lutil_ReportShutdownComplete( void ); LDAP_LUTIL_F (void *) lutil_getRegParam( char *svc, char *value ); LDAP_LUTIL_F (int) lutil_srv_install( char* service, char * displayName, char* filename, int auto_start ); LDAP_LUTIL_F (int) lutil_srv_remove ( char* service, char* filename ); #endif /* HAVE_NT_SERVICE_MANAGER */ #ifdef HAVE_NT_EVENT_LOG LDAP_LUTIL_F (void) lutil_LogStartedEvent( char *svc, int slap_debug, char *configfile, char *urls ); LDAP_LUTIL_F (void) lutil_LogStoppedEvent( char *svc ); #endif #ifdef HAVE_EBCDIC /* Generally this has only been used to put '\n' to stdout. We need to * make sure it is output in EBCDIC. */ #undef putchar #undef putc #define putchar(c) putc((c), stdout) #define putc(c,fp) do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0) #endif LDAP_LUTIL_F (int) lutil_atoix( int *v, const char *s, int x ); LDAP_LUTIL_F (int) lutil_atoux( unsigned *v, const char *s, int x ); LDAP_LUTIL_F (int) lutil_atolx( long *v, const char *s, int x ); LDAP_LUTIL_F (int) lutil_atoulx( unsigned long *v, const char *s, int x ); #define lutil_atoi(v, s) lutil_atoix((v), (s), 10) #define lutil_atou(v, s) lutil_atoux((v), (s), 10) #define lutil_atol(v, s) lutil_atolx((v), (s), 10) #define lutil_atoul(v, s) lutil_atoulx((v), (s), 10) #ifdef HAVE_LONG_LONG #if defined(HAVE_STRTOLL) || defined(HAVE_STRTOQ) LDAP_LUTIL_F (int) lutil_atollx( long long *v, const char *s, int x ); #define lutil_atoll(v, s) lutil_atollx((v), (s), 10) #endif /* HAVE_STRTOLL || HAVE_STRTOQ */ #if defined(HAVE_STRTOULL) || defined(HAVE_STRTOUQ) LDAP_LUTIL_F (int) lutil_atoullx( unsigned long long *v, const char *s, int x ); #define lutil_atoull(v, s) lutil_atoullx((v), (s), 10) #endif /* HAVE_STRTOULL || HAVE_STRTOUQ */ #endif /* HAVE_LONG_LONG */ LDAP_LUTIL_F (int) lutil_str2bin( struct berval *in, struct berval *out, void *ctx ); /* Parse and unparse time intervals */ LDAP_LUTIL_F (int) lutil_parse_time( const char *in, unsigned long *tp ); LDAP_LUTIL_F (int) lutil_unparse_time( char *buf, size_t buflen, unsigned long t ); #ifdef timerdiv #define lutil_timerdiv timerdiv #else /* ! timerdiv */ /* works inplace (x == t) */ #define lutil_timerdiv(t,d,x) \ do { \ time_t s = (t)->tv_sec; \ assert( d > 0 ); \ (x)->tv_sec = s / d; \ (x)->tv_usec = ( (t)->tv_usec + 1000000 * ( s % d ) ) / d; \ } while ( 0 ) #endif /* ! timerdiv */ #ifdef timermul #define lutil_timermul timermul #else /* ! timermul */ /* works inplace (x == t) */ #define lutil_timermul(t,m,x) \ do { \ time_t u = (t)->tv_usec * m; \ assert( m > 0 ); \ (x)->tv_sec = (t)->tv_sec * m + u / 1000000; \ (x)->tv_usec = u % 1000000; \ } while ( 0 ); #endif /* ! timermul */ LDAP_END_DECL #endif /* _LUTIL_H */
{ "content_hash": "0543ad0bcea36e0c06b7bbae443d0e3f", "timestamp": "", "source": "github", "line_count": 363, "max_line_length": 81, "avg_line_length": 24.994490358126722, "alnum_prop": 0.668356662625372, "repo_name": "execunix/vinos", "id": "e860c7c373813938a17a135d46f456e0685bd82c", "size": "9073", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "external/bsd/openldap/dist/include/lutil.h", "mode": "33188", "license": "apache-2.0", "language": [] }
.class public abstract Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub; .super Landroid/os/Binder; .source "ISystemUIAdapterCallback.java" # interfaces .implements Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback; # annotations .annotation system Ldalvik/annotation/EnclosingClass; value = Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback; .end annotation .annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x409 name = "Stub" .end annotation .annotation system Ldalvik/annotation/MemberClasses; value = { Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub$Proxy; } .end annotation # static fields .field private static final DESCRIPTOR:Ljava/lang/String; = "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" .field static final TRANSACTION_excludeExternalStorageForFailedPasswordsWipe:I = 0x6 .field static final TRANSACTION_setAirplaneModeAllowed:I = 0xc .field static final TRANSACTION_setApplicationNameControlEnabled:I = 0x19 .field static final TRANSACTION_setBluetoothAllowed:I = 0x10 .field static final TRANSACTION_setCellularDataAllowed:I = 0xd .field static final TRANSACTION_setGPSStateChangeAllowed:I = 0x15 .field static final TRANSACTION_setKioskModeEnabled:I = 0x3 .field static final TRANSACTION_setLocationProviderAllowed:I = 0x14 .field static final TRANSACTION_setLockedIccIds:I = 0x16 .field static final TRANSACTION_setLockscreenInvisibleOverlay:I = 0x17 .field static final TRANSACTION_setLockscreenWallpaper:I = 0x18 .field static final TRANSACTION_setMaximumFailedPasswordsForDisable:I = 0x4 .field static final TRANSACTION_setMultifactorAuthEnabled:I = 0x8 .field static final TRANSACTION_setNFCAllowed:I = 0xe .field static final TRANSACTION_setNFCStateChangeAllowed:I = 0x11 .field static final TRANSACTION_setNavigationBarHidden:I = 0x2 .field static final TRANSACTION_setPasswordLockDelay:I = 0x7 .field static final TRANSACTION_setPasswordVisibilityEnabled:I = 0x9 .field static final TRANSACTION_setPwdChangeRequested:I = 0x5 .field static final TRANSACTION_setSettingsChangeAllowed:I = 0xa .field static final TRANSACTION_setStatusBarExpansionAllowed:I = 0xb .field static final TRANSACTION_setStatusBarHidden:I = 0x1 .field static final TRANSACTION_setWifiAllowed:I = 0x13 .field static final TRANSACTION_setWifiStateChangeAllowed:I = 0x12 .field static final TRANSACTION_setWifiTetheringAllowed:I = 0xf # direct methods .method public constructor <init>()V .locals 1 invoke-direct {p0}, Landroid/os/Binder;-><init>()V const-string/jumbo v0, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p0, p0, v0}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->attachInterface(Landroid/os/IInterface;Ljava/lang/String;)V return-void .end method .method public static asInterface(Landroid/os/IBinder;)Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback; .locals 2 const/4 v1, 0x0 if-nez p0, :cond_0 return-object v1 :cond_0 const-string/jumbo v1, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-interface {p0, v1}, Landroid/os/IBinder;->queryLocalInterface(Ljava/lang/String;)Landroid/os/IInterface; move-result-object v0 if-eqz v0, :cond_1 instance-of v1, v0, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback; if-eqz v1, :cond_1 check-cast v0, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback; return-object v0 :cond_1 new-instance v1, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub$Proxy; invoke-direct {v1, p0}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub$Proxy;-><init>(Landroid/os/IBinder;)V return-object v1 .end method # virtual methods .method public asBinder()Landroid/os/IBinder; .locals 0 return-object p0 .end method .method public onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z .locals 7 .annotation system Ldalvik/annotation/Throws; value = { Landroid/os/RemoteException; } .end annotation const/4 v6, 0x1 sparse-switch p1, :sswitch_data_0 invoke-super {p0, p1, p2, p3, p4}, Landroid/os/Binder;->onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z move-result v5 return v5 :sswitch_0 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p3, v5}, Landroid/os/Parcel;->writeString(Ljava/lang/String;)V return v6 :sswitch_1 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_0 const/4 v2, 0x1 :goto_0 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setStatusBarHidden(Z)V return v6 :cond_0 const/4 v2, 0x0 goto :goto_0 :sswitch_2 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_1 const/4 v2, 0x1 :goto_1 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setNavigationBarHidden(Z)V return v6 :cond_1 const/4 v2, 0x0 goto :goto_1 :sswitch_3 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_2 const/4 v2, 0x1 :goto_2 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setKioskModeEnabled(Z)V return v6 :cond_2 const/4 v2, 0x0 goto :goto_2 :sswitch_4 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v0 invoke-virtual {p0, v0}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setMaximumFailedPasswordsForDisable(I)V return v6 :sswitch_5 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v0 invoke-virtual {p0, v0}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setPwdChangeRequested(I)V return v6 :sswitch_6 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_3 const/4 v2, 0x1 :goto_3 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->excludeExternalStorageForFailedPasswordsWipe(Z)V return v6 :cond_3 const/4 v2, 0x0 goto :goto_3 :sswitch_7 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v0 invoke-virtual {p0, v0}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setPasswordLockDelay(I)V return v6 :sswitch_8 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_4 const/4 v2, 0x1 :goto_4 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setMultifactorAuthEnabled(Z)V return v6 :cond_4 const/4 v2, 0x0 goto :goto_4 :sswitch_9 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_5 const/4 v2, 0x1 :goto_5 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setPasswordVisibilityEnabled(Z)V return v6 :cond_5 const/4 v2, 0x0 goto :goto_5 :sswitch_a const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_6 const/4 v2, 0x1 :goto_6 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setSettingsChangeAllowed(Z)V return v6 :cond_6 const/4 v2, 0x0 goto :goto_6 :sswitch_b const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_7 const/4 v2, 0x1 :goto_7 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setStatusBarExpansionAllowed(Z)V return v6 :cond_7 const/4 v2, 0x0 goto :goto_7 :sswitch_c const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_8 const/4 v2, 0x1 :goto_8 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setAirplaneModeAllowed(Z)V return v6 :cond_8 const/4 v2, 0x0 goto :goto_8 :sswitch_d const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_9 const/4 v2, 0x1 :goto_9 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setCellularDataAllowed(Z)V return v6 :cond_9 const/4 v2, 0x0 goto :goto_9 :sswitch_e const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_a const/4 v2, 0x1 :goto_a invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setNFCAllowed(Z)V return v6 :cond_a const/4 v2, 0x0 goto :goto_a :sswitch_f const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_b const/4 v2, 0x1 :goto_b invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setWifiTetheringAllowed(Z)V return v6 :cond_b const/4 v2, 0x0 goto :goto_b :sswitch_10 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_c const/4 v2, 0x1 :goto_c invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setBluetoothAllowed(Z)V return v6 :cond_c const/4 v2, 0x0 goto :goto_c :sswitch_11 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_d const/4 v2, 0x1 :goto_d invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setNFCStateChangeAllowed(Z)V return v6 :cond_d const/4 v2, 0x0 goto :goto_d :sswitch_12 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_e const/4 v2, 0x1 :goto_e invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setWifiStateChangeAllowed(Z)V return v6 :cond_e const/4 v2, 0x0 goto :goto_e :sswitch_13 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_f const/4 v2, 0x1 :goto_f invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setWifiAllowed(Z)V return v6 :cond_f const/4 v2, 0x0 goto :goto_f :sswitch_14 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readString()Ljava/lang/String; move-result-object v1 invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_10 const/4 v4, 0x1 :goto_10 invoke-virtual {p0, v1, v4}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setLocationProviderAllowed(Ljava/lang/String;Z)V return v6 :cond_10 const/4 v4, 0x0 goto :goto_10 :sswitch_15 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_11 const/4 v2, 0x1 :goto_11 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setGPSStateChangeAllowed(Z)V return v6 :cond_11 const/4 v2, 0x0 goto :goto_11 :sswitch_16 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->createStringArray()[Ljava/lang/String; move-result-object v3 invoke-virtual {p0, v3}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setLockedIccIds([Ljava/lang/String;)V return v6 :sswitch_17 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_12 const/4 v2, 0x1 :goto_12 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setLockscreenInvisibleOverlay(Z)V return v6 :cond_12 const/4 v2, 0x0 goto :goto_12 :sswitch_18 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_13 const/4 v2, 0x1 :goto_13 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setLockscreenWallpaper(Z)V return v6 :cond_13 const/4 v2, 0x0 goto :goto_13 :sswitch_19 const-string/jumbo v5, "android.sec.enterprise.adapterlayer.ISystemUIAdapterCallback" invoke-virtual {p2, v5}, Landroid/os/Parcel;->enforceInterface(Ljava/lang/String;)V invoke-virtual {p2}, Landroid/os/Parcel;->readInt()I move-result v5 if-eqz v5, :cond_14 const/4 v2, 0x1 :goto_14 invoke-virtual {p0, v2}, Landroid/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub;->setApplicationNameControlEnabled(Z)V return v6 :cond_14 const/4 v2, 0x0 goto :goto_14 nop :sswitch_data_0 .sparse-switch 0x1 -> :sswitch_1 0x2 -> :sswitch_2 0x3 -> :sswitch_3 0x4 -> :sswitch_4 0x5 -> :sswitch_5 0x6 -> :sswitch_6 0x7 -> :sswitch_7 0x8 -> :sswitch_8 0x9 -> :sswitch_9 0xa -> :sswitch_a 0xb -> :sswitch_b 0xc -> :sswitch_c 0xd -> :sswitch_d 0xe -> :sswitch_e 0xf -> :sswitch_f 0x10 -> :sswitch_10 0x11 -> :sswitch_11 0x12 -> :sswitch_12 0x13 -> :sswitch_13 0x14 -> :sswitch_14 0x15 -> :sswitch_15 0x16 -> :sswitch_16 0x17 -> :sswitch_17 0x18 -> :sswitch_18 0x19 -> :sswitch_19 0x5f4e5446 -> :sswitch_0 .end sparse-switch .end method
{ "content_hash": "1bbb42f88af04539db30afb7c361e35b", "timestamp": "", "source": "github", "line_count": 730, "max_line_length": 161, "avg_line_length": 25.024657534246575, "alnum_prop": 0.7105868184804028, "repo_name": "BatMan-Rom/ModdedFiles", "id": "5f7fe705b788ca1feb01a8b24cb41f8bbc7829fb", "size": "18268", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "framework.jar.out/smali_classes2/android/sec/enterprise/adapterlayer/ISystemUIAdapterCallback$Stub.smali", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "GLSL", "bytes": "15069" }, { "name": "HTML", "bytes": "139176" }, { "name": "Smali", "bytes": "541934400" } ] }
The ActiveWarehouse library provides classes and functions which help with building Data Warehouses using Rails. ## Installation To install ActiveWarehouse, add the gem to your Gemfile: gem 'activewarehouse' ## Generators ActiveWarehouse comes with several generators. In the examples below, you can use either example and the results will be the same. ### Facts Creates a SalesFact class and a sales_facts table. script/generate fact Sales script/generate fact sales ### Dimensions Creates a RegionDimension class and a region_dimension table. script/generate dimension Region script/generate dimension region ### Cubes Creates a RegionalSalesCube class. script/generate cube RegionalSales script/generate cube regional_sales ### Bridge Creates a CustomerHierarchyBridge class. script/generate bridge CustomerHierarchy script/generate bridge customer_hierarchy ### Dimension View Creates an OrderDateDimension class which is represented by a view on top of the DateDimension. script/generate dimension_view OrderDate Date script/generate dimension_view order_date date ## Model Naming The rules for naming are as follows: Facts: * Fact classes and tables follow the typical Rails rules: classes are singular and tables are pluralized. * Both the class and table name are suffixed by "_fact". Dimensions: * Dimension classes and tables are both singular. * Both the class name and the table name are suffixed by "_dimension". Cube: * Cube class is singular. If a cube table is created it will also be singular. Bridge: * Bridge classes and tables are both singular. * Both the class name and the table name are suffixed by "_bridge". Dimension View: * Dimension View classes are singular. The underlying data structure is a view * on top of an existing dimension. * Both the class name and the view name are suffixed by "_dimension" ## ETL The ActiveWarehouse plugin does not directly handle Extract-Transform-Load processes, however the ActiveWarehouse ETL gem (installed separately) can help. To install it use: gem install activewarehouse-etl More information on the ETL process can be found at http://activewarehouse.rubyforge.org/etl
{ "content_hash": "444c83203370c71f4745f20d8a53fa87", "timestamp": "", "source": "github", "line_count": 89, "max_line_length": 106, "avg_line_length": 25.168539325842698, "alnum_prop": 0.7709821428571428, "repo_name": "activewarehouse/activewarehouse", "id": "8fc7440cbdd29009e74ed2bb27523298d4f7cbd4", "size": "2259", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "README.markdown", "mode": "33188", "license": "mit", "language": [ { "name": "Ruby", "bytes": "318279" } ] }
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>PHPXRef 0.7.1 : Unnamed Project : Variable Reference: $useragent</title> <link rel="stylesheet" href="../sample.css" type="text/css"> <link rel="stylesheet" href="../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">PHP Cross Reference of Unnamed Project</h2> </td> </tr> </table> <!-- Generated by PHPXref 0.7.1 at Thu Oct 23 18:57:41 2014 --> <!-- PHPXref (c) 2000-2010 Gareth Watts - gareth@omnipotent.net --> <!-- http://phpxref.sourceforge.net/ --> <script src="../phpxref.js" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"> <!-- ext='.html'; relbase='../'; subdir='_variables'; filename='index.html'; cookiekey='phpxref'; handleNavFrame(relbase, subdir, filename); logVariable('useragent'); // --> </script> <script language="JavaScript" type="text/javascript"> if (gwGetCookie('xrefnav')=='off') document.write('<p class="navlinks">[ <a href="javascript:navOn()">Show Explorer<\/a> ]<\/p>'); else document.write('<p class="navlinks">[ <a href="javascript:navOff()">Hide Explorer<\/a> ]<\/p>'); </script> <noscript> <p class="navlinks"> [ <a href="../nav.html" target="_top">Show Explorer</a> ] [ <a href="index.html" target="_top">Hide Navbar</a> ] </p> </noscript> [<a href="../index.html">Top level directory</a>]<br> <script language="JavaScript" type="text/javascript"> <!-- document.writeln('<table align="right" class="searchbox-link"><tr><td><a class="searchbox-link" href="javascript:void(0)" onMouseOver="showSearchBox()">Search</a><br>'); document.writeln('<table border="0" cellspacing="0" cellpadding="0" class="searchbox" id="searchbox">'); document.writeln('<tr><td class="searchbox-title">'); document.writeln('<a class="searchbox-title" href="javascript:showSearchPopup()">Search History +</a>'); document.writeln('<\/td><\/tr>'); document.writeln('<tr><td class="searchbox-body" id="searchbox-body">'); document.writeln('<form name="search" style="margin:0px; padding:0px" onSubmit=\'return jump()\'>'); document.writeln('<a class="searchbox-body" href="../_classes/index.html">Class<\/a>: '); document.writeln('<input type="text" size=10 value="" name="classname"><br>'); document.writeln('<a id="funcsearchlink" class="searchbox-body" href="../_functions/index.html">Function<\/a>: '); document.writeln('<input type="text" size=10 value="" name="funcname"><br>'); document.writeln('<a class="searchbox-body" href="../_variables/index.html">Variable<\/a>: '); document.writeln('<input type="text" size=10 value="" name="varname"><br>'); document.writeln('<a class="searchbox-body" href="../_constants/index.html">Constant<\/a>: '); document.writeln('<input type="text" size=10 value="" name="constname"><br>'); document.writeln('<a class="searchbox-body" href="../_tables/index.html">Table<\/a>: '); document.writeln('<input type="text" size=10 value="" name="tablename"><br>'); document.writeln('<input type="submit" class="searchbox-button" value="Search">'); document.writeln('<\/form>'); document.writeln('<\/td><\/tr><\/table>'); document.writeln('<\/td><\/tr><\/table>'); // --> </script> <div id="search-popup" class="searchpopup"><p id="searchpopup-title" class="searchpopup-title">title</p><div id="searchpopup-body" class="searchpopup-body">Body</div><p class="searchpopup-close"><a href="javascript:gwCloseActive()">[close]</a></p></div> <h3>Variable Cross Reference</h3> <h2><a href="index.html#useragent">$useragent</a></h2> <b>Defined at:</b><ul> <li><a href="../bonfire/codeigniter/libraries/Email.php.html">/bonfire/codeigniter/libraries/Email.php</A> -> <a href="../bonfire/codeigniter/libraries/Email.php.source.html#l31"> line 31</A></li> </ul> <br><b>Referenced 3 times:</b><ul> <li><a href="../bonfire/codeigniter/libraries/Email.php.html">/bonfire/codeigniter/libraries/Email.php</a> -> <a href="../bonfire/codeigniter/libraries/Email.php.source.html#l31"> line 31</a></li> <li><a href="../bonfire/codeigniter/libraries/Email.php.html">/bonfire/codeigniter/libraries/Email.php</a> -> <a href="../bonfire/codeigniter/libraries/Email.php.source.html#l157"> line 157</a></li> <li><a href="../bonfire/codeigniter/libraries/Email.php.html">/bonfire/codeigniter/libraries/Email.php</a> -> <a href="../bonfire/codeigniter/libraries/Email.php.source.html#l964"> line 964</a></li> </ul> <!-- A link to the phpxref site in your customized footer file is appreciated ;-) --> <br><hr> <table width="100%"> <tr><td>Generated: Thu Oct 23 18:57:41 2014</td> <td align="right"><i>Cross-referenced by <a href="http://phpxref.sourceforge.net/">PHPXref 0.7.1</a></i></td> </tr> </table> </body></html>
{ "content_hash": "f977000f5cd499a1bf70219373741a2a", "timestamp": "", "source": "github", "line_count": 98, "max_line_length": 253, "avg_line_length": 52.94897959183673, "alnum_prop": 0.6745037579495086, "repo_name": "inputx/code-ref-doc", "id": "3bd5e3743c7cae088dc60a718cc616afd46fe241", "size": "5189", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "bonfire/_variables/useragent.html", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "17952" }, { "name": "JavaScript", "bytes": "255489" } ] }
@interface UIView (Nib) + (id)viewFromNibWithFileName:(NSString *)file class:(Class)clasz index:(NSInteger)index; + (id)viewFromNibWithFileName:(NSString *)file owner:(id)owner index:(NSInteger)index; @end
{ "content_hash": "58ce14447083bd5b2110a2df83762a1d", "timestamp": "", "source": "github", "line_count": 4, "max_line_length": 89, "avg_line_length": 51.5, "alnum_prop": 0.7766990291262136, "repo_name": "CoderJackie/SkuSample", "id": "ce8f1d3e9f433fcbf483347b4d49d648f895a289", "size": "363", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "SkuSample/SkuSample/UIView+Nib.h", "mode": "33188", "license": "mit", "language": [ { "name": "C", "bytes": "10778" }, { "name": "Objective-C", "bytes": "365858" }, { "name": "Ruby", "bytes": "84" }, { "name": "Shell", "bytes": "4098" } ] }
<?php namespace Magento\CatalogRule\Test\Unit\Model\Product; class PriceModifierTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\CatalogRule\Model\Product\PriceModifier */ protected $priceModifier; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $ruleFactoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $productMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $ruleMock; protected function setUp() { $this->ruleFactoryMock = $this->getMock( 'Magento\CatalogRule\Model\RuleFactory', ['create'], [], '', false ); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); $this->ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false); $this->priceModifier = new \Magento\CatalogRule\Model\Product\PriceModifier($this->ruleFactoryMock); } /** * @param int|null $resultPrice * @param int $expectedPrice * @dataProvider modifyPriceDataProvider */ public function testModifyPriceIfPriceExists($resultPrice, $expectedPrice) { $this->ruleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->ruleMock)); $this->ruleMock->expects( $this->once() )->method( 'calcProductPriceRule' )->with( $this->productMock, 100 )->will( $this->returnValue($resultPrice) ); $this->assertEquals($expectedPrice, $this->priceModifier->modifyPrice(100, $this->productMock)); } public function modifyPriceDataProvider() { return ['resulted_price_exists' => [150, 150], 'resulted_price_not_exists' => [null, 100]]; } public function testModifyPriceIfPriceNotExist() { $this->ruleFactoryMock->expects($this->never())->method('create'); $this->assertEquals(null, $this->priceModifier->modifyPrice(null, $this->productMock)); } }
{ "content_hash": "142d738301e1cd890dd6e1f9865c54b3", "timestamp": "", "source": "github", "line_count": 72, "max_line_length": 116, "avg_line_length": 29.90277777777778, "alnum_prop": 0.6024152345564329, "repo_name": "j-froehlich/magento2_wk", "id": "19069c5c6a5911bc19e5d2e04b61d9750223dfd0", "size": "2261", "binary": false, "copies": "2", "ref": "refs/heads/master", "path": "vendor/magento/module-catalog-rule/Test/Unit/Model/Product/PriceModifierTest.php", "mode": "33188", "license": "mit", "language": [ { "name": "ApacheConf", "bytes": "13636" }, { "name": "CSS", "bytes": "2076720" }, { "name": "HTML", "bytes": "6151072" }, { "name": "JavaScript", "bytes": "2488727" }, { "name": "PHP", "bytes": "12466046" }, { "name": "Shell", "bytes": "6088" }, { "name": "XSLT", "bytes": "19979" } ] }
package org.pitest.maven; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; /** * Goal which runs a coverage mutation report */ @Mojo(name = "mutationCoverage", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class PitMojo extends AbstractPitMojo { }
{ "content_hash": "60ed0f64382a9335c618d5e0c3732868", "timestamp": "", "source": "github", "line_count": 16, "max_line_length": 60, "avg_line_length": 29.125, "alnum_prop": 0.7746781115879828, "repo_name": "hcoles/pitest", "id": "47438cb75e67dadcc78e8ef73ba0bf26d1388119", "size": "466", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "pitest-maven/src/main/java/org/pitest/maven/PitMojo.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "5627" }, { "name": "Groovy", "bytes": "949" }, { "name": "Java", "bytes": "2317356" }, { "name": "Kotlin", "bytes": "4338" }, { "name": "StringTemplate", "bytes": "7641" } ] }
// Pragma mark // View Management // // IDECodeSnippetCompletionPrefix: View Management // IDECodeSnippetCompletionScopes: [ClassInterfaceMethods,StringOrComment,ClassImplementation] // IDECodeSnippetIdentifier: 7B8C0FC0-23DA-4971-85E6-702A5D4C5E72 // IDECodeSnippetLanguage: Xcode.SourceCodeLanguage.Objective-C // IDECodeSnippetUserSnippet: 1 // IDECodeSnippetVersion: 2 /**************************************************************************************************/ #pragma mark - View Management
{ "content_hash": "ec94676e3d67a162d490153da5e1009c", "timestamp": "", "source": "github", "line_count": 11, "max_line_length": 100, "avg_line_length": 45.90909090909091, "alnum_prop": 0.6653465346534654, "repo_name": "rvi/xcode-snippets", "id": "6f5c8fdefe92262ba774360a35c656c70f3c0605", "size": "505", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "pragma_mark.m", "mode": "33188", "license": "mit", "language": [ { "name": "Objective-C", "bytes": "42238" } ] }
package org.apache.camel.bam.model; import java.util.Date; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; /** * @version $Revision$ */ public abstract class TemporalEntity extends EntitySupport { private Date timeStarted; private Date timeCompleted; @Transient public boolean isStarted() { return timeStarted != null; } @Transient public boolean isCompleted() { return timeCompleted != null; } @Temporal(TemporalType.TIME) public Date getTimeStarted() { return timeStarted; } public void setTimeStarted(Date timeStarted) { this.timeStarted = timeStarted; } @Temporal(TemporalType.TIME) public Date getTimeCompleted() { return timeCompleted; } public void setTimeCompleted(Date timeCompleted) { this.timeCompleted = timeCompleted; } }
{ "content_hash": "3e7edfb37dafd376695ad6c48363abc2", "timestamp": "", "source": "github", "line_count": 44, "max_line_length": 60, "avg_line_length": 21.113636363636363, "alnum_prop": 0.6846071044133477, "repo_name": "kingargyle/turmeric-bot", "id": "ba0e2135bdc2b694d59fad0378c8e00e375b0782", "size": "1732", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "components/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "ActionScript", "bytes": "20202" }, { "name": "Batchfile", "bytes": "108" }, { "name": "CSS", "bytes": "220587" }, { "name": "FreeMarker", "bytes": "11350" }, { "name": "Groovy", "bytes": "2711" }, { "name": "HTML", "bytes": "308151" }, { "name": "Java", "bytes": "19316639" }, { "name": "JavaScript", "bytes": "4172468" }, { "name": "PHP", "bytes": "88860" }, { "name": "Protocol Buffer", "bytes": "578" }, { "name": "Ruby", "bytes": "4814" }, { "name": "Scala", "bytes": "185055" }, { "name": "Shell", "bytes": "351" }, { "name": "Tcl", "bytes": "2969" }, { "name": "XQuery", "bytes": "332" }, { "name": "XSLT", "bytes": "37282" } ] }
layout: page title: Valenzuela Reef Entertainment Dinner date: 2016-05-24 author: Gregory Shannon tags: weekly links, java status: published summary: Donec rhoncus nunc justo, sit amet. banner: images/banner/leisure-03.jpg booking: startDate: 12/22/2019 endDate: 12/27/2019 ctyhocn: DTNTXHX groupCode: VRED published: true --- Curabitur aliquam eget justo eget sollicitudin. Aliquam ut quam ac nunc tristique tempor eget et urna. Sed tincidunt ipsum sit amet quam hendrerit, sed tincidunt magna efficitur. In sed libero egestas, bibendum purus quis, tincidunt enim. Nam ultrices quis quam a tempus. Nulla sed porta est. Cras dapibus, nibh non bibendum porta, risus lorem tristique neque, id porttitor risus velit non libero. Quisque venenatis ante nec massa tempor ultrices. Maecenas velit dui, aliquam eget malesuada vel, sollicitudin ac metus. Phasellus eu dignissim urna. Curabitur accumsan interdum metus quis ullamcorper. Donec quam purus, scelerisque eu rhoncus non, tempus quis risus. In hac habitasse platea dictumst. Quisque non molestie ligula. Phasellus hendrerit suscipit suscipit. * Suspendisse pellentesque orci sed lorem eleifend euismod * In lacinia lorem et dapibus volutpat. Sed sed odio dapibus, luctus ex ac, scelerisque velit. Ut eu pretium ante. Cras in leo in ex auctor dignissim et at nisl. Aliquam erat volutpat. Sed ac mattis ligula, sed commodo orci. Nunc luctus mauris at arcu fermentum lobortis. Nullam convallis quam vel dolor maximus hendrerit. In ornare vel lorem sed facilisis. Vestibulum lacinia massa felis, id faucibus turpis scelerisque sed. Nam cursus viverra sem, eu blandit mi volutpat pulvinar. Nunc facilisis turpis maximus, placerat justo sit amet, finibus enim. Vestibulum nec varius tellus, a elementum ex. Mauris vel lectus in ante faucibus fringilla. Etiam commodo, mi nec interdum tristique, ipsum ex scelerisque velit, in fermentum neque purus vel est. Nulla lacus erat, tincidunt non pretium lacinia, aliquet quis lorem. Curabitur at libero ac metus dignissim laoreet sed et arcu. Mauris at bibendum nulla. Aenean non mauris tempus lectus semper elementum. Nam tincidunt libero nec lectus eleifend, non semper eros viverra. Etiam dapibus sem ligula, ut sollicitudin nibh commodo blandit. Morbi lacinia purus quis massa mollis tincidunt.
{ "content_hash": "4be4340636f5c54f1c1414232c577ce0", "timestamp": "", "source": "github", "line_count": 23, "max_line_length": 810, "avg_line_length": 99.8695652173913, "alnum_prop": 0.8093164997823248, "repo_name": "KlishGroup/prose-pogs", "id": "f3c355f74d1eccc0607850b6c71fead688eca48d", "size": "2301", "binary": false, "copies": "1", "ref": "refs/heads/gh-pages", "path": "pogs/D/DTNTXHX/VRED/index.md", "mode": "33188", "license": "mit", "language": [] }
SYNONYM #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
{ "content_hash": "fa8595ce1bb7df9a62241b4c7a4fc71f", "timestamp": "", "source": "github", "line_count": 13, "max_line_length": 39, "avg_line_length": 10.23076923076923, "alnum_prop": 0.6917293233082706, "repo_name": "mdoering/backbone", "id": "2686a67b68d098de1fa9e3204056abbe0873bf69", "size": "187", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "life/Plantae/Magnoliophyta/Liliopsida/Asparagales/Orchidaceae/Dendrobium/Dendrobium chamaephytum/ Syn. Dendrobium salhutuense/README.md", "mode": "33188", "license": "apache-2.0", "language": [] }
// Copyright (c) 2012 Ecma International. All rights reserved. // Ecma International makes this code available under the terms and conditions set // forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the // "Use Terms"). Any redistribution of this code must retain the above // copyright and this notice and otherwise comply with the Use Terms. /*--- es5id: 15.2.3.3-4-197 description: > Object.getOwnPropertyDescriptor returns data desc (all false) for properties on built-ins (Number.MIN_VALUE) includes: [runTestCase.js] ---*/ function testcase() { var desc = Object.getOwnPropertyDescriptor(Number, "MIN_VALUE"); if (desc.writable === false && desc.enumerable === false && desc.configurable === false && desc.hasOwnProperty('get') === false && desc.hasOwnProperty('set') === false) { return true; } } runTestCase(testcase);
{ "content_hash": "940e2d75ed602f1a5b25a238a24a9f32", "timestamp": "", "source": "github", "line_count": 26, "max_line_length": 82, "avg_line_length": 34.46153846153846, "alnum_prop": 0.6975446428571429, "repo_name": "PiotrDabkowski/Js2Py", "id": "f71be62e361630e09d3bffef3cc679e4661546d0", "size": "896", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "tests/test_cases/built-ins/Object/getOwnPropertyDescriptor/15.2.3.3-4-197.js", "mode": "33261", "license": "mit", "language": [ { "name": "Dockerfile", "bytes": "289" }, { "name": "JavaScript", "bytes": "8556970" }, { "name": "Python", "bytes": "4583980" }, { "name": "Shell", "bytes": "457" } ] }
/* Which of the following values can be assigned to a variable of type float and which to a variable of type double: 34.567839023, 12.345, 8923.1234857, 3456.091? Write a program to assign the numbers in variables and print them to ensure no precision is lost. */ #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { float first = 12.345; float second = 3456.091; double third = 34.567839023; double fourth = 8923.1234857; printf("%f\n", first); printf("%f\n", second); printf("%.9f\n", third); printf("%.7f\n", fourth); return (EXIT_SUCCESS); }
{ "content_hash": "e588500677ffaeaaf335ef3ed6c42fef", "timestamp": "", "source": "github", "line_count": 25, "max_line_length": 76, "avg_line_length": 24.6, "alnum_prop": 0.656910569105691, "repo_name": "NikolovV/C-Language", "id": "ab9f3eb8286e4d300c2239e8f10dc1f75f316f73", "size": "615", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "SoftUni/C Programming/C Data Types-Homework/02-Float or Double/main.c", "mode": "33188", "license": "mit", "language": [ { "name": "C", "bytes": "284817" }, { "name": "Groff", "bytes": "325007" }, { "name": "M4", "bytes": "386" }, { "name": "Makefile", "bytes": "97020" }, { "name": "Shell", "bytes": "59273" } ] }
using namespace std; using namespace seqan; // Program entry point int main(int argc, char const ** argv) { // create AA seq and iterate over typedef String<char> TAminoAcidString; TAminoAcidString AA = "MQDRVKRPMNAFIVWSRDQRRKMALEN"; cout << AA << endl; // get size int length = length(AA); // create iterator typedef Iterator<String<char> >::Type TIter; TIter itrStart = begin(AA); TIter itrEnd = end(AA); for(;itrStart!=itrEnd; ++itrStart){ cout << ", " << AA[*itrStart] << " "; } return 0; }
{ "content_hash": "0f15f97da2d700181d6909e84c9e7b85", "timestamp": "", "source": "github", "line_count": 21, "max_line_length": 53, "avg_line_length": 24.428571428571427, "alnum_prop": 0.6764132553606238, "repo_name": "bkahlert/seqan-research", "id": "f1f5efa476f945b1c8f0ac11f1eb43b1d16cd8e8", "size": "628", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "raw/workshop11/workshop2011-data-20110925/sources/20xjp6c6gjzthtye/38/sandbox/mySandbox/apps/my_app/my_app.cpp", "mode": "33188", "license": "mit", "language": [ { "name": "ApacheConf", "bytes": "39014" }, { "name": "Awk", "bytes": "44044" }, { "name": "Batchfile", "bytes": "37736" }, { "name": "C", "bytes": "1261223" }, { "name": "C++", "bytes": "277576131" }, { "name": "CMake", "bytes": "5546616" }, { "name": "CSS", "bytes": "271972" }, { "name": "GLSL", "bytes": "2280" }, { "name": "Groff", "bytes": "2694006" }, { "name": "HTML", "bytes": "15207297" }, { "name": "JavaScript", "bytes": "362928" }, { "name": "LSL", "bytes": "22561" }, { "name": "Makefile", "bytes": "6418610" }, { "name": "Objective-C", "bytes": "3730085" }, { "name": "PHP", "bytes": "3302" }, { "name": "Perl", "bytes": "10468" }, { "name": "PostScript", "bytes": "22762" }, { "name": "Python", "bytes": "9267035" }, { "name": "R", "bytes": "230698" }, { "name": "Rebol", "bytes": "283" }, { "name": "Shell", "bytes": "437340" }, { "name": "Tcl", "bytes": "15439" }, { "name": "TeX", "bytes": "738415" }, { "name": "VimL", "bytes": "12685" } ] }
package com.actionexamples; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import com.facebook.react.LifecycleState; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactRootView; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactInstanceManager mReactInstanceManager; private ReactRootView mReactRootView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReactRootView = new ReactRootView(this); mReactInstanceManager = ReactInstanceManager.builder() .setApplication(getApplication()) .setBundleAssetName("index.android.bundle") .setJSMainModuleName("index.android") .addPackage(new MainReactPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) .build(); mReactRootView.startReactApplication(mReactInstanceManager, "ActionExamples", null); setContentView(mReactRootView); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) { mReactInstanceManager.showDevOptionsDialog(); return true; } return super.onKeyUp(keyCode, event); } @Override public void onBackPressed() { if (mReactInstanceManager != null) { mReactInstanceManager.onBackPressed(); } else { super.onBackPressed(); } } @Override public void invokeDefaultOnBackPressed() { super.onBackPressed(); } @Override protected void onPause() { super.onPause(); if (mReactInstanceManager != null) { mReactInstanceManager.onPause(); } } @Override protected void onResume() { super.onResume(); if (mReactInstanceManager != null) { mReactInstanceManager.onResume(this, this); } } }
{ "content_hash": "3f119c21188a075a556ba950062f5f5d", "timestamp": "", "source": "github", "line_count": 78, "max_line_length": 92, "avg_line_length": 29.423076923076923, "alnum_prop": 0.6736383442265795, "repo_name": "holmesal/react-native-ios-notification-actions", "id": "99d8d57d04eb6187fc0bfbf4c8214f4496ecdded", "size": "2295", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "example/android/app/src/main/java/com/actionexamples/MainActivity.java", "mode": "33188", "license": "mit", "language": [ { "name": "Java", "bytes": "2295" }, { "name": "JavaScript", "bytes": "5172" }, { "name": "Objective-C", "bytes": "15217" }, { "name": "Ruby", "bytes": "702" } ] }
package com.azure.cosmos.implementation.directconnectivity; import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.implementation.ReplicationPolicy; import org.mockito.Mockito; public class GatewayServiceConfiguratorReaderMock { public GatewayServiceConfigurationReader gatewayServiceConfigurationReader; public static GatewayServiceConfiguratorReaderMock from(ConsistencyLevel accountConsistencyLevel) { return new GatewayServiceConfiguratorReaderMock(new ReplicationPolicy("{}"), new ReplicationPolicy("{}"), accountConsistencyLevel); } public static GatewayServiceConfiguratorReaderMock from(ConsistencyLevel accountConsistencyLevel, int systemMaxReplicaCount, int systemMinReplicaCount, int userMaxReplicaCount, int userMinReplicaCount) { ReplicationPolicy userRP = Mockito.mock(ReplicationPolicy.class); Mockito.doReturn(userMaxReplicaCount).when(userRP).getMaxReplicaSetSize(); Mockito.doReturn(userMinReplicaCount).when(userRP).getMinReplicaSetSize(); ReplicationPolicy systemRP = Mockito.mock(ReplicationPolicy.class); Mockito.doReturn(systemMaxReplicaCount).when(systemRP).getMaxReplicaSetSize(); Mockito.doReturn(systemMinReplicaCount).when(systemRP).getMinReplicaSetSize(); return new GatewayServiceConfiguratorReaderMock(userRP, systemRP, accountConsistencyLevel); } public static GatewayServiceConfiguratorReaderMock from(ConsistencyLevel accountConsistencyLevel, int maxReplicaSize, int minReplicaCase) { ReplicationPolicy rp = Mockito.mock(ReplicationPolicy.class); Mockito.doReturn(maxReplicaSize).when(rp).getMaxReplicaSetSize(); Mockito.doReturn(minReplicaCase).when(rp).getMinReplicaSetSize(); return new GatewayServiceConfiguratorReaderMock(rp, rp, accountConsistencyLevel); } public GatewayServiceConfiguratorReaderMock(ReplicationPolicy userReplicationPolicy, ReplicationPolicy systemReplicationPolicy, ConsistencyLevel defaultConsistencyLevel) { this.gatewayServiceConfigurationReader = Mockito.mock(GatewayServiceConfigurationReader.class); Mockito.doReturn(defaultConsistencyLevel).when(this.gatewayServiceConfigurationReader).getDefaultConsistencyLevel(); Mockito.doReturn(systemReplicationPolicy).when(this.gatewayServiceConfigurationReader).getSystemReplicationPolicy(); Mockito.doReturn(userReplicationPolicy).when(this.gatewayServiceConfigurationReader).getUserReplicationPolicy(); } }
{ "content_hash": "5d264f7542b90a7f36ab1fb46bab7bbb", "timestamp": "", "source": "github", "line_count": 49, "max_line_length": 143, "avg_line_length": 57.93877551020408, "alnum_prop": 0.7182106375484325, "repo_name": "selvasingh/azure-sdk-for-java", "id": "f8857795c58c936adddd52551db2b95c4cbafb4a", "size": "2936", "binary": false, "copies": "2", "ref": "refs/heads/master", "path": "sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/directconnectivity/GatewayServiceConfiguratorReaderMock.java", "mode": "33188", "license": "mit", "language": [ { "name": "Java", "bytes": "29891970" }, { "name": "JavaScript", "bytes": "6198" }, { "name": "PowerShell", "bytes": "160" }, { "name": "Shell", "bytes": "609" } ] }
import uuid import mox from neutronclient.common import exceptions from neutronclient.v2_0 import client from oslo.config import cfg from nova.compute import flavors from nova.conductor import api as conductor_api from nova import context from nova import exception from nova.network import model from nova.network import neutronv2 from nova.network.neutronv2 import api as neutronapi from nova.network.neutronv2 import constants from nova.openstack.common import jsonutils from nova import test from nova import utils CONF = cfg.CONF #NOTE: Neutron client raises Exception which is discouraged by HACKING. # We set this variable here and use it for assertions below to avoid # the hacking checks until we can make neutron client throw a custom # exception class instead. NEUTRON_CLIENT_EXCEPTION = Exception class MyComparator(mox.Comparator): def __init__(self, lhs): self.lhs = lhs def _com_dict(self, lhs, rhs): if len(lhs) != len(rhs): return False for key, value in lhs.iteritems(): if key not in rhs: return False rhs_value = rhs[key] if not self._com(value, rhs_value): return False return True def _com_list(self, lhs, rhs): if len(lhs) != len(rhs): return False for lhs_value in lhs: if lhs_value not in rhs: return False return True def _com(self, lhs, rhs): if lhs is None: return rhs is None if isinstance(lhs, dict): if not isinstance(rhs, dict): return False return self._com_dict(lhs, rhs) if isinstance(lhs, list): if not isinstance(rhs, list): return False return self._com_list(lhs, rhs) if isinstance(lhs, tuple): if not isinstance(rhs, tuple): return False return self._com_list(lhs, rhs) return lhs == rhs def equals(self, rhs): return self._com(self.lhs, rhs) def __repr__(self): return str(self.lhs) class TestNeutronClient(test.TestCase): def test_withtoken(self): self.flags(neutron_url='http://anyhost/') self.flags(neutron_url_timeout=30) my_context = context.RequestContext('userid', 'my_tenantid', auth_token='token') self.mox.StubOutWithMock(client.Client, "__init__") client.Client.__init__( endpoint_url=CONF.neutron_url, token=my_context.auth_token, timeout=CONF.neutron_url_timeout, insecure=False).AndReturn(None) self.mox.ReplayAll() neutronv2.get_client(my_context) def test_withouttoken_keystone_connection_error(self): self.flags(neutron_auth_strategy='keystone') self.flags(neutron_url='http://anyhost/') my_context = context.RequestContext('userid', 'my_tenantid') self.assertRaises(NEUTRON_CLIENT_EXCEPTION, neutronv2.get_client, my_context) def test_withouttoken_keystone_not_auth(self): self.flags(neutron_auth_strategy=None) self.flags(neutron_url='http://anyhost/') self.flags(neutron_url_timeout=30) my_context = context.RequestContext('userid', 'my_tenantid') self.mox.StubOutWithMock(client.Client, "__init__") client.Client.__init__( endpoint_url=CONF.neutron_url, auth_strategy=None, timeout=CONF.neutron_url_timeout, insecure=False).AndReturn(None) self.mox.ReplayAll() neutronv2.get_client(my_context) class TestNeutronv2Base(test.TestCase): def setUp(self): super(TestNeutronv2Base, self).setUp() self.context = context.RequestContext('userid', 'my_tenantid') setattr(self.context, 'auth_token', 'bff4a5a6b9eb4ea2a6efec6eefb77936') self.instance = {'project_id': '9d049e4b60b64716978ab415e6fbd5c0', 'uuid': str(uuid.uuid4()), 'display_name': 'test_instance', 'availability_zone': 'nova', 'host': 'some_host', 'security_groups': []} self.instance2 = {'project_id': '9d049e4b60b64716978ab415e6fbd5c0', 'uuid': str(uuid.uuid4()), 'display_name': 'test_instance2', 'availability_zone': 'nova', 'security_groups': []} self.nets1 = [{'id': 'my_netid1', 'name': 'my_netname1', 'tenant_id': 'my_tenantid'}] self.nets2 = [] self.nets2.append(self.nets1[0]) self.nets2.append({'id': 'my_netid2', 'name': 'my_netname2', 'tenant_id': 'my_tenantid'}) self.nets3 = self.nets2 + [{'id': 'my_netid3', 'name': 'my_netname3', 'tenant_id': 'my_tenantid'}] self.nets4 = [{'id': 'his_netid4', 'name': 'his_netname4', 'tenant_id': 'his_tenantid'}] self.nets = [self.nets1, self.nets2, self.nets3, self.nets4] self.port_address = '10.0.1.2' self.port_data1 = [{'network_id': 'my_netid1', 'device_id': self.instance2['uuid'], 'device_owner': 'compute:nova', 'id': 'my_portid1', 'fixed_ips': [{'ip_address': self.port_address, 'subnet_id': 'my_subid1'}], 'mac_address': 'my_mac1', }] self.float_data1 = [{'port_id': 'my_portid1', 'fixed_ip_address': self.port_address, 'floating_ip_address': '172.0.1.2'}] self.dhcp_port_data1 = [{'fixed_ips': [{'ip_address': '10.0.1.9', 'subnet_id': 'my_subid1'}]}] self.port_address2 = '10.0.2.2' self.port_data2 = [] self.port_data2.append(self.port_data1[0]) self.port_data2.append({'network_id': 'my_netid2', 'device_id': self.instance['uuid'], 'device_owner': 'compute:nova', 'id': 'my_portid2', 'fixed_ips': [{'ip_address': self.port_address2, 'subnet_id': 'my_subid2'}], 'mac_address': 'my_mac2', }) self.float_data2 = [] self.float_data2.append(self.float_data1[0]) self.float_data2.append({'port_id': 'my_portid2', 'fixed_ip_address': '10.0.2.2', 'floating_ip_address': '172.0.2.2'}) self.port_data3 = [{'network_id': 'my_netid1', 'device_id': 'device_id3', 'device_owner': 'compute:nova', 'id': 'my_portid3', 'fixed_ips': [], # no fixed ip 'mac_address': 'my_mac3', }] self.subnet_data1 = [{'id': 'my_subid1', 'cidr': '10.0.1.0/24', 'network_id': 'my_netid1', 'gateway_ip': '10.0.1.1', 'dns_nameservers': ['8.8.1.1', '8.8.1.2']}] self.subnet_data2 = [] self.subnet_data_n = [{'id': 'my_subid1', 'cidr': '10.0.1.0/24', 'network_id': 'my_netid1', 'gateway_ip': '10.0.1.1', 'dns_nameservers': ['8.8.1.1', '8.8.1.2']}, {'id': 'my_subid2', 'cidr': '20.0.1.0/24', 'network_id': 'my_netid2', 'gateway_ip': '20.0.1.1', 'dns_nameservers': ['8.8.1.1', '8.8.1.2']}] self.subnet_data2.append({'id': 'my_subid2', 'cidr': '10.0.2.0/24', 'network_id': 'my_netid2', 'gateway_ip': '10.0.2.1', 'dns_nameservers': ['8.8.2.1', '8.8.2.2']}) self.fip_pool = {'id': '4fdbfd74-eaf8-4884-90d9-00bd6f10c2d3', 'name': 'ext_net', 'router:external': True, 'tenant_id': 'admin_tenantid'} self.fip_pool_nova = {'id': '435e20c3-d9f1-4f1b-bee5-4611a1dd07db', 'name': 'nova', 'router:external': True, 'tenant_id': 'admin_tenantid'} self.fip_unassociated = {'tenant_id': 'my_tenantid', 'id': 'fip_id1', 'floating_ip_address': '172.24.4.227', 'floating_network_id': self.fip_pool['id'], 'port_id': None, 'fixed_ip_address': None, 'router_id': None} fixed_ip_address = self.port_data2[1]['fixed_ips'][0]['ip_address'] self.fip_associated = {'tenant_id': 'my_tenantid', 'id': 'fip_id2', 'floating_ip_address': '172.24.4.228', 'floating_network_id': self.fip_pool['id'], 'port_id': self.port_data2[1]['id'], 'fixed_ip_address': fixed_ip_address, 'router_id': 'router_id1'} self._returned_nw_info = [] self.mox.StubOutWithMock(neutronv2, 'get_client') self.moxed_client = self.mox.CreateMock(client.Client) self.addCleanup(CONF.reset) self.addCleanup(self.mox.VerifyAll) self.addCleanup(self.mox.UnsetStubs) self.addCleanup(self.stubs.UnsetAll) def _stub_allocate_for_instance(self, net_idx=1, **kwargs): api = neutronapi.API() self.mox.StubOutWithMock(api, '_get_instance_nw_info') has_portbinding = False if kwargs.get('portbinding'): has_portbinding = True api.extensions[constants.PORTBINDING_EXT] = 1 self.mox.StubOutWithMock(api, '_refresh_neutron_extensions_cache') neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn( self.moxed_client) neutronv2.get_client( mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn( self.moxed_client) api._refresh_neutron_extensions_cache() else: self.mox.StubOutWithMock(api, '_populate_neutron_extension_values') self.mox.StubOutWithMock(api, '_has_port_binding_extension') # Net idx is 1-based for compatibility with existing unit tests nets = self.nets[net_idx - 1] ports = {} fixed_ips = {} macs = kwargs.get('macs') if macs: macs = set(macs) req_net_ids = [] if 'requested_networks' in kwargs: for id, fixed_ip, port_id in kwargs['requested_networks']: if port_id: self.moxed_client.show_port(port_id).AndReturn( {'port': {'id': 'my_portid1', 'network_id': 'my_netid1', 'mac_address': 'my_mac1'}}) ports['my_netid1'] = self.port_data1[0] id = 'my_netid1' if macs is not None: macs.discard('my_mac1') else: fixed_ips[id] = fixed_ip req_net_ids.append(id) expected_network_order = req_net_ids else: expected_network_order = [n['id'] for n in nets] if kwargs.get('_break') == 'pre_list_networks': self.mox.ReplayAll() return api search_ids = [net['id'] for net in nets if net['id'] in req_net_ids] mox_list_network_params = dict(tenant_id=self.instance['project_id'], shared=False) if search_ids: mox_list_network_params['id'] = mox.SameElementsAs(search_ids) self.moxed_client.list_networks( **mox_list_network_params).AndReturn({'networks': nets}) mox_list_network_params = dict(shared=True) if search_ids: mox_list_network_params['id'] = mox.SameElementsAs(search_ids) self.moxed_client.list_networks( **mox_list_network_params).AndReturn({'networks': []}) for net_id in expected_network_order: port_req_body = { 'port': { 'device_id': self.instance['uuid'], 'device_owner': 'compute:nova', }, } if has_portbinding: port_req_body['port']['binding:host_id'] = ( self.instance.get('host')) port = ports.get(net_id, None) if not has_portbinding: api._populate_neutron_extension_values( self.instance, mox.IgnoreArg()).AndReturn(None) else: # since _populate_neutron_extension_values() will call # _has_port_binding_extension() api._has_port_binding_extension().AndReturn(has_portbinding) api._has_port_binding_extension().AndReturn(has_portbinding) if port: port_id = port['id'] self.moxed_client.update_port(port_id, MyComparator(port_req_body) ).AndReturn( {'port': port}) else: fixed_ip = fixed_ips.get(net_id) if fixed_ip: port_req_body['port']['fixed_ips'] = [{'ip_address': fixed_ip}] port_req_body['port']['network_id'] = net_id port_req_body['port']['admin_state_up'] = True port_req_body['port']['tenant_id'] = \ self.instance['project_id'] if macs: port_req_body['port']['mac_address'] = macs.pop() if has_portbinding: port_req_body['port']['binding:host_id'] = ( self.instance.get('host')) res_port = {'port': {'id': 'fake'}} if kwargs.get('_break') == 'mac' + net_id: self.mox.ReplayAll() return api self.moxed_client.create_port( MyComparator(port_req_body)).AndReturn(res_port) api._get_instance_nw_info(mox.IgnoreArg(), self.instance, networks=nets).AndReturn( self._returned_nw_info) self.mox.ReplayAll() return api def _verify_nw_info(self, nw_inf, index=0): id_suffix = index + 1 self.assertEquals('10.0.%s.2' % id_suffix, nw_inf.fixed_ips()[index]['address']) self.assertEquals('172.0.%s.2' % id_suffix, nw_inf.fixed_ips()[index].floating_ip_addresses()[0]) self.assertEquals('my_netname%s' % id_suffix, nw_inf[index]['network']['label']) self.assertEquals('my_portid%s' % id_suffix, nw_inf[index]['id']) self.assertEquals('my_mac%s' % id_suffix, nw_inf[index]['address']) self.assertEquals('10.0.%s.0/24' % id_suffix, nw_inf[index]['network']['subnets'][0]['cidr']) self.assertTrue(model.IP(address='8.8.%s.1' % id_suffix) in nw_inf[index]['network']['subnets'][0]['dns']) def _get_instance_nw_info(self, number): api = neutronapi.API() self.mox.StubOutWithMock(api.db, 'instance_info_cache_update') api.db.instance_info_cache_update(mox.IgnoreArg(), self.instance['uuid'], mox.IgnoreArg()) port_data = number == 1 and self.port_data1 or self.port_data2 self.mox.StubOutWithMock(conductor_api.API, 'instance_get_by_uuid') net_info_cache = [] for port in port_data: net_info_cache.append({"network": {"id": port['network_id']}}) info_cache = {'info_cache': {'network_info': jsonutils.dumps(net_info_cache)}} api.conductor_api.instance_get_by_uuid( mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(info_cache) self.moxed_client.list_ports( tenant_id=self.instance['project_id'], device_id=self.instance['uuid']).AndReturn( {'ports': port_data}) nets = number == 1 and self.nets1 or self.nets2 self.moxed_client.list_networks( tenant_id=self.instance['project_id'], shared=False).AndReturn({'networks': nets}) self.moxed_client.list_networks( shared=True).AndReturn({'networks': []}) for i in xrange(1, number + 1): float_data = number == 1 and self.float_data1 or self.float_data2 for ip in port_data[i - 1]['fixed_ips']: float_data = [x for x in float_data if x['fixed_ip_address'] == ip['ip_address']] self.moxed_client.list_floatingips( fixed_ip_address=ip['ip_address'], port_id=port_data[i - 1]['id']).AndReturn( {'floatingips': float_data}) subnet_data = i == 1 and self.subnet_data1 or self.subnet_data2 self.moxed_client.list_subnets( id=mox.SameElementsAs(['my_subid%s' % i])).AndReturn( {'subnets': subnet_data}) self.moxed_client.list_ports( network_id=subnet_data[0]['network_id'], device_owner='network:dhcp').AndReturn( {'ports': []}) self.mox.ReplayAll() nw_inf = api.get_instance_nw_info(self.context, self.instance) for i in xrange(0, number): self._verify_nw_info(nw_inf, i) def _allocate_for_instance(self, net_idx=1, **kwargs): api = self._stub_allocate_for_instance(net_idx, **kwargs) return api.allocate_for_instance(self.context, self.instance, **kwargs) class TestNeutronv2(TestNeutronv2Base): def setUp(self): super(TestNeutronv2, self).setUp() neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn( self.moxed_client) def test_get_instance_nw_info_1(self): # Test to get one port in one network and subnet. neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn( self.moxed_client) self._get_instance_nw_info(1) def test_get_instance_nw_info_2(self): # Test to get one port in each of two networks and subnets. neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn( self.moxed_client) self._get_instance_nw_info(2) def test_get_instance_nw_info_with_nets(self): # Test get instance_nw_info with networks passed in. api = neutronapi.API() self.mox.StubOutWithMock(api.db, 'instance_info_cache_update') api.db.instance_info_cache_update( mox.IgnoreArg(), self.instance['uuid'], mox.IgnoreArg()) self.moxed_client.list_ports( tenant_id=self.instance['project_id'], device_id=self.instance['uuid']).AndReturn( {'ports': self.port_data1}) port_data = self.port_data1 for ip in port_data[0]['fixed_ips']: self.moxed_client.list_floatingips( fixed_ip_address=ip['ip_address'], port_id=port_data[0]['id']).AndReturn( {'floatingips': self.float_data1}) self.moxed_client.list_subnets( id=mox.SameElementsAs(['my_subid1'])).AndReturn( {'subnets': self.subnet_data1}) self.moxed_client.list_ports( network_id='my_netid1', device_owner='network:dhcp').AndReturn( {'ports': self.dhcp_port_data1}) neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn( self.moxed_client) self.mox.ReplayAll() nw_inf = api.get_instance_nw_info(self.context, self.instance, networks=self.nets1) self._verify_nw_info(nw_inf, 0) def test_get_instance_nw_info_without_subnet(self): # Test get instance_nw_info for a port without subnet. api = neutronapi.API() self.mox.StubOutWithMock(api.db, 'instance_info_cache_update') api.db.instance_info_cache_update( mox.IgnoreArg(), self.instance['uuid'], mox.IgnoreArg()) self.moxed_client.list_ports( tenant_id=self.instance['project_id'], device_id=self.instance['uuid']).AndReturn( {'ports': self.port_data3}) self.moxed_client.list_networks( shared=False, tenant_id=self.instance['project_id']).AndReturn( {'networks': self.nets1}) self.moxed_client.list_networks( shared=True).AndReturn({'networks': []}) neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes().AndReturn( self.moxed_client) self.mox.StubOutWithMock(conductor_api.API, 'instance_get_by_uuid') net_info_cache = [] for port in self.port_data3: net_info_cache.append({"network": {"id": port['network_id']}}) info_cache = {'info_cache': {'network_info': jsonutils.dumps(net_info_cache)}} api.conductor_api.instance_get_by_uuid( mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(info_cache) self.mox.ReplayAll() nw_inf = api.get_instance_nw_info(self.context, self.instance) id_suffix = 3 self.assertEquals(0, len(nw_inf.fixed_ips())) self.assertEquals('my_netname1', nw_inf[0]['network']['label']) self.assertEquals('my_portid%s' % id_suffix, nw_inf[0]['id']) self.assertEquals('my_mac%s' % id_suffix, nw_inf[0]['address']) self.assertEquals(0, len(nw_inf[0]['network']['subnets'])) def test_refresh_neutron_extensions_cache(self): api = neutronapi.API() self.moxed_client.list_extensions().AndReturn( {'extensions': [{'name': 'nvp-qos'}]}) self.mox.ReplayAll() api._refresh_neutron_extensions_cache() self.assertEquals({'nvp-qos': {'name': 'nvp-qos'}}, api.extensions) def test_populate_neutron_extension_values_rxtx_factor(self): api = neutronapi.API() self.moxed_client.list_extensions().AndReturn( {'extensions': [{'name': 'nvp-qos'}]}) self.mox.ReplayAll() instance_type = flavors.get_default_flavor() instance_type['rxtx_factor'] = 1 sys_meta = utils.dict_to_metadata( flavors.save_flavor_info({}, instance_type)) instance = {'system_metadata': sys_meta} port_req_body = {'port': {}} api._populate_neutron_extension_values(instance, port_req_body) self.assertEquals(port_req_body['port']['rxtx_factor'], 1) def test_allocate_for_instance_1(self): # Allocate one port in one network env. self._allocate_for_instance(1) def test_allocate_for_instance_2(self): # Allocate one port in two networks env. self._allocate_for_instance(2) def test_allocate_for_instance_accepts_macs_kwargs_None(self): # The macs kwarg should be accepted as None. self._allocate_for_instance(1, macs=None) def test_allocate_for_instance_accepts_macs_kwargs_set(self): # The macs kwarg should be accepted, as a set, the # _allocate_for_instance helper checks that the mac is used to create a # port. self._allocate_for_instance(1, macs=set(['ab:cd:ef:01:23:45'])) def test_allocate_for_instance_accepts_only_portid(self): # Make sure allocate_for_instance works when only a portid is provided self._returned_nw_info = self.port_data1 result = self._allocate_for_instance( requested_networks=[(None, None, 'my_portid1')]) self.assertEqual(self.port_data1, result) def test_allocate_for_instance_not_enough_macs_via_ports(self): # using a hypervisor MAC via a pre-created port will stop it being # used to dynamically create a port on a network. We put the network # first in requested_networks so that if the code were to not pre-check # requested ports, it would incorrectly assign the mac and not fail. requested_networks = [ (self.nets2[1]['id'], None, None), (None, None, 'my_portid1')] api = self._stub_allocate_for_instance( net_idx=2, requested_networks=requested_networks, macs=set(['my_mac1']), _break='mac' + self.nets2[1]['id']) self.assertRaises(exception.PortNotFree, api.allocate_for_instance, self.context, self.instance, requested_networks=requested_networks, macs=set(['my_mac1'])) def test_allocate_for_instance_not_enough_macs(self): # If not enough MAC addresses are available to allocate to networks, an # error should be raised. # We could pass in macs=set(), but that wouldn't tell us that # allocate_for_instance tracks used macs properly, so we pass in one # mac, and ask for two networks. requested_networks = [ (self.nets2[1]['id'], None, None), (self.nets2[0]['id'], None, None)] api = self._stub_allocate_for_instance( net_idx=2, requested_networks=requested_networks, macs=set(['my_mac2']), _break='mac' + self.nets2[0]['id']) self.assertRaises(exception.PortNotFree, api.allocate_for_instance, self.context, self.instance, requested_networks=requested_networks, macs=set(['my_mac2'])) def test_allocate_for_instance_two_macs_two_networks(self): # If two MACs are available and two networks requested, two new ports # get made and no exceptions raised. requested_networks = [ (self.nets2[1]['id'], None, None), (self.nets2[0]['id'], None, None)] self._allocate_for_instance( net_idx=2, requested_networks=requested_networks, macs=set(['my_mac2', 'my_mac1'])) def test_allocate_for_instance_mac_conflicting_requested_port(self): # specify only first and last network requested_networks = [(None, None, 'my_portid1')] api = self._stub_allocate_for_instance( net_idx=1, requested_networks=requested_networks, macs=set(['unknown:mac']), _break='pre_list_networks') self.assertRaises(exception.PortNotUsable, api.allocate_for_instance, self.context, self.instance, requested_networks=requested_networks, macs=set(['unknown:mac'])) def test_allocate_for_instance_with_requested_networks(self): # specify only first and last network requested_networks = [ (net['id'], None, None) for net in (self.nets3[1], self.nets3[0], self.nets3[2])] self._allocate_for_instance(net_idx=3, requested_networks=requested_networks) def test_allocate_for_instance_with_requested_networks_with_fixedip(self): # specify only first and last network requested_networks = [(self.nets1[0]['id'], '10.0.1.0/24', None)] self._allocate_for_instance(net_idx=1, requested_networks=requested_networks) def test_allocate_for_instance_with_requested_networks_with_port(self): requested_networks = [(None, None, 'myportid1')] self._allocate_for_instance(net_idx=1, requested_networks=requested_networks) def test_allocate_for_instance_no_networks(self): """verify the exception thrown when there are no networks defined.""" api = neutronapi.API() self.moxed_client.list_networks( tenant_id=self.instance['project_id'], shared=False).AndReturn( {'networks': []}) self.moxed_client.list_networks(shared=True).AndReturn( {'networks': []}) self.mox.ReplayAll() nwinfo = api.allocate_for_instance(self.context, self.instance) self.assertEqual(len(nwinfo), 0) def test_allocate_for_instance_ex1(self): """verify we will delete created ports if we fail to allocate all net resources. Mox to raise exception when creating a second port. In this case, the code should delete the first created port. """ api = neutronapi.API() self.mox.StubOutWithMock(api, '_populate_neutron_extension_values') self.mox.StubOutWithMock(api, '_has_port_binding_extension') api._has_port_binding_extension().MultipleTimes().AndReturn(False) self.moxed_client.list_networks( tenant_id=self.instance['project_id'], shared=False).AndReturn( {'networks': self.nets2}) self.moxed_client.list_networks(shared=True).AndReturn( {'networks': []}) index = 0 for network in self.nets2: binding_port_req_body = { 'port': { 'device_id': self.instance['uuid'], 'device_owner': 'compute:nova', }, } port_req_body = { 'port': { 'network_id': network['id'], 'admin_state_up': True, 'tenant_id': self.instance['project_id'], }, } port_req_body['port'].update(binding_port_req_body['port']) port = {'id': 'portid_' + network['id']} api._populate_neutron_extension_values( self.instance, binding_port_req_body).AndReturn(None) if index == 0: self.moxed_client.create_port( MyComparator(port_req_body)).AndReturn({'port': port}) else: self.moxed_client.create_port( MyComparator(port_req_body)).AndRaise( Exception("fail to create port")) index += 1 self.moxed_client.delete_port('portid_' + self.nets2[0]['id']) self.mox.ReplayAll() self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.allocate_for_instance, self.context, self.instance) def test_allocate_for_instance_ex2(self): """verify we have no port to delete if we fail to allocate the first net resource. Mox to raise exception when creating the first port. In this case, the code should not delete any ports. """ api = neutronapi.API() self.moxed_client.list_networks( tenant_id=self.instance['project_id'], shared=False).AndReturn( {'networks': self.nets2}) self.moxed_client.list_networks(shared=True).AndReturn( {'networks': []}) port_req_body = { 'port': { 'network_id': self.nets2[0]['id'], 'admin_state_up': True, 'device_id': self.instance['uuid'], 'tenant_id': self.instance['project_id'], }, } self.moxed_client.create_port( MyComparator(port_req_body)).AndRaise( Exception("fail to create port")) self.mox.ReplayAll() self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.allocate_for_instance, self.context, self.instance) def test_allocate_for_instance_no_port_or_network(self): class BailOutEarly(Exception): pass api = neutronapi.API() self.mox.StubOutWithMock(api, '_get_available_networks') # Make sure we get an empty list and then bail out of the rest # of the function api._get_available_networks(self.context, self.instance['project_id'], []).AndRaise(BailOutEarly) self.mox.ReplayAll() self.assertRaises(BailOutEarly, api.allocate_for_instance, self.context, self.instance, requested_networks=[(None, None, None)]) def test_allocate_for_instance_second_time(self): # Make sure that allocate_for_instance only returns ports that it # allocated during _that_ run. new_port = {'id': 'fake'} self._returned_nw_info = self.port_data1 + [new_port] nw_info = self._allocate_for_instance() self.assertEqual(nw_info, [new_port]) def _deallocate_for_instance(self, number): port_data = number == 1 and self.port_data1 or self.port_data2 self.moxed_client.list_ports( device_id=self.instance['uuid']).AndReturn( {'ports': port_data}) for port in port_data: self.moxed_client.delete_port(port['id']) self.mox.ReplayAll() api = neutronapi.API() api.deallocate_for_instance(self.context, self.instance) def test_deallocate_for_instance_1(self): # Test to deallocate in one port env. self._deallocate_for_instance(1) def test_deallocate_for_instance_2(self): # Test to deallocate in two ports env. self._deallocate_for_instance(2) def _test_deallocate_port_for_instance(self, number): port_data = number == 1 and self.port_data1 or self.port_data2 self.moxed_client.delete_port(port_data[0]['id']) self.mox.StubOutWithMock(conductor_api.API, 'instance_get_by_uuid') net_info_cache = [] for port in port_data: net_info_cache.append({"network": {"id": port['network_id']}}) info_cache = {'info_cache': {'network_info': jsonutils.dumps(net_info_cache)}} api = neutronapi.API() api.conductor_api.instance_get_by_uuid( mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(info_cache) neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn( self.moxed_client) self.moxed_client.list_ports( tenant_id=self.instance['project_id'], device_id=self.instance['uuid']).AndReturn( {'ports': port_data[1:]}) neutronv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn( self.moxed_client) self.moxed_client.list_networks( tenant_id=self.instance['project_id'], shared=False).AndReturn( {'networks': [self.nets2[1]]}) self.moxed_client.list_networks(shared=True).AndReturn( {'networks': []}) float_data = number == 1 and self.float_data1 or self.float_data2 for data in port_data[1:]: for ip in data['fixed_ips']: self.moxed_client.list_floatingips( fixed_ip_address=ip['ip_address'], port_id=data['id']).AndReturn( {'floatingips': float_data[1:]}) for port in port_data[1:]: self.moxed_client.list_subnets(id=['my_subid2']).AndReturn({}) self.mox.ReplayAll() nwinfo = api.deallocate_port_for_instance(self.context, self.instance, port_data[0]['id']) self.assertEqual(len(nwinfo), len(port_data[1:])) if len(port_data) > 1: self.assertEqual(nwinfo[0]['network']['id'], 'my_netid2') def test_deallocate_port_for_instance_1(self): # Test to deallocate the first and only port self._test_deallocate_port_for_instance(1) def test_deallocate_port_for_instance_2(self): # Test to deallocate the first port of two self._test_deallocate_port_for_instance(2) def test_list_ports(self): search_opts = {'parm': 'value'} self.moxed_client.list_ports(**search_opts) self.mox.ReplayAll() neutronapi.API().list_ports(self.context, **search_opts) def test_show_port(self): self.moxed_client.show_port('foo') self.mox.ReplayAll() neutronapi.API().show_port(self.context, 'foo') def test_validate_networks(self): requested_networks = [('my_netid1', 'test', None), ('my_netid2', 'test2', None)] self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2']), tenant_id=self.context.project_id, shared=False).AndReturn( {'networks': self.nets2}) self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2']), shared=True).AndReturn( {'networks': []}) self.mox.ReplayAll() api = neutronapi.API() api.validate_networks(self.context, requested_networks) def test_validate_networks_ex_1(self): requested_networks = [('my_netid1', 'test', None), ('my_netid2', 'test2', None)] self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2']), tenant_id=self.context.project_id, shared=False).AndReturn( {'networks': self.nets1}) self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2']), shared=True).AndReturn( {'networks': []}) self.mox.ReplayAll() api = neutronapi.API() try: api.validate_networks(self.context, requested_networks) except exception.NetworkNotFound as ex: self.assertTrue("my_netid2" in str(ex)) def test_validate_networks_ex_2(self): requested_networks = [('my_netid1', 'test', None), ('my_netid2', 'test2', None), ('my_netid3', 'test3', None)] self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2', 'my_netid3']), tenant_id=self.context.project_id, shared=False).AndReturn( {'networks': self.nets1}) self.moxed_client.list_networks( id=mox.SameElementsAs(['my_netid1', 'my_netid2', 'my_netid3']), shared=True).AndReturn( {'networks': []}) self.mox.ReplayAll() api = neutronapi.API() try: api.validate_networks(self.context, requested_networks) except exception.NetworkNotFound as ex: self.assertTrue("my_netid2, my_netid3" in str(ex)) def test_validate_networks_duplicate(self): """Verify that the correct exception is thrown when duplicate network ids are passed to validate_networks. """ requested_networks = [('my_netid1', None, None), ('my_netid1', None, None)] self.mox.ReplayAll() # Expected call from setUp. neutronv2.get_client(None) api = neutronapi.API() self.assertRaises(exception.NetworkDuplicated, api.validate_networks, self.context, requested_networks) def test_validate_networks_not_specified(self): requested_networks = [] self.moxed_client.list_networks( tenant_id=self.context.project_id, shared=False).AndReturn( {'networks': self.nets1}) self.moxed_client.list_networks( shared=True).AndReturn( {'networks': self.nets2}) self.mox.ReplayAll() api = neutronapi.API() self.assertRaises(exception.NetworkAmbiguous, api.validate_networks, self.context, requested_networks) def _mock_list_ports(self, port_data=None): if port_data is None: port_data = self.port_data2 address = self.port_address self.moxed_client.list_ports( fixed_ips=MyComparator('ip_address=%s' % address)).AndReturn( {'ports': port_data}) self.mox.ReplayAll() return address def test_get_instance_uuids_by_ip_filter(self): self._mock_list_ports() filters = {'ip': '^10\\.0\\.1\\.2$'} api = neutronapi.API() result = api.get_instance_uuids_by_ip_filter(self.context, filters) self.assertEquals(self.instance2['uuid'], result[0]['instance_uuid']) self.assertEquals(self.instance['uuid'], result[1]['instance_uuid']) def test_get_fixed_ip_by_address_fails_for_no_ports(self): address = self._mock_list_ports(port_data=[]) api = neutronapi.API() self.assertRaises(exception.FixedIpNotFoundForAddress, api.get_fixed_ip_by_address, self.context, address) def test_get_fixed_ip_by_address_succeeds_for_1_port(self): address = self._mock_list_ports(port_data=self.port_data1) api = neutronapi.API() result = api.get_fixed_ip_by_address(self.context, address) self.assertEquals(self.instance2['uuid'], result['instance_uuid']) def test_get_fixed_ip_by_address_fails_for_more_than_1_port(self): address = self._mock_list_ports() api = neutronapi.API() self.assertRaises(exception.FixedIpAssociatedWithMultipleInstances, api.get_fixed_ip_by_address, self.context, address) def _get_available_networks(self, prv_nets, pub_nets, req_ids=None): api = neutronapi.API() nets = prv_nets + pub_nets mox_list_network_params = dict(tenant_id=self.instance['project_id'], shared=False) if req_ids: mox_list_network_params['id'] = req_ids self.moxed_client.list_networks( **mox_list_network_params).AndReturn({'networks': prv_nets}) mox_list_network_params = dict(shared=True) if req_ids: mox_list_network_params['id'] = req_ids self.moxed_client.list_networks( **mox_list_network_params).AndReturn({'networks': pub_nets}) self.mox.ReplayAll() rets = api._get_available_networks(self.context, self.instance['project_id'], req_ids) self.assertEqual(rets, nets) def test_get_available_networks_all_private(self): self._get_available_networks(prv_nets=self.nets2, pub_nets=[]) def test_get_available_networks_all_public(self): self._get_available_networks(prv_nets=[], pub_nets=self.nets2) def test_get_available_networks_private_and_public(self): self._get_available_networks(prv_nets=self.nets1, pub_nets=self.nets4) def test_get_available_networks_with_network_ids(self): prv_nets = [self.nets3[0]] pub_nets = [self.nets3[-1]] # specify only first and last network req_ids = [net['id'] for net in (self.nets3[0], self.nets3[-1])] self._get_available_networks(prv_nets, pub_nets, req_ids) def test_get_floating_ip_pools(self): api = neutronapi.API() search_opts = {'router:external': True} self.moxed_client.list_networks(**search_opts).\ AndReturn({'networks': [self.fip_pool, self.fip_pool_nova]}) self.mox.ReplayAll() pools = api.get_floating_ip_pools(self.context) expected = [{'name': self.fip_pool['name']}, {'name': self.fip_pool_nova['name']}] self.assertEqual(expected, pools) def _get_expected_fip_model(self, fip_data, idx=0): expected = {'id': fip_data['id'], 'address': fip_data['floating_ip_address'], 'pool': self.fip_pool['name'], 'project_id': fip_data['tenant_id'], 'fixed_ip_id': fip_data['port_id'], 'fixed_ip': {'address': fip_data['fixed_ip_address']}, 'instance': ({'uuid': self.port_data2[idx]['device_id']} if fip_data['port_id'] else None)} return expected def _test_get_floating_ip(self, fip_data, idx=0, by_address=False): api = neutronapi.API() fip_id = fip_data['id'] net_id = fip_data['floating_network_id'] address = fip_data['floating_ip_address'] if by_address: self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [fip_data]}) else: self.moxed_client.show_floatingip(fip_id).\ AndReturn({'floatingip': fip_data}) self.moxed_client.show_network(net_id).\ AndReturn({'network': self.fip_pool}) if fip_data['port_id']: self.moxed_client.show_port(fip_data['port_id']).\ AndReturn({'port': self.port_data2[idx]}) self.mox.ReplayAll() expected = self._get_expected_fip_model(fip_data, idx) if by_address: fip = api.get_floating_ip_by_address(self.context, address) else: fip = api.get_floating_ip(self.context, fip_id) self.assertEqual(expected, fip) def test_get_floating_ip_unassociated(self): self._test_get_floating_ip(self.fip_unassociated, idx=0) def test_get_floating_ip_associated(self): self._test_get_floating_ip(self.fip_associated, idx=1) def test_get_floating_ip_by_address(self): self._test_get_floating_ip(self.fip_unassociated, idx=0, by_address=True) def test_get_floating_ip_by_address_associated(self): self._test_get_floating_ip(self.fip_associated, idx=1, by_address=True) def test_get_floating_ip_by_address_not_found(self): api = neutronapi.API() address = self.fip_unassociated['floating_ip_address'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': []}) self.mox.ReplayAll() self.assertRaises(exception.FloatingIpNotFoundForAddress, api.get_floating_ip_by_address, self.context, address) def test_get_floating_ip_by_address_multiple_found(self): api = neutronapi.API() address = self.fip_unassociated['floating_ip_address'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_unassociated] * 2}) self.mox.ReplayAll() self.assertRaises(exception.FloatingIpMultipleFoundForAddress, api.get_floating_ip_by_address, self.context, address) def test_get_floating_ips_by_project(self): api = neutronapi.API() project_id = self.context.project_id self.moxed_client.list_floatingips(tenant_id=project_id).\ AndReturn({'floatingips': [self.fip_unassociated, self.fip_associated]}) search_opts = {'router:external': True} self.moxed_client.list_networks(**search_opts).\ AndReturn({'networks': [self.fip_pool, self.fip_pool_nova]}) self.moxed_client.list_ports(tenant_id=project_id).\ AndReturn({'ports': self.port_data2}) self.mox.ReplayAll() expected = [self._get_expected_fip_model(self.fip_unassociated), self._get_expected_fip_model(self.fip_associated, idx=1)] fips = api.get_floating_ips_by_project(self.context) self.assertEqual(expected, fips) def _test_get_instance_id_by_floating_address(self, fip_data, associated=False): api = neutronapi.API() address = fip_data['floating_ip_address'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [fip_data]}) if associated: self.moxed_client.show_port(fip_data['port_id']).\ AndReturn({'port': self.port_data2[1]}) self.mox.ReplayAll() if associated: expected = self.port_data2[1]['device_id'] else: expected = None fip = api.get_instance_id_by_floating_address(self.context, address) self.assertEqual(expected, fip) def test_get_instance_id_by_floating_address(self): self._test_get_instance_id_by_floating_address(self.fip_unassociated) def test_get_instance_id_by_floating_address_associated(self): self._test_get_instance_id_by_floating_address(self.fip_associated, associated=True) def test_allocate_floating_ip(self): api = neutronapi.API() pool_name = self.fip_pool['name'] pool_id = self.fip_pool['id'] search_opts = {'router:external': True, 'fields': 'id', 'name': pool_name} self.moxed_client.list_networks(**search_opts).\ AndReturn({'networks': [self.fip_pool]}) self.moxed_client.create_floatingip( {'floatingip': {'floating_network_id': pool_id}}).\ AndReturn({'floatingip': self.fip_unassociated}) self.mox.ReplayAll() fip = api.allocate_floating_ip(self.context, 'ext_net') self.assertEqual(fip, self.fip_unassociated['floating_ip_address']) def test_allocate_floating_ip_with_pool_id(self): api = neutronapi.API() pool_id = self.fip_pool['id'] search_opts = {'router:external': True, 'fields': 'id', 'id': pool_id} self.moxed_client.list_networks(**search_opts).\ AndReturn({'networks': [self.fip_pool]}) self.moxed_client.create_floatingip( {'floatingip': {'floating_network_id': pool_id}}).\ AndReturn({'floatingip': self.fip_unassociated}) self.mox.ReplayAll() fip = api.allocate_floating_ip(self.context, pool_id) self.assertEqual(fip, self.fip_unassociated['floating_ip_address']) def test_allocate_floating_ip_with_default_pool(self): api = neutronapi.API() pool_name = self.fip_pool_nova['name'] pool_id = self.fip_pool_nova['id'] search_opts = {'router:external': True, 'fields': 'id', 'name': pool_name} self.moxed_client.list_networks(**search_opts).\ AndReturn({'networks': [self.fip_pool_nova]}) self.moxed_client.create_floatingip( {'floatingip': {'floating_network_id': pool_id}}).\ AndReturn({'floatingip': self.fip_unassociated}) self.mox.ReplayAll() fip = api.allocate_floating_ip(self.context) self.assertEqual(fip, self.fip_unassociated['floating_ip_address']) def test_release_floating_ip(self): api = neutronapi.API() address = self.fip_unassociated['floating_ip_address'] fip_id = self.fip_unassociated['id'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_unassociated]}) self.moxed_client.delete_floatingip(fip_id) self.mox.ReplayAll() api.release_floating_ip(self.context, address) def test_release_floating_ip_associated(self): api = neutronapi.API() address = self.fip_associated['floating_ip_address'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_associated]}) self.mox.ReplayAll() self.assertRaises(exception.FloatingIpAssociated, api.release_floating_ip, self.context, address) def _setup_mock_for_refresh_cache(self, api, instances): nw_info = self.mox.CreateMock(model.NetworkInfo) self.mox.StubOutWithMock(api, '_get_instance_nw_info') self.mox.StubOutWithMock(api.db, 'instance_info_cache_update') for instance in instances: nw_info.json() api._get_instance_nw_info(mox.IgnoreArg(), instance).\ AndReturn(nw_info) api.db.instance_info_cache_update(mox.IgnoreArg(), instance['uuid'], mox.IgnoreArg()) def test_associate_floating_ip(self): api = neutronapi.API() address = self.fip_unassociated['floating_ip_address'] fixed_address = self.port_address2 fip_id = self.fip_unassociated['id'] search_opts = {'device_owner': 'compute:nova', 'device_id': self.instance['uuid']} self.moxed_client.list_ports(**search_opts).\ AndReturn({'ports': [self.port_data2[1]]}) self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_unassociated]}) self.moxed_client.update_floatingip( fip_id, {'floatingip': {'port_id': self.fip_associated['port_id'], 'fixed_ip_address': fixed_address}}) self._setup_mock_for_refresh_cache(api, [self.instance]) self.mox.ReplayAll() api.associate_floating_ip(self.context, self.instance, address, fixed_address) def test_reassociate_floating_ip(self): api = neutronapi.API() address = self.fip_associated['floating_ip_address'] old_fixed_address = self.fip_associated['fixed_ip_address'] new_fixed_address = self.port_address fip_id = self.fip_associated['id'] search_opts = {'device_owner': 'compute:nova', 'device_id': self.instance2['uuid']} self.moxed_client.list_ports(**search_opts).\ AndReturn({'ports': [self.port_data2[0]]}) self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_associated]}) self.moxed_client.update_floatingip( fip_id, {'floatingip': {'port_id': 'my_portid1', 'fixed_ip_address': new_fixed_address}}) self.moxed_client.show_port(self.fip_associated['port_id']).\ AndReturn({'port': self.port_data2[1]}) self.mox.StubOutWithMock(api.db, 'instance_get_by_uuid') api.db.instance_get_by_uuid(mox.IgnoreArg(), self.instance['uuid']).\ AndReturn(self.instance) self._setup_mock_for_refresh_cache(api, [self.instance, self.instance2]) self.mox.ReplayAll() api.associate_floating_ip(self.context, self.instance2, address, new_fixed_address) def test_associate_floating_ip_not_found_fixed_ip(self): api = neutronapi.API() address = self.fip_associated['floating_ip_address'] fixed_address = self.fip_associated['fixed_ip_address'] search_opts = {'device_owner': 'compute:nova', 'device_id': self.instance['uuid']} self.moxed_client.list_ports(**search_opts).\ AndReturn({'ports': [self.port_data2[0]]}) self.mox.ReplayAll() self.assertRaises(exception.FixedIpNotFoundForAddress, api.associate_floating_ip, self.context, self.instance, address, fixed_address) def test_disassociate_floating_ip(self): api = neutronapi.API() address = self.fip_associated['floating_ip_address'] fip_id = self.fip_associated['id'] self.moxed_client.list_floatingips(floating_ip_address=address).\ AndReturn({'floatingips': [self.fip_associated]}) self.moxed_client.update_floatingip( fip_id, {'floatingip': {'port_id': None}}) self._setup_mock_for_refresh_cache(api, [self.instance]) self.mox.ReplayAll() api.disassociate_floating_ip(self.context, self.instance, address) def test_add_fixed_ip_to_instance(self): api = neutronapi.API() self._setup_mock_for_refresh_cache(api, [self.instance]) network_id = 'my_netid1' search_opts = {'network_id': network_id} self.moxed_client.list_subnets( **search_opts).AndReturn({'subnets': self.subnet_data_n}) search_opts = {'device_id': self.instance['uuid'], 'device_owner': 'compute:nova', 'network_id': network_id} self.moxed_client.list_ports( **search_opts).AndReturn({'ports': self.port_data1}) port_req_body = { 'port': { 'fixed_ips': [{'subnet_id': 'my_subid1'}, {'subnet_id': 'my_subid1'}], }, } port = self.port_data1[0] port['fixed_ips'] = [{'subnet_id': 'my_subid1'}] self.moxed_client.update_port('my_portid1', MyComparator(port_req_body)).AndReturn({'port': port}) self.mox.ReplayAll() api.add_fixed_ip_to_instance(self.context, self.instance, network_id) def test_remove_fixed_ip_from_instance(self): api = neutronapi.API() self._setup_mock_for_refresh_cache(api, [self.instance]) address = '10.0.0.3' zone = 'compute:%s' % self.instance['availability_zone'] search_opts = {'device_id': self.instance['uuid'], 'device_owner': zone, 'fixed_ips': 'ip_address=%s' % address} self.moxed_client.list_ports( **search_opts).AndReturn({'ports': self.port_data1}) port_req_body = { 'port': { 'fixed_ips': [], }, } port = self.port_data1[0] port['fixed_ips'] = [] self.moxed_client.update_port('my_portid1', MyComparator(port_req_body)).AndReturn({'port': port}) self.mox.ReplayAll() api.remove_fixed_ip_from_instance(self.context, self.instance, address) def test_list_floating_ips_without_l3_support(self): api = neutronapi.API() NeutronNotFound = exceptions.NeutronClientException( status_code=404) self.moxed_client.list_floatingips( fixed_ip_address='1.1.1.1', port_id=1).AndRaise(NeutronNotFound) self.mox.ReplayAll() neutronv2.get_client('fake') floatingips = api._get_floating_ips_by_fixed_and_port( self.moxed_client, '1.1.1.1', 1) self.assertEqual(floatingips, []) def test_nw_info_get_ips(self): fake_port = { 'fixed_ips': [ {'ip_address': '1.1.1.1'}], 'id': 'port-id', } api = neutronapi.API() self.mox.StubOutWithMock(api, '_get_floating_ips_by_fixed_and_port') api._get_floating_ips_by_fixed_and_port( self.moxed_client, '1.1.1.1', 'port-id').AndReturn( [{'floating_ip_address': '10.0.0.1'}]) self.mox.ReplayAll() neutronv2.get_client('fake') result = api._nw_info_get_ips(self.moxed_client, fake_port) self.assertEqual(len(result), 1) self.assertEqual(result[0]['address'], '1.1.1.1') self.assertEqual(result[0]['floating_ips'][0]['address'], '10.0.0.1') def test_nw_info_get_subnets(self): fake_port = { 'fixed_ips': [ {'ip_address': '1.1.1.1'}, {'ip_address': '2.2.2.2'}], 'id': 'port-id', } fake_subnet = model.Subnet(cidr='1.0.0.0/8') fake_ips = [model.IP(x['ip_address']) for x in fake_port['fixed_ips']] api = neutronapi.API() self.mox.StubOutWithMock(api, '_get_subnets_from_port') api._get_subnets_from_port(self.context, fake_port).AndReturn( [fake_subnet]) self.mox.ReplayAll() neutronv2.get_client('fake') subnets = api._nw_info_get_subnets(self.context, fake_port, fake_ips) self.assertEqual(len(subnets), 1) self.assertEqual(len(subnets[0]['ips']), 1) self.assertEqual(subnets[0]['ips'][0]['address'], '1.1.1.1') def _test_nw_info_build_network(self, vif_type): fake_port = { 'fixed_ips': [{'ip_address': '1.1.1.1'}], 'id': 'port-id', 'network_id': 'net-id', 'binding:vif_type': vif_type, } fake_subnets = [model.Subnet(cidr='1.0.0.0/8')] fake_nets = [{'id': 'net-id', 'name': 'foo', 'tenant_id': 'tenant'}] api = neutronapi.API() self.mox.ReplayAll() neutronv2.get_client('fake') net, iid = api._nw_info_build_network(fake_port, fake_nets, fake_subnets) self.assertEqual(net['subnets'], fake_subnets) self.assertEqual(net['id'], 'net-id') self.assertEqual(net['label'], 'foo') self.assertEqual(net.get_meta('tenant_id'), 'tenant') self.assertEqual(net.get_meta('injected'), CONF.flat_injected) return net, iid def test_nw_info_build_network_ovs(self): net, iid = self._test_nw_info_build_network(model.VIF_TYPE_OVS) self.assertEqual(net['bridge'], CONF.neutron_ovs_bridge) self.assertFalse('should_create_bridge' in net) self.assertEqual(iid, 'port-id') def test_nw_info_build_network_bridge(self): net, iid = self._test_nw_info_build_network(model.VIF_TYPE_BRIDGE) self.assertEqual(net['bridge'], 'brqnet-id') self.assertTrue(net['should_create_bridge']) self.assertEqual(iid, None) def test_nw_info_build_network_other(self): net, iid = self._test_nw_info_build_network(None) self.assertEqual(net['bridge'], None) self.assertFalse('should_create_bridge' in net) self.assertEqual(iid, None) def test_build_network_info_model(self): api = neutronapi.API() fake_inst = {'project_id': 'fake', 'uuid': 'uuid'} fake_ports = [ {'id': 'port0', 'network_id': 'net-id', 'fixed_ips': [{'ip_address': '1.1.1.1'}], 'mac_address': 'de:ad:be:ef:00:01', 'binding:vif_type': model.VIF_TYPE_BRIDGE, }, # This does not match the networks we provide below, # so it should be ignored (and is here to verify that) {'id': 'port1', 'network_id': 'other-net-id', }, ] fake_subnets = [model.Subnet(cidr='1.0.0.0/8')] fake_nets = [ {'id': 'net-id', 'name': 'foo', 'tenant_id': 'fake', } ] neutronv2.get_client(mox.IgnoreArg(), admin=True).MultipleTimes( ).AndReturn(self.moxed_client) self.moxed_client.list_ports( tenant_id='fake', device_id='uuid').AndReturn( {'ports': fake_ports}) self.mox.StubOutWithMock(api, '_get_floating_ips_by_fixed_and_port') api._get_floating_ips_by_fixed_and_port( self.moxed_client, '1.1.1.1', 'port0').AndReturn( [{'floating_ip_address': '10.0.0.1'}]) self.mox.StubOutWithMock(api, '_get_subnets_from_port') api._get_subnets_from_port(self.context, fake_ports[0]).AndReturn( fake_subnets) self.mox.ReplayAll() neutronv2.get_client('fake') nw_info = api._build_network_info_model(self.context, fake_inst, fake_nets) self.assertEqual(len(nw_info), 1) self.assertEqual(nw_info[0]['id'], 'port0') self.assertEqual(nw_info[0]['address'], 'de:ad:be:ef:00:01') self.assertEqual(nw_info[0]['devname'], 'tapport0') self.assertEqual(nw_info[0]['ovs_interfaceid'], None) self.assertEqual(nw_info[0]['type'], model.VIF_TYPE_BRIDGE) self.assertEqual(nw_info[0]['network']['bridge'], 'brqnet-id') def test_get_all_empty_list_networks(self): api = neutronapi.API() self.moxed_client.list_networks().AndReturn({'networks': []}) self.mox.ReplayAll() networks = api.get_all(self.context) self.assertEqual(networks, []) class TestNeutronv2ModuleMethods(test.TestCase): def test_ensure_requested_network_ordering_no_preference_ids(self): l = [1, 2, 3] neutronapi._ensure_requested_network_ordering( lambda x: x, l, None) def test_ensure_requested_network_ordering_no_preference_hashes(self): l = [{'id': 3}, {'id': 1}, {'id': 2}] neutronapi._ensure_requested_network_ordering( lambda x: x['id'], l, None) self.assertEqual(l, [{'id': 3}, {'id': 1}, {'id': 2}]) def test_ensure_requested_network_ordering_with_preference(self): l = [{'id': 3}, {'id': 1}, {'id': 2}] neutronapi._ensure_requested_network_ordering( lambda x: x['id'], l, [1, 2, 3]) self.assertEqual(l, [{'id': 1}, {'id': 2}, {'id': 3}]) class TestNeutronv2Portbinding(TestNeutronv2Base): def test_allocate_for_instance_portbinding(self): self._allocate_for_instance(1, portbinding=True) def test_populate_neutron_extension_values_binding(self): api = neutronapi.API() neutronv2.get_client(mox.IgnoreArg()).AndReturn( self.moxed_client) self.moxed_client.list_extensions().AndReturn( {'extensions': [{'name': constants.PORTBINDING_EXT}]}) self.mox.ReplayAll() host_id = 'my_host_id' instance = {'host': host_id} port_req_body = {'port': {}} api._populate_neutron_extension_values(instance, port_req_body) self.assertEquals(port_req_body['port']['binding:host_id'], host_id) def test_migrate_instance_finish_binding_false(self): api = neutronapi.API() self.mox.StubOutWithMock(api, '_has_port_binding_extension') api._has_port_binding_extension(refresh_cache=True).AndReturn(False) self.mox.ReplayAll() api.migrate_instance_finish(self.context, None, None) def test_migrate_instance_finish_binding_true(self): api = neutronapi.API() self.mox.StubOutWithMock(api, '_has_port_binding_extension') api._has_port_binding_extension(refresh_cache=True).AndReturn(True) neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn( self.moxed_client) search_opts = {'device_id': self.instance['uuid'], 'tenant_id': self.instance['project_id']} ports = {'ports': [{'id': 'test1'}]} self.moxed_client.list_ports(**search_opts).AndReturn(ports) port_req_body = {'port': {'binding:host_id': self.instance.get('host')}} self.moxed_client.update_port('test1', port_req_body).AndReturn(None) self.mox.ReplayAll() api.migrate_instance_finish(self.context, self.instance, None) def test_migrate_instance_finish_binding_true_exception(self): api = neutronapi.API() self.mox.StubOutWithMock(api, '_has_port_binding_extension') api._has_port_binding_extension(refresh_cache=True).AndReturn(True) neutronv2.get_client(mox.IgnoreArg(), admin=True).AndReturn( self.moxed_client) search_opts = {'device_id': self.instance['uuid'], 'tenant_id': self.instance['project_id']} ports = {'ports': [{'id': 'test1'}]} self.moxed_client.list_ports(**search_opts).AndReturn(ports) port_req_body = {'port': {'binding:host_id': self.instance.get('host')}} self.moxed_client.update_port('test1', port_req_body).AndRaise( Exception("fail to update port")) self.mox.ReplayAll() self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.migrate_instance_finish, self.context, self.instance, None)
{ "content_hash": "e7a6b96fc47b2ad1b5744ff572a9d313", "timestamp": "", "source": "github", "line_count": 1573, "max_line_length": 79, "avg_line_length": 44.52447552447553, "alnum_prop": 0.547624826877222, "repo_name": "qwefi/nova", "id": "b3ebc54c0761dec208675cfebe3ca8a35a42191b", "size": "70718", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "nova/tests/network/test_neutronv2.py", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "Python", "bytes": "11596912" }, { "name": "Shell", "bytes": "17148" } ] }
ACCEPTED #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
{ "content_hash": "2c018c2dfadbf500fd1e1033828edd43", "timestamp": "", "source": "github", "line_count": 13, "max_line_length": 39, "avg_line_length": 10.307692307692308, "alnum_prop": 0.6940298507462687, "repo_name": "mdoering/backbone", "id": "f12fae70ff7a997475b641bb3c4dfaa260d70994", "size": "188", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "life/Plantae/Magnoliophyta/Liliopsida/Asparagales/Orchidaceae/Sanderella/Sanderella riograndensis/README.md", "mode": "33188", "license": "apache-2.0", "language": [] }
package bus import ( "bytes" "encoding/json" "errors" "fmt" "io" "io/ioutil" "net/http" ) func Connect(url string, capabilities map[string]interface{}, httpClient *http.Client) (*Client, error) { requestBody, err := capabilitiesToJSON(capabilities) if err != nil { return nil, err } if httpClient == nil { httpClient = http.DefaultClient } sessionID, err := openSession(url, requestBody, httpClient) if err != nil { return nil, err } sessionURL := fmt.Sprintf("%s/session/%s", url, sessionID) return &Client{sessionURL, httpClient}, nil } func capabilitiesToJSON(capabilities map[string]interface{}) (io.Reader, error) { if capabilities == nil { capabilities = map[string]interface{}{} } desiredCapabilities := struct { DesiredCapabilities map[string]interface{} `json:"desiredCapabilities"` }{capabilities} capabiltiesJSON, err := json.Marshal(desiredCapabilities) if err != nil { return nil, err } return bytes.NewReader(capabiltiesJSON), err } func openSession(url string, body io.Reader, httpClient *http.Client) (sessionID string, err error) { request, err := http.NewRequest("POST", fmt.Sprintf("%s/session", url), body) if err != nil { return "", err } request.Header.Add("Content-Type", "application/json") response, err := httpClient.Do(request) if err != nil { return "", err } defer response.Body.Close() var sessionResponse struct { SessionID string // fallback for GeckoDriver Value struct { SessionID string } } responseBody, err := ioutil.ReadAll(response.Body) if err != nil { return "", err } if err := json.Unmarshal(responseBody, &sessionResponse); err != nil { return "", err } if sessionResponse.SessionID == "" { // fallback for GeckoDriver if sessionResponse.Value.SessionID != "" { return sessionResponse.Value.SessionID, nil } return "", errors.New("failed to retrieve a session ID") } return sessionResponse.SessionID, nil }
{ "content_hash": "6d290dc837f0764b60e83854bfaecf8c", "timestamp": "", "source": "github", "line_count": 86, "max_line_length": 105, "avg_line_length": 22.674418604651162, "alnum_prop": 0.696923076923077, "repo_name": "sclevine/agouti", "id": "da83615789118e02951495bd81548cf3a04a184f", "size": "1950", "binary": false, "copies": "2", "ref": "refs/heads/master", "path": "api/internal/bus/connect.go", "mode": "33188", "license": "mit", "language": [ { "name": "Go", "bytes": "407783" }, { "name": "HTML", "bytes": "3052" } ] }
FROM golang:1.17 ARG GOMPLATE_VERSION # Install gomplate RUN go install github.com/hairyhenderson/gomplate/v3/cmd/gomplate@v${GOMPLATE_VERSION} # Create the mount point for the library RUN mkdir /gatekeeper-library WORKDIR /gatekeeper-library ENTRYPOINT ["/bin/bash"]
{ "content_hash": "a093fe52f73abd92179dbba3c7d9875d", "timestamp": "", "source": "github", "line_count": 12, "max_line_length": 86, "avg_line_length": 22.666666666666668, "alnum_prop": 0.7941176470588235, "repo_name": "open-policy-agent/gatekeeper-library", "id": "9431467540bb7a5d595cbb641f9425f9e7d6d0c1", "size": "272", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "build/gomplate/Dockerfile", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "3334" }, { "name": "Dockerfile", "bytes": "819" }, { "name": "Go", "bytes": "21007" }, { "name": "JavaScript", "bytes": "4813" }, { "name": "Makefile", "bytes": "3405" }, { "name": "Open Policy Agent", "bytes": "348091" }, { "name": "Shell", "bytes": "9766" } ] }
package com.whereareyou; import javax.persistence.EntityManager; import javax.persistence.Persistence; import java.util.ArrayList; import java.util.List; /** * Created by 家玮 on 2014/7/26. */ public class Util { public static EntityManager ENTITY_MANAGER = Persistence.createEntityManagerFactory("database").createEntityManager(); public static Object save(Lamb lamb){ ENTITY_MANAGER.getTransaction().begin(); Object object = lamb.run(); ENTITY_MANAGER.persist(object); ENTITY_MANAGER.getTransaction().commit(); return object; } public static Object save(Object object){ ENTITY_MANAGER.getTransaction().begin(); ENTITY_MANAGER.persist(object); ENTITY_MANAGER.getTransaction().commit(); return object; } public static List<Object> save(Object... objects){ List result = new ArrayList<Object>(); for(int i=0;i<objects.length;i++){ result.add(Util.save(objects[i])); } return result; } }
{ "content_hash": "d12f85517d96942ec67154fdd3954697", "timestamp": "", "source": "github", "line_count": 35, "max_line_length": 122, "avg_line_length": 29.542857142857144, "alnum_prop": 0.660541586073501, "repo_name": "fanjiawei/sweden-demo", "id": "38e893679d7708ed6eeecca996899a7c76183753", "size": "1038", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/main/java/com/whereareyou/Util.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "801" }, { "name": "Java", "bytes": "16099" }, { "name": "JavaScript", "bytes": "2326" } ] }
{% extends "!layout.html" %} {% block footer %} {{ super() }} <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21520458-1']); _gaq.push(['_setDomainName', '.chemkit.org']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> {% endblock %}
{ "content_hash": "aebbc225b47a63dd73e850e5072de9c0", "timestamp": "", "source": "github", "line_count": 17, "max_line_length": 117, "avg_line_length": 35.294117647058826, "alnum_prop": 0.6083333333333333, "repo_name": "kylelutz/chemkit", "id": "a5572750be911c8dee2373415c2a2f49436611a2", "size": "600", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "doc/python/_templates/layout.html", "mode": "33188", "license": "bsd-3-clause", "language": [ { "name": "C", "bytes": "17720" }, { "name": "C++", "bytes": "3214072" }, { "name": "CMake", "bytes": "81286" }, { "name": "GLSL", "bytes": "8857" }, { "name": "Inno Setup", "bytes": "1521" }, { "name": "Python", "bytes": "183506" }, { "name": "Shell", "bytes": "17242" } ] }
ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name null ### Remarks null
{ "content_hash": "3cda245e0909beb48c8c159f24e8e170", "timestamp": "", "source": "github", "line_count": 13, "max_line_length": 31, "avg_line_length": 9.692307692307692, "alnum_prop": 0.7063492063492064, "repo_name": "mdoering/backbone", "id": "67f4d39946b89f4bf0d468b1888c6c07833c31d0", "size": "217", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "life/Plantae/Magnoliophyta/Liliopsida/Poales/Poaceae/Bothriochloa/Bothriochloa saccharoides/Bothriochloa saccharoides parvispiculus/README.md", "mode": "33188", "license": "apache-2.0", "language": [] }
// Copyright © 2008, 2014, Oracle and/or its affiliates. All rights reserved. // // MySQL Connector/NET is licensed under the terms of the GPLv2 // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most // MySQL Connectors. There are special exceptions to the terms and // conditions of the GPLv2 as it is applied to this software, see the // FLOSS License Exception // <http://www.mysql.com/about/legal/licensing/foss-exception.html>. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published // by the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA using System.Text; using System.Collections.Generic; using MySql.Data.MySqlClient; using System.Data.Common; using System.Diagnostics; using System; #if EF6 using System.Data.Entity.Core.Common.CommandTrees; using System.Data.Entity.Core.Metadata.Edm; #else using System.Data.Common.CommandTrees; using System.Data.Metadata.Edm; #endif namespace MySql.Data.Entity { class InsertGenerator : SqlGenerator { public override string GenerateSQL(DbCommandTree tree) { DbInsertCommandTree commandTree = tree as DbInsertCommandTree; InsertStatement statement = new InsertStatement(); DbExpressionBinding e = commandTree.Target; statement.Target = (InputFragment)e.Expression.Accept(this); scope.Add("target", statement.Target); foreach (DbSetClause setClause in commandTree.SetClauses) statement.Sets.Add(setClause.Property.Accept(this)); if (values == null) values = new Dictionary<EdmMember, SqlFragment>(); foreach (DbSetClause setClause in commandTree.SetClauses) { DbExpression value = setClause.Value; SqlFragment valueFragment = value.Accept(this); statement.Values.Add(valueFragment); if (value.ExpressionKind != DbExpressionKind.Null) { EdmMember property = ((DbPropertyExpression)setClause.Property).Property; values.Add(property, valueFragment); } } if (commandTree.Returning != null) statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning); return statement.ToString(); } protected virtual SelectStatement GenerateReturningSql(DbModificationCommandTree tree, DbExpression returning) { SelectStatement select = base.GenerateReturningSql(tree, returning); ListFragment where = new ListFragment(); EntitySetBase table = ((DbScanExpression)tree.Target.Expression).Target; bool foundIdentity = false; where.Append(" row_count() > 0"); foreach (EdmMember keyMember in table.ElementType.KeyMembers) { SqlFragment value; if (!values.TryGetValue(keyMember, out value)) { if (foundIdentity) throw new NotSupportedException(); foundIdentity = true; PrimitiveTypeKind type = ((PrimitiveType)keyMember.TypeUsage.EdmType.BaseType).PrimitiveTypeKind; if ((type == PrimitiveTypeKind.Byte) || (type == PrimitiveTypeKind.SByte) || (type == PrimitiveTypeKind.Int16) || (type == PrimitiveTypeKind.Int32) || (type == PrimitiveTypeKind.Int64) || (type == PrimitiveTypeKind.Decimal && IsValidMySqlDataType(keyMember.TypeUsage.EdmType.FullName))) { value = new LiteralFragment("last_insert_id()"); } else if (keyMember.TypeUsage.EdmType.BaseType.Name == "Guid") value = new LiteralFragment(string.Format("ANY(SELECT guid FROM tmpIdentity_{0})", (table as MetadataItem).MetadataProperties["Table"].Value)); } where.Append(String.Format(" AND `{0}`=", keyMember)); where.Append(value); } select.Where = where; return select; } private bool IsValidMySqlDataType(string dataType) { return (new List<string>() { "MySql.ubigint" }).Contains(dataType); } } }
{ "content_hash": "063029c56098667ab2e43c20ba5dd0ad", "timestamp": "", "source": "github", "line_count": 117, "max_line_length": 155, "avg_line_length": 38.162393162393165, "alnum_prop": 0.6947368421052632, "repo_name": "chenlianwd/MES", "id": "1303b566a49af215febf3cc66d38ff2d197eda38", "size": "4468", "binary": false, "copies": "2", "ref": "refs/heads/master", "path": "Reference_Projects/MySql/Source/MySql.Data.EntityFramework5/Generators/InsertGenerator.cs", "mode": "33188", "license": "mit", "language": [ { "name": "ASP", "bytes": "178239" }, { "name": "C#", "bytes": "3800877" }, { "name": "CSS", "bytes": "1294971" }, { "name": "HTML", "bytes": "773037" }, { "name": "JavaScript", "bytes": "7389831" }, { "name": "PLSQL", "bytes": "127579" }, { "name": "PLpgSQL", "bytes": "23102" }, { "name": "Python", "bytes": "3106" }, { "name": "SQLPL", "bytes": "13840" }, { "name": "Shell", "bytes": "709" }, { "name": "Visual Basic", "bytes": "13005" } ] }
--- uid: SolidEdgePart.PartDocument.LockedSketch summary: remarks: ---
{ "content_hash": "558a19a82ff382c532883cc12ddc716d", "timestamp": "", "source": "github", "line_count": 5, "max_line_length": 44, "avg_line_length": 14.8, "alnum_prop": 0.7297297297297297, "repo_name": "SolidEdgeCommunity/docs", "id": "b4b24cdb96ddc571c1259b9f5f03568828d7844e", "size": "76", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "docfx_project/apidoc/SolidEdgePart.PartDocument.LockedSketch.md", "mode": "33188", "license": "mit", "language": [ { "name": "Batchfile", "bytes": "38" }, { "name": "C#", "bytes": "5048212" }, { "name": "C++", "bytes": "2265" }, { "name": "CSS", "bytes": "148" }, { "name": "PowerShell", "bytes": "180" }, { "name": "Smalltalk", "bytes": "1996" }, { "name": "Visual Basic", "bytes": "10236277" } ] }
package org.folio.marccat; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.folio.marccat.config.Global; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres; import java.io.File; import java.io.IOException; import static junit.framework.TestCase.fail; import static org.folio.marccat.ModMarccat.BASE_URI; import static org.springframework.web.util.UriComponentsBuilder.fromUriString; import static ru.yandex.qatools.embed.postgresql.distribution.Version.Main.V9_6; /** * Supertype layer for all bibliographic test cases. * * @author cchiama * @since 1.0 */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public abstract class BaseIntegrationTestCase { @LocalServerPort protected int port; @Autowired protected TestRestTemplate client; @Autowired protected TestConfiguration configuration; protected final static String DB_USERNAME = "amicus"; protected final static String DB_PASSWORD = "oracle"; private final static EmbeddedPostgres POSTGRES = new EmbeddedPostgres(V9_6); private static String POSTGRES_JDBC_URL; private static String getFile(String filename) throws IOException { return IOUtils.toString(BaseIntegrationTestCase.class.getClassLoader().getResourceAsStream(filename), "UTF-8"); } /** * Starts the embedded database instance. * * @throws Exception hopefully never, otherwise the test fails. */ @BeforeClass public static void prepareDatabase() throws Exception { File f = FileUtils.getFile("src/resources/marccat.sql"); final File dbdump = new File("src/resources/marccat.sql"); if (!dbdump.canRead()) { fail("Unable to find the database dump."); } POSTGRES_JDBC_URL = POSTGRES.start("151.1.165.20", 5433, "folio_marccat_test1", DB_USERNAME, DB_PASSWORD); POSTGRES.getProcess().ifPresent(pg -> pg.importFromFile(dbdump)); } /** * Stops the embedded database instance. */ @AfterClass public static void stopDatabase() { POSTGRES.stop(); } @Before public void setUp() { configuration.injectData(POSTGRES_JDBC_URL, DB_USERNAME, DB_PASSWORD); } /** * Retrieves the object associated with that URI. * * @param uri the target URI. * @param responseType the response type. * @param <T> the response instance type. * @return the object associated with that URI. */ protected <T> T get(final String uri, Class<T> responseType) { final HttpHeaders headers = new HttpHeaders(); headers.add(Global.OKAPI_TENANT_HEADER_NAME, String.valueOf(System.currentTimeMillis())); final ResponseEntity<T> response = client.getRestTemplate() .exchange( fromUriString(uri).build().toUri(), HttpMethod.GET, new HttpEntity<>("parameters", headers), responseType); if (response.getStatusCode().isError()) { throw new RuntimeException(uri + " >> " + response.getStatusCode()); } return response.getBody(); } /** * Retrieves the object associated with that URI. * * @param uri the target URI. * @return the object associated with that URI. */ protected void delete(final String uri) { final HttpHeaders headers = new HttpHeaders(); headers.add(Global.OKAPI_TENANT_HEADER_NAME, String.valueOf(System.currentTimeMillis())); ResponseEntity<Void> response = client.exchange( fromUriString(uri).build().toUri(), HttpMethod.DELETE, new HttpEntity<>("parameters", headers), Void.class); if (response.getStatusCode().isError()) { throw new RuntimeException(uri + " >> " + response.getStatusCode()); } } /** * Returns the Pipeline API address endpoint. * * @param path the specific path service identifier. * @return the Pipeline API address endpoint. */ protected String address(final String path) { return "http://localhost:" + this.port + "/" + BASE_URI + path + (path.contains("?") ? "&" : "?") + "lang=eng"; } }
{ "content_hash": "85b65b703bb344ffc30b54629d0a3399", "timestamp": "", "source": "github", "line_count": 144, "max_line_length": 115, "avg_line_length": 32.729166666666664, "alnum_prop": 0.7258646297475069, "repo_name": "atcult/mod-cataloging", "id": "555fc65619140a68a3c6d3127fa5f85a7d1d36ef", "size": "4713", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "src/test/java/org/folio/marccat/BaseIntegrationTestCase.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "Dockerfile", "bytes": "301" }, { "name": "Java", "bytes": "3468472" }, { "name": "PLpgSQL", "bytes": "15766763" }, { "name": "Python", "bytes": "612" }, { "name": "Shell", "bytes": "38444" } ] }
package org.jasig.cas.services; import com.fasterxml.jackson.annotation.JsonTypeInfo; import org.apache.commons.lang3.builder.CompareToBuilder; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.JoinTable; import javax.persistence.Lob; import javax.persistence.OneToMany; import javax.persistence.PostLoad; import javax.persistence.Table; import javax.persistence.Transient; import javax.validation.constraints.NotNull; import java.net.URL; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * Base class for mutable, persistable registered services. * * @author Marvin S. Addison * @author Scott Battaglia * @author Misagh Moayyed * @since 3.0.0 */ @Entity @Inheritance @DiscriminatorColumn(name = "expression_type", length = 15, discriminatorType = DiscriminatorType.STRING, columnDefinition = "VARCHAR(15) DEFAULT 'ant'") @Table(name = "RegisteredServiceImpl") @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class") public abstract class AbstractRegisteredService implements RegisteredService, Comparable<RegisteredService> { private static final long serialVersionUID = 7645279151115635245L; /** The logger instance. */ @Transient protected final transient Logger logger = LoggerFactory.getLogger(this.getClass()); /** The unique identifier for this service. */ @Column(length = 255, updatable = true, insertable = true, nullable = false) protected String serviceId; @Column(length = 255, updatable = true, insertable = true, nullable = false) private String name; @Column(length = 255, updatable = true, insertable = true, nullable = true) private String theme; @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id = RegisteredService.INITIAL_IDENTIFIER_VALUE; @Column(length = 255, updatable = true, insertable = true, nullable = false) private String description; /** * Proxy policy for the service. * By default, the policy is {@link RefuseRegisteredServiceProxyPolicy}. */ @Lob @Column(name = "proxy_policy", nullable = true, length = Integer.MAX_VALUE) private RegisteredServiceProxyPolicy proxyPolicy = new RefuseRegisteredServiceProxyPolicy(); @Column(name = "evaluation_order", nullable = false) private int evaluationOrder; /** * Resolve the username for this service. * By default the resolver is {@link DefaultRegisteredServiceUsernameProvider}. */ @Lob @Column(name = "username_attr", nullable = true, length = Integer.MAX_VALUE) private RegisteredServiceUsernameAttributeProvider usernameAttributeProvider = new DefaultRegisteredServiceUsernameProvider(); /** * The logout type of the service. * The default logout type is the back channel one. */ @Column(name = "logout_type", nullable = true) private LogoutType logoutType = LogoutType.BACK_CHANNEL; @Lob @Column(name = "required_handlers", length = Integer.MAX_VALUE) private HashSet<String> requiredHandlers = new HashSet<>(); /** The attribute filtering policy. */ @Lob @Column(name = "attribute_release", nullable = true, length = Integer.MAX_VALUE) private RegisteredServiceAttributeReleasePolicy attributeReleasePolicy = new ReturnAllowedAttributeReleasePolicy(); @Column(name = "logo") private URL logo; @Column(name = "logout_url") private URL logoutUrl; @Lob @Column(name = "access_strategy", nullable = true, length = Integer.MAX_VALUE) private RegisteredServiceAccessStrategy accessStrategy = new DefaultRegisteredServiceAccessStrategy(); @Lob @Column(name = "public_key", nullable = true, length = Integer.MAX_VALUE) private RegisteredServicePublicKey publicKey; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name="RegisteredServiceImpl_Properties") private Map<String, DefaultRegisteredServiceProperty> properties = new HashMap<>(); @Override public long getId() { return this.id; } @Override public String getDescription() { return this.description; } @Override public String getServiceId() { return this.serviceId; } @Override public String getName() { return this.name; } @Override public String getTheme() { return this.theme; } @Override public RegisteredServiceProxyPolicy getProxyPolicy() { return this.proxyPolicy; } @Override public RegisteredServiceAccessStrategy getAccessStrategy() { return this.accessStrategy; } @Override public URL getLogoutUrl() { return this.logoutUrl; } /** * Initializes the registered service with default values * for fields that are unspecified. Only triggered by JPA. * @since 4.1 */ @PostLoad public final void postLoad() { if (this.proxyPolicy == null) { this.proxyPolicy = new RefuseRegisteredServiceProxyPolicy(); } if (this.usernameAttributeProvider == null) { this.usernameAttributeProvider = new DefaultRegisteredServiceUsernameProvider(); } if (this.logoutType == null) { this.logoutType = LogoutType.BACK_CHANNEL; } if (this.requiredHandlers == null) { this.requiredHandlers = new HashSet<>(); } if (this.accessStrategy == null) { this.accessStrategy = new DefaultRegisteredServiceAccessStrategy(); } if (this.properties == null) { this.properties = new HashMap<>(); } if (this.attributeReleasePolicy == null) { this.attributeReleasePolicy = new ReturnAllowedAttributeReleasePolicy(); } } @Override public boolean equals(final Object o) { if (o == null) { return false; } if (this == o) { return true; } if (!(o instanceof AbstractRegisteredService)) { return false; } final AbstractRegisteredService that = (AbstractRegisteredService) o; final EqualsBuilder builder = new EqualsBuilder(); return builder .append(this.proxyPolicy, that.proxyPolicy) .append(this.evaluationOrder, that.evaluationOrder) .append(this.description, that.description) .append(this.name, that.name) .append(this.serviceId, that.serviceId) .append(this.theme, that.theme) .append(this.usernameAttributeProvider, that.usernameAttributeProvider) .append(this.logoutType, that.logoutType) .append(this.attributeReleasePolicy, that.attributeReleasePolicy) .append(this.accessStrategy, that.accessStrategy) .append(this.logo, that.logo) .append(this.publicKey, that.publicKey) .append(this.logoutUrl, that.logoutUrl) .append(this.requiredHandlers, that.requiredHandlers) .append(this.proxyPolicy, that.proxyPolicy) .append(this.properties, that.properties) .isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(7, 31) .append(this.description) .append(this.serviceId) .append(this.name) .append(this.theme) .append(this.evaluationOrder) .append(this.usernameAttributeProvider) .append(this.accessStrategy) .append(this.logoutType) .append(this.attributeReleasePolicy) .append(this.accessStrategy) .append(this.logo) .append(this.publicKey) .append(this.logoutUrl) .append(this.requiredHandlers) .append(this.proxyPolicy) .append(this.properties) .toHashCode(); } public void setProxyPolicy(final RegisteredServiceProxyPolicy policy) { this.proxyPolicy = policy; } public void setDescription(final String description) { this.description = description; } /** * Sets the service identifier. Extensions are to define the format. * * @param id the new service id */ public abstract void setServiceId(String id); public void setId(final long id) { this.id = id; } public void setName(final String name) { this.name = name; } public void setTheme(final String theme) { this.theme = theme; } @Override public void setEvaluationOrder(final int evaluationOrder) { this.evaluationOrder = evaluationOrder; } @Override public int getEvaluationOrder() { return this.evaluationOrder; } @Override public RegisteredServiceUsernameAttributeProvider getUsernameAttributeProvider() { return this.usernameAttributeProvider; } public void setAccessStrategy(final RegisteredServiceAccessStrategy accessStrategy) { this.accessStrategy = accessStrategy; } public void setLogoutUrl(final URL logoutUrl) { this.logoutUrl = logoutUrl; } /** * Sets the user attribute provider instance * when providing usernames to this registered service. * * @param usernameProvider the new username attribute */ public void setUsernameAttributeProvider(final RegisteredServiceUsernameAttributeProvider usernameProvider) { this.usernameAttributeProvider = usernameProvider; } @Override public final LogoutType getLogoutType() { return logoutType; } /** * Set the logout type of the service. * * @param logoutType the logout type of the service. */ public final void setLogoutType(final LogoutType logoutType) { this.logoutType = logoutType; } @Override public final AbstractRegisteredService clone() { final AbstractRegisteredService clone = newInstance(); clone.copyFrom(this); return clone; } /** * Copies the properties of the source service into this instance. * * @param source Source service from which to copy properties. */ public void copyFrom(final RegisteredService source) { this.setId(source.getId()); this.setProxyPolicy(source.getProxyPolicy()); this.setDescription(source.getDescription()); this.setName(source.getName()); this.setServiceId(source.getServiceId()); this.setTheme(source.getTheme()); this.setEvaluationOrder(source.getEvaluationOrder()); this.setUsernameAttributeProvider(source.getUsernameAttributeProvider()); this.setLogoutType(source.getLogoutType()); this.setAttributeReleasePolicy(source.getAttributeReleasePolicy()); this.setAccessStrategy(source.getAccessStrategy()); this.setLogo(source.getLogo()); this.setLogoutUrl(source.getLogoutUrl()); this.setPublicKey(source.getPublicKey()); this.setRequiredHandlers(source.getRequiredHandlers()); this.setProperties(source.getProperties()); } /** * {@inheritDoc} * Compares this instance with the {@code other} registered service based on * evaluation order, name. The name comparison is case insensitive. * * @see #getEvaluationOrder() */ @Override public int compareTo(final RegisteredService other) { return new CompareToBuilder() .append(this.getEvaluationOrder(), other.getEvaluationOrder()) .append(this.getName().toLowerCase(), other.getName().toLowerCase()) .append(this.getServiceId(), other.getServiceId()) .toComparison(); } @Override public String toString() { final ToStringBuilder toStringBuilder = new ToStringBuilder(null, ToStringStyle.SHORT_PREFIX_STYLE); toStringBuilder.append("id", this.id); toStringBuilder.append("name", this.name); toStringBuilder.append("description", this.description); toStringBuilder.append("serviceId", this.serviceId); toStringBuilder.append("usernameAttributeProvider", this.usernameAttributeProvider); toStringBuilder.append("theme", this.theme); toStringBuilder.append("evaluationOrder", this.evaluationOrder); toStringBuilder.append("logoutType", this.logoutType); toStringBuilder.append("attributeReleasePolicy", this.attributeReleasePolicy); toStringBuilder.append("accessStrategy", this.accessStrategy); toStringBuilder.append("publicKey", this.publicKey); toStringBuilder.append("proxyPolicy", this.proxyPolicy); toStringBuilder.append("logo", this.logo); toStringBuilder.append("logoutUrl", this.logoutUrl); toStringBuilder.append("requiredHandlers", this.requiredHandlers); toStringBuilder.append("properties", this.properties); return toStringBuilder.toString(); } /** * Create a new service instance. * * @return the registered service */ protected abstract AbstractRegisteredService newInstance(); @Override public Set<String> getRequiredHandlers() { if (this.requiredHandlers == null) { this.requiredHandlers = new HashSet<>(); } return this.requiredHandlers; } /** * Sets the required handlers for this service. * * @param handlers the new required handlers */ public void setRequiredHandlers(final Set<String> handlers) { getRequiredHandlers().clear(); if (handlers == null) { return; } getRequiredHandlers().addAll(handlers); } /** * Sets the attribute filtering policy. * * @param policy the new attribute filtering policy */ public final void setAttributeReleasePolicy(final RegisteredServiceAttributeReleasePolicy policy) { this.attributeReleasePolicy = policy; } @Override public final RegisteredServiceAttributeReleasePolicy getAttributeReleasePolicy() { return this.attributeReleasePolicy; } @Override public URL getLogo() { return this.logo; } public void setLogo(final URL logo) { this.logo = logo; } @Override public RegisteredServicePublicKey getPublicKey() { return this.publicKey; } public void setPublicKey(@NotNull final RegisteredServicePublicKey publicKey) { this.publicKey = publicKey; } @Override public Map<String, RegisteredServiceProperty> getProperties() { return (Map) this.properties; } public void setProperties(final Map<String, RegisteredServiceProperty> properties) { this.properties = (Map) properties; } }
{ "content_hash": "6a326fac63a9057fef67db80745ed67e", "timestamp": "", "source": "github", "line_count": 471, "max_line_length": 113, "avg_line_length": 33.28025477707006, "alnum_prop": 0.6671132376395534, "repo_name": "joansmith/cas", "id": "bcd3d9d35b4609d180297e8a593735a43c6d9d5e", "size": "15675", "binary": false, "copies": "1", "ref": "refs/heads/master", "path": "cas-server-core-services/src/main/java/org/jasig/cas/services/AbstractRegisteredService.java", "mode": "33188", "license": "apache-2.0", "language": [ { "name": "CSS", "bytes": "185031" }, { "name": "Groovy", "bytes": "331" }, { "name": "HTML", "bytes": "7502" }, { "name": "Java", "bytes": "3239311" }, { "name": "JavaScript", "bytes": "41487" }, { "name": "Shell", "bytes": "4235" } ] }
End of preview.

No dataset card yet

Downloads last month
3